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

http://github.com/tybor/Liberty · Specman e · 151 lines · 120 code · 17 blank · 14 comment · 6 complexity · 22c2621f94c2c02805c727e3da77e682 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_RESOLVER_IN_TYPE
  16. inherit
  17. LIBERTY_DELAYED_RESOLVER
  18. insert
  19. EIFFEL_NODE_HANDLER
  20. redefine out_in_tagged_out_memory, is_equal
  21. end
  22. creation {LIBERTY_TYPE_RESOLVER_IN_TYPE}
  23. like_current, like_feature
  24. creation {LIBERTY_DELAYED_RESOLVER_IN_TYPE}
  25. specialized
  26. feature {ANY}
  27. out_in_tagged_out_memory is
  28. do
  29. current_type.out_in_tagged_out_memory
  30. if feature_name /= Void then
  31. tagged_out_memory.append(once ".")
  32. feature_name.out_in_tagged_out_memory
  33. end
  34. end
  35. hash_code: INTEGER is
  36. do
  37. Result := current_type.hash_code
  38. end
  39. is_equal (other: like Current): BOOLEAN is
  40. do
  41. Result := other = Current
  42. end
  43. feature {LIBERTY_DELAYED_TYPE}
  44. can_resolve: BOOLEAN is
  45. local
  46. fd: LIBERTY_FEATURE_DEFINITION
  47. bound_feature: LIBERTY_FEATURE
  48. do
  49. if feature_name = Void then
  50. Result := True
  51. elseif current_type.has_feature(feature_name) then
  52. fd := definition_type.feature_definition(feature_name)
  53. if definition_type = current_type then
  54. bound_feature := fd.the_feature
  55. elseif fd.the_feature.is_bound(current_type) then
  56. bound_feature := fd.the_feature.bound(current_type)
  57. end
  58. if bound_feature /= Void then
  59. Result := bound_feature.result_type.is_known
  60. end
  61. end
  62. end
  63. resolved: LIBERTY_KNOWN_TYPE is
  64. do
  65. if feature_name = Void then
  66. Result := current_type
  67. else
  68. Result := definition_type.feature_definition(feature_name).the_feature.bound(current_type).result_type.known_type
  69. end
  70. end
  71. full_name: FIXED_STRING is
  72. do
  73. Result := current_type.full_name
  74. end
  75. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  76. do
  77. if a_type.is_child_of(definition_type) then
  78. create Result.specialized(a_type, definition_type, feature_name)
  79. else
  80. Result := Current
  81. end
  82. end
  83. feature {}
  84. like_current (a_type: like current_type) is
  85. require
  86. a_type /= Void
  87. do
  88. current_type := a_type
  89. definition_type := a_type
  90. ensure
  91. current_type = a_type
  92. definition_type = a_type
  93. feature_name = Void
  94. end
  95. like_feature (a_type: like current_type; a_feature_name: like feature_name) is
  96. require
  97. a_type /= Void
  98. a_feature_name /= Void
  99. do
  100. current_type := a_type
  101. definition_type := a_type
  102. feature_name := a_feature_name
  103. ensure
  104. current_type = a_type
  105. definition_type = a_type
  106. feature_name = a_feature_name
  107. end
  108. specialized (a_type: like current_type; a_definition_type: like definition_type; a_feature_name: like feature_name) is
  109. require
  110. a_type /= Void
  111. a_definition_type /= Void
  112. a_type.is_child_of(a_definition_type)
  113. do
  114. debug ("feature.specialization")
  115. log.trace.put_string(once "Creating specialized type resolver from ")
  116. log.trace.put_string(a_definition_type.full_name)
  117. log.trace.put_string(once " to ")
  118. log.trace.put_line(a_type.full_name)
  119. end
  120. current_type := a_type
  121. definition_type := a_definition_type
  122. feature_name := a_feature_name
  123. ensure
  124. current_type = a_type
  125. definition_type = a_definition_type
  126. feature_name = a_feature_name
  127. end
  128. current_type: LIBERTY_ACTUAL_TYPE
  129. definition_type: LIBERTY_ACTUAL_TYPE
  130. feature_name: LIBERTY_FEATURE_NAME
  131. invariant
  132. current_type /= Void
  133. definition_type /= Void
  134. end -- class LIBERTY_DELAYED_RESOLVER_IN_TYPE