add the addresses from labels as constants
This commit is contained in:
@ -12,7 +12,7 @@ module Mom
|
||||
@label = label
|
||||
end
|
||||
def to_risc(compiler)
|
||||
compiler.add_code Risc::Branch.new(self , @label.risc_label)
|
||||
compiler.add_code Risc::Branch.new(self , @label.risc_label(compiler))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -32,19 +32,16 @@ module Mom
|
||||
end
|
||||
|
||||
# generate the risc label lazily
|
||||
def risc_label
|
||||
def risc_label(comiler)
|
||||
@risc_label ||= Risc.label(self,name)
|
||||
comiler.add_constant(@risc_label.address)
|
||||
@risc_label
|
||||
end
|
||||
|
||||
# add the risc_label to the compiler (instruction flow)
|
||||
# should only be called once
|
||||
def to_risc(compiler)
|
||||
if( @added )
|
||||
raise "added already #{@added}"
|
||||
else
|
||||
@added = true
|
||||
compiler.add_code( risc_label )
|
||||
end
|
||||
compiler.add_code( risc_label(compiler) )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ module Mom
|
||||
l_reg = left.to_register(compiler, self)
|
||||
r_reg = right.to_register(compiler, self)
|
||||
compiler.add_code Risc.op( self , :- , l_reg , r_reg)
|
||||
compiler.add_code Risc::IsZero.new( self, false_jump.risc_label)
|
||||
compiler.add_code Risc::IsZero.new( self, false_jump.risc_label(compiler))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ module Mom
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
false_label = @false_jump.risc_label
|
||||
false_label = @false_jump.risc_label(compiler)
|
||||
builder = compiler.builder("TruthCheck")
|
||||
condition_reg = @condition.to_register(compiler,self)
|
||||
builder.build do
|
||||
|
Reference in New Issue
Block a user