/src/tools/semantics/code/assertions/liberty_variant.e

http://github.com/tybor/Liberty · Specman e · 71 lines · 48 code · 9 blank · 14 comment · 1 complexity · 66282a7ad0f96a19aa84a6157a5e28b7 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_VARIANT
  16. insert
  17. LIBERTY_REACHABLE
  18. create {LIBERTY_BUILDER_TOOLS, LIBERTY_VARIANT}
  19. make
  20. feature {ANY}
  21. expression: LIBERTY_EXPRESSION
  22. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  23. mark_reachable_code (mark: INTEGER) is
  24. do
  25. expression.mark_reachable_code(mark)
  26. end
  27. feature {LIBERTY_LOOP}
  28. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  29. require
  30. a_type /= Void
  31. local
  32. e: like expression
  33. do
  34. e := expression.specialized_in(a_type)
  35. if e = expression then
  36. Result := Current
  37. else
  38. create Result.make(expression)
  39. end
  40. ensure
  41. Result /= Void
  42. end
  43. feature {}
  44. make (a_expression: like expression) is
  45. require
  46. a_expression /= Void
  47. do
  48. expression := a_expression
  49. ensure
  50. expression = a_expression
  51. end
  52. feature {ANY}
  53. accept (v: VISITOR) is
  54. local
  55. v0: LIBERTY_VARIANT_VISITOR
  56. do
  57. v0 ::= v
  58. v0.visit_liberty_variant(Current)
  59. end
  60. invariant
  61. expression /= Void
  62. end