From ac7b9138ff3433ce366400df46ee4001f90cfafb Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 2 Apr 2017 18:25:30 +0300 Subject: [PATCH] bit of cleaning --- lib/vool/compiler.rb | 25 +++++++++++++------------ lib/vool/send_statement.rb | 3 +++ test/test_all.rb | 2 ++ test/vool/test_all.rb | 2 ++ test/vool/test_variables.rb | 8 ++++---- 5 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 test/vool/test_all.rb diff --git a/lib/vool/compiler.rb b/lib/vool/compiler.rb index 088d26f6..39ede5a1 100644 --- a/lib/vool/compiler.rb +++ b/lib/vool/compiler.rb @@ -69,9 +69,10 @@ module Vool def on_dsym raise "Not implemented dynamix symbols (with interpolation)" end - def on_kwbegin expression - ScopeStatement.new process_all( expression.children ) + def on_kwbegin statement + ScopeStatement.new process_all( statement.children ) end + alias :on_begin :on_kwbegin # Array + Hashes def on_array expression @@ -88,8 +89,10 @@ module Vool end #Variables + def on_lvar expression + LocalVariable.new(expression.children.first) + end def on_lvasgn expression - puts "EXP #{expression}" name = expression.children[0] value = process(expression.children[1]) LocalAssignment.new(name,value) @@ -148,25 +151,23 @@ module Vool end def on_send statement - puts "SEND #{statement}" kids = statement.children.dup receiver = kids.shift name = kids.shift arguments = kids - w = SendStatement.new() + w = SendStatement.new( name ) w.receiver = process(receiver) || SelfStatement.new - w.name = name w.arguments = process_all(arguments) w end - def on_name statement - NameStatement.new(statement.children.first) - end + # def on_name statement + # NameStatement.new(statement.children.first) + # end - def on_class_name expression - ClassStatement.new(expression.children.first) - end + # def on_class_name expression + # ClassStatement.new(expression.children.first) + # end def on_assignment statement name , value = *statement diff --git a/lib/vool/send_statement.rb b/lib/vool/send_statement.rb index 9836ce72..e231508d 100644 --- a/lib/vool/send_statement.rb +++ b/lib/vool/send_statement.rb @@ -1,5 +1,8 @@ module Vool class SendStatement < Statement attr_accessor :name , :receiver , :arguments + def initialize(name) + @name = name + end end end diff --git a/test/test_all.rb b/test/test_all.rb index c6c80f50..b9e59563 100644 --- a/test/test_all.rb +++ b/test/test_all.rb @@ -6,6 +6,8 @@ require_relative "lib/test_all" require_relative "rubyx/test_all" +require_relative "vool/test_all" + require_relative "parfait/test_all" require_relative "risc/test_all" diff --git a/test/vool/test_all.rb b/test/vool/test_all.rb new file mode 100644 index 00000000..65f18f56 --- /dev/null +++ b/test/vool/test_all.rb @@ -0,0 +1,2 @@ +require_relative "helper" +require_relative "test_compiler" diff --git a/test/vool/test_variables.rb b/test/vool/test_variables.rb index 793b3bb9..b27ea87c 100644 --- a/test/vool/test_variables.rb +++ b/test/vool/test_variables.rb @@ -5,10 +5,10 @@ module Vool # "free standing" local can not be tested as it will result in send # in other words ther is no way of knowing if a name is variable or method - def ptest_send_to_local - lst = Compiler.compile( "foo = 1 ; foo.bar") - assert_equal LocalVariable , lst.receiver - end + # def test_send_to_local + # lst = Compiler.compile( "foo.bar") + # assert_equal SendStatement , lst.class + # end end end