fix tests (just using local gem)
This commit is contained in:
@ -7,7 +7,7 @@ module Register
|
||||
plus_function = Virtual::MethodSource.create_method(:Integer,:plus , [Virtual::Integer] )
|
||||
plus_function.source.return_type = Virtual::Integer
|
||||
plus_function.source.receiver = Virtual::Integer
|
||||
plus_function.source.add_code Register::Math.new( plus_function, :add , 0 )
|
||||
plus_function.source.add_code Register::OperatorInstruction.new( plus_function, :add , 0 , 0 )
|
||||
|
||||
return plus_function
|
||||
end
|
||||
|
@ -49,3 +49,4 @@ require_relative "instructions/function_return"
|
||||
require_relative "instructions/save_return"
|
||||
require_relative "instructions/register_transfer"
|
||||
require_relative "instructions/branch"
|
||||
require_relative "instructions/operator_instruction"
|
||||
|
18
lib/register/instructions/operator_instruction.rb
Normal file
18
lib/register/instructions/operator_instruction.rb
Normal file
@ -0,0 +1,18 @@
|
||||
module Register
|
||||
|
||||
class OperatorInstruction < Instruction
|
||||
def initialize source , operator , left , right
|
||||
super(source)
|
||||
@operator = operator
|
||||
@left = left
|
||||
@right = right
|
||||
end
|
||||
attr_reader :left , :right
|
||||
|
||||
def to_s
|
||||
"OperatorInstruction: #{left} #{operator} #{right}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -157,9 +157,10 @@ module Virtual
|
||||
@space.get_class_by_name(:Word).add_instance_method Register::Builtin::Word.send(:putstring , nil)
|
||||
|
||||
obj = @space.get_class_by_name(:Integer)
|
||||
[:putint,:fibo].each do |f|
|
||||
[:putint,:fibo , :plus].each do |f|
|
||||
obj.add_instance_method Register::Builtin::Integer.send(f , nil)
|
||||
end
|
||||
# obj.alias :plus , :+
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user