/src/tools/semantics/types/delayed_resolver/liberty_delayed_feature_type.e
Specman e | 139 lines | 105 code | 20 blank | 14 comment | 3 complexity | 873271506790ef7409f3798fcc9176c3 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_DELAYED_FEATURE_TYPE 16 17inherit 18 LIBERTY_DELAYED_RESOLVER 19 20insert 21 LIBERTY_REACHABLE 22 redefine out_in_tagged_out_memory, is_equal 23 end 24 25creation {LIBERTY_FEATURE_ENTITY, LIBERTY_DELAYED_FEATURE_TYPE} 26 make 27 28feature {ANY} 29 out_in_tagged_out_memory is 30 do 31 if can_resolve then 32 resolved.out_in_tagged_out_memory 33 else 34 tagged_out_memory.append(once "like (") 35 type.full_name.out_in_tagged_out_memory 36 tagged_out_memory.extend('.') 37 name.out_in_tagged_out_memory 38 tagged_out_memory.extend(')') 39 end 40 end 41 42 full_name: FIXED_STRING is 43 do 44 Result := full_name_memory 45 end 46 47 hash_code: INTEGER is 48 do 49 Result := full_name_memory.hash_code 50 end 51 52 is_equal (other: like Current): BOOLEAN is 53 do 54 Result := other = Current 55 end 56 57feature {LIBERTY_DELAYED_TYPE} 58 can_resolve: BOOLEAN is 59 do 60 Result := is_ready 61 and then the_feature.result_type /= Void 62 and then the_feature.result_type.is_known 63 end 64 65 resolved: LIBERTY_KNOWN_TYPE is 66 do 67 Result := the_feature.result_type.known_type 68 end 69 70feature {LIBERTY_DELAYED_TYPE, LIBERTY_FEATURE_ENTITY} 71 specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is 72 local 73 t: like type 74 do 75 t := type.specialized_in(a_type) 76 if t = type then 77 Result := Current 78 else 79 create Result.make(t, name) -- ????? 80 end 81 end 82 83feature {LIBERTY_FEATURE_ENTITY} 84 is_ready: BOOLEAN is 85 do 86 Result := type.is_known 87 and then type.known_type.has_feature(name) 88 and then type.known_type.feature_definition(name).the_feature /= Void 89 end 90 91 the_feature: LIBERTY_FEATURE is 92 require 93 is_ready 94 do 95 Result := type.known_type.feature_definition(name).the_feature 96 end 97 98 name: LIBERTY_FEATURE_NAME 99 type: LIBERTY_TYPE 100 101feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER} 102 mark_reachable_code (mark: INTEGER) is 103 do 104 type.mark_reachable_code(mark) 105 if is_ready then 106 the_feature.mark_reachable_code(mark) 107 end 108 end 109 110feature {} 111 make (a_type: like type; a_name: like name) is 112 require 113 a_type /= Void 114 a_name /= Void 115 do 116 type := a_type 117 name := a_name 118 119 lock_tagged_out 120 tagged_out_memory.copy(once "like (") 121 type.full_name.out_in_tagged_out_memory 122 tagged_out_memory.extend('.') 123 name.out_in_tagged_out_memory 124 tagged_out_memory.extend(')') 125 unlock_tagged_out 126 127 full_name_memory := tagged_out_memory.intern 128 ensure 129 type = a_type 130 name = a_name 131 end 132 133 full_name_memory: FIXED_STRING 134 135invariant 136 type /= Void 137 name /= Void 138 139end -- class LIBERTY_DELAYED_FEATURE_TYPE