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

http://github.com/tybor/Liberty · Specman e · 76 lines · 51 code · 9 blank · 16 comment · 1 complexity · 34ed95e116e4af9e30b1e65acdcc45f2 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_ENTITY_REFERENCE
  16. -- expressions like "$entity"
  17. inherit
  18. LIBERTY_EXPRESSION
  19. create {LIBERTY_BUILDER_TOOLS, LIBERTY_ENTITY_REFERENCE}
  20. make
  21. feature {ANY}
  22. entity: LIBERTY_ENTITY
  23. result_type: LIBERTY_TYPE
  24. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  25. local
  26. e: like entity
  27. do
  28. check result_type.specialized_in(a_type) = result_type end
  29. e := entity.specialized_in(a_type)
  30. if e = entity then
  31. Result := Current
  32. else
  33. create Result.make(result_type, e, position)
  34. end
  35. end
  36. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  37. mark_reachable_code (mark: INTEGER) is
  38. do
  39. -- nothing
  40. end
  41. feature {}
  42. make (type: like result_type; a_entity: like entity; a_position: like position) is
  43. require
  44. type /= Void -- type is POINTER
  45. a_entity /= Void
  46. a_position /= Void
  47. do
  48. result_type := type
  49. entity := a_entity
  50. position := a_position
  51. ensure
  52. result_type = type
  53. entity = a_entity
  54. position = a_position
  55. end
  56. feature {ANY}
  57. accept (v: VISITOR) is
  58. local
  59. v0: LIBERTY_ENTITY_REFERENCE_VISITOR
  60. do
  61. v0 ::= v
  62. v0.visit_liberty_entity_reference(Current)
  63. end
  64. invariant
  65. result_type /= Void -- result_type is POINTER
  66. entity /= Void
  67. end