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

http://github.com/tybor/Liberty · Specman e · 107 lines · 82 code · 11 blank · 14 comment · 3 complexity · eaa25c5516a8601463dbc7e8146a4311 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. class LIBERTY_INLINE_AGENT
  16. inherit
  17. LIBERTY_EXPRESSION
  18. redefine
  19. is_agent_call
  20. end
  21. create {LIBERTY_BUILDER_TOOLS, LIBERTY_INLINE_AGENT}
  22. make
  23. feature {ANY}
  24. result_type: LIBERTY_TYPE is
  25. do
  26. Result := context.result_type
  27. end
  28. is_agent_call: BOOLEAN is True
  29. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  30. local
  31. ins: like instruction
  32. act: like actuals
  33. ctx: like context
  34. exp: LIBERTY_EXPRESSION
  35. i: INTEGER
  36. do
  37. ins := instruction.specialized_in(a_type)
  38. ctx := context.specialized_in(a_type)
  39. from
  40. act := actuals
  41. i := act.lower
  42. until
  43. i > act.upper
  44. loop
  45. exp := act.item(i).specialized_in(a_type)
  46. if exp /= act.item(i) then
  47. if act = actuals then
  48. act := act.twin
  49. end
  50. act.put(exp, i)
  51. end
  52. i := i + 1
  53. end
  54. if ins = instruction and then act = actuals and then ctx = context then
  55. Result := Current
  56. else
  57. create Result.make(ins, act, ctx)
  58. end
  59. end
  60. feature {ANY}
  61. accept (v: VISITOR) is
  62. local
  63. v0: LIBERTY_INLINE_AGENT_VISITOR
  64. do
  65. v0 ::= v
  66. v0.visit_liberty_inline_agent(Current)
  67. end
  68. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  69. mark_reachable_code (mark: INTEGER) is
  70. do
  71. instruction.mark_reachable_code(mark)
  72. expressions_marker.mark_reachable_code(mark, actuals)
  73. end
  74. feature {}
  75. make (a_instruction: like instruction; a_actuals: like actuals; a_context: like context) is
  76. require
  77. a_instruction /= Void
  78. a_actuals /= Void
  79. a_context /= Void
  80. do
  81. instruction := a_instruction
  82. actuals := a_actuals
  83. context := a_context
  84. ensure
  85. instruction = a_instruction
  86. actuals = a_actuals
  87. context = a_context
  88. end
  89. instruction: LIBERTY_INSTRUCTION
  90. actuals: COLLECTION[LIBERTY_EXPRESSION]
  91. context: LIBERTY_INLINE_AGENT_CONTEXT
  92. invariant
  93. instruction /= Void
  94. actuals /= Void
  95. context /= Void
  96. end