PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/interpreter/builtins/liberty_interpreter_external_type_arguments_builtins.e

http://github.com/tybor/Liberty
Specman e | 65 lines | 45 code | 6 blank | 14 comment | 1 complexity | c38dbcf656c299e5299cbd58d4e575be MD5 | raw file
 1-- This file is part of Liberty Eiffel.
 2--
 3-- Liberty Eiffel is free software: you can redistribute it and/or modify
 4-- it under the terms of the GNU General Public License as published by
 5-- the Free Software Foundation, version 3 of the License.
 6--
 7-- Liberty Eiffel is distributed in the hope that it will be useful,
 8-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10-- GNU General Public License for more details.
11--
12-- You should have received a copy of the GNU General Public License
13-- along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
14--
15class LIBERTY_INTERPRETER_EXTERNAL_TYPE_ARGUMENTS_BUILTINS
16
17insert
18   LIBERTY_INTERPRETER_EXTERNAL_BUILTINS_CALLER
19   COMMAND_LINE_ARGUMENT_FACTORY
20
21creation {LIBERTY_INTERPRETER_EXTERNAL_BUILTIN_CALL}
22   make
23
24feature {LIBERTY_INTERPRETER_EXTERNAL_BUILTIN_CALL}
25   call (builtin_call: LIBERTY_INTERPRETER_FEATURE_CALL): LIBERTY_INTERPRETER_OBJECT is
26      local
27         index: INTEGER; argv: STRING
28      do
29         last_call_failed := False
30         builtin_call.evaluate_parameters
31         inspect
32            builtin_call.name
33         when "se_argc" then
34            Result := interpreter.new_integer(remaining_parameters.item.count + 1, builtin_call.position)
35         when "se_argv" then
36            index := integer(builtin_call)
37            if index = 0 then
38               argv := root_class_and_feature
39            else
40               argv := remaining_parameters.item.item(index-1).out
41            end
42            Result := interpreter.new_string(argv, builtin_call.position)
43         else
44            last_call_failed := True
45         end
46      end
47
48feature {}
49   integer (builtin_call: LIBERTY_INTERPRETER_FEATURE_CALL): INTEGER is
50      local
51         obj: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64]
52      do
53         builtin_call.evaluate_parameters
54         obj ::= builtin_call.parameters.first
55         Result := obj.item.to_integer_32
56      end
57
58   root_class_and_feature: STRING is
59      once
60         Result := interpreter.root_type.full_name.out
61         Result.extend('.')
62         Result.append(interpreter.root_feature_name.full_name)
63      end
64
65end -- class LIBERTY_INTERPRETER_EXTERNAL_TYPE_ARGUMENTS_BUILTINS