better calcite and operator to expand the interpreter test

This commit is contained in:
Torsten Ruger
2015-10-07 10:05:34 +03:00
parent af6366f2d1
commit 83ef902b55
6 changed files with 97 additions and 24 deletions

View File

@ -101,6 +101,13 @@ module Interpreter
false
end
def execute_IsZeroBranch
puts @instruction.inspect
target = @instruction.block
set_block target
false
end
def execute_LoadConstant
to = @instruction.register
value = @instruction.constant
@ -173,18 +180,25 @@ module Interpreter
end
def execute_OperatorInstruction
left = get_register(@instruction.left)
rr = @instruction.right
right = get_register(rr)
case @instruction.operator
when :add
left = get_register(@instruction.left)
rr = @instruction.right
right = get_register(rr)
result = left + right
puts "#{@instruction} == #{result}"
right = set_register(rr , result)
when "/"
result = left / right
when "-"
result = left - right
when "<"
result = left < right
when "=="
result = left == right
else
raise "unimplemented operator #{@instruction}"
raise "unimplemented #{@instruction.operator} #{@instruction}"
end
puts "#{@instruction} == #{result}"
right = set_register(rr , result)
true
end
end