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

http://github.com/tybor/Liberty · Specman e · 91 lines · 68 code · 9 blank · 14 comment · 5 complexity · 1e266aafcdd0898c26655e68c9c4d9a6 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_SLICE
  16. insert
  17. LIBERTY_POSITIONABLE
  18. LIBERTY_REACHABLE
  19. create {LIBERTY_BUILDER_TOOLS, LIBERTY_INSPECT_SLICE}
  20. make
  21. feature {ANY}
  22. lower, upper: LIBERTY_EXPRESSION
  23. feature {LIBERTY_INSPECT_CLAUSE}
  24. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  25. local
  26. l, u: LIBERTY_EXPRESSION
  27. do
  28. l := lower.specialized_in(a_type)
  29. if lower = upper then
  30. if l = lower then
  31. Result := Current
  32. else
  33. create Result.make(l, l, position)
  34. end
  35. else
  36. u := upper.specialized_in(a_type)
  37. if l = lower and then u = upper then
  38. Result := Current
  39. else
  40. create Result.make(l, u, position)
  41. end
  42. end
  43. end
  44. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  45. mark_reachable_code (mark: INTEGER) is
  46. do
  47. lower.mark_reachable_code(mark)
  48. if upper /= lower then
  49. upper.mark_reachable_code(mark)
  50. end
  51. end
  52. feature {}
  53. make (a_lower: like lower; a_upper: like upper; a_position: like position) is
  54. require
  55. a_lower /= Void
  56. a_position /= Void
  57. do
  58. lower := a_lower
  59. if a_upper /= Void then
  60. upper := a_upper
  61. else
  62. upper := a_lower
  63. end
  64. position := a_position
  65. ensure
  66. lower = a_lower
  67. a_upper /= Void implies upper = a_upper
  68. a_upper = Void implies upper = a_lower
  69. position = a_position
  70. end
  71. feature {ANY}
  72. accept (v: VISITOR) is
  73. local
  74. v0: LIBERTY_INSPECT_SLICE_VISITOR
  75. do
  76. v0 ::= v
  77. v0.visit_liberty_inspect_slice(Current)
  78. end
  79. invariant
  80. lower /= Void
  81. upper /= Void
  82. end