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

http://github.com/tybor/Liberty · Specman e · 110 lines · 80 code · 15 blank · 15 comment · 1 complexity · 71c81965c94dd51256f1e03dc4db2da6 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_TYPE
  16. insert
  17. ANY
  18. redefine
  19. is_equal
  20. end
  21. create {ANY}
  22. make
  23. feature {ANY}
  24. id: INTEGER
  25. attributes_count: INTEGER
  26. -- Number of attributes
  27. methods_count: INTEGER is
  28. do
  29. Result := methods.count
  30. end
  31. is_equal (other: like Current): BOOLEAN is
  32. do
  33. Result := id = other.id
  34. and then attributes_count = other.attributes_count
  35. and then methods.count = other.methods.count
  36. and then methods.for_all(agent other.methods.has)
  37. end
  38. method (index: INTEGER): LIBERTY_ASM_METHOD is
  39. require
  40. index.in_range(0, methods_count - 1)
  41. do
  42. Result := methods.item(index)
  43. ensure
  44. Result /= Void
  45. end
  46. do_all_methods (action: PROCEDURE[TUPLE[LIBERTY_ASM_METHOD]]) is
  47. require
  48. action /= Void
  49. do
  50. methods.do_all(action)
  51. end
  52. resolve_method (method_id: INTEGER): LIBERTY_ASM_METHOD is
  53. do
  54. if methods.valid_index(method_id) then
  55. Result := method(method_id)
  56. end
  57. end
  58. feature {LIBERTY_ASM_METHOD}
  59. add_method (a_method: LIBERTY_ASM_METHOD): INTEGER is
  60. require
  61. a_method /= Void
  62. resolve_method(a_method.id) = Void
  63. do
  64. Result := methods.count
  65. methods.add_last(a_method)
  66. ensure
  67. methods_count = old methods_count + 1
  68. method(methods_count - 1) = a_method
  69. end
  70. has_method (a_method: LIBERTY_ASM_METHOD): BOOLEAN is
  71. require
  72. a_method.type = Current
  73. do
  74. Result := methods.valid_index(a_method.id) and then methods.item(a_method.id) = a_method
  75. ensure
  76. assertions_only_because_it_is_obvious: Result
  77. end
  78. feature {}
  79. make (a_id: like id; a_attributes_count: like attributes_count) is
  80. require
  81. a_attributes_count >= 0
  82. do
  83. id := a_id
  84. attributes_count := a_attributes_count
  85. create methods.make(0)
  86. ensure
  87. id = a_id
  88. attributes_count = a_attributes_count
  89. end
  90. feature {LIBERTY_ASM_TYPE}
  91. methods: FAST_ARRAY[LIBERTY_ASM_METHOD]
  92. invariant
  93. attributes_count >= 0
  94. methods /= Void
  95. end -- class LIBERTY_ASM_TYPE