update the reader rewrite and reflect name changes
This commit is contained in:
@ -11,11 +11,11 @@ class Object
|
||||
end
|
||||
HERE
|
||||
|
||||
expressions = Virtual.machine.boot.parse_and_compile input
|
||||
if( expressions.first.is_a? Virtual::Self )
|
||||
expressions.first.type.instance_variable_set :@of_class , nil
|
||||
statements = Virtual.machine.boot.parse_and_compile input
|
||||
if( statements.first.is_a? Virtual::Self )
|
||||
statements.first.type.instance_variable_set :@of_class , nil
|
||||
end
|
||||
is = Sof.write(expressions)
|
||||
is = Sof.write(statements)
|
||||
#puts is
|
||||
assert_equal @output , is
|
||||
end
|
||||
|
@ -7,16 +7,16 @@ class CompilerTest < MiniTest::Test
|
||||
Virtual.machine.boot
|
||||
end
|
||||
def check
|
||||
res = Phisol::Compiler.compile( @expression )
|
||||
res = Phisol::Compiler.compile( @statement )
|
||||
assert res.is_a?(Virtual::Slot) , "compiler must compile to slot, not #{res.inspect}"
|
||||
end
|
||||
def test_function_expression
|
||||
@expression = s(:class, :Foo,
|
||||
def test_function_statement
|
||||
@statement = s(:class, :Foo,
|
||||
s(:derives, :Object),
|
||||
s(:expressions,
|
||||
s(:statements,
|
||||
s(:function, :int, s(:name, :foo),
|
||||
s(:parameters, s(:parameter, :ref, :x)),
|
||||
s(:expressions, s(:int, 5)))))
|
||||
s(:statements, s(:int, 5)))))
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ class HelloTest < MiniTest::Test
|
||||
machine = Virtual.machine.boot
|
||||
Parfait::Space.object_space.get_class_by_name(:Integer).remove_instance_method :plus
|
||||
#TODO remove this hack: write proper aliases
|
||||
expressions = machine.parse_and_compile @string_input
|
||||
statements = machine.parse_and_compile @string_input
|
||||
output_at = "Register::CallImplementation"
|
||||
#{}"Register::CallImplementation"
|
||||
machine.run_before output_at
|
||||
|
@ -2,14 +2,14 @@ require_relative '../helper'
|
||||
|
||||
# simple tests to check parsing pworks and the first classes come out right.
|
||||
#
|
||||
# build up from small to check larger expressions are correct
|
||||
# build up from small to check larger statements are correct
|
||||
|
||||
module Fragments
|
||||
|
||||
def check
|
||||
expressions = Virtual.machine.boot.parse_and_compile @string_input
|
||||
statements = Virtual.machine.boot.parse_and_compile @string_input
|
||||
@expect.each_with_index do | should , i |
|
||||
exp_i = expressions[i]
|
||||
exp_i = statements[i]
|
||||
assert exp_i.is_a?(Virtual::Slot) , "compiles should return #{should}, not #{exp_i}"
|
||||
assert_equal should , exp_i.class
|
||||
end
|
||||
|
@ -8,11 +8,11 @@ class AddTest < MiniTest::Test
|
||||
Virtual.machine.boot
|
||||
code = s(:class, :Object,
|
||||
s(:derives, nil),
|
||||
s(:expressions,
|
||||
s(:statements,
|
||||
s(:function, :int,
|
||||
s(:name, :main),
|
||||
s(:parameters),
|
||||
s(:expressions,
|
||||
s(:statements,
|
||||
s(:call,
|
||||
s(:name, :plus),
|
||||
s(:arguments , s(:int , 5)),
|
||||
|
@ -53,8 +53,8 @@ HERE
|
||||
puts parts.inspect
|
||||
Phisol::Compiler.compile( parts )
|
||||
|
||||
# expressions = Virtual.machine.boot.parse_and_compile @string_input
|
||||
# Phisol::Compiler.compile( expressions , Virtual.machine.space.get_main )
|
||||
# statements = Virtual.machine.boot.parse_and_compile @string_input
|
||||
# Phisol::Compiler.compile( statements , Virtual.machine.space.get_main )
|
||||
Virtual.machine.run_before "Register::CallImplementation"
|
||||
@interpreter = Interpreter::Interpreter.new
|
||||
@interpreter.start Virtual.machine.init
|
||||
|
@ -7,11 +7,11 @@ class TestPuts < MiniTest::Test
|
||||
Virtual.machine.boot
|
||||
code = s(:class, :Object,
|
||||
s(:derives, nil),
|
||||
s(:expressions,
|
||||
s(:statements,
|
||||
s(:function, :int,
|
||||
s(:name, :main),
|
||||
s(:parameters),
|
||||
s(:expressions,
|
||||
s(:statements,
|
||||
s(:call,
|
||||
s(:name, :putstring),
|
||||
s(:arguments),
|
||||
|
@ -24,7 +24,7 @@ class TestRunner < MiniTest::Test
|
||||
syntax = parser.parse_with_debug(string)
|
||||
assert syntax
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
# file is a list of expressions, all but the last must be a function
|
||||
# file is a list of statements, all but the last must be a function
|
||||
# and the last is wrapped as a main
|
||||
parts.each_with_index do |part,index|
|
||||
if index == (parts.length - 1)
|
||||
|
Reference in New Issue
Block a user