From 024e6cb3893227881e4abc1484d00a89e80ae2bd Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 9 Oct 2015 18:06:00 +0300 Subject: [PATCH] ion out last changes from grammar update surprisingly painless, considering it was more or less a rewrite --- lib/interpreter/interpreter.rb | 6 +++--- lib/phisol/compiler/if_statement.rb | 2 +- lib/phisol/compiler/operator_value.rb | 4 ++-- lib/phisol/compiler/while_statement.rb | 2 +- test/compiler/test_methods.rb | 6 +++--- test/fragments/test_class.rb | 8 +++----- test/fragments/test_if.rb | 4 ++-- test/interpreter/test_puti.rb | 3 ++- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/interpreter/interpreter.rb b/lib/interpreter/interpreter.rb index f2998131..f3f82854 100644 --- a/lib/interpreter/interpreter.rb +++ b/lib/interpreter/interpreter.rb @@ -183,8 +183,8 @@ module Interpreter left = get_register(@instruction.left) rr = @instruction.right right = get_register(rr) - case @instruction.operator - when :add + case @instruction.operator.to_s + when "add" result = left + right when "/" result = left / right @@ -195,7 +195,7 @@ module Interpreter when "==" result = left == right else - raise "unimplemented #{@instruction.operator} #{@instruction}" + raise "unimplemented '#{@instruction.operator}' #{@instruction}" end puts "#{@instruction} == #{result}" right = set_register(rr , result) diff --git a/lib/phisol/compiler/if_statement.rb b/lib/phisol/compiler/if_statement.rb index 0443f3e1..a46ad4cd 100644 --- a/lib/phisol/compiler/if_statement.rb +++ b/lib/phisol/compiler/if_statement.rb @@ -2,7 +2,7 @@ module Phisol Compiler.class_eval do # if - attr_reader :cond, :if_true, :if_false - def on_if statement + def on_if_statement statement condition , if_true , if_false = *statement condition = condition.first # to execute the logic as the if states it, the blocks are the other way around diff --git a/lib/phisol/compiler/operator_value.rb b/lib/phisol/compiler/operator_value.rb index 26db036a..5e20aab7 100644 --- a/lib/phisol/compiler/operator_value.rb +++ b/lib/phisol/compiler/operator_value.rb @@ -1,7 +1,7 @@ module Phisol Compiler.class_eval do - def on_operator statement + def on_operator_value statement puts "operator #{statement.inspect}" operator , left_e , right_e = *statement left_slot = process(left_e) @@ -22,7 +22,7 @@ module Phisol Virtual::Return.new(:int ) end - def on_assign statement + def on_assignment statement puts statement.inspect name , value = *statement name = name.to_a.first diff --git a/lib/phisol/compiler/while_statement.rb b/lib/phisol/compiler/while_statement.rb index c1e1334c..206c17bd 100644 --- a/lib/phisol/compiler/while_statement.rb +++ b/lib/phisol/compiler/while_statement.rb @@ -1,7 +1,7 @@ module Phisol Compiler.class_eval do - def on_while statement + def on_while_statement statement #puts statement.inspect condition , statements = *statement condition = condition.first diff --git a/test/compiler/test_methods.rb b/test/compiler/test_methods.rb index c7d5e1d9..cfa9856f 100644 --- a/test/compiler/test_methods.rb +++ b/test/compiler/test_methods.rb @@ -49,9 +49,9 @@ HERE def test_int_function @string_input = <