From 50379a1fea44e4c0142cbb445a1d362f36d25b95 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 19 Oct 2015 15:31:48 +0300 Subject: [PATCH] update to new syntax and patch tests basic semantics remain, but have to improve test for new functionality that has to be written for new branch types --- Gemfile.lock | 4 +-- lib/phisol/compiler/if_statement.rb | 2 +- lib/phisol/compiler/while_statement.rb | 2 +- lib/register/assembler.rb | 2 +- test/compiler/fragments/test_if.rb | 6 ++-- test/compiler/statements/test_if.rb | 4 +-- test/compiler/statements/test_while.rb | 6 ++-- test/interpreter/test_puti.rb | 49 +++++++++++++------------- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2335ab74..ca7933b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,7 +12,7 @@ GIT GIT remote: git://github.com/salama/salama-reader.git - revision: ab0a94bd51c996637453331adeb28bf1731f9b65 + revision: 6710567af979b0b367245c16a0c6af260675bc71 specs: salama-reader (0.4.0) ast (~> 2.1.0) @@ -20,7 +20,7 @@ GIT GIT remote: git://github.com/whitequark/ast.git - revision: 82e280fe0f9d528a581721d02d22d1fbf3755142 + revision: 3814fb102af82a30bf334005ebe17332744f9dad specs: ast (2.1.0) diff --git a/lib/phisol/compiler/if_statement.rb b/lib/phisol/compiler/if_statement.rb index a46ad4cd..4c3a32c5 100644 --- a/lib/phisol/compiler/if_statement.rb +++ b/lib/phisol/compiler/if_statement.rb @@ -3,7 +3,7 @@ module Phisol # if - attr_reader :cond, :if_true, :if_false def on_if_statement statement - condition , if_true , if_false = *statement + branch_type , 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 # so we can the jump over the else if true , diff --git a/lib/phisol/compiler/while_statement.rb b/lib/phisol/compiler/while_statement.rb index 206c17bd..d87e4237 100644 --- a/lib/phisol/compiler/while_statement.rb +++ b/lib/phisol/compiler/while_statement.rb @@ -3,7 +3,7 @@ module Phisol def on_while_statement statement #puts statement.inspect - condition , statements = *statement + branch_type , condition , statements = *statement condition = condition.first # this is where the while ends and both branches meet diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index b06f23ea..b9e6e245 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -98,7 +98,7 @@ module Register next if objekt.is_a? Parfait::BinaryCode write_any( objekt ) end - puts "Assembled #{stream_position} bytes" + #puts "Assembled #{stream_position} bytes" return @stream.string end diff --git a/test/compiler/fragments/test_if.rb b/test/compiler/fragments/test_if.rb index e9db8e28..e20d0faa 100644 --- a/test/compiler/fragments/test_if.rb +++ b/test/compiler/fragments/test_if.rb @@ -8,7 +8,7 @@ class TestIf < MiniTest::Test class Object int main() int n = 10 - if( n - 12) + if_plus( n - 12) return 3 else return 4 @@ -25,7 +25,7 @@ HERE class Object int main() int n = 10 - if(8 - n ) + if_minus(8 - n ) "10".putstring() end end @@ -41,7 +41,7 @@ HERE @string_input = < 0) + while_minus(n > 0) n = n - 1 end end @@ -43,7 +43,7 @@ HERE class Object int main() int n = 10 - while( n > 5) + while_notzero( n > 5) n = n + 1 return n end diff --git a/test/interpreter/test_puti.rb b/test/interpreter/test_puti.rb index 1b328de2..d03ee431 100644 --- a/test/interpreter/test_puti.rb +++ b/test/interpreter/test_puti.rb @@ -8,19 +8,19 @@ class AddTest < MiniTest::Test @string_input = <