PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/semantics/code/instructions/liberty_loop.e

http://github.com/tybor/Liberty
Specman e | 103 lines | 80 code | 9 blank | 14 comment | 3 complexity | 9959ace146c89dd385d2280e5ecfd418 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_LOOP
 16
 17inherit
 18   LIBERTY_INSTRUCTION
 19
 20create {LIBERTY_BUILDER_TOOLS, LIBERTY_LOOP}
 21   make
 22
 23feature {ANY}
 24   init: LIBERTY_INSTRUCTION
 25   invariant_clause: LIBERTY_INVARIANT
 26   variant_clause: LIBERTY_VARIANT
 27   expression: LIBERTY_EXPRESSION
 28   body: LIBERTY_INSTRUCTION
 29
 30   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 31      local
 32         i: like init
 33         iv: like invariant_clause
 34         v: like variant_clause
 35         e: like expression
 36         b: like body
 37      do
 38         i := init.specialized_in(a_type)
 39         iv := invariant_clause.specialized_in(a_type)
 40         if variant_clause /= Void then
 41            v := variant_clause.specialized_in(a_type)
 42         end
 43         e := expression.specialized_in(a_type)
 44         b := body.specialized_in(a_type)
 45         if i = init and then iv = invariant_clause and then v = variant_clause and then e = expression and then b = body then
 46            Result := Current
 47         else
 48            create Result.make(i, iv, v, e, b, position)
 49         end
 50      end
 51
 52feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 53   mark_reachable_code (mark: INTEGER) is
 54      do
 55         init.mark_reachable_code(mark)
 56         invariant_clause.mark_reachable_code(mark)
 57         if variant_clause /= Void then
 58            variant_clause.mark_reachable_code(mark)
 59         end
 60         expression.mark_reachable_code(mark)
 61         body.mark_reachable_code(mark)
 62      end
 63
 64feature {}
 65   make (a_init: like init; a_invariant_clause: like invariant_clause; a_variant_clause: like variant_clause; a_expression: like expression; a_body: like body; a_position: like position) is
 66      require
 67         a_init /= Void
 68         a_invariant_clause /= Void
 69         a_expression /= Void
 70         a_body /= Void
 71         a_position /= Void
 72      do
 73         init := a_init
 74         invariant_clause := a_invariant_clause
 75         variant_clause := a_variant_clause
 76         expression := a_expression
 77         body := a_body
 78         position := a_position
 79      ensure
 80         init = a_init
 81         invariant_clause = a_invariant_clause
 82         variant_clause = a_variant_clause
 83         expression = a_expression
 84         body = a_body
 85         position = a_position
 86      end
 87
 88feature {ANY}
 89   accept (v: VISITOR) is
 90      local
 91         v0: LIBERTY_LOOP_VISITOR
 92      do
 93         v0 ::= v
 94         v0.visit_liberty_loop(Current)
 95      end
 96
 97invariant
 98   init /= Void
 99   invariant_clause /= Void
100   expression /= Void
101   body /= Void
102
103end