change all to_risc functions to add directly
still #11 test not working yet
This commit is contained in:
parent
57dc6c45bb
commit
253d2fead8
@ -35,7 +35,7 @@ module Mom
|
||||
transfer = SlotLoad.new([:message , :next_message , :receiver] , @receiver, self).to_risc(compiler)
|
||||
compiler.reset_regs
|
||||
@arguments.each do |arg|
|
||||
transfer << arg.to_risc(compiler)
|
||||
arg.to_risc(compiler)
|
||||
compiler.reset_regs
|
||||
end
|
||||
transfer
|
||||
|
@ -12,7 +12,8 @@ module Mom
|
||||
@label = label
|
||||
end
|
||||
def to_risc(compiler)
|
||||
Risc::Branch.new(self , @label.to_risc(compiler))
|
||||
label = @label.to_risc(compiler)
|
||||
compiler.add_code Risc::Branch.new(self , label)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -27,8 +27,7 @@ module Mom
|
||||
# Move method name, frame and arguemnt types from the method to the next_message
|
||||
# Get the message from Space and link it.
|
||||
def to_risc(compiler)
|
||||
builder = compiler.code_builder(self)
|
||||
build_with(builder)
|
||||
build_with(compiler.builder(self))
|
||||
end
|
||||
|
||||
# directly called by to_risc
|
||||
|
@ -23,11 +23,10 @@ module Mom
|
||||
# basically move both left and right values into register
|
||||
# subtract them and see if IsZero comparison
|
||||
def to_risc(compiler)
|
||||
l_val = left.to_register(compiler, self)
|
||||
r_val = right.to_register(compiler, self)
|
||||
check = Risc.op( self , :- , l_val.register , r_val.register)
|
||||
check << Risc::IsZero.new( self, false_jump.to_risc(compiler))
|
||||
l_val << r_val << check
|
||||
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.to_risc(compiler))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ module Mom
|
||||
def to_risc( compiler )
|
||||
name_ = @name
|
||||
cache_entry_ = @cache_entry
|
||||
builder = compiler.code_builder(self)
|
||||
builder = compiler.builder(self)
|
||||
builder.build do
|
||||
word! << name_
|
||||
cache_entry! << cache_entry_
|
||||
@ -64,7 +64,6 @@ module Mom
|
||||
add_code ok_label
|
||||
cache_entry[:cached_method] << callable_method
|
||||
end
|
||||
return builder.built
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ module Mom
|
||||
class ReturnJump < Instruction
|
||||
|
||||
def to_risc(compiler)
|
||||
Risc::Branch.new(self , compiler.return_label)
|
||||
compiler.add_code Risc::Branch.new(self , compiler.return_label)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ module Mom
|
||||
class ReturnSequence < Instruction
|
||||
def to_risc(compiler)
|
||||
compiler.reset_regs
|
||||
builder = compiler.code_builder(self)
|
||||
builder = compiler.builder(self)
|
||||
builder.build do
|
||||
object! << message[:return_value]
|
||||
caller_reg! << message[:caller]
|
||||
@ -38,7 +38,6 @@ module Mom
|
||||
message << message[:caller]
|
||||
return_address.function_return
|
||||
end
|
||||
builder.built
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
@ -20,18 +20,16 @@ module Mom
|
||||
|
||||
def to_risc(compiler)
|
||||
false_label = @false_jump.to_risc(compiler)
|
||||
builder = compiler.code_builder("TruthCheck")
|
||||
condition_code = @condition.to_register(compiler,self)
|
||||
condition = condition_code.register#.set_builder(builder)
|
||||
built = builder.build do
|
||||
builder = compiler.builder("TruthCheck")
|
||||
condition_reg = @condition.to_register(compiler,self)
|
||||
builder.build do
|
||||
object! << Parfait.object_space.false_object
|
||||
object.op :- , condition
|
||||
object.op :- , condition_reg
|
||||
if_zero false_label
|
||||
object << Parfait.object_space.nil_object
|
||||
object.op :- , condition
|
||||
object.op :- , condition_reg
|
||||
if_zero false_label
|
||||
end
|
||||
condition_code << built
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user