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
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

View File

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

View File

@ -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"

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
# 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