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

http://github.com/tybor/Liberty · Specman e · 84 lines · 60 code · 8 blank · 16 comment · 1 complexity · 051f07e44dd20f80d8a5520af137ab6c 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. deferred class LIBERTY_COMPARISON
  16. inherit
  17. LIBERTY_EXPRESSION
  18. feature {ANY}
  19. left, right: LIBERTY_EXPRESSION
  20. result_type: LIBERTY_TYPE
  21. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  22. local
  23. l, r: LIBERTY_EXPRESSION
  24. do
  25. check result_type.specialized_in(a_type) = result_type end
  26. l := left.specialized_in(a_type)
  27. r := right.specialized_in(a_type)
  28. if l = left and then r = right then
  29. Result := Current
  30. else
  31. Result := make_new(l, r, result_type, position)
  32. end
  33. end
  34. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  35. mark_reachable_code (mark: INTEGER) is
  36. do
  37. left.mark_reachable_code(mark)
  38. right.mark_reachable_code(mark)
  39. end
  40. feature {}
  41. make_new (a_left: like left; a_right: like right; a_result_type: like result_type; a_position: like position): like Current is
  42. require
  43. a_left /= Void
  44. a_right /= Void
  45. a_result_type /= Void
  46. -- a_result_type is BOOLEAN
  47. a_position /= Void
  48. deferred
  49. ensure
  50. Result.left = a_left
  51. Result.right = a_right
  52. Result.result_type = a_result_type
  53. Result.position = a_position
  54. end
  55. make (a_left: like left; a_right: like right; a_result_type: like result_type; a_position: like position) is
  56. require
  57. a_left /= Void
  58. a_right /= Void
  59. a_result_type /= Void
  60. -- a_result_type is BOOLEAN
  61. a_position /= Void
  62. do
  63. left := a_left
  64. right := a_right
  65. result_type := a_result_type
  66. position := a_position
  67. ensure
  68. left = a_left
  69. right = a_right
  70. result_type = a_result_type
  71. position = a_position
  72. end
  73. invariant
  74. left /= Void
  75. right /= Void
  76. end