/src/tools/semantics/types/impl/liberty_delayed_type.e

http://github.com/tybor/Liberty · Specman e · 129 lines · 95 code · 17 blank · 17 comment · 3 complexity · 7d4ce73a7bf498dfd4b367cf656b2847 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_DELAYED_TYPE
  16. --
  17. -- A type to be resolved later.
  18. --
  19. inherit
  20. LIBERTY_TYPE
  21. redefine mark_reachable_code, is_equal
  22. end
  23. creation {ANY}
  24. make
  25. feature {ANY}
  26. known_type: LIBERTY_KNOWN_TYPE
  27. is_known: BOOLEAN
  28. full_name: FIXED_STRING is
  29. do
  30. if is_known then
  31. Result := known_type.full_name
  32. else
  33. Result := delayed_resolver.full_name
  34. end
  35. end
  36. hash_code: INTEGER is
  37. do
  38. Result := delayed_resolver.hash_code
  39. end
  40. is_equal (other: like Current): BOOLEAN is
  41. do
  42. Result := other = Current
  43. end
  44. out_in_tagged_out_memory is
  45. do
  46. full_name.out_in_tagged_out_memory
  47. end
  48. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  49. local
  50. dr: like delayed_resolver
  51. do
  52. dr := delayed_resolver.specialized_in(a_type)
  53. if dr = delayed_resolver then
  54. Result := Current
  55. else
  56. create Result.make(dr)
  57. end
  58. end
  59. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  60. mark_reachable_code (mark: like reachable_mark) is
  61. local
  62. old_mark: like reachable_mark
  63. do
  64. old_mark := reachable_mark
  65. Precursor(mark)
  66. if old_mark < mark and then is_known then
  67. known_type.mark_reachable_code(mark)
  68. end
  69. end
  70. feature {LIBERTY_KNOWN_TYPE}
  71. full_name_in (buffer: STRING) is
  72. do
  73. buffer.append(full_name)
  74. end
  75. feature {LIBERTY_UNIVERSE}
  76. can_resolve: BOOLEAN is
  77. require
  78. not is_known
  79. do
  80. Result := delayed_resolver.can_resolve
  81. end
  82. resolve is
  83. require
  84. can_resolve
  85. do
  86. known_type := delayed_resolver.resolved
  87. is_known := True
  88. fire_type_known
  89. torch.burn
  90. ensure
  91. is_known
  92. end
  93. feature {}
  94. make (a_delayed_resolver: like delayed_resolver) is
  95. require
  96. a_delayed_resolver /= Void
  97. do
  98. delayed_resolver := a_delayed_resolver
  99. lookup.resolver.delayed_types.add_last(Current)
  100. create {FAST_ARRAY[LIBERTY_TYPE_LISTENER]} listeners.with_capacity(2)
  101. create result_entity.make(Current, errors.unknown_position)
  102. ensure
  103. delayed_resolver = a_delayed_resolver
  104. not_yet_reachable: not is_reachable
  105. end
  106. delayed_resolver: LIBERTY_DELAYED_RESOLVER
  107. lookup: LIBERTY_TYPE_LOOKUP
  108. errors: LIBERTY_ERRORS
  109. invariant
  110. delayed_resolver /= Void
  111. result_entity /= Void
  112. end -- class LIBERTY_DELAYED_TYPE