PageRenderTime 24ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/tybor/Liberty
Specman e | 126 lines | 99 code | 13 blank | 14 comment | 5 complexity | ce81d92a5532f5a479c606d5f2a100f3 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_CREATION_INSTRUCTION
 16
 17inherit
 18   LIBERTY_INSTRUCTION
 19
 20create {LIBERTY_BUILDER_TOOLS, LIBERTY_CREATION_INSTRUCTION}
 21   make
 22
 23feature {ANY}
 24   writable: LIBERTY_WRITABLE
 25   feature_entity: LIBERTY_FEATURE_ENTITY
 26
 27   feature_arguments: TRAVERSABLE[LIBERTY_EXPRESSION] is
 28      do
 29         Result := feature_arguments_list
 30      end
 31
 32   type: LIBERTY_TYPE is
 33      do
 34         if explicit_type = Void then
 35            Result := writable.result_type
 36         else
 37            Result := explicit_type
 38         end
 39      end
 40
 41   is_known: BOOLEAN is True
 42
 43   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 44      local
 45         w: like writable
 46         fe: like feature_entity
 47         fa: like feature_arguments_list
 48         et: like explicit_type
 49         e: LIBERTY_EXPRESSION
 50         i: INTEGER
 51      do
 52         w := writable.specialized_in(a_type)
 53         fe := feature_entity.specialized_in(a_type)
 54         from
 55            fa := feature_arguments_list
 56            i := fa.lower
 57         until
 58            i > fa.upper
 59         loop
 60            e := fa.item(i).specialized_in(a_type)
 61            if e /= fa.item(i) then
 62               if fa = feature_arguments_list then
 63                  fa := fa.twin
 64               end
 65               fa.put(e, i)
 66            end
 67            i := i + 1
 68         end
 69         if explicit_type /= Void then
 70            et := explicit_type.specialized_in(a_type)
 71         end
 72         if w = writable and then fe = feature_entity and then fa = feature_arguments_list and then et = explicit_type then
 73            Result := Current
 74         else
 75            create Result.make(w, et, fe, fa, position)
 76         end
 77      end
 78
 79feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 80   mark_reachable_code (mark: INTEGER) is
 81      do
 82         type.mark_reachable_code(mark)
 83         writable.mark_reachable_code(mark)
 84         feature_entity.mark_reachable_code(mark)
 85         expressions_marker.mark_reachable_code(mark, feature_arguments)
 86      end
 87
 88feature {}
 89   make (a_writable: like writable; a_type: like type; a_feature_entity: like feature_entity; a_feature_arguments: like feature_arguments_list; a_position: like position) is
 90      require
 91         a_writable /= Void
 92         a_feature_entity /= Void
 93         a_feature_arguments /= Void
 94         a_position /= Void
 95      do
 96         writable := a_writable
 97         explicit_type := a_type
 98         feature_entity := a_feature_entity
 99         feature_arguments_list := a_feature_arguments
100         position := a_position
101      ensure
102         writable = a_writable
103         a_type /= Void implies type = a_type
104         feature_entity = a_feature_entity
105         feature_arguments_list = a_feature_arguments
106         position = a_position
107      end
108
109   explicit_type: LIBERTY_TYPE
110   feature_arguments_list: COLLECTION[LIBERTY_EXPRESSION]
111
112feature {ANY}
113   accept (v: VISITOR) is
114      local
115         v0: LIBERTY_CREATION_INSTRUCTION_VISITOR
116      do
117         v0 ::= v
118         v0.visit_liberty_creation_instruction(Current)
119      end
120
121invariant
122   writable /= Void
123   feature_entity /= Void
124   feature_arguments /= Void
125
126end