From 9ddcb3224c58179ba997e1153088ad9904ef684d Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 15 Mar 2018 11:32:32 +0530 Subject: [PATCH] rename --- lib/vool/statement.rb | 2 +- lib/vool/statements/if_statement.rb | 2 +- lib/vool/statements/normalizer.rb | 6 +++--- lib/vool/vool_compiler.rb | 1 + test/vool/{statements => ruby_compiler}/helper.rb | 0 .../{statements => ruby_compiler}/test_array_statement.rb | 0 .../vool/{statements => ruby_compiler}/test_basic_values.rb | 0 .../{statements => ruby_compiler}/test_class_statement.rb | 0 .../{statements => ruby_compiler}/test_hash_statement.rb | 0 .../vool/{statements => ruby_compiler}/test_if_statement.rb | 0 test/vool/{statements => ruby_compiler}/test_ivar.rb | 0 test/vool/{statements => ruby_compiler}/test_local.rb | 0 .../{statements => ruby_compiler}/test_logical_statement.rb | 0 .../{statements => ruby_compiler}/test_method_statement.rb | 0 .../{statements => ruby_compiler}/test_return_statement.rb | 0 .../{statements => ruby_compiler}/test_send_statement.rb | 0 test/vool/{statements => ruby_compiler}/test_variables.rb | 0 .../{statements => ruby_compiler}/test_while_statement.rb | 0 18 files changed, 6 insertions(+), 5 deletions(-) rename test/vool/{statements => ruby_compiler}/helper.rb (100%) rename test/vool/{statements => ruby_compiler}/test_array_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_basic_values.rb (100%) rename test/vool/{statements => ruby_compiler}/test_class_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_hash_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_if_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_ivar.rb (100%) rename test/vool/{statements => ruby_compiler}/test_local.rb (100%) rename test/vool/{statements => ruby_compiler}/test_logical_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_method_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_return_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_send_statement.rb (100%) rename test/vool/{statements => ruby_compiler}/test_variables.rb (100%) rename test/vool/{statements => ruby_compiler}/test_while_statement.rb (100%) diff --git a/lib/vool/statement.rb b/lib/vool/statement.rb index dd0f8f5d..5d4fb587 100644 --- a/lib/vool/statement.rb +++ b/lib/vool/statement.rb @@ -27,7 +27,7 @@ module Vool # after creation vool normalizes to ensure valid syntax and simplify # also throw errors if violation - def normalize + def normalize(method) return self end diff --git a/lib/vool/statements/if_statement.rb b/lib/vool/statements/if_statement.rb index 1484d9af..4c6fdb92 100644 --- a/lib/vool/statements/if_statement.rb +++ b/lib/vool/statements/if_statement.rb @@ -13,7 +13,7 @@ module Vool end def normalize(method) - cond , rest = *normalize_name(@condition) + cond , rest = *normalize_name(@condition, method) fals = @if_false ? @if_false.normalize(method) : nil me = IfStatement.new(cond , @if_true.normalize(method), fals) return me unless rest diff --git a/lib/vool/statements/normalizer.rb b/lib/vool/statements/normalizer.rb index b4a5e196..e6e73949 100644 --- a/lib/vool/statements/normalizer.rb +++ b/lib/vool/statements/normalizer.rb @@ -6,10 +6,10 @@ module Vool # # eg if( @var % 5) is not normalized # but if(tmp_123) is with tmp_123 = @var % 5 hoited above the if - def normalize_name( method ) - return [@condition] if @condition.is_a?(Named) + def normalize_name( condition , method ) + return [condition] if condition.is_a?(Named) local = method.create_tmp - assign = LocalAssignment.new( local , @condition) + assign = LocalAssignment.new( local , condition) [LocalVariable.new(local) , assign] end end diff --git a/lib/vool/vool_compiler.rb b/lib/vool/vool_compiler.rb index e72ff867..cffac6c5 100644 --- a/lib/vool/vool_compiler.rb +++ b/lib/vool/vool_compiler.rb @@ -5,6 +5,7 @@ module Vool def self.ruby_to_vool( ruby_source ) statements = RubyCompiler.compile( ruby_source ) + statements = statements.normalize(nil) statements.create_objects statements end diff --git a/test/vool/statements/helper.rb b/test/vool/ruby_compiler/helper.rb similarity index 100% rename from test/vool/statements/helper.rb rename to test/vool/ruby_compiler/helper.rb diff --git a/test/vool/statements/test_array_statement.rb b/test/vool/ruby_compiler/test_array_statement.rb similarity index 100% rename from test/vool/statements/test_array_statement.rb rename to test/vool/ruby_compiler/test_array_statement.rb diff --git a/test/vool/statements/test_basic_values.rb b/test/vool/ruby_compiler/test_basic_values.rb similarity index 100% rename from test/vool/statements/test_basic_values.rb rename to test/vool/ruby_compiler/test_basic_values.rb diff --git a/test/vool/statements/test_class_statement.rb b/test/vool/ruby_compiler/test_class_statement.rb similarity index 100% rename from test/vool/statements/test_class_statement.rb rename to test/vool/ruby_compiler/test_class_statement.rb diff --git a/test/vool/statements/test_hash_statement.rb b/test/vool/ruby_compiler/test_hash_statement.rb similarity index 100% rename from test/vool/statements/test_hash_statement.rb rename to test/vool/ruby_compiler/test_hash_statement.rb diff --git a/test/vool/statements/test_if_statement.rb b/test/vool/ruby_compiler/test_if_statement.rb similarity index 100% rename from test/vool/statements/test_if_statement.rb rename to test/vool/ruby_compiler/test_if_statement.rb diff --git a/test/vool/statements/test_ivar.rb b/test/vool/ruby_compiler/test_ivar.rb similarity index 100% rename from test/vool/statements/test_ivar.rb rename to test/vool/ruby_compiler/test_ivar.rb diff --git a/test/vool/statements/test_local.rb b/test/vool/ruby_compiler/test_local.rb similarity index 100% rename from test/vool/statements/test_local.rb rename to test/vool/ruby_compiler/test_local.rb diff --git a/test/vool/statements/test_logical_statement.rb b/test/vool/ruby_compiler/test_logical_statement.rb similarity index 100% rename from test/vool/statements/test_logical_statement.rb rename to test/vool/ruby_compiler/test_logical_statement.rb diff --git a/test/vool/statements/test_method_statement.rb b/test/vool/ruby_compiler/test_method_statement.rb similarity index 100% rename from test/vool/statements/test_method_statement.rb rename to test/vool/ruby_compiler/test_method_statement.rb diff --git a/test/vool/statements/test_return_statement.rb b/test/vool/ruby_compiler/test_return_statement.rb similarity index 100% rename from test/vool/statements/test_return_statement.rb rename to test/vool/ruby_compiler/test_return_statement.rb diff --git a/test/vool/statements/test_send_statement.rb b/test/vool/ruby_compiler/test_send_statement.rb similarity index 100% rename from test/vool/statements/test_send_statement.rb rename to test/vool/ruby_compiler/test_send_statement.rb diff --git a/test/vool/statements/test_variables.rb b/test/vool/ruby_compiler/test_variables.rb similarity index 100% rename from test/vool/statements/test_variables.rb rename to test/vool/ruby_compiler/test_variables.rb diff --git a/test/vool/statements/test_while_statement.rb b/test/vool/ruby_compiler/test_while_statement.rb similarity index 100% rename from test/vool/statements/test_while_statement.rb rename to test/vool/ruby_compiler/test_while_statement.rb