/src/tools/semantics/liberty_type.e

http://github.com/tybor/Liberty · Specman e · 136 lines · 103 code · 16 blank · 17 comment · 3 complexity · a013bad8dc0398dfb13a4950a40a8add 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_TYPE
  16. --
  17. -- The type referenced in entity definitions
  18. --
  19. inherit
  20. HASHABLE
  21. undefine out_in_tagged_out_memory
  22. end
  23. LOGGING
  24. undefine out_in_tagged_out_memory
  25. end
  26. insert
  27. LIBERTY_REACHABLE_MARKED
  28. undefine out_in_tagged_out_memory, is_equal
  29. end
  30. feature {ANY}
  31. known_type: LIBERTY_KNOWN_TYPE is
  32. require
  33. is_known
  34. deferred
  35. end
  36. result_entity: LIBERTY_RESULT
  37. is_known: BOOLEAN is
  38. deferred
  39. end
  40. full_name: FIXED_STRING is
  41. deferred
  42. ensure
  43. Result /= Void
  44. end
  45. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  46. deferred
  47. ensure
  48. Result /= Void
  49. end
  50. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  51. mark_reachable_code (mark: like reachable_mark) is
  52. do
  53. if not is_reachable then
  54. torch.burn
  55. log.trace.put_string(once "Marked reachable the type: ")
  56. log.trace.put_line(full_name)
  57. end
  58. reachable_mark := mark
  59. end
  60. feature {LIBERTY_KNOWN_TYPE}
  61. full_name_in (buffer: STRING) is
  62. require
  63. buffer /= Void
  64. deferred
  65. end
  66. feature {LIBERTY_TYPE_LISTENER}
  67. add_listener (a_listener: LIBERTY_TYPE_LISTENER) is
  68. require
  69. a_listener /= Void
  70. not has_listener(a_listener)
  71. do
  72. if is_known then
  73. known_type.add_listener(a_listener)
  74. else
  75. listeners.add_last(a_listener)
  76. end
  77. ensure
  78. not is_known implies has_listener(a_listener)
  79. end
  80. remove_listener (a_listener: LIBERTY_TYPE_LISTENER) is
  81. require
  82. a_listener /= Void
  83. has_listener(a_listener)
  84. do
  85. listeners.remove(listeners.fast_first_index_of(a_listener))
  86. ensure
  87. not has_listener(a_listener)
  88. end
  89. has_listener (a_listener: LIBERTY_TYPE_LISTENER): BOOLEAN is
  90. require
  91. a_listener /= Void
  92. do
  93. Result := listeners /= Void and then listeners.fast_has(a_listener)
  94. end
  95. feature {}
  96. fire_type_known is
  97. local
  98. i: INTEGER
  99. listener: LIBERTY_TYPE_LISTENER
  100. do
  101. from
  102. i := listeners.lower
  103. until
  104. i > listeners.upper
  105. loop
  106. listener := listeners.item(i)
  107. listener.on_type_known(Current)
  108. if not known_type.has_listener(listener) then
  109. known_type.add_listener(listener)
  110. end
  111. i := i + 1
  112. end
  113. listeners := Void
  114. end
  115. feature {}
  116. listeners: COLLECTION[LIBERTY_TYPE_LISTENER]
  117. torch: LIBERTY_ENLIGHTENING_THE_WORLD
  118. invariant
  119. not is_known implies listeners /= Void
  120. end