PageRenderTime 44ms CodeModel.GetById 35ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/semantics/code/expressions/liberty_inline_agent.e

http://github.com/tybor/Liberty
Specman e | 107 lines | 82 code | 11 blank | 14 comment | 3 complexity | eaa25c5516a8601463dbc7e8146a4311 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_INLINE_AGENT
 16
 17inherit
 18   LIBERTY_EXPRESSION
 19      redefine
 20         is_agent_call
 21      end
 22
 23create {LIBERTY_BUILDER_TOOLS, LIBERTY_INLINE_AGENT}
 24   make
 25
 26feature {ANY}
 27   result_type: LIBERTY_TYPE is
 28      do
 29         Result := context.result_type
 30      end
 31
 32   is_agent_call: BOOLEAN is True
 33
 34   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 35      local
 36         ins: like instruction
 37         act: like actuals
 38         ctx: like context
 39         exp: LIBERTY_EXPRESSION
 40         i: INTEGER
 41      do
 42         ins := instruction.specialized_in(a_type)
 43         ctx := context.specialized_in(a_type)
 44         from
 45            act := actuals
 46            i := act.lower
 47         until
 48            i > act.upper
 49         loop
 50            exp := act.item(i).specialized_in(a_type)
 51            if exp /= act.item(i) then
 52               if act = actuals then
 53                  act := act.twin
 54               end
 55               act.put(exp, i)
 56            end
 57            i := i + 1
 58         end
 59         if ins = instruction and then act = actuals and then ctx = context then
 60            Result := Current
 61         else
 62            create Result.make(ins, act, ctx)
 63         end
 64      end
 65
 66feature {ANY}
 67   accept (v: VISITOR) is
 68      local
 69         v0: LIBERTY_INLINE_AGENT_VISITOR
 70      do
 71         v0 ::= v
 72         v0.visit_liberty_inline_agent(Current)
 73      end
 74
 75feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 76   mark_reachable_code (mark: INTEGER) is
 77      do
 78         instruction.mark_reachable_code(mark)
 79         expressions_marker.mark_reachable_code(mark, actuals)
 80      end
 81
 82feature {}
 83   make (a_instruction: like instruction; a_actuals: like actuals; a_context: like context) is
 84      require
 85         a_instruction /= Void
 86         a_actuals /= Void
 87         a_context /= Void
 88      do
 89         instruction := a_instruction
 90         actuals := a_actuals
 91         context := a_context
 92      ensure
 93         instruction = a_instruction
 94         actuals = a_actuals
 95         context = a_context
 96      end
 97
 98   instruction: LIBERTY_INSTRUCTION
 99   actuals: COLLECTION[LIBERTY_EXPRESSION]
100   context: LIBERTY_INLINE_AGENT_CONTEXT
101
102invariant
103   instruction /= Void
104   actuals /= Void
105   context /= Void
106
107end