PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/interpreter/liberty_interpreter_object_native.e

http://github.com/tybor/Liberty
Specman e | 162 lines | 129 code | 18 blank | 15 comment | 6 complexity | 6f1f5451a1c70f52395565a2dfac847e 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_NATIVE[E_]
 16
 17inherit
 18   LIBERTY_INTERPRETER_OBJECT
 19
 20feature {ANY}
 21   type: LIBERTY_ACTUAL_TYPE
 22
 23   is_equal (other: LIBERTY_INTERPRETER_OBJECT): BOOLEAN is
 24      local
 25         o: like Current
 26      do
 27         if other.is_void then
 28            -- Obviously this object is not Void.
 29         else
 30            o ::= other
 31            Result := item = o.item
 32         end
 33      end
 34
 35   item: E_
 36
 37   set_item (a_item: like item) is
 38      do
 39         item := a_item
 40      ensure
 41         item = a_item
 42      end
 43
 44feature {LIBERTY_INTERPRETER_EXTERNAL_TYPE_ANY_BUILTINS} -- Standard builtings
 45   builtin_is_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
 46      local
 47         o: like Current
 48      do
 49         if type = other.type then
 50            o ::= other
 51            Result := item.is_equal(o.item)
 52         else
 53            interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
 54         end
 55      end
 56
 57   builtin_standard_is_equal (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION): BOOLEAN is
 58      local
 59         o: like Current
 60      do
 61         if type = other.type then
 62            o ::= other
 63            Result := item.is_equal(o.item)
 64         else
 65            interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
 66         end
 67      end
 68
 69   builtin_copy (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION) is
 70      local
 71         o: like Current
 72      do
 73         if type = other.type then
 74            o ::= other
 75            item := o.item
 76         else
 77            interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
 78         end
 79      end
 80
 81   builtin_twin (a_position: LIBERTY_POSITION): like Current is
 82      do
 83         Result := as_right_value
 84      end
 85
 86   builtin_standard_copy (other: LIBERTY_INTERPRETER_OBJECT; a_position: LIBERTY_POSITION) is
 87      local
 88         o: like Current
 89      do
 90         if type = other.type then
 91            o ::= other
 92            item := o.item
 93         else
 94            interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
 95         end
 96      end
 97
 98   builtin_standard_twin (a_position: LIBERTY_POSITION): like Current is
 99      do
100         Result := as_right_value
101      end
102
103feature {LIBERTY_INTERPRETER_OBJECT}
104   do_deep_twin (deep_twin_memory: DICTIONARY[LIBERTY_INTERPRETER_OBJECT, LIBERTY_INTERPRETER_OBJECT]; a_position: LIBERTY_POSITION): LIBERTY_INTERPRETER_OBJECT is
105      do
106         Result := as_right_value
107      end
108
109   do_deep_equal (other: LIBERTY_INTERPRETER_OBJECT; deep_equal_memory: SET[LIBERTY_INTERPRETER_OBJECT]; a_position: LIBERTY_POSITION): BOOLEAN is
110      local
111         o: like Current
112      do
113         if type = other.type then
114            o ::= other
115            Result := item.is_equal(o.item)
116         else
117            interpreter.fatal_error("Type mismatch: expected " + type.full_name + ", but got " + other.type.full_name, a_position)
118         end
119      end
120
121feature {LIBERTY_INTERPRETER_OBJECT_PRINTER, LIBERTY_INTERPRETER_FEATURE_CALL}
122   show_stack (o: OUTPUT_STREAM; indent: INTEGER) is
123      do
124         item.print_on(o)
125         o.put_new_line
126      end
127
128feature {}
129   make (a_interpreter: like interpreter; a_type: like type; a_position: like position) is
130      require
131         a_interpreter /= Void
132         a_type /= Void
133         a_position /= Void
134      do
135         interpreter := a_interpreter
136         type := a_type
137         position := a_position
138      ensure
139         interpreter = a_interpreter
140         type = a_type
141         position = a_position
142      end
143
144   with_item (a_interpreter: like interpreter; a_type: like type; a_item: like item; a_position: like position) is
145      require
146         a_interpreter /= Void
147         a_type /= Void
148         a_position /= Void
149      do
150         make(a_interpreter, a_type, a_position)
151         item := a_item
152      ensure
153         interpreter = a_interpreter
154         type = a_type
155         item = a_item
156         position = a_position
157      end
158
159invariant
160   item_is_expanded: item /= Void
161
162end -- class LIBERTY_INTERPRETER_OBJECT_NATIVE