/src/tools/interpreter/liberty_interpreter_to_external.e
Specman e | 204 lines | 158 code | 32 blank | 14 comment | 0 complexity | 8b11097cb04ab29a402b64b3b9dc1697 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_TO_EXTERNAL 16 17inherit 18 LIBERTY_TYPE_VISITOR 19 20create {LIBERTY_INTERPRETER_EXTERNAL_PLUGINS} 21 make 22 23feature {LIBERTY_INTERPRETER_EXTERNAL_PLUGINS} 24 item (a_object: LIBERTY_INTERPRETER_OBJECT): FOREIGN_OBJECT is 25 require 26 a_object /= Void 27 do 28 liberty_object := a_object 29 a_object.result_type.known_type.accept(Current) 30 Result := external_object 31 end 32 33feature {} 34 external_object: FOREIGN_OBJECT 35 liberty_object: LIBERTY_INTERPRETER_OBJECT 36 37feature {LIBERTY_UNIVERSE} 38 visit_type_any (a_type: LIBERTY_ACTUAL_TYPE) is 39 do 40 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 41 end 42 43 visit_type_arguments (a_type: LIBERTY_ACTUAL_TYPE) is 44 do 45 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 46 end 47 48 visit_type_platform (a_type: LIBERTY_ACTUAL_TYPE) is 49 do 50 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 51 end 52 53 visit_type_pointer (a_type: LIBERTY_ACTUAL_TYPE) is 54 local 55 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[POINTER] 56 do 57 p ::= liberty_object 58 external_object := foreign_types.create_pointer(p.item) 59 end 60 61 visit_type_integer_64 (a_type: LIBERTY_ACTUAL_TYPE) is 62 local 63 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64] 64 do 65 p ::= liberty_object 66 external_object := foreign_types.create_sint64(p.item) 67 end 68 69 visit_type_integer_32 (a_type: LIBERTY_ACTUAL_TYPE) is 70 local 71 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64] 72 do 73 p ::= liberty_object 74 external_object := foreign_types.create_sint32(p.item.to_integer_32) 75 end 76 77 visit_type_integer_16 (a_type: LIBERTY_ACTUAL_TYPE) is 78 local 79 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64] 80 do 81 p ::= liberty_object 82 external_object := foreign_types.create_sint16(p.item.to_integer_16) 83 end 84 85 visit_type_integer_8 (a_type: LIBERTY_ACTUAL_TYPE) is 86 local 87 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[INTEGER_64] 88 do 89 p ::= liberty_object 90 external_object := foreign_types.create_sint8(p.item.to_integer_8) 91 end 92 93 visit_type_real_64 (a_type: LIBERTY_ACTUAL_TYPE) is 94 local 95 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128] 96 do 97 p ::= liberty_object 98 external_object := foreign_types.create_double(p.item.force_to_real_64) 99 end 100 101 visit_type_real_32 (a_type: LIBERTY_ACTUAL_TYPE) is 102 local 103 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[REAL_128] 104 do 105 p ::= liberty_object 106 external_object := foreign_types.create_double(p.item.force_to_real_32) 107 end 108 109 visit_type_real_80 (a_type: LIBERTY_ACTUAL_TYPE) is 110 do 111 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 112 end 113 114 visit_type_real_128 (a_type: LIBERTY_ACTUAL_TYPE) is 115 do 116 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 117 end 118 119 visit_type_character (a_type: LIBERTY_ACTUAL_TYPE) is 120 local 121 p: LIBERTY_INTERPRETER_OBJECT_NATIVE[CHARACTER] 122 do 123 p ::= liberty_object 124 external_object := foreign_types.create_schar(p.item) 125 end 126 127 visit_type_string (a_type: LIBERTY_ACTUAL_TYPE) is 128 do 129 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 130 end 131 132 visit_type_boolean (a_type: LIBERTY_ACTUAL_TYPE) is 133 local 134 p: LIBERTY_INTERPRETER_OBJECT_BOOLEAN 135 do 136 p ::= liberty_object 137 external_object := foreign_types.create_sint32(p.item.to_integer) 138 end 139 140 visit_type_native_array (a_type: LIBERTY_ACTUAL_TYPE) is 141 local 142 p: LIBERTY_INTERPRETER_NATIVE_ARRAY 143 do 144 p ::= liberty_object 145 external_object := foreign_types.create_pointer(p.to_external) 146 end 147 148 visit_type_tuple (a_type: LIBERTY_ACTUAL_TYPE) is 149 do 150 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 151 end 152 153 visit_type_routine (a_type: LIBERTY_ACTUAL_TYPE) is 154 do 155 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 156 end 157 158 visit_type_procedure (a_type: LIBERTY_ACTUAL_TYPE) is 159 do 160 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 161 end 162 163 visit_type_function (a_type: LIBERTY_ACTUAL_TYPE) is 164 do 165 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 166 end 167 168 visit_type_predicate (a_type: LIBERTY_ACTUAL_TYPE) is 169 do 170 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 171 end 172 173 visit_user_type (a_type: LIBERTY_ACTUAL_TYPE) is 174 do 175 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 176 end 177 178feature {LIBERTY_VOID_TYPE} 179 visit_void (a_type: LIBERTY_VOID_TYPE) is 180 do 181 interpreter.fatal_error("The type " + a_type.full_name + " cannot be transmitted to a plugin", errors.unknown_position) 182 end 183 184feature {} 185 make (a_interpreter: like interpreter) is 186 require 187 a_interpreter /= Void 188 do 189 interpreter := a_interpreter 190 ensure 191 interpreter = a_interpreter 192 end 193 194 interpreter: LIBERTY_INTERPRETER 195 foreign_types: FOREIGN_TYPES 196 197 storage_attribute: FIXED_STRING is 198 once 199 Result := "storage".intern 200 end 201 202 errors: LIBERTY_ERRORS 203 204end -- LIBERTY_INTERPRETER_TO_EXTERNAL