PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/src/tools/interpreter/liberty_interpreter_object.e

http://github.com/tybor/Liberty
Specman e | 200 lines | 153 code | 30 blank | 17 comment | 2 complexity | a409ce0c784da13347af2a8e86bb1e1b 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--
 15deferred class LIBERTY_INTERPRETER_OBJECT
 16
 17inherit
 18   LIBERTY_EXPRESSION
 19      redefine
 20         is_equal
 21      end
 22   HASHABLE
 23
 24insert
 25   ARRAYED_COLLECTION_HANDLER
 26
 27feature {ANY}
 28   is_void: BOOLEAN is False
 29
 30   is_equal (other: LIBERTY_INTERPRETER_OBJECT): BOOLEAN is
 31      deferred
 32      end
 33
 34   result_type: LIBERTY_TYPE is
 35      do
 36         Result := type
 37      end
 38
 39   type: LIBERTY_KNOWN_TYPE is
 40         -- the actual dynamic type of the object
 41      deferred
 42      end
 43
 44   is_open: BOOLEAN is False
 45
 46   is_between (lower, upper: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
 47      local
 48         fd: LIBERTY_FEATURE_DEFINITION
 49         cmp: LIBERTY_INTERPRETER_OBJECT_NATIVE[BOOLEAN]
 50      do
 51         fd := type.feature_definition(le_feature_name)
 52         cmp ::= interpreter.item_feature(lower, fd, {FAST_ARRAY[LIBERTY_INTERPRETER_OBJECT] << Current >> }, a_position)
 53         if cmp.item then
 54            cmp ::= interpreter.item_feature(Current, fd, {FAST_ARRAY[LIBERTY_INTERPRETER_OBJECT] << upper >> }, a_position)
 55            Result := cmp.item
 56         end
 57      end
 58
 59   as_target (a_position: LIBERTY_POSITION): like Current is
 60         -- Current when used as a target
 61      do
 62         Result := Current
 63      ensure
 64         Result = Current
 65      end
 66
 67   as_right_value: like Current is
 68         -- either Current or a twin depending on the storage class (expanded, reference, separate)
 69      do
 70         if type.is_expanded then
 71            Result := expanded_twin
 72         elseif type.is_separate then
 73            not_yet_implemented
 74         else
 75            Result := Current
 76         end
 77      ensure
 78         is_equal(Result)
 79      end
 80
 81   converted_to (target_type: LIBERTY_ACTUAL_TYPE): LIBERTY_INTERPRETER_OBJECT is
 82      require
 83         type.converts_to(target_type)
 84      deferred
 85      ensure
 86         Result.type = target_type
 87      end
 88
 89   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 90      do
 91         check False end
 92         crash
 93      end
 94
 95feature {LIBERTY_INTERPRETER_EXTERNAL_TYPE_ANY_BUILTINS} -- Standard builtings
 96   builtin_is_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
 97      require
 98         not other.is_void
 99      deferred
100      end
101
102   builtin_standard_is_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
103      require
104         not other.is_void
105      deferred
106      end
107
108   builtin_is_deep_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
109      require
110         not other.is_void
111      local
112         deep_equal_memory: SET[LIBERTY_INTERPRETER_OBJECT]
113      do
114         create {HASHED_SET[LIBERTY_INTERPRETER_OBJECT]} deep_equal_memory.make
115         Result := do_deep_equal(other, deep_equal_memory, a_position)
116      end
117
118   builtin_copy (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION) is
119      require
120         not other.is_void
121      deferred
122      end
123
124   builtin_twin (a_position: LIBERTY_POSITION): like Current is
125      deferred
126      end
127
128   builtin_standard_copy (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION) is
129      require
130         not other.is_void
131      deferred
132      end
133
134   builtin_standard_twin (a_position: LIBERTY_POSITION): like Current is
135      deferred
136      end
137
138   builtin_deep_twin (a_position: LIBERTY_POSITION): LIBERTY_INTERPRETER_OBJECT is
139      local
140         deep_twin_memory: DICTIONARY[LIBERTY_INTERPRETER_OBJECT, LIBERTY_INTERPRETER_OBJECT]
141      do
142         create {HASHED_DICTIONARY[LIBERTY_INTERPRETER_OBJECT, LIBERTY_INTERPRETER_OBJECT]} deep_twin_memory.make
143         Result := do_deep_twin(deep_twin_memory, a_position)
144      end
145
146feature {LIBERTY_INTERPRETER_OBJECT}
147   do_deep_twin (deep_twin_memory: DICTIONARY[LIBERTY_INTERPRETER_OBJECT, LIBERTY_INTERPRETER_OBJECT]; a_position: LIBERTY_POSITION): LIBERTY_INTERPRETER_OBJECT is
148      require
149         deep_twin_memory /= Void
150      deferred
151      end
152
153   do_deep_equal (object: LIBERTY_INTERPRETER_OBJECT; deep_equal_memory: SET[LIBERTY_INTERPRETER_OBJECT]; a_position: LIBERTY_POSITION): BOOLEAN is
154      require
155         object /= Void
156         deep_equal_memory /= Void
157      deferred
158      end
159
160feature {LIBERTY_INTERPRETER_OBJECT_PRINTER, LIBERTY_INTERPRETER_FEATURE_CALL}
161   show_stack (o: OUTPUT_STREAM; indent: INTEGER) is
162      deferred
163      end
164
165feature {}
166   expanded_twin: like Current is
167      require
168         type.is_expanded
169      deferred
170      ensure
171         is_equal(Result)
172      end
173
174   interpreter: LIBERTY_INTERPRETER
175
176   le_feature_name: LIBERTY_FEATURE_NAME is
177      once
178         create Result.infixed("<=".intern)
179      end
180
181feature {ANY}
182   accept (visitor: VISITOR) is
183      local
184         v: LIBERTY_INTERPRETER_OBJECT_VISITOR
185      do
186         v ::= visitor
187         v.visit_liberty_object(Current)
188      end
189
190feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
191   mark_reachable_code (mark: INTEGER) is
192      do
193         check False end
194      end
195
196invariant
197   type /= Void
198   interpreter /= Void
199
200end -- class LIBERTY_INTERPRETER_OBJECT