fix test result, but not test yet

This commit is contained in:
Torsten Ruger
2015-08-07 16:46:55 +03:00
parent 4afd7f78ca
commit ca14ef8914
6 changed files with 40 additions and 16 deletions

View File

@ -170,5 +170,17 @@ module Interpreter
# we jump back to the call instruction. so it is as if the call never happened and we continue
true
end
def execute_OperatorInstruction
case @instruction.operator
when :add
puts @instruction
else
raise "unimplemented operator #{@instruction}"
end
true
end
end
end

View File

@ -7,9 +7,15 @@ module Register
plus_function = Virtual::MethodSource.create_method(:Integer,:plus , [:Integer] )
plus_function.source.return_type = Virtual::Integer
plus_function.source.receiver = Virtual::Integer
plus_function.source.add_code Register::OperatorInstruction.new( plus_function, :add , 0 , 0 )
tmp = Register.tmp_reg
index = Register.arg_index 1
plus_function.source.add_code Register.get_slot( plus_function , :message , index , tmp )
add = Register::OperatorInstruction.new( plus_function, :add , tmp , Register.self_reg )
plus_function.source.add_code add
return plus_function
end
# The conversion to base10 is quite a bit more complicated than i thought.
# The bulk of it is in div10
# We set up variables, do the devision and write the result to the string

View File

@ -7,7 +7,7 @@ module Register
@left = left
@right = right
end
attr_reader :left , :right
attr_reader :operator, :left , :right
def to_s
"OperatorInstruction: #{left} #{operator} #{right}"

View File

@ -126,4 +126,11 @@ module Register
end
return register
end
# when knowing the index of the argument, return the index into the message
# index passed is parfait, ie stats at 1
def self.arg_index i
last = resolve_index :message , :name
return last + i
end
end