/src/tools/semantics/code/liberty_precursor.e

http://github.com/tybor/Liberty · Specman e · 95 lines · 72 code · 9 blank · 14 comment · 3 complexity · 05395c8995f9fcc9d72c89904aba7a04 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. deferred class LIBERTY_PRECURSOR
  16. insert
  17. LIBERTY_POSITIONABLE
  18. LIBERTY_REACHABLE
  19. feature {ANY}
  20. the_feature: LIBERTY_FEATURE
  21. actuals: TRAVERSABLE[LIBERTY_EXPRESSION] is
  22. do
  23. Result := actuals_list
  24. end
  25. specialized_in (a_type: LIBERTY_ACTUAL_TYPE): like Current is
  26. local
  27. f: like the_feature
  28. a: like actuals_list
  29. e: LIBERTY_EXPRESSION
  30. i: INTEGER
  31. do
  32. f := the_feature.specialized_in(a_type)
  33. from
  34. a := actuals_list
  35. i := a.lower
  36. until
  37. i > a.upper
  38. loop
  39. e := a.item(i).specialized_in(a_type)
  40. if e /= a.item(i) then
  41. if a = actuals_list then
  42. a := a.twin
  43. end
  44. a.put(e, i)
  45. end
  46. i := i + 1
  47. end
  48. if f = the_feature and then a = actuals_list then
  49. Result := Current
  50. else
  51. Result := make_new(f, a, position)
  52. end
  53. end
  54. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  55. mark_reachable_code (mark: INTEGER) is
  56. do
  57. the_feature.mark_reachable_code(mark)
  58. expressions_marker.mark_reachable_code(mark, actuals)
  59. end
  60. feature {}
  61. make_new (a_feature: like the_feature; a_actuals: like actuals_list; a_position: like position): like Current is
  62. deferred
  63. ensure
  64. Result.the_feature = a_feature
  65. Result.actuals = a_actuals
  66. Result.position = a_position
  67. end
  68. make (a_feature: like the_feature; a_actuals: like actuals_list; a_position: like position) is
  69. require
  70. a_feature /= Void
  71. a_actuals /= Void
  72. a_position /= Void
  73. do
  74. the_feature := a_feature
  75. actuals_list := a_actuals
  76. position := a_position
  77. ensure
  78. the_feature = a_feature
  79. actuals_list = a_actuals
  80. position = a_position
  81. end
  82. actuals_list: COLLECTION[LIBERTY_EXPRESSION]
  83. invariant
  84. the_feature /= Void
  85. actuals /= Void
  86. end