/src/tools/semantics/types/type_resolver/liberty_type_resolver_in_feature.e
Specman e | 133 lines | 101 code | 15 blank | 17 comment | 4 complexity | 5327093a9fd90ddc528509f35e3cd09f 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_TYPE_RESOLVER_IN_FEATURE 16 17inherit 18 LIBERTY_TYPE_RESOLVER 19 20creation {LIBERTY_TYPE_FEATURES_LOADER} 21 make 22 23creation {LIBERTY_FEATURE} 24 specialized 25 26feature {LIBERTY_FEATURE} 27 set_the_feature (a_feature: like the_feature; replace: BOOLEAN) is 28 require 29 a_feature.context = local_context 30 the_feature /= Void implies replace 31 do 32 the_feature := a_feature 33 ensure 34 the_feature = a_feature 35 end 36 37 feature_name: LIBERTY_AST_FEATURE_NAME 38 39feature {ANY} 40 local_context: LIBERTY_FEATURE_DEFINITION_CONTEXT 41 the_feature: LIBERTY_FEATURE 42 43 out_in_tagged_out_memory is 44 local 45 fnoa: LIBERTY_AST_FEATURE_NAME_OR_ALIAS 46 do 47 tagged_out_memory.append(once "resolver in feature ") 48 fnoa := feature_name.feature_name_or_alias 49 if fnoa.is_regular then 50 tagged_out_memory.append(fnoa.entity_name.image.image.intern) 51 elseif fnoa.is_prefix then 52 tagged_out_memory.append(once "prefix ") 53 tagged_out_memory.append(fnoa.free_operator_name.image.image.intern) 54 else 55 check fnoa.is_infix end 56 tagged_out_memory.append(once "infix ") 57 tagged_out_memory.append(fnoa.free_operator_name.image.image.intern) 58 end 59 end 60 61 specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is 62 do 63 Result := the_feature.specialized_in(a_type).type_resolver 64 end 65 66feature {} 67 lookup_type (type_definition: LIBERTY_AST_TYPE_DEFINITION): LIBERTY_TYPE is 68 local 69 name: FIXED_STRING 70 do 71 if type_definition.is_like_result then 72 if local_context.result_type = Void then 73 --|*** TODO: error: not a function 74 not_yet_implemented 75 end 76 Result := local_context.result_type 77 elseif type_definition.is_like_entity then 78 -- If it's an anchor to a parameter or a local, resolve it immediately. (TODO: beware of cycles!) 79 -- Other cases will be caught by parent resolvers. 80 name := type_definition.entity_anchor.image.image.intern 81 if local_context.is_parameter(name) then 82 Result := local_context.parameter(name).result_type 83 elseif local_context.is_local(name) then 84 Result := local_context.local_var(name).result_type 85 end 86 end 87 end 88 89 lookup_export_type (type_definition: LIBERTY_AST_TYPE_DEFINITION): LIBERTY_TYPE is 90 do 91 check Result = Void end 92 end 93 94 lookup_position (type_definition: LIBERTY_AST_TYPE_DEFINITION): LIBERTY_POSITION is 95 do 96 check Result = Void end 97 end 98 99feature {} 100 make (a_feature_name: like feature_name; a_local_context: like local_context) is 101 require 102 a_feature_name /= Void 103 a_local_context /= Void 104 do 105 feature_name := a_feature_name 106 local_context := a_local_context 107 ensure 108 feature_name = a_feature_name 109 local_context = a_local_context 110 end 111 112 specialized (a_feature_name: like feature_name; a_feature: like the_feature; a_parent: like parent) is 113 require 114 a_feature_name /= Void 115 a_feature /= Void 116 a_parent /= Void 117 do 118 feature_name := a_feature_name 119 local_context := a_feature.context 120 the_feature := a_feature 121 parent := a_parent 122 ensure 123 feature_name = a_feature_name 124 the_feature = a_feature 125 local_context = a_feature.context 126 parent = a_parent 127 end 128 129invariant 130 feature_name /= Void 131 local_context /= Void 132 133end -- class LIBERTY_TYPE_RESOLVER_IN_FEATURE