/src/tools/semantics/code/instructions/liberty_creation_instruction.e

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