bit of cleaning

This commit is contained in:
Torsten Ruger 2017-04-02 18:25:30 +03:00
parent 539ab692a3
commit ac7b9138ff
5 changed files with 24 additions and 16 deletions

View File

@ -69,9 +69,10 @@ module Vool
def on_dsym def on_dsym
raise "Not implemented dynamix symbols (with interpolation)" raise "Not implemented dynamix symbols (with interpolation)"
end end
def on_kwbegin expression def on_kwbegin statement
ScopeStatement.new process_all( expression.children ) ScopeStatement.new process_all( statement.children )
end end
alias :on_begin :on_kwbegin
# Array + Hashes # Array + Hashes
def on_array expression def on_array expression
@ -88,8 +89,10 @@ module Vool
end end
#Variables #Variables
def on_lvar expression
LocalVariable.new(expression.children.first)
end
def on_lvasgn expression def on_lvasgn expression
puts "EXP #{expression}"
name = expression.children[0] name = expression.children[0]
value = process(expression.children[1]) value = process(expression.children[1])
LocalAssignment.new(name,value) LocalAssignment.new(name,value)
@ -148,25 +151,23 @@ module Vool
end end
def on_send statement def on_send statement
puts "SEND #{statement}"
kids = statement.children.dup kids = statement.children.dup
receiver = kids.shift receiver = kids.shift
name = kids.shift name = kids.shift
arguments = kids arguments = kids
w = SendStatement.new() w = SendStatement.new( name )
w.receiver = process(receiver) || SelfStatement.new w.receiver = process(receiver) || SelfStatement.new
w.name = name
w.arguments = process_all(arguments) w.arguments = process_all(arguments)
w w
end end
def on_name statement # def on_name statement
NameStatement.new(statement.children.first) # NameStatement.new(statement.children.first)
end # end
def on_class_name expression # def on_class_name expression
ClassStatement.new(expression.children.first) # ClassStatement.new(expression.children.first)
end # end
def on_assignment statement def on_assignment statement
name , value = *statement name , value = *statement

View File

@ -1,5 +1,8 @@
module Vool module Vool
class SendStatement < Statement class SendStatement < Statement
attr_accessor :name , :receiver , :arguments attr_accessor :name , :receiver , :arguments
def initialize(name)
@name = name
end
end end
end end

View File

@ -6,6 +6,8 @@ require_relative "lib/test_all"
require_relative "rubyx/test_all" require_relative "rubyx/test_all"
require_relative "vool/test_all"
require_relative "parfait/test_all" require_relative "parfait/test_all"
require_relative "risc/test_all" require_relative "risc/test_all"

2
test/vool/test_all.rb Normal file
View File

@ -0,0 +1,2 @@
require_relative "helper"
require_relative "test_compiler"

View File

@ -5,10 +5,10 @@ module Vool
# "free standing" local can not be tested as it will result in send # "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 # in other words ther is no way of knowing if a name is variable or method
def ptest_send_to_local # def test_send_to_local
lst = Compiler.compile( "foo = 1 ; foo.bar") # lst = Compiler.compile( "foo.bar")
assert_equal LocalVariable , lst.receiver # assert_equal SendStatement , lst.class
end # end
end end
end end