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

http://github.com/tybor/Liberty · Specman e · 93 lines · 69 code · 10 blank · 14 comment · 3 complexity · b2687f3897c4443e8cafa6efb7fa2303 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_FEATURE_ROUTINE
  16. inherit
  17. LIBERTY_FEATURE
  18. rename
  19. make as make_late_binding
  20. redefine
  21. mark_reachable_code, set_specialized_in
  22. end
  23. feature {ANY}
  24. block_instruction: LIBERTY_INSTRUCTION
  25. rescue_instruction: LIBERTY_INSTRUCTION
  26. locals: TRAVERSABLE[LIBERTY_LOCAL] is
  27. require
  28. has_context
  29. do
  30. Result := context.locals
  31. ensure
  32. exists: Result /= Void
  33. end
  34. feature {LIBERTY_FEATURE}
  35. set_specialized_in (a_original: like Current; a_context: like context) is
  36. do
  37. Precursor(a_original, a_context)
  38. block_instruction := block_instruction.specialized_in(a_context.current_type)
  39. if rescue_instruction /= Void then
  40. rescue_instruction := rescue_instruction.specialized_in(a_context.current_type)
  41. end
  42. end
  43. feature {LIBERTY_BUILDER_TOOLS}
  44. set_rescue (a_rescue: like rescue_instruction) is
  45. require
  46. rescue_instruction = Void
  47. a_rescue /= Void
  48. do
  49. rescue_instruction := a_rescue
  50. ensure
  51. rescue_instruction = a_rescue
  52. end
  53. feature {}
  54. make (a_definition_type: like definition_type; a_instruction: like block_instruction; a_accelerator: like accelerator) is
  55. require
  56. a_definition_type /= Void
  57. a_instruction /= Void
  58. a_accelerator /= Void
  59. do
  60. make_late_binding(a_definition_type, a_accelerator)
  61. block_instruction := a_instruction
  62. ensure
  63. definition_type = a_definition_type
  64. block_instruction = a_instruction
  65. end
  66. feature {LIBERTY_REACHABLE, LIBERTY_REACHABLE_COLLECTION_MARKER}
  67. mark_reachable_code (mark: INTEGER) is
  68. local
  69. old_mark: like reachable_mark
  70. do
  71. old_mark := reachable_mark
  72. Precursor(mark)
  73. if old_mark < mark then
  74. block_instruction.mark_reachable_code(mark)
  75. if rescue_instruction /= Void then
  76. rescue_instruction.mark_reachable_code(mark)
  77. end
  78. end
  79. end
  80. invariant
  81. block_instruction /= Void
  82. accelerator /= Void
  83. end