give labels an integer that will end up being the position at runtime
Since integers are first class objects, we need to use an integer object as the return address. The actual address can not be stored in an instance variable since it is not an object. The address is unique to the label and never changes after positioning (using the int is next up)
This commit is contained in:
@ -8,11 +8,13 @@ module Risc
|
||||
#
|
||||
|
||||
class Label < Instruction
|
||||
def initialize( source , name , nekst = nil)
|
||||
def initialize( source , name , int , nekst = nil)
|
||||
super(source , nekst)
|
||||
@name = name
|
||||
@integer = int
|
||||
raise "Not int #{int}" if int and !int.is_a?(Parfait::Integer)
|
||||
end
|
||||
attr_reader :name
|
||||
attr_reader :name , :integer
|
||||
|
||||
def to_cpu(translator)
|
||||
@cpu_label ||= super
|
||||
@ -51,7 +53,8 @@ module Risc
|
||||
alias :padded_length :byte_length
|
||||
end
|
||||
|
||||
def self.label( source , name , nekst = nil)
|
||||
Label.new( source , name , nekst = nil)
|
||||
def self.label( source , name , position = nil , nekst = nil)
|
||||
position ||= Parfait.object_space.get_integer
|
||||
Label.new( source , name , position, nekst )
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user