/src/tools/compiler/asm/liberty_asm_instruction_proxy_equal_visitor.e

http://github.com/tybor/Liberty · Specman e · 113 lines · 87 code · 12 blank · 14 comment · 4 complexity · df0ce5be2eb3d2f634ce238a73acc2ad 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_INSTRUCTION_PROXY_EQUAL_VISITOR
  16. inherit
  17. LIBERTY_ASM_PROXY_VISITOR
  18. create {LIBERTY_ASM_INSTRUCTION_PROXY}
  19. make
  20. feature {LIBERTY_ASM_INSTRUCTION_PROXY}
  21. start (a_instruction: LIBERTY_ASM_INSTRUCTION_PROXY) is
  22. do
  23. kind := kind_unset
  24. a_instruction.accept(Current)
  25. end
  26. confirm (a_instruction: LIBERTY_ASM_INSTRUCTION_PROXY) is
  27. do
  28. a_instruction.accept(Current)
  29. inspect kind
  30. when kind_new then
  31. confirmed := type_id > 0
  32. when kind_invoke then
  33. confirmed := type_id > 0 and then method_id > 0
  34. when kind_jump then
  35. confirmed := position > 0
  36. else
  37. confirmed := False
  38. end
  39. end
  40. confirmed: BOOLEAN
  41. feature {LIBERTY_ASM_INSTRUCTION_PROXY}
  42. visit_proxy_new (a_instruction: LIBERTY_ASM_INSTRUCTION_PROXY; a_type_id: INTEGER) is
  43. do
  44. inspect
  45. kind
  46. when kind_unset then
  47. type_id := a_type_id
  48. when kind_new then
  49. if type_id /= a_type_id then
  50. type_id := -1
  51. end
  52. else
  53. kind := kind_error
  54. end
  55. end
  56. visit_proxy_invoke (a_instruction: LIBERTY_ASM_INSTRUCTION_PROXY; a_method_id, a_type_id: INTEGER) is
  57. do
  58. inspect
  59. kind
  60. when kind_unset then
  61. type_id := a_type_id
  62. method_id := a_method_id
  63. when kind_invoke then
  64. if type_id /= a_type_id then
  65. type_id := -1
  66. end
  67. if method_id /= a_method_id then
  68. method_id := -1
  69. end
  70. else
  71. kind := kind_error
  72. end
  73. end
  74. visit_proxy_jump (a_instruction: LIBERTY_ASM_INSTRUCTION_PROXY; a_position: INTEGER) is
  75. do
  76. inspect
  77. kind
  78. when kind_unset then
  79. position := a_position
  80. when kind_jump then
  81. if position /= a_position then
  82. position := -1
  83. end
  84. else
  85. kind := kind_error
  86. end
  87. end
  88. feature {}
  89. make is
  90. do
  91. end
  92. kind: INTEGER_8
  93. type_id: INTEGER
  94. method_id: INTEGER
  95. position: INTEGER
  96. kind_error: INTEGER_8 is -1
  97. kind_unset: INTEGER_8 is 0
  98. kind_new: INTEGER_8 is 1
  99. kind_invoke: INTEGER_8 is 2
  100. kind_jump: INTEGER_8 is 3
  101. end -- class LIBERTY_ASM_INSTRUCTION_PROXY_EQUAL_VISITOR