/src/tools/semantics/code/liberty_call.e
Specman e | 125 lines | 97 code | 14 blank | 14 comment | 5 complexity | b99bb591c66d417896dfec48a202ef61 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-- 15deferred class LIBERTY_CALL 16 17insert 18 LIBERTY_REACHABLE 19 LIBERTY_POSITIONABLE 20 21feature {ANY} 22 target: LIBERTY_EXPRESSION is 23 deferred 24 end 25 26 entity: LIBERTY_FEATURE_ENTITY is 27 deferred 28 end 29 30 actuals: TRAVERSABLE[LIBERTY_EXPRESSION] is 31 do 32 Result := actuals_list 33 end 34 35 is_implicit_current: BOOLEAN is 36 do 37 Result := target = Void 38 end 39 40 specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is 41 local 42 t: like target 43 e: like entity 44 a: like actuals_list 45 x: LIBERTY_EXPRESSION 46 i: INTEGER 47 do 48 if target /= Void then 49 t := target.specialized_in(a_type) 50 end 51 e := entity.specialized_in(a_type) 52 from 53 a := actuals_list 54 i := a.lower 55 until 56 i > a.upper 57 loop 58 x := a.item(i).specialized_in(a_type) 59 if x /= a.item(i) then 60 if a = actuals_list then 61 a := a.twin 62 end 63 a.put(x, i) 64 end 65 i := i + 1 66 end 67 if t = target and then e = entity and then a = actuals_list then 68 Result := Current 69 else 70 Result := make_new(t, e, a, position) 71 end 72 end 73 74feature {} 75 register_for_promotion is 76 require 77 explicit_current: target /= Void 78 do 79 if actuals.count = 1 then 80 create promotion.make(Current, target.result_type, actuals.first.result_type) 81 end 82 end 83 84 promotion: LIBERTY_CALL_PROMOTION[like Current] 85 86 make_new (a_target: like target; a_entity: like entity; a_actuals: like actuals_list; a_position: like position): like Current is 87 require 88 a_entity /= Void 89 a_actuals /= Void 90 a_position /= Void 91 deferred 92 ensure 93 Result.target = a_target 94 Result.entity = a_entity 95 Result.actuals = a_actuals 96 Result.position = a_position 97 end 98 99 actuals_list: COLLECTION[LIBERTY_EXPRESSION] is 100 deferred 101 end 102 103feature {LIBERTY_CALL_PROMOTION} 104 set_entity (a_entity: like entity) is 105 require 106 a_entity /= Void 107 deferred 108 ensure 109 entity = a_entity 110 end 111 112 set_target (a_target: like target) is 113 require 114 explicit_current: target /= Void 115 still_explicit: a_target /= Void 116 deferred 117 ensure 118 target = a_target 119 end 120 121invariant 122 entity /= Void 123 actuals_list /= Void 124 125end -- class LIBERTY_CALL