reworking method and block assembly for new aproach

This commit is contained in:
Torsten Ruger
2014-08-30 13:47:51 +03:00
parent 90e5b4584a
commit d33077c2b1
2 changed files with 19 additions and 23 deletions

View File

@ -19,7 +19,7 @@ module Virtual
@codes = []
end
attr_reader :name , :codes , :method
attr_reader :name , :codes , :method , :position
attr_accessor :branch
def reachable ret = []
@ -48,6 +48,17 @@ module Virtual
codes.dup.reverse.find{ |c| c.is_a? StackInstruction }
end
# position is what another block uses to jump to. this is determined by the assembler
# the assembler allso assembles and assumes a linear instruction sequence
# Note: this will have to change for plocks and maybe anyway. back to oo, no more visitors
def set_position at
@position = at
end
def length
@codes.inject(0){|count , instruction| count += instruction.length }
end
private
# helper for determining reachable blocks
def add_next ret