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

http://github.com/tybor/Liberty · Specman e · 123 lines · 93 code · 13 blank · 17 comment · 3 complexity · abb966eec0f61e7477b07bec5ab9e876 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_ASSIGNMENT_TEST
  16. inherit
  17. LIBERTY_EXPRESSION
  18. create {LIBERTY_BUILDER_TOOLS, LIBERTY_ASSIGNMENT_TEST}
  19. test_entity, test_type
  20. feature {ANY}
  21. result_type: LIBERTY_TYPE
  22. expression: LIBERTY_EXPRESSION
  23. tested_type: LIBERTY_TYPE is
  24. do
  25. if type /= Void then
  26. Result := type
  27. else
  28. Result := entity.result_type
  29. end
  30. end
  31. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  32. local
  33. e: like expression
  34. n: like entity
  35. t: like type
  36. do
  37. check
  38. result_type.specialized_in(a_type) = result_type
  39. end
  40. e := expression.specialized_in(a_type)
  41. if entity /= Void then
  42. n := entity.specialized_in(a_type)
  43. else
  44. t := type.specialized_in(a_type)
  45. end
  46. if e = expression and then n = entity and then t = type then
  47. Result := Current
  48. elseif n /= Void then
  49. create Result.test_entity(n, e, result_type, position)
  50. else
  51. create Result.test_type(t, e, result_type, position)
  52. end
  53. end
  54. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  55. mark_reachable_code (mark: INTEGER) is
  56. do
  57. -- nothing
  58. end
  59. feature {}
  60. test_entity (a_entity: like entity; a_expression: like expression; a_result_type: like result_type; a_position: like position) is
  61. require
  62. a_entity /= Void
  63. a_expression /= Void
  64. a_result_type /= Void
  65. -- a_result_type is BOOLEAN
  66. a_position /= Void
  67. do
  68. entity := a_entity
  69. expression := a_expression
  70. result_type := a_result_type
  71. position := a_position
  72. ensure
  73. entity = a_entity
  74. expression = a_expression
  75. result_type = a_result_type
  76. type = Void
  77. position = a_position
  78. end
  79. test_type (a_type: like type; a_expression: like expression; a_result_type: like result_type; a_position: like position) is
  80. require
  81. a_type /= Void
  82. a_expression /= Void
  83. a_result_type /= Void
  84. -- a_result_type is BOOLEAN
  85. a_position /= Void
  86. do
  87. type := a_type
  88. expression := a_expression
  89. result_type := a_result_type
  90. position := a_position
  91. ensure
  92. type = a_type
  93. expression = a_expression
  94. result_type = a_result_type
  95. entity = Void
  96. position = a_position
  97. end
  98. entity: LIBERTY_ENTITY
  99. type: LIBERTY_ACTUAL_TYPE --|*** TODO: ??? we cannot check generics assignment???
  100. feature {ANY}
  101. accept (v: VISITOR) is
  102. local
  103. v0: LIBERTY_ASSIGNMENT_TEST_VISITOR
  104. do
  105. v0 ::= v
  106. v0.visit_liberty_assignment_test(Current)
  107. end
  108. invariant
  109. (entity /= Void) /= (type /= Void)
  110. end