Renaming Vool exppressions rightly
Class, Method and Lambda (was block) are expressions. Just making things clearer, especially for the blocks (ahem, lambdas) is matters. wip
This commit is contained in:
parent
ae16551ed0
commit
f87526f86f
@ -5,13 +5,13 @@ module Mom
|
||||
class Constant
|
||||
end
|
||||
|
||||
class BlockConstant < Constant
|
||||
attr_reader :block
|
||||
class LambdaConstant < Constant
|
||||
attr_reader :lambda
|
||||
def initialize(bl)
|
||||
@block = bl
|
||||
@lambda = bl
|
||||
end
|
||||
def to_parfait(compiler)
|
||||
@block
|
||||
@lambda
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -20,14 +20,12 @@ module Parfait
|
||||
end
|
||||
|
||||
end
|
||||
["object" , "factory" ].each do |file_name|
|
||||
["object" , "data_object","integer","factory" ].each do |file_name|
|
||||
path = File.expand_path( "../parfait/#{file_name}.rb" , __FILE__)
|
||||
module_eval( File.read path)
|
||||
end
|
||||
end
|
||||
|
||||
require_relative "parfait/data_object"
|
||||
require_relative "parfait/integer"
|
||||
require_relative "parfait/behaviour"
|
||||
require_relative "parfait/class"
|
||||
require_relative "parfait/meta_class"
|
||||
|
@ -19,11 +19,10 @@
|
||||
# DataObjects still have a type, and so can have objects before the data starts
|
||||
#
|
||||
# A marker class
|
||||
module Parfait
|
||||
class DataObject < Object
|
||||
|
||||
def self.type_length
|
||||
raise "called #{self}"
|
||||
raise "called " + self.to_s
|
||||
end
|
||||
def padded_length
|
||||
self.class.memory_size * 4
|
||||
@ -53,4 +52,3 @@ module Parfait
|
||||
32
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,3 @@
|
||||
module Parfait
|
||||
# Integer class for representing maths on Integers
|
||||
# Integers are Objects, specifically DataObjects
|
||||
# - they have fixed value
|
||||
@ -92,4 +91,3 @@ module Parfait
|
||||
1 # 0 type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ module Parfait
|
||||
raise "Name must be symbol" unless name.is_a?(Symbol)
|
||||
raise "args_type must be type" unless args_type.is_a?(Parfait::Type)
|
||||
raise "frame_type must be type" unless frame_type.is_a?(Parfait::Type)
|
||||
raise "source must be vool" unless source.is_a?(Vool::Statement)
|
||||
raise "source must be vool not#{source.class}" unless source.is_a?(Vool::Statement)
|
||||
raise "Empty bod" if(@source.is_a?(Vool::Statements) and @source.empty?)
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ module Ruby
|
||||
class ClassMethodStatement < MethodStatement
|
||||
|
||||
def to_vool
|
||||
Vool::ClassMethodStatement.new( @name , @args.dup , @body.to_vool)
|
||||
Vool::ClassMethodExpression.new( @name , @args.dup , @body.to_vool)
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
|
@ -29,7 +29,7 @@ module Ruby
|
||||
meths += transform_statement(meth)
|
||||
end
|
||||
end
|
||||
Vool::ClassStatement.new(@name , @super_class_name, Vool::Statements.new(meths) )
|
||||
Vool::ClassExpression.new(@name , @super_class_name, Vool::Statements.new(meths) )
|
||||
end
|
||||
|
||||
# We rewrite certain send statements (so raise error for all else)
|
||||
|
@ -14,7 +14,7 @@ module Ruby
|
||||
else
|
||||
@body = replace_return( @body )
|
||||
end
|
||||
Vool::MethodStatement.new( @name , @args.dup , @body.to_vool)
|
||||
Vool::MethodExpression.new( @name , @args.dup , @body.to_vool)
|
||||
end
|
||||
|
||||
def replace_return(statement)
|
||||
|
@ -20,7 +20,7 @@ module Ruby
|
||||
#
|
||||
def to_vool
|
||||
block_name = "implicit_block_#{object_id}".to_sym
|
||||
block = Vool::LambdaStatement.new( @args.dup , @body.to_vool)
|
||||
block = Vool::LambdaExpression.new( @args.dup , @body.to_vool)
|
||||
assign = Vool::LocalAssignment.new( block_name , block)
|
||||
sendd = @send.to_vool
|
||||
if(sendd.is_a?(Vool::Statements))
|
||||
|
@ -34,11 +34,12 @@ module Ruby
|
||||
self
|
||||
end
|
||||
def to_vool
|
||||
if( single? )
|
||||
first.to_vool
|
||||
else
|
||||
vool_brother.new(@statements.collect{|s| s.to_vool})
|
||||
return first.to_vool if( single? )
|
||||
brother = vool_brother.new(nil)
|
||||
@statements.each do |s|
|
||||
brother << s.to_vool
|
||||
end
|
||||
brother
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
|
@ -33,7 +33,7 @@ module Vool
|
||||
# Derived classes do not implement to_mom, only slot_position
|
||||
def to_mom(compiler)
|
||||
to = Mom::SlotDefinition.new(:message , self.slot_position(compiler))
|
||||
from = @value.slot_definition(compiler)
|
||||
from = @value.to_slot(compiler)
|
||||
assign = Mom::SlotLoad.new(self,to,from)
|
||||
return assign unless @value.is_a?(CallStatement)
|
||||
@value.to_mom(compiler) << assign
|
||||
|
@ -1,9 +1,6 @@
|
||||
module Vool
|
||||
#Marker class for different constants
|
||||
class Constant < Expression
|
||||
#gobble it up
|
||||
def each(&block)
|
||||
end
|
||||
end
|
||||
|
||||
# An integer at the vool level
|
||||
@ -12,17 +9,15 @@ module Vool
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , [])
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Integer)
|
||||
end
|
||||
def to_s
|
||||
def to_s(depth = 0)
|
||||
value.to_s
|
||||
end
|
||||
def each(&block)
|
||||
end
|
||||
end
|
||||
# An float at the vool level
|
||||
class FloatConstant < Constant
|
||||
@ -33,7 +28,7 @@ module Vool
|
||||
def ct_type
|
||||
true
|
||||
end
|
||||
def to_s
|
||||
def to_s(depth = 0)
|
||||
value.to_s
|
||||
end
|
||||
end
|
||||
@ -42,7 +37,7 @@ module Vool
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:True)
|
||||
end
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new(Parfait.object_space.true_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
@ -54,7 +49,7 @@ module Vool
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:False)
|
||||
end
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new(Parfait.object_space.false_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
@ -66,7 +61,7 @@ module Vool
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Nil)
|
||||
end
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new(Parfait.object_space.nil_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
@ -80,7 +75,7 @@ module Vool
|
||||
def initialize(type = nil)
|
||||
@my_type = type
|
||||
end
|
||||
def slot_definition(compiler)
|
||||
def to_slot(compiler)
|
||||
@my_type = compiler.receiver_type
|
||||
Mom::SlotDefinition.new(:message , [:receiver])
|
||||
end
|
||||
@ -101,7 +96,7 @@ module Vool
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[])
|
||||
end
|
||||
def ct_type
|
||||
|
@ -10,7 +10,7 @@ module Vool
|
||||
|
||||
# When used as right hand side, this tells what data to move to get the result into
|
||||
# a varaible. It is (off course) the return value of the message
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
Mom::SlotDefinition.new(:message ,[ :return_value])
|
||||
end
|
||||
|
||||
|
@ -8,14 +8,14 @@ module Vool
|
||||
#
|
||||
# The Parfait class gets created lazily on the way down to mom, ie the clazz
|
||||
# attribute will only be set after to_mom, or a direct call to create_class
|
||||
class ClassStatement < Statement
|
||||
class ClassExpression < Expression
|
||||
attr_reader :name, :super_class_name , :body
|
||||
attr_reader :clazz
|
||||
|
||||
def initialize( name , supe , body)
|
||||
@name , @super_class_name = name , supe
|
||||
case body
|
||||
when MethodStatement
|
||||
when MethodExpression
|
||||
@body = Statements.new([body])
|
||||
when Statements
|
||||
@body = body
|
@ -1,5 +1,5 @@
|
||||
module Vool
|
||||
class ClassMethodStatement < Statement
|
||||
class ClassMethodExpression < Expression
|
||||
attr_reader :name, :args , :body
|
||||
|
||||
def initialize( name , args , body )
|
@ -15,7 +15,7 @@ module Vool
|
||||
false_label = Mom::Label.new( self , "false_label_#{object_id.to_s(16)}")
|
||||
merge_label = Mom::Label.new( self , "merge_label_#{object_id.to_s(16)}")
|
||||
|
||||
check = Mom::TruthCheck.new(condition.slot_definition(compiler) , false_label)
|
||||
check = Mom::TruthCheck.new(condition.to_slot(compiler) , false_label)
|
||||
if @condition.is_a?(CallStatement)
|
||||
head = @condition.to_mom(compiler)
|
||||
head << check
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Vool
|
||||
class LambdaStatement < Statement
|
||||
class LambdaExpression < Expression
|
||||
attr_reader :args , :body , :clazz
|
||||
|
||||
def initialize( args , body , clazz = nil)
|
||||
@ -13,7 +13,7 @@ module Vool
|
||||
#
|
||||
# This means we do the compiler here (rather than to_mom, which is in
|
||||
# fact never called)
|
||||
def slot_definition(compiler)
|
||||
def to_slot(compiler)
|
||||
return Mom::SlotDefinition.new(Mom::LambdaConstant.new(parfait_block(compiler)) , [])
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Vool
|
||||
class MethodStatement < Statement
|
||||
class MethodExpression < Expression
|
||||
attr_reader :name, :args , :body
|
||||
|
||||
def initialize( name , args , body )
|
@ -18,7 +18,7 @@ module Vool
|
||||
# - activate return sequence (reinstantiate old message and jump to return address)
|
||||
def to_mom( compiler )
|
||||
load = Mom::SlotLoad.new( self , [:message , :return_value] ,
|
||||
@return_value.slot_definition(compiler) )
|
||||
@return_value.to_slot(compiler) )
|
||||
if @return_value.is_a?(CallStatement)
|
||||
ret = @return_value.to_mom(compiler)
|
||||
ret << load
|
||||
|
@ -46,11 +46,11 @@ module Vool
|
||||
|
||||
def message_setup(compiler,called_method)
|
||||
setup = Mom::MessageSetup.new( called_method )
|
||||
mom_receive = @receiver.slot_definition(compiler)
|
||||
mom_receive = @receiver.to_slot(compiler)
|
||||
arg_target = [:message , :next_message , :arguments]
|
||||
args = []
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.slot_definition(compiler))
|
||||
args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.to_slot(compiler))
|
||||
end
|
||||
setup << Mom::ArgumentTransfer.new(self, mom_receive , args )
|
||||
end
|
||||
@ -90,7 +90,7 @@ module Vool
|
||||
|
||||
private
|
||||
def receiver_type_definition(compiler)
|
||||
defi = @receiver.slot_definition(compiler)
|
||||
defi = @receiver.to_slot(compiler)
|
||||
defi.slots << :type
|
||||
defi
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Object Oriented
|
||||
# Language
|
||||
#
|
||||
# VOOL is the abstraction of ruby, ruby minus some of the fluff
|
||||
# VOOL is the abstraction of ruby, ruby minusthe fluff
|
||||
# fluff is generally what makes ruby nice to use, like 3 ways to achieve the same thing
|
||||
# if/unless/ternary , reverse ifs (ie statement if condition), reverse whiles,
|
||||
# implicit blocks, splats and multiple assigns etc
|
||||
@ -10,19 +10,17 @@
|
||||
# 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
|
||||
#
|
||||
# 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
|
||||
# classes.
|
||||
#
|
||||
# Also Vool has expression and statements, revealing that age old dichotomy of code and
|
||||
# data. Statements represent code whereas Expressions resolve to data.
|
||||
# (in ruby there are no pure statements, everthing resolves to data)
|
||||
module Vool
|
||||
|
||||
# Base class for all statements in the tree. Derived classes correspond to known language
|
||||
# constructs
|
||||
#
|
||||
# Compilers or compiler passes are written by implementing methods.
|
||||
#
|
||||
# Basically Statements represent code, generally speaking code "does things".
|
||||
# But Vool distinguishes Expressions (see below), that represent data, and as such
|
||||
# don't do things themselves, rather passively participate in being pushed around
|
||||
class Statement
|
||||
|
||||
def to_mom( _ )
|
||||
@ -37,7 +35,13 @@ module Vool
|
||||
|
||||
end
|
||||
|
||||
class Expression
|
||||
# An Expression is a Statement that represents data. ie variables constants
|
||||
# (see basic_values) , but alos classes, methods and lambdas
|
||||
class Expression < Statement
|
||||
|
||||
def each(&block)
|
||||
block.call(self)
|
||||
end
|
||||
|
||||
def ct_type
|
||||
nil
|
||||
@ -46,20 +50,13 @@ module Vool
|
||||
def normalize
|
||||
raise "should not be normalized #{self}"
|
||||
end
|
||||
def to_mom(compiler)
|
||||
raise "should not be momed #{self}"
|
||||
end
|
||||
|
||||
# for loading into a lot, return the "slot_definition" that can be passed to
|
||||
# for loading into a slot, return the "slot_definition" that can be passed to
|
||||
# SlotLoad.
|
||||
def slot_definition(compiler)
|
||||
def to_slot(compiler)
|
||||
raise "not iplemented in #{self}"
|
||||
end
|
||||
|
||||
def at_depth(depth , *strings)
|
||||
prefix = " " * 2 * depth
|
||||
strings.collect{|str| prefix + str}.join("\n")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -67,14 +64,14 @@ end
|
||||
|
||||
require_relative "assignment"
|
||||
require_relative "basic_values"
|
||||
require_relative "block_statement"
|
||||
require_relative "call_statement"
|
||||
require_relative "class_statement"
|
||||
require_relative "class_expression"
|
||||
require_relative "if_statement"
|
||||
require_relative "ivar_assignment"
|
||||
require_relative "lambda_expression"
|
||||
require_relative "local_assignment"
|
||||
require_relative "method_statement"
|
||||
require_relative "class_method_statement"
|
||||
require_relative "method_expression"
|
||||
require_relative "class_method_expression"
|
||||
require_relative "return_statement"
|
||||
require_relative "statements"
|
||||
require_relative "send_statement"
|
||||
|
@ -36,13 +36,18 @@ module Vool
|
||||
end
|
||||
def <<(o)
|
||||
if(o.is_a?(Statements))
|
||||
o.each {|s| @statements << s }
|
||||
o.statements.each do |s|
|
||||
raise "not a statement #{s}" unless s.is_a?(Statement)
|
||||
@statements << s
|
||||
end
|
||||
else
|
||||
raise "not a statement #{o}" unless o.is_a?(Statement)
|
||||
@statements << o
|
||||
end
|
||||
self
|
||||
end
|
||||
def prepend(o)
|
||||
raise "not a statement #{o}" unless o.is_a?(Statement)
|
||||
@statements = [o] + @statements
|
||||
end
|
||||
def shift
|
||||
@ -62,7 +67,12 @@ module Vool
|
||||
stats = @statements.dup
|
||||
first = stats.shift.to_mom(compiler)
|
||||
while( nekst = stats.shift )
|
||||
first.append nekst.to_mom(compiler)
|
||||
next_mom = nekst.to_mom(compiler)
|
||||
if next_mom.is_a?(Mom::BlockCompiler)
|
||||
compiler.block_compilers << next_mom
|
||||
else
|
||||
first.append next_mom
|
||||
end
|
||||
end
|
||||
first
|
||||
end
|
||||
|
@ -10,11 +10,11 @@ module Vool
|
||||
|
||||
class LocalVariable < Expression
|
||||
include Named
|
||||
def slot_definition(compiler)
|
||||
def to_slot(compiler)
|
||||
slot_def = compiler.slot_type_for(@name)
|
||||
Mom::SlotDefinition.new(:message , slot_def)
|
||||
end
|
||||
def to_s
|
||||
def to_s(depth = 0)
|
||||
name.to_s
|
||||
end
|
||||
def each(&block)
|
||||
@ -24,7 +24,7 @@ module Vool
|
||||
|
||||
class InstanceVariable < Expression
|
||||
include Named
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
||||
end
|
||||
# used to collect type information
|
||||
@ -51,7 +51,7 @@ module Vool
|
||||
def ct_type
|
||||
get_named_class.meta_class.instance_type
|
||||
end
|
||||
def slot_definition(_)
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new( get_named_class, [])
|
||||
end
|
||||
def get_named_class
|
||||
|
@ -15,7 +15,7 @@ module Vool
|
||||
codes = cond_label
|
||||
codes << @hoisted.to_mom(compiler) if @hoisted
|
||||
codes << @condition.to_mom(compiler) if @condition.is_a?(SendStatement)
|
||||
codes << Mom::TruthCheck.new(condition.slot_definition(compiler) , merge_label)
|
||||
codes << Mom::TruthCheck.new(condition.to_slot(compiler) , merge_label)
|
||||
codes << @body.to_mom(compiler)
|
||||
codes << Mom::Jump.new(cond_label)
|
||||
codes << merge_label
|
||||
|
@ -49,11 +49,11 @@ module Vool
|
||||
def yield_arg_block(compiler)
|
||||
arg_index = compiler.get_method.arguments_type.get_length - 1
|
||||
setup = Mom::MessageSetup.new( arg_index )
|
||||
mom_receive = @receiver.slot_definition(compiler)
|
||||
mom_receive = @receiver.to_slot(compiler)
|
||||
arg_target = [:message , :next_message , :arguments]
|
||||
args = []
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.slot_definition(compiler))
|
||||
args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.to_slot(compiler))
|
||||
end
|
||||
setup << Mom::ArgumentTransfer.new( self , mom_receive , args )
|
||||
setup << Mom::BlockYield.new( self , arg_index )
|
||||
|
@ -29,13 +29,13 @@ module Ruby
|
||||
@vool.body.statements.last
|
||||
end
|
||||
def test_class
|
||||
assert_equal Vool::ClassStatement , @vool.class
|
||||
assert_equal Vool::ClassExpression , @vool.class
|
||||
end
|
||||
def test_body
|
||||
assert_equal Vool::Statements , @vool.body.class
|
||||
end
|
||||
def test_getter
|
||||
assert_equal Vool::MethodStatement , getter.class
|
||||
assert_equal Vool::MethodExpression , getter.class
|
||||
end
|
||||
def test_getter_return
|
||||
assert_equal Vool::ReturnStatement , getter.body.class
|
||||
|
@ -43,7 +43,7 @@ module Ruby
|
||||
@lst = compile( input ).to_vool
|
||||
end
|
||||
def test_method
|
||||
assert_equal Vool::ClassMethodStatement , @lst.class
|
||||
assert_equal Vool::ClassMethodExpression , @lst.class
|
||||
end
|
||||
def test_method_args
|
||||
assert_equal [:arg1, :arg2] , @lst.args
|
||||
|
@ -9,7 +9,7 @@ module Ruby
|
||||
@vool = compile( input ).to_vool
|
||||
end
|
||||
def test_class
|
||||
assert_equal Vool::ClassStatement , @vool.class
|
||||
assert_equal Vool::ClassExpression , @vool.class
|
||||
end
|
||||
def test_body
|
||||
assert_equal Vool::Statements , @vool.body.class
|
||||
|
@ -12,7 +12,7 @@ module Ruby
|
||||
assert_equal 2 , @vool.body.length , "setter, getter"
|
||||
end
|
||||
def test_setter
|
||||
assert_equal Vool::MethodStatement , setter.class
|
||||
assert_equal Vool::MethodExpression , setter.class
|
||||
end
|
||||
def test_setter_assign
|
||||
assert_equal Vool::Statements , setter.body.class
|
||||
|
@ -11,7 +11,7 @@ module Ruby
|
||||
assert_equal 4 , @vool.body.length , "2 setters, 2 getters"
|
||||
end
|
||||
def test_setter
|
||||
assert_equal Vool::MethodStatement , setter.class
|
||||
assert_equal Vool::MethodExpression , setter.class
|
||||
end
|
||||
def test_setter_assign
|
||||
assert_equal Vool::Statements , setter.body.class
|
||||
|
@ -38,7 +38,7 @@ module Ruby
|
||||
def test_first
|
||||
assert_equal Vool::LocalAssignment , @lst.first.class
|
||||
assert @lst.first.name.to_s.start_with?("implicit_block_")
|
||||
assert_equal Vool::LambdaStatement , @lst.first.value.class
|
||||
assert_equal Vool::LambdaExpression , @lst.first.value.class
|
||||
end
|
||||
def test_last_send
|
||||
assert_equal 2 , @lst.length
|
||||
|
@ -41,7 +41,7 @@ module Ruby
|
||||
assert @lst.first.first.name.to_s.start_with?("implicit_block")
|
||||
end
|
||||
def test_block_assign_right
|
||||
assert_equal Vool::LambdaStatement , @lst.first.first.value.class
|
||||
assert_equal Vool::LambdaExpression , @lst.first.first.value.class
|
||||
end
|
||||
def test_a_assign
|
||||
assert_equal Vool::LocalAssignment , @lst.first.last.class
|
||||
|
@ -55,8 +55,8 @@ module Ruby
|
||||
class TestVariablesVool < MiniTest::Test
|
||||
include RubyTests
|
||||
def test_local_basic
|
||||
lst = compile( "foo = 1 ; foo").to_vool
|
||||
assert_equal Vool::LocalVariable , lst.statements[1].class
|
||||
lst = compile( "foo = 1 ; return foo").to_vool
|
||||
assert_equal Vool::LocalVariable , lst.statements[1].return_value.class
|
||||
end
|
||||
|
||||
def test_instance_basic
|
||||
|
41
test/rubyx/parfait/test_data_object.rb
Normal file
41
test/rubyx/parfait/test_data_object.rb
Normal file
@ -0,0 +1,41 @@
|
||||
require_relative "helper"
|
||||
|
||||
module RubyX
|
||||
|
||||
class TestDatObjectCompile #< MiniTest::Test
|
||||
include ParfaitHelper
|
||||
def setup
|
||||
@compiler = compiler
|
||||
@compiler.ruby_to_vool load_parfait(:object)
|
||||
end
|
||||
def source
|
||||
load_parfait(:data_object)
|
||||
end
|
||||
def test_load
|
||||
assert source.include?("class DataObject")
|
||||
assert source.length > 1500 , source.length
|
||||
end
|
||||
def test_vool
|
||||
vool = @compiler.ruby_to_vool source
|
||||
assert_equ Vool::ScopeStatement , vool.class
|
||||
assert_equal Vool::ClassStatement , vool[0].class
|
||||
assert_equal Vool::ScopeStatement , vool[1].class
|
||||
assert_equal Vool::ClassStatement , vool[1][0].class
|
||||
assert_equal :DataObject , vool[1][0].name
|
||||
assert_equal :Data4 , vool[1][1].name
|
||||
assert_equal :Data8 , vool[1][2].name
|
||||
end
|
||||
def test_mom
|
||||
mom = @compiler.ruby_to_mom source
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
end
|
||||
def qtest_risc
|
||||
risc = compiler.ruby_to_risc source
|
||||
assert_equal Risc::RiscCollection , risc.class
|
||||
end
|
||||
def qtest_binary
|
||||
risc = compiler.ruby_to_binary source , :interpreter
|
||||
assert_equal Risc::Linker , risc.class
|
||||
end
|
||||
end
|
||||
end
|
32
test/rubyx/parfait/test_integer.rb
Normal file
32
test/rubyx/parfait/test_integer.rb
Normal file
@ -0,0 +1,32 @@
|
||||
require_relative "helper"
|
||||
|
||||
module RubyX
|
||||
|
||||
class TestIntegerCompile < MiniTest::Test
|
||||
include ParfaitHelper
|
||||
def source
|
||||
load_parfait(:integer)
|
||||
end
|
||||
def test_load
|
||||
assert source.include?("class Integer")
|
||||
assert source.length > 2000
|
||||
end
|
||||
def qtest_vool
|
||||
vool = compiler.ruby_to_vool source
|
||||
assert_equal Vool::ClassStatement , vool.class
|
||||
assert_equal :Object , vool.name
|
||||
end
|
||||
def qtest_mom
|
||||
mom = compiler.ruby_to_mom source
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
end
|
||||
def qtest_risc
|
||||
risc = compiler.ruby_to_risc source
|
||||
assert_equal Risc::RiscCollection , risc.class
|
||||
end
|
||||
def qtest_binary
|
||||
risc = compiler.ruby_to_binary source , :interpreter
|
||||
assert_equal Risc::Linker , risc.class
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user