/src/tools/semantics/code/features/liberty_feature_redefined.e
Specman e | 193 lines | 155 code | 23 blank | 15 comment | 12 complexity | 1fc51bcca93c261373faea19e4d3a6bb 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_FEATURE_REDEFINED 16 17inherit 18 LIBERTY_FEATURE 19 rename 20 make as make_late_binding 21 redefine 22 mark_reachable_code, add_if_redefined, do_debug_display, set_specialized_in, 23 has_accelerator, accelerate_call 24 end 25 26create {LIBERTY_BUILDER_TOOLS} 27 make 28 29feature {ANY} 30 redefined_feature: LIBERTY_FEATURE 31 32 accept (v: VISITOR) is 33 local 34 v0: LIBERTY_FEATURE_REDEFINED_VISITOR 35 do 36 v0 ::= v 37 v0.visit_liberty_feature_redefined(Current) 38 end 39 40 has_accelerator: BOOLEAN is 41 do 42 Result := redefined_feature /= Void and then redefined_feature.has_accelerator 43 end 44 45 accelerate_call (a: LIBERTY_FEATURE_ACCELERATOR) is 46 do 47 redefined_feature.accelerate_call(a) 48 end 49 50feature {LIBERTY_FEATURE} 51 set_specialized_in (a_original: like Current; a_context: like context) is 52 do 53 Precursor(a_original, a_context) 54 if redefined_feature /= Void then 55 redefined_feature := redefined_feature.specialized_in(a_context.current_type) 56 end 57 end 58 59 do_debug_display (o: OUTPUT_STREAM; tab: INTEGER) is 60 do 61 Precursor(o, tab) 62 tabulate(o, tab + 1) 63 if redefined_feature = Void then 64 o.put_line(once "(unknown or unattached redefined feature)") 65 else 66 redefined_feature.do_debug_display(o, tab + 1) 67 end 68 end 69 70feature {LIBERTY_BUILDER_TOOLS} 71 add_if_redefined (type: LIBERTY_ACTUAL_TYPE; name: LIBERTY_FEATURE_NAME; redefined_features: DICTIONARY[LIBERTY_FEATURE_REDEFINED, LIBERTY_FEATURE_NAME]) is 72 do 73 if definition_type = type then 74 if not redefined_features.has(name) then 75 redefined_features.add(Current, name) 76 end 77 end 78 end 79 80feature {} 81 do_join (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 82 do 83 Result := a_feature.joined_redefined(a_type, Current, other_fd, current_fd) 84 end 85 86feature {LIBERTY_FEATURE} 87 joined_attribute (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_ATTRIBUTE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 88 do 89 if a_feature.definition_type = definition_type then 90 current_fd.fatal_join_error_redefined_concrete(a_type, other_fd) 91 end 92 Result := Current 93 end 94 95 joined_constant (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_CONSTANT; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 96 do 97 if a_feature.definition_type = definition_type then 98 current_fd.fatal_join_error_redefined_concrete(a_type, other_fd) 99 end 100 Result := Current 101 end 102 103 joined_deferred (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_DEFERRED; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 104 do 105 if a_feature.definition_type = definition_type then 106 --| *** TODO: warning, mixed undefine and redefine, expected redefinition 107 end 108 Result := Current 109 end 110 111 joined_do (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_DO; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 112 do 113 if a_feature.definition_type = definition_type then 114 current_fd.fatal_join_error_redefined_concrete(a_type, other_fd) 115 end 116 Result := Current 117 end 118 119 joined_external (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_EXTERNAL; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 120 do 121 if a_feature.definition_type = definition_type then 122 current_fd.fatal_join_error_redefined_concrete(a_type, other_fd) 123 end 124 Result := Current 125 end 126 127 joined_once (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_ONCE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 128 do 129 if a_feature.definition_type = definition_type then 130 current_fd.fatal_join_error_redefined_concrete(a_type, other_fd) 131 end 132 Result := Current 133 end 134 135 joined_redefined (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_REDEFINED; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 136 do 137 Result := Current 138 end 139 140 joined_unique (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_UNIQUE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is 141 do 142 if a_feature.definition_type = definition_type then 143 current_fd.fatal_join_error_redefined_concrete(a_type, other_fd) 144 end 145 Result := Current 146 end 147 148feature {LIBERTY_BUILDER_TOOLS} 149 set_redefined_feature (a_feature: like redefined_feature) is 150 require 151 only_once: redefined_feature = Void 152 useful: a_feature /= Void 153 do 154 check 155 a_feature.type_resolver /= Void 156 end 157 type_resolver := a_feature.type_resolver 158 redefined_feature := a_feature 159 set_precondition(a_feature.precondition) 160 set_postcondition(a_feature.postcondition) 161 set_context(a_feature.context) 162 set_obsolete(a_feature.obsolete_message) 163 a_feature.set_is_redefined 164 type_resolver.set_the_feature(Current, True) 165 torch.burn 166 ensure 167 redefined_feature = a_feature 168 end 169 170feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER} 171 mark_reachable_code (mark: INTEGER) is 172 local 173 old_mark: like reachable_mark 174 do 175 old_mark := reachable_mark 176 Precursor(mark) 177 if old_mark < mark and then redefined_feature /= Void then 178 redefined_feature.mark_reachable_code(mark) 179 end 180 end 181 182feature {} 183 make (a_definition_type: like definition_type) is 184 do 185 make_late_binding(a_definition_type, Void) 186 end 187 188invariant 189 not is_redefined 190 redefined_feature /= Void implies redefined_feature.is_redefined 191 accelerator = Void 192 193end