PageRenderTime 143ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 135ms

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

http://github.com/tybor/Liberty
Specman e | 107 lines | 82 code | 11 blank | 14 comment | 3 complexity | cb17a74326ddcf3c554fa5442d81afef 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_EXPRESSION
 16
 17inherit
 18   LIBERTY_EXPRESSION
 19
 20create {LIBERTY_BUILDER_TOOLS, LIBERTY_CREATION_EXPRESSION}
 21   make
 22
 23feature {ANY}
 24   result_type: LIBERTY_TYPE
 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   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 33      local
 34         r: like result_type
 35         fe: like feature_entity
 36         fa: like feature_arguments_list
 37         e: LIBERTY_EXPRESSION
 38         i: INTEGER
 39      do
 40         r := result_type.specialized_in(a_type)
 41         fe := feature_entity.specialized_in(a_type)
 42         from
 43            fa := feature_arguments_list
 44            i := fa.lower
 45         until
 46            i > fa.upper
 47         loop
 48            e := fa.item(i).specialized_in(a_type)
 49            if e /= fa.item(i) then
 50               if fa = feature_arguments_list then
 51                  fa := fa.twin
 52               end
 53               fa.put(e, i)
 54            end
 55            i := i + 1
 56         end
 57         if r = result_type and then fe = feature_entity and then fa = feature_arguments_list then
 58            Result := Current
 59         else
 60            create Result.make(r, fe, fa, position)
 61         end
 62      end
 63
 64feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 65   mark_reachable_code (mark: INTEGER) is
 66      do
 67         result_type.mark_reachable_code(mark)
 68         feature_entity.mark_reachable_code(mark)
 69         expressions_marker.mark_reachable_code(mark, feature_arguments)
 70      end
 71
 72feature {}
 73   make (a_type: like result_type; a_feature_entity: like feature_entity; a_feature_arguments: like feature_arguments_list; a_position: like position) is
 74      require
 75         a_type /= Void
 76         a_feature_entity /= Void
 77         a_feature_arguments /= Void
 78         a_position /= Void
 79      do
 80         result_type := a_type
 81         feature_entity := a_feature_entity
 82         feature_arguments_list := a_feature_arguments
 83         position := a_position
 84      ensure
 85         result_type = a_type
 86         feature_entity = a_feature_entity
 87         feature_arguments_list = a_feature_arguments
 88         position = a_position
 89      end
 90
 91   feature_arguments_list: COLLECTION[LIBERTY_EXPRESSION]
 92
 93feature {ANY}
 94   accept (v: VISITOR) is
 95      local
 96         v0: LIBERTY_CREATION_EXPRESSION_VISITOR
 97      do
 98         v0 ::= v
 99         v0.visit_liberty_creation_expression(Current)
100      end
101
102invariant
103   result_type /= Void
104   feature_entity /= Void
105   feature_arguments /= Void
106
107end