let boot_functions return the compilers
methods are still added, but this is a good step to removing the risc/cpu level from the methods
This commit is contained in:
@ -17,7 +17,7 @@ module Risc
|
||||
builder.add_new_int(source,me , two)
|
||||
builder.add_reg_to_slot( source , two , :message , :return_value)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
def >( context )
|
||||
comparison( :> )
|
||||
@ -54,12 +54,12 @@ module Risc
|
||||
builder.add_code merge_label
|
||||
builder.add_reg_to_slot( "#{operator} save ret" , other , :message , :return_value)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
def putint(context)
|
||||
compiler = compiler_for(:Integer,:putint ,{})
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
def operator_method( op_sym )
|
||||
compiler = compiler_for(:Integer, op_sym ,{other: :Integer})
|
||||
@ -71,7 +71,7 @@ module Risc
|
||||
builder.add_new_int(op_sym.to_s + " new int", me , other)
|
||||
builder.add_reg_to_slot( op_sym.to_s + "save ret" , other , :message , :return_value)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
def div10( context )
|
||||
s = "div_10 "
|
||||
@ -134,7 +134,7 @@ module Risc
|
||||
builder.add_reg_to_slot( s , tmp , :message , :return_value)
|
||||
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
end
|
||||
extend ClassMethods
|
||||
|
@ -17,7 +17,7 @@ module Risc
|
||||
# and put it back into the return value
|
||||
builder.add_reg_to_slot( source , me , :message , :return_value)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
# self[index] = val basically. Index is the first arg , value the second
|
||||
@ -31,7 +31,7 @@ module Risc
|
||||
# do the set
|
||||
builder.add_reg_to_slot( source , value , me , index)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
# every object needs a method missing.
|
||||
@ -39,7 +39,7 @@ module Risc
|
||||
def _method_missing( context )
|
||||
compiler = compiler_for(:Object,:method_missing ,{})
|
||||
emit_syscall( compiler.compiler_builder(compiler.method) , :exit )
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
# this is the really really first place the machine starts (apart from the jump here)
|
||||
@ -73,7 +73,7 @@ module Risc
|
||||
end
|
||||
compiler.reset_regs
|
||||
exit_sequence(builder)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
# a sort of inline version of exit method.
|
||||
@ -89,7 +89,7 @@ module Risc
|
||||
compiler = compiler_for(:Object,:exit ,{})
|
||||
builder = compiler.compiler_builder(compiler.method)
|
||||
exit_sequence(builder)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
def emit_syscall( builder , name )
|
||||
|
@ -10,7 +10,7 @@ module Risc
|
||||
def main(context)
|
||||
compiler = compiler_for(:Space , :main ,{args: :Integer})
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ module Risc
|
||||
builder.add_slot_to_reg( "putstring" , :new_message , index , reg )
|
||||
Risc::Builtin::Object.emit_syscall( builder , :putstring )
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
compiler.method
|
||||
compiler
|
||||
end
|
||||
|
||||
# self[index] basically. Index is the first arg > 0
|
||||
@ -30,7 +30,7 @@ module Risc
|
||||
# and put it back into the return value
|
||||
builder.add_reg_to_slot( source , index , :message , :return_value)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
# self[index] = val basically. Index is the first arg ( >0),
|
||||
@ -48,7 +48,7 @@ module Risc
|
||||
value = builder.load_int_arg_at(source , 1 )
|
||||
builder.add_reg_to_slot( source , value , :message , :return_value)
|
||||
compiler.add_mom( Mom::ReturnSequence.new)
|
||||
return compiler.method
|
||||
return compiler
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user