/src/tools/semantics/code/liberty_call.e

http://github.com/tybor/Liberty · Specman e · 125 lines · 97 code · 14 blank · 14 comment · 5 complexity · b99bb591c66d417896dfec48a202ef61 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_CALL
  16. insert
  17. LIBERTY_REACHABLE
  18. LIBERTY_POSITIONABLE
  19. feature {ANY}
  20. target: LIBERTY_EXPRESSION is
  21. deferred
  22. end
  23. entity: LIBERTY_FEATURE_ENTITY is
  24. deferred
  25. end
  26. actuals: TRAVERSABLE[LIBERTY_EXPRESSION] is
  27. do
  28. Result := actuals_list
  29. end
  30. is_implicit_current: BOOLEAN is
  31. do
  32. Result := target = Void
  33. end
  34. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  35. local
  36. t: like target
  37. e: like entity
  38. a: like actuals_list
  39. x: LIBERTY_EXPRESSION
  40. i: INTEGER
  41. do
  42. if target /= Void then
  43. t := target.specialized_in(a_type)
  44. end
  45. e := entity.specialized_in(a_type)
  46. from
  47. a := actuals_list
  48. i := a.lower
  49. until
  50. i > a.upper
  51. loop
  52. x := a.item(i).specialized_in(a_type)
  53. if x /= a.item(i) then
  54. if a = actuals_list then
  55. a := a.twin
  56. end
  57. a.put(x, i)
  58. end
  59. i := i + 1
  60. end
  61. if t = target and then e = entity and then a = actuals_list then
  62. Result := Current
  63. else
  64. Result := make_new(t, e, a, position)
  65. end
  66. end
  67. feature {}
  68. register_for_promotion is
  69. require
  70. explicit_current: target /= Void
  71. do
  72. if actuals.count = 1 then
  73. create promotion.make(Current, target.result_type, actuals.first.result_type)
  74. end
  75. end
  76. promotion: LIBERTY_CALL_PROMOTION[like Current]
  77. make_new (a_target: like target; a_entity: like entity; a_actuals: like actuals_list; a_position: like position): like Current is
  78. require
  79. a_entity /= Void
  80. a_actuals /= Void
  81. a_position /= Void
  82. deferred
  83. ensure
  84. Result.target = a_target
  85. Result.entity = a_entity
  86. Result.actuals = a_actuals
  87. Result.position = a_position
  88. end
  89. actuals_list: COLLECTION[LIBERTY_EXPRESSION] is
  90. deferred
  91. end
  92. feature {LIBERTY_CALL_PROMOTION}
  93. set_entity (a_entity: like entity) is
  94. require
  95. a_entity /= Void
  96. deferred
  97. ensure
  98. entity = a_entity
  99. end
  100. set_target (a_target: like target) is
  101. require
  102. explicit_current: target /= Void
  103. still_explicit: a_target /= Void
  104. deferred
  105. ensure
  106. target = a_target
  107. end
  108. invariant
  109. entity /= Void
  110. actuals_list /= Void
  111. end -- class LIBERTY_CALL