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

http://github.com/tybor/Liberty · Specman e · 131 lines · 102 code · 15 blank · 14 comment · 3 complexity · 1870acaccffd476bd1e173357e34d5bf 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_INSPECT_CLAUSE
  16. insert
  17. LIBERTY_POSITIONABLE
  18. LIBERTY_REACHABLE
  19. create {LIBERTY_BUILDER_TOOLS}
  20. make
  21. create {LIBERTY_INSPECT_CLAUSE}
  22. make_specialized
  23. feature {ANY}
  24. instruction: LIBERTY_INSTRUCTION
  25. values: TRAVERSABLE[LIBERTY_INSPECT_SLICE] is
  26. do
  27. Result := values_list
  28. ensure
  29. Result = values_list
  30. end
  31. feature {LIBERTY_INSPECT}
  32. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  33. local
  34. ins: like instruction
  35. v: like values_list
  36. slice: LIBERTY_INSPECT_SLICE
  37. i: INTEGER
  38. do
  39. ins := instruction.specialized_in(a_type)
  40. from
  41. v := values_list
  42. i := v.lower
  43. until
  44. i > v.upper
  45. loop
  46. slice := v.item(i).specialized_in(a_type)
  47. if slice /= v.item(i) then
  48. if v = values_list then
  49. v := v.twin
  50. end
  51. v.put(slice, i)
  52. end
  53. i := i + 1
  54. end
  55. if ins = instruction and then v = values_list then
  56. Result := Current
  57. else
  58. create Result.make_specialized(ins, v, position)
  59. end
  60. end
  61. feature {LIBERTY_BUILDER_TOOLS}
  62. add_value (a_value: LIBERTY_INSPECT_SLICE) is
  63. require
  64. a_value /= Void
  65. do
  66. values_list.add_last(a_value)
  67. ensure
  68. values.last = a_value
  69. end
  70. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  71. mark_reachable_code (mark: INTEGER) is
  72. do
  73. instruction.mark_reachable_code(mark)
  74. inspect_slices_marker.mark_reachable_code(mark, values)
  75. end
  76. feature {}
  77. make (a_instruction: like instruction; a_position: like position) is
  78. require
  79. a_instruction /= Void
  80. a_position /= Void
  81. do
  82. instruction := a_instruction
  83. create {FAST_ARRAY[LIBERTY_INSPECT_SLICE]} values_list.with_capacity(2)
  84. position := a_position
  85. ensure
  86. instruction = a_instruction
  87. position = a_position
  88. end
  89. make_specialized (a_instruction: like instruction; a_values_list: like values_list; a_position: like position) is
  90. require
  91. a_instruction /= Void
  92. a_values_list /= Void
  93. a_position /= Void
  94. do
  95. instruction := a_instruction
  96. values_list := a_values_list
  97. position := a_position
  98. ensure
  99. instruction = a_instruction
  100. values_list = a_values_list
  101. position = a_position
  102. end
  103. values_list: COLLECTION[LIBERTY_INSPECT_SLICE]
  104. inspect_slices_marker: LIBERTY_REACHABLE_COLLECTION_MARKER[LIBERTY_INSPECT_SLICE]
  105. feature {ANY}
  106. accept (v: VISITOR) is
  107. local
  108. v0: LIBERTY_INSPECT_CLAUSE_VISITOR
  109. do
  110. v0 ::= v
  111. v0.visit_liberty_inspect_clause(Current)
  112. end
  113. invariant
  114. instruction /= Void
  115. values_list /= Void
  116. end