/src/tools/semantics/code/instructions/liberty_loop.e

http://github.com/tybor/Liberty · Specman e · 103 lines · 80 code · 9 blank · 14 comment · 3 complexity · 9959ace146c89dd385d2280e5ecfd418 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_LOOP
  16. inherit
  17. LIBERTY_INSTRUCTION
  18. create {LIBERTY_BUILDER_TOOLS, LIBERTY_LOOP}
  19. make
  20. feature {ANY}
  21. init: LIBERTY_INSTRUCTION
  22. invariant_clause: LIBERTY_INVARIANT
  23. variant_clause: LIBERTY_VARIANT
  24. expression: LIBERTY_EXPRESSION
  25. body: LIBERTY_INSTRUCTION
  26. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  27. local
  28. i: like init
  29. iv: like invariant_clause
  30. v: like variant_clause
  31. e: like expression
  32. b: like body
  33. do
  34. i := init.specialized_in(a_type)
  35. iv := invariant_clause.specialized_in(a_type)
  36. if variant_clause /= Void then
  37. v := variant_clause.specialized_in(a_type)
  38. end
  39. e := expression.specialized_in(a_type)
  40. b := body.specialized_in(a_type)
  41. if i = init and then iv = invariant_clause and then v = variant_clause and then e = expression and then b = body then
  42. Result := Current
  43. else
  44. create Result.make(i, iv, v, e, b, position)
  45. end
  46. end
  47. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  48. mark_reachable_code (mark: INTEGER) is
  49. do
  50. init.mark_reachable_code(mark)
  51. invariant_clause.mark_reachable_code(mark)
  52. if variant_clause /= Void then
  53. variant_clause.mark_reachable_code(mark)
  54. end
  55. expression.mark_reachable_code(mark)
  56. body.mark_reachable_code(mark)
  57. end
  58. feature {}
  59. make (a_init: like init; a_invariant_clause: like invariant_clause; a_variant_clause: like variant_clause; a_expression: like expression; a_body: like body; a_position: like position) is
  60. require
  61. a_init /= Void
  62. a_invariant_clause /= Void
  63. a_expression /= Void
  64. a_body /= Void
  65. a_position /= Void
  66. do
  67. init := a_init
  68. invariant_clause := a_invariant_clause
  69. variant_clause := a_variant_clause
  70. expression := a_expression
  71. body := a_body
  72. position := a_position
  73. ensure
  74. init = a_init
  75. invariant_clause = a_invariant_clause
  76. variant_clause = a_variant_clause
  77. expression = a_expression
  78. body = a_body
  79. position = a_position
  80. end
  81. feature {ANY}
  82. accept (v: VISITOR) is
  83. local
  84. v0: LIBERTY_LOOP_VISITOR
  85. do
  86. v0 ::= v
  87. v0.visit_liberty_loop(Current)
  88. end
  89. invariant
  90. init /= Void
  91. invariant_clause /= Void
  92. expression /= Void
  93. body /= Void
  94. end