starts on local variable collection

500 tests (in under 2 seconds), yippie
This commit is contained in:
Torsten Ruger 2017-04-08 12:28:31 +03:00
parent ea41f9cae9
commit b0e3978b15
7 changed files with 37 additions and 3 deletions

View File

@ -23,7 +23,6 @@ module Vool
def on_class( statement )
name , sup , body = *statement
puts "CLASS #{statement}"
ClassStatement.new( get_name(name) , get_name(sup) , process(body) )
end

View File

@ -10,6 +10,10 @@ module Vool
end
end
class LocalAssignment < Assignment
# used to collect frame information
def add_local( array )
array << @name
end
end
class InstanceAssignment < Assignment
# used to collect type information

View File

@ -0,0 +1,3 @@
require_relative "helper"
require_relative "test_ivar_collect"
require_relative "test_local_collect"

View File

@ -0,0 +1,27 @@
require_relative "helper"
module Vool
module Compilers
class TestLocalCollect < MiniTest::Test
def compile(input)
lst = VoolCompiler.compile( input )
vars = []
lst.collect([]).each do |node|
node.add_local(vars)
end
vars
end
def test_assign_collect
vars = compile( "var = 5" )
assert_equal :var , vars.first
end
def test_return_collect
vars = compile( "var = 5 ; return var" )
assert_equal :var , vars.first
end
end
end
end

View File

@ -1,2 +1,4 @@
require_relative "helper"
require_relative "test_ruby_compiler"
require_relative "statements/test_all"
require_relative "compilers/test_all"
require_relative "test_vool_compiler"

View File

@ -1 +0,0 @@
require_relative "statements/test_all"