introducing expressions and constants
not everything statement anymore (as in ruby) basic statement tests working, rest havoc
This commit is contained in:
parent
163cad456f
commit
78ef1368de
@ -4,7 +4,7 @@ module Mom
|
|||||||
# the a is an instance variable on the current frame, and the frame is an instance
|
# the a is an instance variable on the current frame, and the frame is an instance
|
||||||
# of the current message, so the effect is something like message.frame.a = 5
|
# of the current message, so the effect is something like message.frame.a = 5
|
||||||
# @left: See SlotLoad, an array of symbols
|
# @left: See SlotLoad, an array of symbols
|
||||||
# @right: A Constant from parse, ie an instance of classes in basc_value, like TrueStatement
|
# @right: A Constant from parse, ie an instance of classes in basc_value, like TrueConstant
|
||||||
class SlotConstant < SlotLoad
|
class SlotConstant < SlotLoad
|
||||||
|
|
||||||
def initialize(left , right)
|
def initialize(left , right)
|
||||||
|
@ -38,31 +38,31 @@ module Vool
|
|||||||
|
|
||||||
#basic Values
|
#basic Values
|
||||||
def on_self exp
|
def on_self exp
|
||||||
SelfStatement.new
|
SelfExpression.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_nil expression
|
def on_nil expression
|
||||||
NilStatement.new
|
NilConstant.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_int expression
|
def on_int expression
|
||||||
IntegerStatement.new(expression.children.first)
|
IntegerConstant.new(expression.children.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_float expression
|
def on_float expression
|
||||||
FloatStatement.new(expression.children.first)
|
FloatConstant.new(expression.children.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_true expression
|
def on_true expression
|
||||||
TrueStatement.new
|
TrueConstant.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_false expression
|
def on_false expression
|
||||||
FalseStatement.new
|
FalseConstant.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_str expression
|
def on_str expression
|
||||||
StringStatement.new(expression.children.first)
|
StringConstant.new(expression.children.first)
|
||||||
end
|
end
|
||||||
alias :on_string :on_str
|
alias :on_string :on_str
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ module Vool
|
|||||||
alias :on_xstr :on_dstr
|
alias :on_xstr :on_dstr
|
||||||
|
|
||||||
def on_sym expression
|
def on_sym expression
|
||||||
SymbolStatement.new(expression.children.first)
|
SymbolConstant.new(expression.children.first)
|
||||||
end
|
end
|
||||||
alias :on_string :on_str
|
alias :on_string :on_str
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ module Vool
|
|||||||
|
|
||||||
def on_send statement
|
def on_send statement
|
||||||
kids = statement.children.dup
|
kids = statement.children.dup
|
||||||
receiver = process(kids.shift) || SelfStatement.new
|
receiver = process(kids.shift) || SelfExpression.new
|
||||||
name = kids.shift
|
name = kids.shift
|
||||||
arguments = process_all(kids)
|
arguments = process_all(kids)
|
||||||
SendStatement.new( name , receiver , arguments )
|
SendStatement.new( name , receiver , arguments )
|
||||||
@ -167,14 +167,14 @@ module Vool
|
|||||||
|
|
||||||
# this is a call to super without args (z = zero arity)
|
# this is a call to super without args (z = zero arity)
|
||||||
def on_zsuper exp
|
def on_zsuper exp
|
||||||
SendStatement.new( nil , SuperStatement.new , nil)
|
SendStatement.new( nil , SuperExpression.new , nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this is a call to super with args and
|
# this is a call to super with args and
|
||||||
# same name as current method, which is set later
|
# same name as current method, which is set later
|
||||||
def on_super( statement )
|
def on_super( statement )
|
||||||
arguments = process_all(statement.children)
|
arguments = process_all(statement.children)
|
||||||
SendStatement.new( nil , SuperStatement.new , arguments)
|
SendStatement.new( nil , SuperExpression.new , arguments)
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_assignment statement
|
def on_assignment statement
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
# Also, Vool is a typed tree, not abstract, so there is a base class Statement
|
# Also, Vool is a typed tree, not abstract, so there is a base class Statement
|
||||||
# and all it's derivation that make up the syntax tree
|
# and all it's derivation that make up the syntax tree
|
||||||
#
|
#
|
||||||
|
# Also Vool has expression and statements and simple syntax. So returns must be explicit
|
||||||
|
# not everthing is just assignable, ifs can only test simple expressions etc (wip)
|
||||||
|
#
|
||||||
# This allows us to write compilers or passes of the compiler(s) as functions on the
|
# This allows us to write compilers or passes of the compiler(s) as functions on the
|
||||||
# classes.
|
# classes.
|
||||||
#
|
#
|
||||||
@ -22,6 +25,13 @@ module Vool
|
|||||||
#
|
#
|
||||||
class Statement
|
class Statement
|
||||||
|
|
||||||
|
# after creation vool normalizes to ensure valid syntax and simplify
|
||||||
|
# also throw errors if violation
|
||||||
|
def normalize
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
# flatten tree to array
|
||||||
def collect(arr)
|
def collect(arr)
|
||||||
arr << self
|
arr << self
|
||||||
end
|
end
|
||||||
@ -51,6 +61,10 @@ module Vool
|
|||||||
def set_class( clazz )
|
def set_class( clazz )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Expression
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +75,7 @@ require_relative "statements/class_statement"
|
|||||||
require_relative "statements/hash_statement"
|
require_relative "statements/hash_statement"
|
||||||
require_relative "statements/if_statement"
|
require_relative "statements/if_statement"
|
||||||
require_relative "statements/logical_statement"
|
require_relative "statements/logical_statement"
|
||||||
require_relative "statements/local_statement"
|
require_relative "statements/local_assignment"
|
||||||
require_relative "statements/method_statement"
|
require_relative "statements/method_statement"
|
||||||
require_relative "statements/return_statement"
|
require_relative "statements/return_statement"
|
||||||
require_relative "statements/statements"
|
require_relative "statements/statements"
|
||||||
|
@ -5,6 +5,14 @@ module Vool
|
|||||||
def initialize(name , value )
|
def initialize(name , value )
|
||||||
@name , @value = name , value
|
@name , @value = name , value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize()
|
||||||
|
raise "not named left #{name}" unless @name.is_a?(Named)
|
||||||
|
raise "unsupported right #{value}" unless @name.is_a?(Named) or
|
||||||
|
@name.is_a?(SendStatement) or @name.is_a?(Constant)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
def collect(arr)
|
def collect(arr)
|
||||||
@value.collect(arr)
|
@value.collect(arr)
|
||||||
super
|
super
|
||||||
|
@ -4,13 +4,13 @@ module Vool
|
|||||||
Mom::SlotMove
|
Mom::SlotMove
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class ConstantStatement < Statement
|
class Constant < Expression
|
||||||
def slot_class
|
def slot_class
|
||||||
Mom::SlotConstant
|
Mom::SlotConstant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class IntegerStatement < ConstantStatement
|
class IntegerConstant < Constant
|
||||||
attr_reader :value
|
attr_reader :value
|
||||||
def initialize(value)
|
def initialize(value)
|
||||||
@value = value
|
@value = value
|
||||||
@ -22,7 +22,7 @@ module Vool
|
|||||||
Parfait.object_space.get_class_by_name(:Integer).instance_type
|
Parfait.object_space.get_class_by_name(:Integer).instance_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class FloatStatement < ConstantStatement
|
class FloatConstant < Constant
|
||||||
attr_reader :value
|
attr_reader :value
|
||||||
def initialize(value)
|
def initialize(value)
|
||||||
@value = value
|
@value = value
|
||||||
@ -31,22 +31,22 @@ module Vool
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TrueStatement < ConstantStatement
|
class TrueConstant < Constant
|
||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_class_by_name(:True).instance_type
|
Parfait.object_space.get_class_by_name(:True).instance_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class FalseStatement < ConstantStatement
|
class FalseConstant < Constant
|
||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_class_by_name(:False).instance_type
|
Parfait.object_space.get_class_by_name(:False).instance_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class NilStatement < ConstantStatement
|
class NilConstant < Constant
|
||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_class_by_name(:Nil).instance_type
|
Parfait.object_space.get_class_by_name(:Nil).instance_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class SelfStatement < Statement
|
class SelfExpression < Expression
|
||||||
attr_reader :clazz
|
attr_reader :clazz
|
||||||
def set_class(clazz)
|
def set_class(clazz)
|
||||||
@clazz = clazz
|
@clazz = clazz
|
||||||
@ -58,9 +58,9 @@ module Vool
|
|||||||
@clazz.instance_type
|
@clazz.instance_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class SuperStatement < Statement
|
class SuperExpression < Statement
|
||||||
end
|
end
|
||||||
class StringStatement < ConstantStatement
|
class StringConstant < Constant
|
||||||
attr_reader :value
|
attr_reader :value
|
||||||
def initialize(value)
|
def initialize(value)
|
||||||
@value = value
|
@value = value
|
||||||
@ -72,7 +72,7 @@ module Vool
|
|||||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class SymbolStatement < StringStatement
|
class SymbolConstant < StringConstant
|
||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_class_by_name(:Word).instance_type
|
Parfait.object_space.get_class_by_name(:Word).instance_type
|
||||||
end
|
end
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
module Vool
|
|
||||||
module Hoister
|
|
||||||
def hoist_condition( method )
|
|
||||||
return [@condition] if @condition.is_a?(Vool::Named)
|
|
||||||
local = method.create_tmp
|
|
||||||
assign = LocalAssignment.new( local , @condition)
|
|
||||||
[Vool::LocalVariable.new(local) , assign]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "hoister"
|
require_relative "normalizer"
|
||||||
module Vool
|
module Vool
|
||||||
class IfStatement < Statement
|
class IfStatement < Statement
|
||||||
include Hoister
|
include Normalizer
|
||||||
|
|
||||||
attr_reader :condition , :if_true , :if_false
|
attr_reader :condition , :if_true , :if_false
|
||||||
|
|
||||||
@ -12,6 +12,14 @@ module Vool
|
|||||||
simplify_condition
|
simplify_condition
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize(method)
|
||||||
|
cond , rest = *normalize_name(@condition)
|
||||||
|
fals = @if_false ? @if_false.normalize(method) : nil
|
||||||
|
me = IfStatement.new(cond , @if_true.normalize(method), fals)
|
||||||
|
return me unless rest
|
||||||
|
rest << me
|
||||||
|
end
|
||||||
|
|
||||||
def to_mom( method )
|
def to_mom( method )
|
||||||
if_true = @if_true.to_mom( method )
|
if_true = @if_true.to_mom( method )
|
||||||
if_false = @if_false ? @if_false.to_mom( method ) : nil
|
if_false = @if_false ? @if_false.to_mom( method ) : nil
|
||||||
|
16
lib/vool/statements/normalizer.rb
Normal file
16
lib/vool/statements/normalizer.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
module Vool
|
||||||
|
module Normalizer
|
||||||
|
# given a something, determine if it is a Name
|
||||||
|
#
|
||||||
|
# Return a Name, and a possible rest that has a hoisted part of the statement
|
||||||
|
#
|
||||||
|
# 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)
|
||||||
|
local = method.create_tmp
|
||||||
|
assign = LocalAssignment.new( local , @condition)
|
||||||
|
[LocalVariable.new(local) , assign]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -96,8 +96,8 @@ module Vool
|
|||||||
[Mom::SlotMove.new([@dynamic, :cached_type] , [:receiver , :type])]
|
[Mom::SlotMove.new([@dynamic, :cached_type] , [:receiver , :type])]
|
||||||
end
|
end
|
||||||
def build_method_cache_update(in_method)
|
def build_method_cache_update(in_method)
|
||||||
receiver = StringStatement.new(@name)
|
receiver = StringConstant.new(@name)
|
||||||
resolve = SendStatement.new(:resolve_method , receiver , [SelfStatement.new])
|
resolve = SendStatement.new(:resolve_method , receiver , [SelfExpression.new])
|
||||||
move_method = Mom::SlotMove.new([@dynamic, :cached_method] , [:receiver , :return])
|
move_method = Mom::SlotMove.new([@dynamic, :cached_method] , [:receiver , :return])
|
||||||
resolve.to_mom(in_method) << move_method
|
resolve.to_mom(in_method) << move_method
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class LocalVariable < Statement
|
class LocalVariable < Expression
|
||||||
include Named
|
include Named
|
||||||
def to_mom(method)
|
def to_mom(method)
|
||||||
if method.args_type.variable_index(@name)
|
if method.args_type.variable_index(@name)
|
||||||
@ -18,7 +18,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class InstanceVariable < Statement
|
class InstanceVariable < Expression
|
||||||
include Named
|
include Named
|
||||||
def to_mom(method)
|
def to_mom(method)
|
||||||
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
||||||
@ -29,11 +29,11 @@ module Vool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ClassVariable < Statement
|
class ClassVariable < Expression
|
||||||
include Named
|
include Named
|
||||||
end
|
end
|
||||||
|
|
||||||
class ModuleName < Statement
|
class ModuleName < Expression
|
||||||
include Named
|
include Named
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require_relative "hoister"
|
require_relative "normalizer"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class WhileStatement < Statement
|
class WhileStatement < Statement
|
||||||
include Hoister
|
include Normalizer
|
||||||
attr_reader :condition , :statements
|
attr_reader :condition , :statements
|
||||||
|
|
||||||
def initialize( condition , statements )
|
def initialize( condition , statements )
|
||||||
@ -11,6 +11,13 @@ module Vool
|
|||||||
simplify_condition
|
simplify_condition
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize(method)
|
||||||
|
cond , rest = *normalize_name(@condition)
|
||||||
|
me = WhileStatement.new(cond , @statements.normalize(method))
|
||||||
|
return me unless rest
|
||||||
|
rest << me
|
||||||
|
end
|
||||||
|
|
||||||
def to_mom( method )
|
def to_mom( method )
|
||||||
statements = @statements.to_mom( method )
|
statements = @statements.to_mom( method )
|
||||||
condition , hoisted = hoist_condition( method )
|
condition , hoisted = hoist_condition( method )
|
||||||
|
@ -5,31 +5,31 @@ module Vool
|
|||||||
|
|
||||||
def test_self
|
def test_self
|
||||||
lst = RubyCompiler.compile( "self")
|
lst = RubyCompiler.compile( "self")
|
||||||
assert_equal SelfStatement , lst.class
|
assert_equal SelfExpression , lst.class
|
||||||
end
|
end
|
||||||
def test_nil
|
def test_nil
|
||||||
lst = RubyCompiler.compile( "nil")
|
lst = RubyCompiler.compile( "nil")
|
||||||
assert_equal NilStatement , lst.class
|
assert_equal NilConstant , lst.class
|
||||||
end
|
end
|
||||||
def test_false
|
def test_false
|
||||||
lst = RubyCompiler.compile( "false")
|
lst = RubyCompiler.compile( "false")
|
||||||
assert_equal FalseStatement , lst.class
|
assert_equal FalseConstant , lst.class
|
||||||
end
|
end
|
||||||
def test_true
|
def test_true
|
||||||
lst = RubyCompiler.compile( "true")
|
lst = RubyCompiler.compile( "true")
|
||||||
assert_equal TrueStatement , lst.class
|
assert_equal TrueConstant , lst.class
|
||||||
end
|
end
|
||||||
def test_integer
|
def test_integer
|
||||||
lst = RubyCompiler.compile( "123")
|
lst = RubyCompiler.compile( "123")
|
||||||
assert_equal IntegerStatement , lst.class
|
assert_equal IntegerConstant , lst.class
|
||||||
end
|
end
|
||||||
def test_string
|
def test_string
|
||||||
lst = RubyCompiler.compile( "'string'")
|
lst = RubyCompiler.compile( "'string'")
|
||||||
assert_equal StringStatement , lst.class , lst.inspect
|
assert_equal StringConstant , lst.class , lst.inspect
|
||||||
end
|
end
|
||||||
def test_sym
|
def test_sym
|
||||||
lst = RubyCompiler.compile( ":symbol")
|
lst = RubyCompiler.compile( ":symbol")
|
||||||
assert_equal SymbolStatement , lst.class , lst.inspect
|
assert_equal SymbolConstant , lst.class , lst.inspect
|
||||||
end
|
end
|
||||||
def test_dstr
|
def test_dstr
|
||||||
assert_raises RuntimeError do
|
assert_raises RuntimeError do
|
||||||
|
@ -37,7 +37,7 @@ module Vool
|
|||||||
def test_compile_two_methods
|
def test_compile_two_methods
|
||||||
lst = RubyCompiler.compile( in_Test("false; true;") )
|
lst = RubyCompiler.compile( in_Test("false; true;") )
|
||||||
assert_equal ScopeStatement , lst.body.class
|
assert_equal ScopeStatement , lst.body.class
|
||||||
assert_equal TrueStatement , lst.body.statements[1].class
|
assert_equal TrueConstant , lst.body.statements[1].class
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_if_basic_branches
|
def test_if_basic_branches
|
||||||
lst = RubyCompiler.compile( basic_if )
|
lst = RubyCompiler.compile( basic_if )
|
||||||
assert_equal TrueStatement , lst.if_true.class
|
assert_equal TrueConstant , lst.if_true.class
|
||||||
assert_nil lst.if_false
|
assert_nil lst.if_false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,12 +29,12 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_if_double_cond
|
def test_if_double_cond
|
||||||
lst = RubyCompiler.compile( double_if )
|
lst = RubyCompiler.compile( double_if )
|
||||||
assert_equal FalseStatement , lst.condition.class
|
assert_equal FalseConstant , lst.condition.class
|
||||||
end
|
end
|
||||||
def test_if_double_branches
|
def test_if_double_branches
|
||||||
lst = RubyCompiler.compile( double_if )
|
lst = RubyCompiler.compile( double_if )
|
||||||
assert_equal TrueStatement , lst.if_true.class
|
assert_equal TrueConstant , lst.if_true.class
|
||||||
assert_equal FalseStatement, lst.if_false.class
|
assert_equal FalseConstant, lst.if_false.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverse_if
|
def reverse_if
|
||||||
@ -46,11 +46,11 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_if_reverse_cond
|
def test_if_reverse_cond
|
||||||
lst = RubyCompiler.compile( reverse_if )
|
lst = RubyCompiler.compile( reverse_if )
|
||||||
assert_equal FalseStatement , lst.condition.class
|
assert_equal FalseConstant , lst.condition.class
|
||||||
end
|
end
|
||||||
def test_if_reverse_branches
|
def test_if_reverse_branches
|
||||||
lst = RubyCompiler.compile( reverse_if )
|
lst = RubyCompiler.compile( reverse_if )
|
||||||
assert_equal TrueStatement , lst.if_true.class
|
assert_equal TrueConstant , lst.if_true.class
|
||||||
assert_nil lst.if_false
|
assert_nil lst.if_false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,12 +63,12 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_if_reverse_cond
|
def test_if_reverse_cond
|
||||||
lst = RubyCompiler.compile( reverse_unless )
|
lst = RubyCompiler.compile( reverse_unless )
|
||||||
assert_equal FalseStatement , lst.condition.class
|
assert_equal FalseConstant , lst.condition.class
|
||||||
end
|
end
|
||||||
def test_if_reverse_branches
|
def test_if_reverse_branches
|
||||||
lst = RubyCompiler.compile( reverse_unless )
|
lst = RubyCompiler.compile( reverse_unless )
|
||||||
assert_nil lst.if_true
|
assert_nil lst.if_true
|
||||||
assert_equal TrueStatement ,lst.if_false.class
|
assert_equal TrueConstant ,lst.if_false.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def ternary
|
def ternary
|
||||||
@ -80,12 +80,12 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_if_ternary_cond
|
def test_if_ternary_cond
|
||||||
lst = RubyCompiler.compile( ternary )
|
lst = RubyCompiler.compile( ternary )
|
||||||
assert_equal FalseStatement , lst.condition.class
|
assert_equal FalseConstant , lst.condition.class
|
||||||
end
|
end
|
||||||
def test_if_ternary_branches
|
def test_if_ternary_branches
|
||||||
lst = RubyCompiler.compile( ternary )
|
lst = RubyCompiler.compile( ternary )
|
||||||
assert_equal TrueStatement , lst.if_true.class
|
assert_equal TrueConstant , lst.if_true.class
|
||||||
assert_equal FalseStatement, lst.if_false.class
|
assert_equal FalseConstant, lst.if_false.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_simple_receiver
|
def test_simple_receiver
|
||||||
lst = RubyCompiler.compile( "foo")
|
lst = RubyCompiler.compile( "foo")
|
||||||
assert_equal SelfStatement , lst.receiver.class
|
assert_equal SelfExpression , lst.receiver.class
|
||||||
end
|
end
|
||||||
def test_simple_args
|
def test_simple_args
|
||||||
lst = RubyCompiler.compile( "foo")
|
lst = RubyCompiler.compile( "foo")
|
||||||
@ -30,7 +30,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_one_arg_receiver
|
def test_one_arg_receiver
|
||||||
lst = RubyCompiler.compile( "bar(1)")
|
lst = RubyCompiler.compile( "bar(1)")
|
||||||
assert_equal SelfStatement , lst.receiver.class
|
assert_equal SelfExpression , lst.receiver.class
|
||||||
end
|
end
|
||||||
def test_one_arg_args
|
def test_one_arg_args
|
||||||
lst = RubyCompiler.compile( "bar(1)")
|
lst = RubyCompiler.compile( "bar(1)")
|
||||||
@ -39,7 +39,7 @@ module Vool
|
|||||||
|
|
||||||
def test_super0_receiver
|
def test_super0_receiver
|
||||||
lst = RubyCompiler.compile( "super")
|
lst = RubyCompiler.compile( "super")
|
||||||
assert_equal SuperStatement , lst.receiver.class
|
assert_equal SuperExpression , lst.receiver.class
|
||||||
end
|
end
|
||||||
def test_super0
|
def test_super0
|
||||||
lst = RubyCompiler.compile( "super")
|
lst = RubyCompiler.compile( "super")
|
||||||
@ -48,7 +48,7 @@ module Vool
|
|||||||
|
|
||||||
def test_super_receiver
|
def test_super_receiver
|
||||||
lst = RubyCompiler.compile( "super(1)")
|
lst = RubyCompiler.compile( "super(1)")
|
||||||
assert_equal SuperStatement , lst.receiver.class
|
assert_equal SuperExpression , lst.receiver.class
|
||||||
end
|
end
|
||||||
def test_super_args
|
def test_super_args
|
||||||
lst = RubyCompiler.compile( "super(1)")
|
lst = RubyCompiler.compile( "super(1)")
|
||||||
|
@ -16,7 +16,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_while_basic_branches
|
def test_while_basic_branches
|
||||||
lst = RubyCompiler.compile( basic_while )
|
lst = RubyCompiler.compile( basic_while )
|
||||||
assert_equal TrueStatement , lst.statements.class
|
assert_equal TrueConstant , lst.statements.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverse_while
|
def reverse_while
|
||||||
@ -28,11 +28,11 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_while_reverse_cond
|
def test_while_reverse_cond
|
||||||
lst = RubyCompiler.compile( reverse_while )
|
lst = RubyCompiler.compile( reverse_while )
|
||||||
assert_equal FalseStatement , lst.condition.class
|
assert_equal FalseConstant , lst.condition.class
|
||||||
end
|
end
|
||||||
def test_while_reverse_branches
|
def test_while_reverse_branches
|
||||||
lst = RubyCompiler.compile( reverse_while )
|
lst = RubyCompiler.compile( reverse_while )
|
||||||
assert_equal TrueStatement , lst.statements.class
|
assert_equal TrueConstant , lst.statements.class
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user