/src/tools/semantics/types/type_resolver/liberty_type_resolver_in_feature.e

http://github.com/tybor/Liberty · Specman e · 133 lines · 101 code · 15 blank · 17 comment · 4 complexity · 5327093a9fd90ddc528509f35e3cd09f 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_TYPE_RESOLVER_IN_FEATURE
  16. inherit
  17. LIBERTY_TYPE_RESOLVER
  18. creation {LIBERTY_TYPE_FEATURES_LOADER}
  19. make
  20. creation {LIBERTY_FEATURE}
  21. specialized
  22. feature {LIBERTY_FEATURE}
  23. set_the_feature (a_feature: like the_feature; replace: BOOLEAN) is
  24. require
  25. a_feature.context = local_context
  26. the_feature /= Void implies replace
  27. do
  28. the_feature := a_feature
  29. ensure
  30. the_feature = a_feature
  31. end
  32. feature_name: LIBERTY_AST_FEATURE_NAME
  33. feature {ANY}
  34. local_context: LIBERTY_FEATURE_DEFINITION_CONTEXT
  35. the_feature: LIBERTY_FEATURE
  36. out_in_tagged_out_memory is
  37. local
  38. fnoa: LIBERTY_AST_FEATURE_NAME_OR_ALIAS
  39. do
  40. tagged_out_memory.append(once "resolver in feature ")
  41. fnoa := feature_name.feature_name_or_alias
  42. if fnoa.is_regular then
  43. tagged_out_memory.append(fnoa.entity_name.image.image.intern)
  44. elseif fnoa.is_prefix then
  45. tagged_out_memory.append(once "prefix ")
  46. tagged_out_memory.append(fnoa.free_operator_name.image.image.intern)
  47. else
  48. check fnoa.is_infix end
  49. tagged_out_memory.append(once "infix ")
  50. tagged_out_memory.append(fnoa.free_operator_name.image.image.intern)
  51. end
  52. end
  53. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  54. do
  55. Result := the_feature.specialized_in(a_type).type_resolver
  56. end
  57. feature {}
  58. lookup_type (type_definition: LIBERTY_AST_TYPE_DEFINITION): LIBERTY_TYPE is
  59. local
  60. name: FIXED_STRING
  61. do
  62. if type_definition.is_like_result then
  63. if local_context.result_type = Void then
  64. --|*** TODO: error: not a function
  65. not_yet_implemented
  66. end
  67. Result := local_context.result_type
  68. elseif type_definition.is_like_entity then
  69. -- If it's an anchor to a parameter or a local, resolve it immediately. (TODO: beware of cycles!)
  70. -- Other cases will be caught by parent resolvers.
  71. name := type_definition.entity_anchor.image.image.intern
  72. if local_context.is_parameter(name) then
  73. Result := local_context.parameter(name).result_type
  74. elseif local_context.is_local(name) then
  75. Result := local_context.local_var(name).result_type
  76. end
  77. end
  78. end
  79. lookup_export_type (type_definition: LIBERTY_AST_TYPE_DEFINITION): LIBERTY_TYPE is
  80. do
  81. check Result = Void end
  82. end
  83. lookup_position (type_definition: LIBERTY_AST_TYPE_DEFINITION): LIBERTY_POSITION is
  84. do
  85. check Result = Void end
  86. end
  87. feature {}
  88. make (a_feature_name: like feature_name; a_local_context: like local_context) is
  89. require
  90. a_feature_name /= Void
  91. a_local_context /= Void
  92. do
  93. feature_name := a_feature_name
  94. local_context := a_local_context
  95. ensure
  96. feature_name = a_feature_name
  97. local_context = a_local_context
  98. end
  99. specialized (a_feature_name: like feature_name; a_feature: like the_feature; a_parent: like parent) is
  100. require
  101. a_feature_name /= Void
  102. a_feature /= Void
  103. a_parent /= Void
  104. do
  105. feature_name := a_feature_name
  106. local_context := a_feature.context
  107. the_feature := a_feature
  108. parent := a_parent
  109. ensure
  110. feature_name = a_feature_name
  111. the_feature = a_feature
  112. local_context = a_feature.context
  113. parent = a_parent
  114. end
  115. invariant
  116. feature_name /= Void
  117. local_context /= Void
  118. end -- class LIBERTY_TYPE_RESOLVER_IN_FEATURE