/src/tools/interpreter/liberty_interpreter_postcondition_browser.e
Specman e | 135 lines | 103 code | 18 blank | 14 comment | 2 complexity | dfe0cf4ec48d52646d5210e6d140bb55 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_POSTCONDITION_BROWSER 16 17inherit 18 LIBERTY_INTERPRETER_EXPRESSIONS 19 redefine 20 make, visit_liberty_old 21 end 22 LIBERTY_ASSERTION_VISITOR 23 24creation {LIBERTY_INTERPRETER} 25 make 26 27feature {LIBERTY_INTERPRETER_FEATURE_CALL} 28 gather_old (contract: LIBERTY_ASSERTIONS) is 29 do 30 if contract /= Void then 31 interpreter.start_gathering_old_values 32 contract.accept(Current) 33 interpreter.finished_gathering_old_values 34 end 35 end 36 37feature {LIBERTY_OLD} 38 visit_liberty_old (v: LIBERTY_OLD) is 39 do 40 if not interpreter.has_old_value(v.expression) then 41 interpreter.start_evaluating_old_value 42 v.expression.accept(Current) 43 interpreter.add_old_value(v.expression, eval_as_right_value) 44 end 45 end 46 47feature {LIBERTY_ASSERTIONS_AND_THEN} 48 visit_liberty_assertions_and_then (v: LIBERTY_ASSERTIONS_AND_THEN) is 49 do 50 v.left.accept(Current) 51 v.right.accept(Current) 52 end 53 54feature {LIBERTY_ASSERTIONS_OR_ELSE} 55 visit_liberty_assertions_or_else (v: LIBERTY_ASSERTIONS_OR_ELSE) is 56 do 57 v.left.accept(Current) 58 v.right.accept(Current) 59 end 60 61feature {LIBERTY_CHECK} 62 visit_liberty_check (v: LIBERTY_CHECK) is 63 do 64 check False end 65 end 66 67feature {LIBERTY_ENSURE} 68 visit_liberty_ensure (v: LIBERTY_ENSURE) is 69 do 70 gather_written_assertions(v) 71 end 72 73feature {LIBERTY_ENSURE_THEN} 74 visit_liberty_ensure_then (v: LIBERTY_ENSURE_THEN) is 75 do 76 gather_written_assertions(v) 77 end 78 79feature {LIBERTY_INVARIANT} 80 visit_liberty_invariant (v: LIBERTY_INVARIANT) is 81 do 82 check False end 83 end 84 85feature {LIBERTY_REQUIRE} 86 visit_liberty_require (v: LIBERTY_REQUIRE) is 87 do 88 check False end 89 end 90 91feature {LIBERTY_REQUIRE_ELSE} 92 visit_liberty_require_else (v: LIBERTY_REQUIRE_ELSE) is 93 do 94 check False end 95 end 96 97feature {LIBERTY_REQUIRE_THEN} 98 visit_liberty_require_then (v: LIBERTY_REQUIRE_THEN) is 99 do 100 check False end 101 end 102 103feature {LIBERTY_VARIANT} 104 visit_liberty_variant (v: LIBERTY_VARIANT) is 105 do 106 check False end 107 end 108 109feature {} 110 gather_written_assertions (contract: LIBERTY_WRITTEN_ASSERTIONS) is 111 local 112 assertions: TRAVERSABLE[LIBERTY_ASSERTION] 113 i: INTEGER 114 do 115 assertions := contract.assertions 116 from 117 i := assertions.lower 118 until 119 i > assertions.upper 120 loop 121 assertions.item(i).assertion.accept(Current) 122 i := i + 1 123 end 124 end 125 126feature {} 127 make (a_interpreter: like interpreter) is 128 do 129 interpreter := a_interpreter 130 end 131 132invariant 133 interpreter /= Void 134 135end -- class LIBERTY_INTERPRETER_POSTCONDITION_BROWSER