/src/tools/semantics/code/features/liberty_feature_redefined.e

http://github.com/tybor/Liberty · Specman e · 193 lines · 155 code · 23 blank · 15 comment · 12 complexity · 1fc51bcca93c261373faea19e4d3a6bb 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_FEATURE_REDEFINED
  16. inherit
  17. LIBERTY_FEATURE
  18. rename
  19. make as make_late_binding
  20. redefine
  21. mark_reachable_code, add_if_redefined, do_debug_display, set_specialized_in,
  22. has_accelerator, accelerate_call
  23. end
  24. create {LIBERTY_BUILDER_TOOLS}
  25. make
  26. feature {ANY}
  27. redefined_feature: LIBERTY_FEATURE
  28. accept (v: VISITOR) is
  29. local
  30. v0: LIBERTY_FEATURE_REDEFINED_VISITOR
  31. do
  32. v0 ::= v
  33. v0.visit_liberty_feature_redefined(Current)
  34. end
  35. has_accelerator: BOOLEAN is
  36. do
  37. Result := redefined_feature /= Void and then redefined_feature.has_accelerator
  38. end
  39. accelerate_call (a: LIBERTY_FEATURE_ACCELERATOR) is
  40. do
  41. redefined_feature.accelerate_call(a)
  42. end
  43. feature {LIBERTY_FEATURE}
  44. set_specialized_in (a_original: like Current; a_context: like context) is
  45. do
  46. Precursor(a_original, a_context)
  47. if redefined_feature /= Void then
  48. redefined_feature := redefined_feature.specialized_in(a_context.current_type)
  49. end
  50. end
  51. do_debug_display (o: OUTPUT_STREAM; tab: INTEGER) is
  52. do
  53. Precursor(o, tab)
  54. tabulate(o, tab + 1)
  55. if redefined_feature = Void then
  56. o.put_line(once "(unknown or unattached redefined feature)")
  57. else
  58. redefined_feature.do_debug_display(o, tab + 1)
  59. end
  60. end
  61. feature {LIBERTY_BUILDER_TOOLS}
  62. add_if_redefined (type: LIBERTY_ACTUAL_TYPE; name: LIBERTY_FEATURE_NAME; redefined_features: DICTIONARY[LIBERTY_FEATURE_REDEFINED, LIBERTY_FEATURE_NAME]) is
  63. do
  64. if definition_type = type then
  65. if not redefined_features.has(name) then
  66. redefined_features.add(Current, name)
  67. end
  68. end
  69. end
  70. feature {}
  71. do_join (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  72. do
  73. Result := a_feature.joined_redefined(a_type, Current, other_fd, current_fd)
  74. end
  75. feature {LIBERTY_FEATURE}
  76. joined_attribute (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_ATTRIBUTE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  77. do
  78. if a_feature.definition_type = definition_type then
  79. current_fd.fatal_join_error_redefined_concrete(a_type, other_fd)
  80. end
  81. Result := Current
  82. end
  83. joined_constant (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_CONSTANT; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  84. do
  85. if a_feature.definition_type = definition_type then
  86. current_fd.fatal_join_error_redefined_concrete(a_type, other_fd)
  87. end
  88. Result := Current
  89. end
  90. joined_deferred (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_DEFERRED; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  91. do
  92. if a_feature.definition_type = definition_type then
  93. --| *** TODO: warning, mixed undefine and redefine, expected redefinition
  94. end
  95. Result := Current
  96. end
  97. joined_do (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_DO; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  98. do
  99. if a_feature.definition_type = definition_type then
  100. current_fd.fatal_join_error_redefined_concrete(a_type, other_fd)
  101. end
  102. Result := Current
  103. end
  104. joined_external (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_EXTERNAL; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  105. do
  106. if a_feature.definition_type = definition_type then
  107. current_fd.fatal_join_error_redefined_concrete(a_type, other_fd)
  108. end
  109. Result := Current
  110. end
  111. joined_once (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_ONCE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  112. do
  113. if a_feature.definition_type = definition_type then
  114. current_fd.fatal_join_error_redefined_concrete(a_type, other_fd)
  115. end
  116. Result := Current
  117. end
  118. joined_redefined (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_REDEFINED; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  119. do
  120. Result := Current
  121. end
  122. joined_unique (a_type: LIBERTY_ACTUAL_TYPE; a_feature: LIBERTY_FEATURE_UNIQUE; current_fd, other_fd: LIBERTY_FEATURE_DEFINITION): LIBERTY_FEATURE is
  123. do
  124. if a_feature.definition_type = definition_type then
  125. current_fd.fatal_join_error_redefined_concrete(a_type, other_fd)
  126. end
  127. Result := Current
  128. end
  129. feature {LIBERTY_BUILDER_TOOLS}
  130. set_redefined_feature (a_feature: like redefined_feature) is
  131. require
  132. only_once: redefined_feature = Void
  133. useful: a_feature /= Void
  134. do
  135. check
  136. a_feature.type_resolver /= Void
  137. end
  138. type_resolver := a_feature.type_resolver
  139. redefined_feature := a_feature
  140. set_precondition(a_feature.precondition)
  141. set_postcondition(a_feature.postcondition)
  142. set_context(a_feature.context)
  143. set_obsolete(a_feature.obsolete_message)
  144. a_feature.set_is_redefined
  145. type_resolver.set_the_feature(Current, True)
  146. torch.burn
  147. ensure
  148. redefined_feature = a_feature
  149. end
  150. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  151. mark_reachable_code (mark: INTEGER) is
  152. local
  153. old_mark: like reachable_mark
  154. do
  155. old_mark := reachable_mark
  156. Precursor(mark)
  157. if old_mark < mark and then redefined_feature /= Void then
  158. redefined_feature.mark_reachable_code(mark)
  159. end
  160. end
  161. feature {}
  162. make (a_definition_type: like definition_type) is
  163. do
  164. make_late_binding(a_definition_type, Void)
  165. end
  166. invariant
  167. not is_redefined
  168. redefined_feature /= Void implies redefined_feature.is_redefined
  169. accelerator = Void
  170. end