PageRenderTime 82ms CodeModel.GetById 79ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/interpreter/liberty_interpreter_native_array_creator.e

http://github.com/tybor/Liberty
Specman e | 193 lines | 146 code | 33 blank | 14 comment | 0 complexity | 20fdd003a8f478747398a1d6242f264a 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_NATIVE_ARRAY_CREATOR
 16
 17inherit
 18   LIBERTY_TYPE_VISITOR
 19
 20creation {LIBERTY_INTERPRETER}
 21   make
 22
 23feature {LIBERTY_INTERPRETER}
 24   new_array (type: like array_type; a_capacity: INTEGER; a_position: like position): LIBERTY_INTERPRETER_NATIVE_ARRAY is
 25      do
 26         array_type := type
 27         capacity := a_capacity
 28         position := a_position
 29         elements := default_pointer
 30         check
 31            type.parameters.count = 1
 32         end
 33         type.parameters.first.known_type.accept(Current)
 34         Result := last_created
 35      ensure
 36         Result.type = type
 37      end
 38
 39   from_external (type: like array_type; a_capacity: INTEGER; a_elements: POINTER; a_position: like position): LIBERTY_INTERPRETER_NATIVE_ARRAY is
 40      do
 41         array_type := type
 42         capacity := a_capacity
 43         position := a_position
 44         elements := a_elements
 45         check
 46            type.parameters.count = 1
 47         end
 48         type.parameters.first.known_type.accept(Current)
 49         Result := last_created
 50      end
 51
 52feature {LIBERTY_UNIVERSE}
 53   visit_type_any (type: LIBERTY_ACTUAL_TYPE) is
 54      do
 55         check False end
 56      end
 57
 58   visit_type_arguments (type: LIBERTY_ACTUAL_TYPE) is
 59      do
 60         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_OBJECT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 61      end
 62
 63   visit_type_platform (type: LIBERTY_ACTUAL_TYPE) is
 64      do
 65         check False end
 66      end
 67
 68   visit_type_pointer (type: LIBERTY_ACTUAL_TYPE) is
 69      do
 70         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[POINTER]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 71      end
 72
 73   visit_type_integer_64 (type: LIBERTY_ACTUAL_TYPE) is
 74      do
 75         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 76      end
 77
 78   visit_type_integer_32 (type: LIBERTY_ACTUAL_TYPE) is
 79      do
 80         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 81      end
 82
 83   visit_type_integer_16 (type: LIBERTY_ACTUAL_TYPE) is
 84      do
 85         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 86      end
 87
 88   visit_type_integer_8 (type: LIBERTY_ACTUAL_TYPE) is
 89      do
 90         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[INTEGER_64]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 91      end
 92
 93   visit_type_real_64 (type: LIBERTY_ACTUAL_TYPE) is
 94      do
 95         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
 96      end
 97
 98   visit_type_real_32 (type: LIBERTY_ACTUAL_TYPE) is
 99      do
100         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
101      end
102
103   visit_type_real_80 (type: LIBERTY_ACTUAL_TYPE) is
104      do
105         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
106      end
107
108   visit_type_real_128 (type: LIBERTY_ACTUAL_TYPE) is
109      do
110         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[REAL_128]} last_created.make(interpreter, array_type, type, elements, capacity, position)
111      end
112
113   visit_type_character (type: LIBERTY_ACTUAL_TYPE) is
114      do
115         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[CHARACTER]} last_created.make(interpreter, array_type, type, elements, capacity, position)
116      end
117
118   visit_type_string (type: LIBERTY_ACTUAL_TYPE) is
119      do
120         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_OBJECT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
121      end
122
123   visit_type_boolean (type: LIBERTY_ACTUAL_TYPE) is
124      do
125         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[BOOLEAN]} last_created.make(interpreter, array_type, type, elements, capacity, position)
126      end
127
128   visit_type_native_array (type: LIBERTY_ACTUAL_TYPE) is
129      do
130         interpreter.fatal_error("Don't try to make NATIVE_ARRAY[NATIVE_ARRAY]!!!", position)
131      end
132
133   visit_type_tuple (type: LIBERTY_ACTUAL_TYPE) is
134      do
135         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[TUPLE]} last_created.make(interpreter, array_type, type, elements, capacity, position)
136      end
137
138   visit_type_routine (type: LIBERTY_ACTUAL_TYPE) is
139      do
140         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
141      end
142
143   visit_type_procedure (type: LIBERTY_ACTUAL_TYPE) is
144      do
145         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
146      end
147
148   visit_type_function (type: LIBERTY_ACTUAL_TYPE) is
149      do
150         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
151      end
152
153   visit_type_predicate (type: LIBERTY_ACTUAL_TYPE) is
154      do
155         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_AGENT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
156      end
157
158   visit_user_type (type: LIBERTY_ACTUAL_TYPE) is
159      do
160         create {LIBERTY_INTERPRETER_NATIVE_ARRAY_TYPED[LIBERTY_INTERPRETER_OBJECT]} last_created.make(interpreter, array_type, type, elements, capacity, position)
161      end
162
163feature {LIBERTY_VOID_TYPE}
164   visit_void (type: LIBERTY_VOID_TYPE) is
165      do
166         check False end
167      end
168
169feature {}
170   make (a_interpreter: like interpreter) is
171      require
172         a_interpreter /= Void
173      do
174         interpreter := a_interpreter
175      ensure
176         interpreter = a_interpreter
177      end
178
179   last_created: LIBERTY_INTERPRETER_NATIVE_ARRAY
180   interpreter: LIBERTY_INTERPRETER
181
182   position: LIBERTY_POSITION
183   array_type: LIBERTY_ACTUAL_TYPE
184   capacity: INTEGER
185   elements: POINTER
186
187   native_array_creator: LIBERTY_INTERPRETER_NATIVE_ARRAY_CREATOR
188
189invariant
190   interpreter /= Void
191   native_array_creator /= Void
192
193end -- class LIBERTY_INTERPRETER_NATIVE_ARRAY_CREATOR