fix builtin methods according to last commit
This commit is contained in:
parent
9867234c38
commit
8c322329fb
@ -8,13 +8,14 @@ module Risc
|
|||||||
def mod4(context)
|
def mod4(context)
|
||||||
source = "mod4"
|
source = "mod4"
|
||||||
compiler = compiler_for(:Integer,:mod4 ,{})
|
compiler = compiler_for(:Integer,:mod4 ,{})
|
||||||
me = compiler.add_known( :receiver )
|
builder = compiler.builder(true)
|
||||||
compiler.reduce_int( source , me )
|
me = builder.add_known( :receiver )
|
||||||
|
builder.reduce_int( source , me )
|
||||||
two = compiler.use_reg :fixnum , 2
|
two = compiler.use_reg :fixnum , 2
|
||||||
compiler.add_load_data( source , 2 , two )
|
builder.add_load_data( source , 2 , two )
|
||||||
compiler.add_code Risc.op( source , :>> , me , two)
|
builder.add_code Risc.op( source , :>> , me , two)
|
||||||
compiler.add_new_int(source,me , two)
|
builder.add_new_int(source,me , two)
|
||||||
compiler.add_reg_to_slot( source , two , :message , :return_value)
|
builder.add_reg_to_slot( source , two , :message , :return_value)
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
@ -34,73 +35,75 @@ module Risc
|
|||||||
end
|
end
|
||||||
def operator_method(op_name , op_sym )
|
def operator_method(op_name , op_sym )
|
||||||
compiler = compiler_for(:Integer, op_sym ,{other: :Integer})
|
compiler = compiler_for(:Integer, op_sym ,{other: :Integer})
|
||||||
me , other = compiler.self_and_int_arg(op_name + "load receiver and arg")
|
builder = compiler.builder(true)
|
||||||
compiler.reduce_int( op_name + " fix me", me )
|
me , other = builder.self_and_int_arg(op_name + "load receiver and arg")
|
||||||
compiler.reduce_int( op_name + " fix arg", other )
|
builder.reduce_int( op_name + " fix me", me )
|
||||||
compiler.add_code Risc.op( op_name + " operator", op_sym , me , other)
|
builder.reduce_int( op_name + " fix arg", other )
|
||||||
compiler.add_new_int(op_name + " new int", me , other)
|
builder.add_code Risc.op( op_name + " operator", op_sym , me , other)
|
||||||
compiler.add_reg_to_slot( op_name + "save ret" , other , :message , :return_value)
|
builder.add_new_int(op_name + " new int", me , other)
|
||||||
|
builder.add_reg_to_slot( op_name + "save ret" , other , :message , :return_value)
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
def div10( context )
|
def div10( context )
|
||||||
s = "div_10 "
|
s = "div_10 "
|
||||||
compiler = compiler_for(:Integer,:div10 ,{})
|
compiler = compiler_for(:Integer,:div10 ,{})
|
||||||
|
builder = compiler.builder(true)
|
||||||
#FIX: this could load receiver once, reduce and then transfer twice
|
#FIX: this could load receiver once, reduce and then transfer twice
|
||||||
me = compiler.add_known( :receiver )
|
me = builder.add_known( :receiver )
|
||||||
tmp = compiler.add_known( :receiver )
|
tmp = builder.add_known( :receiver )
|
||||||
q = compiler.add_known( :receiver )
|
q = builder.add_known( :receiver )
|
||||||
compiler.reduce_int( s , me )
|
builder.reduce_int( s , me )
|
||||||
compiler.reduce_int( s , tmp )
|
builder.reduce_int( s , tmp )
|
||||||
compiler.reduce_int( s , q )
|
builder.reduce_int( s , q )
|
||||||
const = compiler.use_reg :fixnum , 1
|
const = compiler.use_reg :fixnum , 1
|
||||||
compiler.add_load_data( s , 1 , const )
|
builder.add_load_data( s , 1 , const )
|
||||||
# int tmp = self >> 1
|
# int tmp = self >> 1
|
||||||
compiler.add_code Risc.op( s , :>> , tmp , const)
|
builder.add_code Risc.op( s , :>> , tmp , const)
|
||||||
# int q = self >> 2
|
# int q = self >> 2
|
||||||
compiler.add_load_data( s , 2 , const)
|
builder.add_load_data( s , 2 , const)
|
||||||
compiler.add_code Risc.op( s , :>> , q , const)
|
builder.add_code Risc.op( s , :>> , q , const)
|
||||||
# q = q + tmp
|
# q = q + tmp
|
||||||
compiler.add_code Risc.op( s , :+ , q , tmp )
|
builder.add_code Risc.op( s , :+ , q , tmp )
|
||||||
# tmp = q >> 4
|
# tmp = q >> 4
|
||||||
compiler.add_load_data( s , 4 , const)
|
builder.add_load_data( s , 4 , const)
|
||||||
compiler.add_transfer( s, q , tmp)
|
builder.add_transfer( s, q , tmp)
|
||||||
compiler.add_code Risc.op( s , :>> , tmp , const)
|
builder.add_code Risc.op( s , :>> , tmp , const)
|
||||||
# q = q + tmp
|
# q = q + tmp
|
||||||
compiler.add_code Risc.op( s , :+ , q , tmp )
|
builder.add_code Risc.op( s , :+ , q , tmp )
|
||||||
# tmp = q >> 8
|
# tmp = q >> 8
|
||||||
compiler.add_load_data( s , 8 , const)
|
builder.add_load_data( s , 8 , const)
|
||||||
compiler.add_transfer( s, q , tmp)
|
builder.add_transfer( s, q , tmp)
|
||||||
compiler.add_code Risc.op( s , :>> , tmp , const)
|
builder.add_code Risc.op( s , :>> , tmp , const)
|
||||||
# q = q + tmp
|
# q = q + tmp
|
||||||
compiler.add_code Risc.op( s , :+ , q , tmp )
|
builder.add_code Risc.op( s , :+ , q , tmp )
|
||||||
# tmp = q >> 16
|
# tmp = q >> 16
|
||||||
compiler.add_load_data( s , 16 , const)
|
builder.add_load_data( s , 16 , const)
|
||||||
compiler.add_transfer( s, q , tmp)
|
builder.add_transfer( s, q , tmp)
|
||||||
compiler.add_code Risc.op( s , :>> , tmp , const)
|
builder.add_code Risc.op( s , :>> , tmp , const)
|
||||||
# q = q + tmp
|
# q = q + tmp
|
||||||
compiler.add_code Risc.op( s , :+ , q , tmp )
|
builder.add_code Risc.op( s , :+ , q , tmp )
|
||||||
# q = q >> 3
|
# q = q >> 3
|
||||||
compiler.add_load_data( s , 3 , const)
|
builder.add_load_data( s , 3 , const)
|
||||||
compiler.add_code Risc.op( s , :>> , q , const)
|
builder.add_code Risc.op( s , :>> , q , const)
|
||||||
# tmp = q * 10
|
# tmp = q * 10
|
||||||
compiler.add_load_data( s , 10 , const)
|
builder.add_load_data( s , 10 , const)
|
||||||
compiler.add_transfer( s, q , tmp)
|
builder.add_transfer( s, q , tmp)
|
||||||
compiler.add_code Risc.op( s , :* , tmp , const)
|
builder.add_code Risc.op( s , :* , tmp , const)
|
||||||
# tmp = self - tmp
|
# tmp = self - tmp
|
||||||
compiler.add_code Risc.op( s , :- , me , tmp )
|
builder.add_code Risc.op( s , :- , me , tmp )
|
||||||
compiler.add_transfer( s , me , tmp)
|
builder.add_transfer( s , me , tmp)
|
||||||
# tmp = tmp + 6
|
# tmp = tmp + 6
|
||||||
compiler.add_load_data( s , 6 , const)
|
builder.add_load_data( s , 6 , const)
|
||||||
compiler.add_code Risc.op( s , :+ , tmp , const )
|
builder.add_code Risc.op( s , :+ , tmp , const )
|
||||||
# tmp = tmp >> 4
|
# tmp = tmp >> 4
|
||||||
compiler.add_load_data( s , 4 , const)
|
builder.add_load_data( s , 4 , const)
|
||||||
compiler.add_code Risc.op( s , :>> , tmp , const )
|
builder.add_code Risc.op( s , :>> , tmp , const )
|
||||||
# return q + tmp
|
# return q + tmp
|
||||||
compiler.add_code Risc.op( s , :+ , q , tmp )
|
builder.add_code Risc.op( s , :+ , q , tmp )
|
||||||
|
|
||||||
compiler.add_new_int(s,q , tmp)
|
builder.add_new_int(s,q , tmp)
|
||||||
compiler.add_reg_to_slot( s , tmp , :message , :return_value)
|
builder.add_reg_to_slot( s , tmp , :message , :return_value)
|
||||||
|
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
|
@ -9,12 +9,13 @@ module Risc
|
|||||||
# (this method returns a new method off course, like all builtin)
|
# (this method returns a new method off course, like all builtin)
|
||||||
def get_internal_word( context )
|
def get_internal_word( context )
|
||||||
compiler = compiler_for(:Object , :get_internal_word ,{at: :Integer})
|
compiler = compiler_for(:Object , :get_internal_word ,{at: :Integer})
|
||||||
|
builder = compiler.builder(true)
|
||||||
source = "get_internal_word"
|
source = "get_internal_word"
|
||||||
me , index = compiler.self_and_int_arg(source)
|
me , index = builder.self_and_int_arg(source)
|
||||||
# reduce me to me[index]
|
# reduce me to me[index]
|
||||||
compiler.add_slot_to_reg( source , me , index , me)
|
builder.add_slot_to_reg( source , me , index , me)
|
||||||
# and put it back into the return value
|
# and put it back into the return value
|
||||||
compiler.add_reg_to_slot( source , me , :message , :return_value)
|
builder.add_reg_to_slot( source , me , :message , :return_value)
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
@ -24,11 +25,12 @@ module Risc
|
|||||||
def set_internal_word( context )
|
def set_internal_word( context )
|
||||||
compiler = compiler_for(:Object , :set_internal_word , {at: :Integer, :value => :Object} )
|
compiler = compiler_for(:Object , :set_internal_word , {at: :Integer, :value => :Object} )
|
||||||
source = "set_internal_word"
|
source = "set_internal_word"
|
||||||
me , index = compiler.self_and_int_arg(source)
|
builder = compiler.builder(true)
|
||||||
value = compiler.load_int_arg_at(source , 2)
|
me , index = builder.self_and_int_arg(source)
|
||||||
|
value = builder.load_int_arg_at(source , 2)
|
||||||
|
|
||||||
# do the set
|
# do the set
|
||||||
compiler.add_reg_to_slot( source , value , me , index)
|
builder.add_reg_to_slot( source , value , me , index)
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
@ -37,7 +39,7 @@ module Risc
|
|||||||
# Even if it's just this one, sys_exit (later raise)
|
# Even if it's just this one, sys_exit (later raise)
|
||||||
def _method_missing( context )
|
def _method_missing( context )
|
||||||
compiler = compiler_for(:Object,:method_missing ,{})
|
compiler = compiler_for(:Object,:method_missing ,{})
|
||||||
emit_syscall( compiler , :exit )
|
emit_syscall( compiler.builder(true) , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
# this is the really really first place the machine starts (apart from the jump here)
|
# this is the really really first place the machine starts (apart from the jump here)
|
||||||
@ -46,7 +48,7 @@ module Risc
|
|||||||
def __init__ context
|
def __init__ context
|
||||||
compiler = Risc::MethodCompiler.create_method(:Object,:__init__ ,
|
compiler = Risc::MethodCompiler.create_method(:Object,:__init__ ,
|
||||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||||
builder = Risc::Builder.new(compiler)
|
builder = compiler.builder(true)
|
||||||
builder.build do
|
builder.build do
|
||||||
space << Parfait.object_space
|
space << Parfait.object_space
|
||||||
message << space[:first_message]
|
message << space[:first_message]
|
||||||
@ -54,8 +56,7 @@ module Risc
|
|||||||
space[:first_message] << next_message
|
space[:first_message] << next_message
|
||||||
end
|
end
|
||||||
|
|
||||||
risc = Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder )
|
Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder )
|
||||||
compiler.add_code(risc)
|
|
||||||
|
|
||||||
builder.build do
|
builder.build do
|
||||||
message << message[:next_message]
|
message << message[:next_message]
|
||||||
@ -64,49 +65,51 @@ module Risc
|
|||||||
|
|
||||||
exit_label = Risc.label("_exit_label for __init__" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
|
exit_label = Risc.label("_exit_label for __init__" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
|
||||||
ret_tmp = compiler.use_reg(:Label)
|
ret_tmp = compiler.use_reg(:Label)
|
||||||
compiler.add_load_constant("__init__ load return", exit_label , ret_tmp)
|
builder.build do
|
||||||
compiler.add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address)
|
add_load_constant("__init__ load return", exit_label , ret_tmp)
|
||||||
compiler.add_function_call( "__init__ issue call" , Parfait.object_space.get_main , ret_tmp)
|
add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address)
|
||||||
compiler.add_code exit_label
|
add_function_call( "__init__ issue call" , Parfait.object_space.get_main , ret_tmp)
|
||||||
emit_syscall( compiler , :exit )
|
add_code exit_label
|
||||||
|
end
|
||||||
|
emit_syscall( builder , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit( context )
|
def exit( context )
|
||||||
compiler = compiler_for(:Object,:exit ,{})
|
compiler = compiler_for(:Object,:exit ,{})
|
||||||
emit_syscall( compiler , :exit )
|
emit_syscall( compiler.builder(true) , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
|
|
||||||
def emit_syscall( compiler , name )
|
def emit_syscall( builder , name )
|
||||||
save_message( compiler )
|
save_message( builder )
|
||||||
compiler.add_code Syscall.new("emit_syscall(#{name})", name )
|
builder.add_code Syscall.new("emit_syscall(#{name})", name )
|
||||||
restore_message(compiler)
|
restore_message(builder)
|
||||||
return unless (@clazz and @method)
|
return unless (@clazz and @method)
|
||||||
compiler.add_label( "#{@clazz.name}.#{@message.name}" , "return_syscall" )
|
builder.add_code Risc.label( "#{@clazz.name}.#{@message.name}" , "return_syscall" )
|
||||||
end
|
end
|
||||||
|
|
||||||
# save the current message, as the syscall destroys all context
|
# save the current message, as the syscall destroys all context
|
||||||
#
|
#
|
||||||
# This relies on linux to save and restore all registers
|
# This relies on linux to save and restore all registers
|
||||||
#
|
#
|
||||||
def save_message(compiler)
|
def save_message(builder)
|
||||||
r8 = RiscValue.new( :r8 , :Message)
|
r8 = RiscValue.new( :r8 , :Message)
|
||||||
compiler.add_transfer("save_message", Risc.message_reg , r8 )
|
builder.add_code Risc.transfer("save_message", Risc.message_reg , r8 )
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore_message(compiler)
|
def restore_message(builder)
|
||||||
r8 = RiscValue.new( :r8 , :Message)
|
r8 = RiscValue.new( :r8 , :Message)
|
||||||
return_tmp = compiler.use_reg :fixnum
|
return_tmp = builder.compiler.use_reg :fixnum
|
||||||
source = "_restore_message"
|
source = "_restore_message"
|
||||||
# get the sys return out of the way
|
# get the sys return out of the way
|
||||||
compiler.add_transfer(source, Risc.message_reg , return_tmp )
|
builder.add_code Risc.transfer(source, Risc.message_reg , return_tmp )
|
||||||
# load the stored message into the base register
|
# load the stored message into the base register
|
||||||
compiler.add_transfer(source, r8 , Risc.message_reg )
|
builder.add_code Risc.transfer(source, r8 , Risc.message_reg )
|
||||||
int = compiler.use_reg(:Integer)
|
int = builder.compiler.use_reg(:Integer)
|
||||||
compiler.add_new_int(source , return_tmp , int )
|
builder.add_new_int(source , return_tmp , int )
|
||||||
# save the return value into the message
|
# save the return value into the message
|
||||||
compiler.add_reg_to_slot( source , int , :message , :return_value )
|
builder.add_code Risc.reg_to_slot( source , int , :message , :return_value )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -6,11 +6,12 @@ module Risc
|
|||||||
|
|
||||||
def putstring( context)
|
def putstring( context)
|
||||||
compiler = compiler_for(:Word , :putstring ,{})
|
compiler = compiler_for(:Word , :putstring ,{})
|
||||||
compiler.add_slot_to_reg( "putstring" , :message , :receiver , :new_message )
|
builder = compiler.builder(true)
|
||||||
|
builder.add_slot_to_reg( "putstring" , :message , :receiver , :new_message )
|
||||||
index = Parfait::Word.get_length_index
|
index = Parfait::Word.get_length_index
|
||||||
reg = RiscValue.new(:r2 , :Integer)
|
reg = RiscValue.new(:r2 , :Integer)
|
||||||
compiler.add_slot_to_reg( "putstring" , :new_message , index , reg )
|
builder.add_slot_to_reg( "putstring" , :new_message , index , reg )
|
||||||
Risc::Builtin::Object.emit_syscall( compiler , :putstring )
|
Risc::Builtin::Object.emit_syscall( builder , :putstring )
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
compiler.method
|
compiler.method
|
||||||
end
|
end
|
||||||
@ -20,13 +21,14 @@ module Risc
|
|||||||
def get_internal_byte( context)
|
def get_internal_byte( context)
|
||||||
compiler = compiler_for(:Word , :get_internal_byte , {at: :Integer})
|
compiler = compiler_for(:Word , :get_internal_byte , {at: :Integer})
|
||||||
source = "get_internal_byte"
|
source = "get_internal_byte"
|
||||||
me , index = compiler.self_and_int_arg(source)
|
builder = compiler.builder(true)
|
||||||
compiler.reduce_int( source + " fix arg", index )
|
me , index = builder.self_and_int_arg(source)
|
||||||
|
builder.reduce_int( source + " fix arg", index )
|
||||||
# reduce me to me[index]
|
# reduce me to me[index]
|
||||||
compiler.add_byte_to_reg( source , me , index , me)
|
builder.add_byte_to_reg( source , me , index , me)
|
||||||
compiler.add_new_int(source, me , index)
|
builder.add_new_int(source, me , index)
|
||||||
# and put it back into the return value
|
# and put it back into the return value
|
||||||
compiler.add_reg_to_slot( source , index , :message , :return_value)
|
builder.add_reg_to_slot( source , index , :message , :return_value)
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
@ -37,60 +39,17 @@ module Risc
|
|||||||
def set_internal_byte( context )
|
def set_internal_byte( context )
|
||||||
compiler = compiler_for(:Word, :set_internal_byte , {at: :Integer , :value => :Integer} )
|
compiler = compiler_for(:Word, :set_internal_byte , {at: :Integer , :value => :Integer} )
|
||||||
source = "set_internal_byte"
|
source = "set_internal_byte"
|
||||||
me , index = compiler.self_and_int_arg(source)
|
builder = compiler.builder(true)
|
||||||
value = compiler.load_int_arg_at(source , 2 )
|
me , index = builder.self_and_int_arg(source)
|
||||||
compiler.reduce_int( source + " fix me", value )
|
value = builder.load_int_arg_at(source , 2 )
|
||||||
compiler.reduce_int( source + " fix arg", index )
|
builder.reduce_int( source + " fix me", value )
|
||||||
compiler.add_reg_to_byte( source , value , me , index)
|
builder.reduce_int( source + " fix arg", index )
|
||||||
compiler.add_reg_to_slot( source , me , :message , :return_value)
|
builder.add_reg_to_byte( source , value , me , index)
|
||||||
|
builder.add_reg_to_slot( source , me , :message , :return_value)
|
||||||
compiler.add_mom( Mom::ReturnSequence.new)
|
compiler.add_mom( Mom::ReturnSequence.new)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
|
|
||||||
# resolve the method name of self, on the given object
|
|
||||||
# may seem wrong way around at first sight, but we know the type of string. And
|
|
||||||
# thus resolving this method happens at compile time, whereas any method on an
|
|
||||||
# unknown self (the object given) needs resolving and that is just what we are doing
|
|
||||||
# ( ie the snake bites it's tail)
|
|
||||||
# This method is just a placeholder until boot is over and the real method is
|
|
||||||
# parsed.
|
|
||||||
def resolve_method( context)
|
|
||||||
compiler = compiler_for(:Word, :resolve_method , {:value => :Type} )
|
|
||||||
source = "resolve_method "
|
|
||||||
|
|
||||||
compiler.build do
|
|
||||||
word << message[ :receiver ]
|
|
||||||
|
|
||||||
type << message[:arguments]
|
|
||||||
type << type[2]
|
|
||||||
type << type[:type]
|
|
||||||
typed_method << type[:methods]
|
|
||||||
add while_start_label
|
|
||||||
space << Parfait.object_space
|
|
||||||
space << space[:nil_object]
|
|
||||||
|
|
||||||
space - typed_method
|
|
||||||
if_zero exit_label
|
|
||||||
|
|
||||||
name << typed_method[:name]
|
|
||||||
name - word
|
|
||||||
if_not_zero false_label
|
|
||||||
|
|
||||||
typed_method << typed_method[:binary]
|
|
||||||
message[:return_value] << typed_method
|
|
||||||
|
|
||||||
add Mom::ReturnSequence.new.to_risc(compiler)
|
|
||||||
|
|
||||||
add false_label
|
|
||||||
typed_method << typed_method[:next_method]
|
|
||||||
branch while_start_label
|
|
||||||
|
|
||||||
add exit_label
|
|
||||||
end
|
|
||||||
Risc::Builtin::Object.emit_syscall( compiler , :exit )
|
|
||||||
return compiler.method
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
extend ClassMethods
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
|
@ -21,6 +21,7 @@ module Util
|
|||||||
# ie insert into the linked list that the instructions form
|
# ie insert into the linked list that the instructions form
|
||||||
# but allowing the instruction to be a list too (ie more than one)
|
# but allowing the instruction to be a list too (ie more than one)
|
||||||
def insert( instruction )
|
def insert( instruction )
|
||||||
|
raise "circular insert #{instruction}" if instruction == self
|
||||||
instruction.last.set_next @next
|
instruction.last.set_next @next
|
||||||
@next = instruction
|
@next = instruction
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestReturnDynamic < MiniTest::Test
|
class TestReturnDynamic #< MiniTest::Test
|
||||||
include Statements
|
include Statements
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -61,5 +61,8 @@ module Risc
|
|||||||
def test_label_is_not_method
|
def test_label_is_not_method
|
||||||
assert ! @label.is_method
|
assert ! @label.is_method
|
||||||
end
|
end
|
||||||
|
def test_insert_self
|
||||||
|
assert_raises {@label.insert(@label)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user