/src/tools/semantics/code/expressions/liberty_creation_expression.e

http://github.com/tybor/Liberty · Specman e · 107 lines · 82 code · 11 blank · 14 comment · 3 complexity · cb17a74326ddcf3c554fa5442d81afef 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_CREATION_EXPRESSION
  16. inherit
  17. LIBERTY_EXPRESSION
  18. create {LIBERTY_BUILDER_TOOLS, LIBERTY_CREATION_EXPRESSION}
  19. make
  20. feature {ANY}
  21. result_type: LIBERTY_TYPE
  22. feature_entity: LIBERTY_FEATURE_ENTITY
  23. feature_arguments: TRAVERSABLE[LIBERTY_EXPRESSION] is
  24. do
  25. Result := feature_arguments_list
  26. end
  27. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  28. local
  29. r: like result_type
  30. fe: like feature_entity
  31. fa: like feature_arguments_list
  32. e: LIBERTY_EXPRESSION
  33. i: INTEGER
  34. do
  35. r := result_type.specialized_in(a_type)
  36. fe := feature_entity.specialized_in(a_type)
  37. from
  38. fa := feature_arguments_list
  39. i := fa.lower
  40. until
  41. i > fa.upper
  42. loop
  43. e := fa.item(i).specialized_in(a_type)
  44. if e /= fa.item(i) then
  45. if fa = feature_arguments_list then
  46. fa := fa.twin
  47. end
  48. fa.put(e, i)
  49. end
  50. i := i + 1
  51. end
  52. if r = result_type and then fe = feature_entity and then fa = feature_arguments_list then
  53. Result := Current
  54. else
  55. create Result.make(r, fe, fa, position)
  56. end
  57. end
  58. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  59. mark_reachable_code (mark: INTEGER) is
  60. do
  61. result_type.mark_reachable_code(mark)
  62. feature_entity.mark_reachable_code(mark)
  63. expressions_marker.mark_reachable_code(mark, feature_arguments)
  64. end
  65. feature {}
  66. make (a_type: like result_type; a_feature_entity: like feature_entity; a_feature_arguments: like feature_arguments_list; a_position: like position) is
  67. require
  68. a_type /= Void
  69. a_feature_entity /= Void
  70. a_feature_arguments /= Void
  71. a_position /= Void
  72. do
  73. result_type := a_type
  74. feature_entity := a_feature_entity
  75. feature_arguments_list := a_feature_arguments
  76. position := a_position
  77. ensure
  78. result_type = a_type
  79. feature_entity = a_feature_entity
  80. feature_arguments_list = a_feature_arguments
  81. position = a_position
  82. end
  83. feature_arguments_list: COLLECTION[LIBERTY_EXPRESSION]
  84. feature {ANY}
  85. accept (v: VISITOR) is
  86. local
  87. v0: LIBERTY_CREATION_EXPRESSION_VISITOR
  88. do
  89. v0 ::= v
  90. v0.visit_liberty_creation_expression(Current)
  91. end
  92. invariant
  93. result_type /= Void
  94. feature_entity /= Void
  95. feature_arguments /= Void
  96. end