/src/tools/compiler/asm/data/liberty_asm_method.e

http://github.com/tybor/Liberty · Specman e · 153 lines · 119 code · 20 blank · 14 comment · 0 complexity · 3a55e025ed3548fa7ed2bbbe42842c0f 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_ASM_METHOD
  16. insert
  17. SAFE_EQUAL[LIBERTY_ASM_INSTRUCTION]
  18. redefine
  19. is_equal
  20. end
  21. create {ANY}
  22. make
  23. feature {ANY}
  24. id: INTEGER
  25. type: LIBERTY_ASM_TYPE
  26. code: LIBERTY_ASM_INSTRUCTION
  27. code_size: INTEGER
  28. retry_code: LIBERTY_ASM_INSTRUCTION
  29. retry_size: INTEGER
  30. precondition: LIBERTY_ASM_INSTRUCTION
  31. precondition_size: INTEGER
  32. postcondition: LIBERTY_ASM_INSTRUCTION
  33. postcondition_size: INTEGER
  34. parameters: COLLECTION[LIBERTY_ASM_PARAMETER]
  35. is_equal (other: like Current): BOOLEAN is
  36. do
  37. Result := id = other.id and then type.id = other.type.id -- don't check type.is_equal because it would incur an infinite recursion
  38. and then parameters.is_equal(other.parameters)
  39. and then safe_equal(code, other.code)
  40. and then safe_equal(retry_code, other.retry_code)
  41. and then safe_equal(precondition, other.precondition)
  42. and then safe_equal(postcondition, other.postcondition)
  43. end
  44. set_code (a_code: like code) is
  45. require
  46. a_code /= Void
  47. do
  48. code := a_code
  49. ensure
  50. code = a_code
  51. end
  52. set_code_size (a_code_size: like code_size) is
  53. require
  54. code_size = 0
  55. a_code_size > 0
  56. do
  57. code_size := a_code_size
  58. ensure
  59. code_size = a_code_size
  60. end
  61. set_retry (a_retry: like retry_code) is
  62. require
  63. retry_code /= Void implies a_retry /= Void
  64. do
  65. retry_code := a_retry
  66. ensure
  67. retry_code = a_retry
  68. end
  69. set_retry_size (a_retry_size: like retry_size) is
  70. require
  71. a_retry_size > 0
  72. retry_code /= Void
  73. do
  74. retry_size := a_retry_size
  75. ensure
  76. retry_size = a_retry_size
  77. end
  78. set_precondition (a_precondition: like precondition) is
  79. require
  80. precondition /= Void implies a_precondition /= Void
  81. do
  82. precondition := a_precondition
  83. ensure
  84. precondition = a_precondition
  85. end
  86. set_precondition_size (a_precondition_size: like precondition_size) is
  87. require
  88. a_precondition_size > 0
  89. precondition /= Void
  90. do
  91. precondition_size := a_precondition_size
  92. ensure
  93. precondition_size = a_precondition_size
  94. end
  95. set_postcondition (a_postcondition: like postcondition) is
  96. require
  97. postcondition /= Void implies a_postcondition /= Void
  98. do
  99. postcondition := a_postcondition
  100. ensure
  101. postcondition = a_postcondition
  102. end
  103. set_postcondition_size (a_postcondition_size: like postcondition_size) is
  104. require
  105. a_postcondition_size > 0
  106. postcondition /= Void
  107. do
  108. postcondition_size := a_postcondition_size
  109. ensure
  110. postcondition_size = a_postcondition_size
  111. end
  112. feature {}
  113. make (a_type: like type; a_code: like code; a_parameters: like parameters) is
  114. require
  115. a_type /= Void
  116. a_code /= Void
  117. a_parameters /= Void
  118. do
  119. type := a_type
  120. code := a_code
  121. parameters := a_parameters
  122. id := type.add_method(Current)
  123. ensure
  124. type = a_type
  125. type.has_method(Current)
  126. code = a_code
  127. parameters = a_parameters
  128. end
  129. invariant
  130. type /= Void
  131. code /= Void
  132. parameters /= Void
  133. end -- class LIBERTY_ASM_METHOD