/src/tools/semantics/types/delayed_resolver/liberty_delayed_feature_type.e

http://github.com/tybor/Liberty · Specman e · 139 lines · 105 code · 20 blank · 14 comment · 3 complexity · 873271506790ef7409f3798fcc9176c3 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_FEATURE_TYPE
  16. inherit
  17. LIBERTY_DELAYED_RESOLVER
  18. insert
  19. LIBERTY_REACHABLE
  20. redefine out_in_tagged_out_memory, is_equal
  21. end
  22. creation {LIBERTY_FEATURE_ENTITY, LIBERTY_DELAYED_FEATURE_TYPE}
  23. make
  24. feature {ANY}
  25. out_in_tagged_out_memory is
  26. do
  27. if can_resolve then
  28. resolved.out_in_tagged_out_memory
  29. else
  30. tagged_out_memory.append(once "like (")
  31. type.full_name.out_in_tagged_out_memory
  32. tagged_out_memory.extend('.')
  33. name.out_in_tagged_out_memory
  34. tagged_out_memory.extend(')')
  35. end
  36. end
  37. full_name: FIXED_STRING is
  38. do
  39. Result := full_name_memory
  40. end
  41. hash_code: INTEGER is
  42. do
  43. Result := full_name_memory.hash_code
  44. end
  45. is_equal (other: like Current): BOOLEAN is
  46. do
  47. Result := other = Current
  48. end
  49. feature {LIBERTY_DELAYED_TYPE}
  50. can_resolve: BOOLEAN is
  51. do
  52. Result := is_ready
  53. and then the_feature.result_type /= Void
  54. and then the_feature.result_type.is_known
  55. end
  56. resolved: LIBERTY_KNOWN_TYPE is
  57. do
  58. Result := the_feature.result_type.known_type
  59. end
  60. feature {LIBERTY_DELAYED_TYPE, LIBERTY_FEATURE_ENTITY}
  61. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  62. local
  63. t: like type
  64. do
  65. t := type.specialized_in(a_type)
  66. if t = type then
  67. Result := Current
  68. else
  69. create Result.make(t, name) -- ?????
  70. end
  71. end
  72. feature {LIBERTY_FEATURE_ENTITY}
  73. is_ready: BOOLEAN is
  74. do
  75. Result := type.is_known
  76. and then type.known_type.has_feature(name)
  77. and then type.known_type.feature_definition(name).the_feature /= Void
  78. end
  79. the_feature: LIBERTY_FEATURE is
  80. require
  81. is_ready
  82. do
  83. Result := type.known_type.feature_definition(name).the_feature
  84. end
  85. name: LIBERTY_FEATURE_NAME
  86. type: LIBERTY_TYPE
  87. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  88. mark_reachable_code (mark: INTEGER) is
  89. do
  90. type.mark_reachable_code(mark)
  91. if is_ready then
  92. the_feature.mark_reachable_code(mark)
  93. end
  94. end
  95. feature {}
  96. make (a_type: like type; a_name: like name) is
  97. require
  98. a_type /= Void
  99. a_name /= Void
  100. do
  101. type := a_type
  102. name := a_name
  103. lock_tagged_out
  104. tagged_out_memory.copy(once "like (")
  105. type.full_name.out_in_tagged_out_memory
  106. tagged_out_memory.extend('.')
  107. name.out_in_tagged_out_memory
  108. tagged_out_memory.extend(')')
  109. unlock_tagged_out
  110. full_name_memory := tagged_out_memory.intern
  111. ensure
  112. type = a_type
  113. name = a_name
  114. end
  115. full_name_memory: FIXED_STRING
  116. invariant
  117. type /= Void
  118. name /= Void
  119. end -- class LIBERTY_DELAYED_FEATURE_TYPE