PageRenderTime 26ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/tybor/Liberty
Specman e | 106 lines | 78 code | 14 blank | 14 comment | 1 complexity | 1f582dda3b5539f0fe3d8b7198deb959 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--
 15deferred class LIBERTY_INFIX_CALL
 16
 17inherit
 18   LIBERTY_EXPRESSION
 19
 20insert
 21   LIBERTY_CALL
 22
 23feature {ANY}
 24   target: LIBERTY_EXPRESSION
 25   entity: LIBERTY_FEATURE_ENTITY
 26
 27   result_type: LIBERTY_TYPE is
 28      do
 29         Result := entity.result_type
 30      end
 31
 32feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
 33   mark_reachable_code (mark: INTEGER) is
 34      do
 35         target.mark_reachable_code(mark)
 36         entity.mark_reachable_code(mark)
 37         expressions_marker.mark_reachable_code(mark, actuals)
 38      end
 39
 40feature {}
 41   make (a_left, a_right: LIBERTY_EXPRESSION; a_entity_builder: FUNCTION[TUPLE[LIBERTY_TYPE, LIBERTY_FEATURE_NAME], LIBERTY_FEATURE_ENTITY]; a_position: like position) is
 42      require
 43         a_left /= Void
 44         a_right /= Void
 45         a_entity_builder /= Void
 46         a_position /= Void
 47      do
 48         create infix_name.make_infix(the_infix_name, a_position)
 49         target := a_left
 50         actuals_list := {FAST_ARRAY[LIBERTY_EXPRESSION] << a_right >> }
 51         entity := a_entity_builder.item([target.result_type, infix_name])
 52         position := a_position
 53         register_for_promotion
 54      ensure
 55         target = a_left or else {LIBERTY_CAST_EXPRESSION} ?:= target
 56         actuals.first = a_right
 57         position = a_position
 58      end
 59
 60   new (a_target: like target; a_entity: like entity; a_actuals: like actuals_list; a_position: like position) is
 61      require
 62         a_target /= Void
 63         a_actuals.count = 1
 64         a_position /= Void
 65      do
 66         target := a_target
 67         entity := a_entity
 68         actuals_list := a_actuals
 69         position := a_position
 70      ensure
 71         target = a_target
 72         entity = a_entity
 73         actuals_list = a_actuals
 74         position = a_position
 75      end
 76
 77   infix_name: LIBERTY_FEATURE_NAME is
 78      attribute
 79      ensure
 80         Result.is_infix
 81      end
 82
 83   the_infix_name: FIXED_STRING is
 84      deferred
 85      ensure
 86         Result /= Void
 87      end
 88
 89   actuals_list: COLLECTION[LIBERTY_EXPRESSION]
 90
 91feature {LIBERTY_CALL_PROMOTION}
 92   set_entity (a_entity: like entity) is
 93      do
 94         entity := a_entity
 95      end
 96
 97   set_target (a_target: like target) is
 98      do
 99         target := a_target
100      end
101
102invariant
103   actuals.count = 1
104   not is_implicit_current
105
106end