PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

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