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

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

http://github.com/tybor/Liberty
Specman e | 123 lines | 93 code | 13 blank | 17 comment | 3 complexity | abb966eec0f61e7477b07bec5ab9e876 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_ASSIGNMENT_TEST
 16
 17inherit
 18   LIBERTY_EXPRESSION
 19
 20create {LIBERTY_BUILDER_TOOLS, LIBERTY_ASSIGNMENT_TEST}
 21   test_entity, test_type
 22
 23feature {ANY}
 24   result_type: LIBERTY_TYPE
 25
 26   expression: LIBERTY_EXPRESSION
 27
 28   tested_type: LIBERTY_TYPE is
 29      do
 30         if type /= Void then
 31            Result := type
 32         else
 33            Result := entity.result_type
 34         end
 35      end
 36
 37   specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
 38      local
 39         e: like expression
 40         n: like entity
 41         t: like type
 42      do
 43         check
 44            result_type.specialized_in(a_type) = result_type
 45         end
 46         e := expression.specialized_in(a_type)
 47         if entity /= Void then
 48            n := entity.specialized_in(a_type)
 49         else
 50            t := type.specialized_in(a_type)
 51         end
 52         if e = expression and then n = entity and then t = type then
 53            Result := Current
 54         elseif n /= Void then
 55            create Result.test_entity(n, e, result_type, position)
 56         else
 57            create Result.test_type(t, e, result_type, position)
 58         end
 59      end
 60
 61feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 62   mark_reachable_code (mark: INTEGER) is
 63      do
 64         -- nothing
 65      end
 66
 67feature {}
 68   test_entity (a_entity: like entity; a_expression: like expression; a_result_type: like result_type; a_position: like position) is
 69      require
 70         a_entity /= Void
 71         a_expression /= Void
 72         a_result_type /= Void
 73         -- a_result_type is BOOLEAN
 74         a_position /= Void
 75      do
 76         entity := a_entity
 77         expression := a_expression
 78         result_type := a_result_type
 79         position := a_position
 80      ensure
 81         entity = a_entity
 82         expression = a_expression
 83         result_type = a_result_type
 84         type = Void
 85         position = a_position
 86      end
 87
 88   test_type (a_type: like type; a_expression: like expression; a_result_type: like result_type; a_position: like position) is
 89      require
 90         a_type /= Void
 91         a_expression /= Void
 92         a_result_type /= Void
 93         -- a_result_type is BOOLEAN
 94         a_position /= Void
 95      do
 96         type := a_type
 97         expression := a_expression
 98         result_type := a_result_type
 99         position := a_position
100      ensure
101         type = a_type
102         expression = a_expression
103         result_type = a_result_type
104         entity = Void
105         position = a_position
106      end
107
108   entity: LIBERTY_ENTITY
109   type: LIBERTY_ACTUAL_TYPE --|*** TODO: ??? we cannot check generics assignment???
110
111feature {ANY}
112   accept (v: VISITOR) is
113      local
114         v0: LIBERTY_ASSIGNMENT_TEST_VISITOR
115      do
116         v0 ::= v
117         v0.visit_liberty_assignment_test(Current)
118      end
119
120invariant
121   (entity /= Void) /= (type /= Void)
122
123end