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