rename
This commit is contained in:
parent
78ef1368de
commit
9ddcb3224c
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user