Change Mom to SlotMachine

rather large commit, but essentially a simple rename
Rationale in docs and blogs
This commit is contained in:
Torsten Rüger 2019-10-03 20:55:41 +03:00
parent fd8a3e9cc5
commit c43436f35a
170 changed files with 481 additions and 480 deletions

View File

@ -30,7 +30,7 @@ guard :minitest , all_on_start: false do # with Minitest::Unit
[ Dir["test/vool/send/test_*.rb"] ] }
# message setup
watch(%r{^lib/mom/instruction/message_setup.rb}) { Dir["test/mom/send/test_setup*.rb"] }
watch(%r{^lib/slot_machine/instruction/message_setup.rb}) { Dir["test/slot_machine/send/test_setup*.rb"] }
# mains test
watch(%r{^test/mains/source/(.*)\.rb}) { "test/mains/test_interpreted.rb" }

View File

@ -12,7 +12,7 @@ X can be read as X times faster, or a decade away, depending on mindset.
The last rewrite clarified the roles of the different layers
of the system, see below. The overhaul is done and rubyx produces working binaries.
Processing goes through layers: Ruby --> Vool --> Mom --> Risc --> Arm --> binary .
Processing goes through layers: Ruby --> Vool --> SlotMachine --> Risc --> Arm --> binary .
Currently most basic constructs work to some (usable) degree, ie if, while,
assignment, ivars, calling and dynamic dispatch all work. Simple blocks, those
@ -38,15 +38,15 @@ Vool is Ruby without the fluff. No unless, no reverse if/while, no splats. Just
oo. (Without this level the step down to the next layer was just too big)
### Mom
### SlotMachine
The Minimal Object Machine layer is the first machine layer. This means it has instructions
rather than statements. Instructions (in all machine layers) are a linked list.
Mom has no concept of memory yet, only objects. Data is transferred directly from object
to object with one of Mom's main instructions, the SlotLoad.
SlotMachine has no concept of memory yet, only objects. Data is transferred directly from object
to object with one of SlotMachine's main instructions, the SlotLoad.
Mainly Mom is an easy to understand step on the way down. A mix of oo and machine. In
Mainly SlotMachine is an easy to understand step on the way down. A mix of oo and machine. In
practise it means that the amount of instructions that need to be generated in vool
is much smaller (easier to understand) and the mapping down to risc is quite straightforward.
@ -63,7 +63,7 @@ Instructions are derived from a base class, so the instruction set is extensible
way additional functionality may be added by external code.
Risc knows memory and has a small set of registers. It allows memory to register transfer
and back, and inter register transfer. But has no memory to memory transfer like Mom.
and back, and inter register transfer. But has no memory to memory transfer like SlotMachine.
### Arm
@ -124,7 +124,7 @@ All Objects have a Type, as their first member (also integers!). The Type points
Class that the object has in oo terms.
Classes are defined by ruby code, but the methods of a Type (that are executed) are defined
by Mom and Risc only.
by SlotMachine and Risc only.
## Other

View File

@ -13,7 +13,7 @@ module Arm
@source = source
@next = nekst
return unless source
raise "Source must be string or Instruction, not #{source.class}" unless source.is_a?(String) or source.is_a?(Mom::Instruction)
raise "Source must be string or Instruction, not #{source.class}" unless source.is_a?(String) or source.is_a?(SlotMachine::Instruction)
end
attr_reader :source

View File

@ -38,8 +38,8 @@ module Parfait
callable_method = self_type.get_method(@name)
#puts "Using #{name} for #{self_type.object_class.name}.#{self_type.hash}" unless callable_method
raise "Callable not found #{@name}" unless callable_method
compiler = Mom::MethodCompiler.new( callable_method )
head = @source.to_mom( compiler )
compiler = SlotMachine::MethodCompiler.new( callable_method )
head = @source.to_slot( compiler )
compiler.add_code(head)
compiler
end

View File

@ -7,9 +7,9 @@ module Risc
attr_reader :block , :risc_instructions , :constants , :in_method
def initialize( block , in_method , mom_label)
def initialize( block , in_method , slot_label)
@in_method = in_method
super(block , mom_label)
super(block , slot_label)
end
def source_name

View File

@ -204,18 +204,18 @@ module Risc
# - setting up the next message
# - moving receiver (factory) and arguments (none)
# - issuing the call
# These steps shadow the MomInstructions MessageSetup, ArgumentTransfer and SimpleCall
# These steps shadow the SlotMachineInstructions MessageSetup, ArgumentTransfer and SimpleCall
def call_get_more
factory = Parfait.object_space.get_factory_for( :Integer )
calling = factory.get_type.get_method( :get_more )
calling = Parfait.object_space.get_method!(:Space,:main) #until we actually parse Factory
raise "no main defined" unless calling
Mom::MessageSetup.new( calling ).build_with( self )
SlotMachine::MessageSetup.new( calling ).build_with( self )
self.build do
factory_reg! << factory
message[:receiver] << factory_reg
end
Mom::SimpleCall.new(calling).to_risc(compiler)
SlotMachine::SimpleCall.new(calling).to_risc(compiler)
end
end

View File

@ -14,12 +14,12 @@ module Risc
# Must pass the callable (method/block)
# Also start instuction, usually a label is mandatory
def initialize( callable , mom_label)
def initialize( callable , slot_label)
raise "No method" unless callable
@callable = callable
@regs = []
@constants = []
@current = @risc_instructions = mom_label.risc_label(self)
@current = @risc_instructions = slot_label.risc_label(self)
reset_regs
end
attr_reader :risc_instructions , :constants , :callable , :current

View File

@ -8,7 +8,7 @@ module Risc
#
# We can load and store their contents, move data between them and
# access (get/set) memory at a constant offset from a register
# While Mom works with objects, the register machine has registers,
# While SlotMachine works with objects, the register machine has registers,
# but we keep the names for better understanding, r2-5 are temporary/scratch
# There is no direct memory access, only through registers
# Constants can/must be loaded into registers before use
@ -27,7 +27,7 @@ module Risc
@next = nekst
return unless source
raise "Source must be string or Instruction, not #{source.class}" unless source.is_a?(String) or
source.is_a?(Mom::Instruction) or source.is_a?(Parfait::Callable)
source.is_a?(SlotMachine::Instruction) or source.is_a?(Parfait::Callable)
end
attr_reader :source

View File

@ -9,7 +9,7 @@ module Risc
super(source)
@register = register
@constant = constant
raise "Not Constant #{constant}" if constant.is_a?(Mom::SlotDefinition)
raise "Not Constant #{constant}" if constant.is_a?(SlotMachine::SlotDefinition)
raise "Not register #{register}" unless RegisterValue.look_like_reg(register)
end
attr_accessor :register , :constant

View File

@ -7,8 +7,8 @@ module Risc
# Methods starts with a Label, both in risc and mom.
# Pass in the callable(method) and the mom label that the method starts with
def initialize( method , mom_label)
super(method , mom_label)
def initialize( method , slot_label)
super(method , slot_label)
end
def source_name

View File

@ -24,7 +24,7 @@ module Ruby
#
# The next step is then to go to the vool level, which is
# simpler, and then finally to compile
# to the next level down, MOM (Minimal Object Machine)
# to the next level down, SlotMachine (Minimal Object Machine)
class RubyCompiler < AST::Processor
include AST::Sexp

View File

@ -3,7 +3,7 @@ require "rx-file"
require_relative "util"
require_relative "elf/object_writer"
require_relative "risc"
require_relative "mom/mom"
require_relative "slot_machine/slot_machine"
require_relative "arm/arm_machine"
require_relative "arm/arm_platform"
require_relative "vool/statement"

View File

@ -35,7 +35,7 @@ module RubyX
end
# The highest level function creates binary code for the given ruby code
# for the given platform (see Platform). Binary code means that vool/mom/risc
# for the given platform (see Platform). Binary code means that vool/slot_machine/risc
# are created and then assembled into BinaryCode objects.
# (no executable is generated, only the binary code and objects needed for a binary)
#
@ -67,11 +67,11 @@ module RubyX
# Transform the incoming ruby source (string) to mom
#
# The vool is stored using ruby_to_vool,the to_mom is called
# Return Mom Statement
def ruby_to_mom(ruby)
# The vool is stored using ruby_to_vool,the to_slot is called
# Return SlotMachine Statement
def ruby_to_slot(ruby)
ruby_to_vool(ruby)
to_mom
to_slot
end
# Process previously stored vool source to binary.
@ -97,14 +97,14 @@ module RubyX
# Process previously stored vool source to risc.
# return a Risc::RiscCollection , a collection of MethodCompilers
def to_risc()
mom = to_mom
mom = to_slot
mom.to_risc()
end
# return mom for the previously stored vool source.
def to_mom
def to_slot
@vool.to_parfait
@vool.to_mom(nil)
@vool.to_slot(nil)
end
# ruby_to_vool compiles the ruby to ast, and then to vool

View File

@ -1,4 +1,4 @@
# MOM , Minimal Object Machine
# SlotMachine , Minimal Object Machine
This layer sits between the language layer (vool) and the risc machine layer.
It is meant to make the transition (between vool and risc) easier to understand.
@ -9,7 +9,7 @@ that everything in computing can be fixed by another layer :-)
## Recap
A little recap of why the transition was too steep will naturally reveal the design of MOM.
A little recap of why the transition was too steep will naturally reveal the design of SlotMachine.
### Structure
@ -34,7 +34,7 @@ used (stacks are messy, not oo)
The *essential* step from vool to risc, is the one from a language to a machine. From statements
that hang in the air, to an instruction set.
So to put a layer in the middle of those two, MOM will be:
So to put a layer in the middle of those two, SlotMachine will be:
### Linked list

View File

@ -1,12 +1,12 @@
module Mom
# The Compiler/Collection for the Mom level is a collection of Mom level Method
module SlotMachine
# The Compiler/Collection for the SlotMachine level is a collection of SlotMachine level Method
# compilers These will transform to Risc MethodCompilers on the way down.
#
# As RubyCompiler pools source at the vool level, when several classes are compiled
# from vool to mom, several MomCompilers get instantiated. They must be merged before
# from vool to mom, several SlotMachineCompilers get instantiated. They must be merged before
# proceeding with translate. Thus we have a append method.
#
class MomCollection
class SlotCollection
attr_reader :method_compilers
# Initialize with an array of risc MethodCompilers
@ -19,8 +19,8 @@ module Mom
def init_compilers
return if @init_compilers
@init_compilers = true
add_compiler MomCollection.create_init_compiler
add_compiler MomCollection.create_mm_compiler
add_compiler SlotCollection.create_init_compiler
add_compiler SlotCollection.create_mm_compiler
self
end
@ -40,7 +40,7 @@ module Mom
self
end
# Append another MomCompilers method_compilers to this one.
# Append another SlotMachineCompilers method_compilers to this one.
def append(collection)
@method_compilers.add_method_compiler( collection.method_compilers)
self

View File

@ -7,12 +7,13 @@
#
# ### Instruction based
#
# So a machine rather than a language. No control structures, but compare and jump instructions.
# No send or call, just objects and jump.
# Machine capabilities (instructions) for basic operations. Use of macros for higher level.
# So a machine rather than a language. No control structures, but compare and jump
# instructions. No send or dynamic call, just objects and jump.
# Machine capabilities (instructions) for basic operations.
# Use of macros for higher level.
require_relative "instruction.rb"
require_relative "mom_collection"
require_relative "slot_collection"
require_relative "callable_compiler"
require_relative "method_compiler"
require_relative "block_compiler"

View File

@ -12,7 +12,7 @@ Possibly later other languages can compile to this level and use rx-file as code
Vool is a layer with concrete syntax tree, just like the ruby layer above.
Vool is just simplified, without fluff, see below.
The next layer down is the Mom, Minimal object Machine, which uses an instruction list.
The next layer down is the SlotMachine, Minimal object Machine, which uses an instruction list.
The nodes of the syntax tree are all the things one would expect from a language,
if statements and the like. There is no context yet, and actual objects,
@ -33,4 +33,4 @@ existence of until, which really means if not. Other examples, some more impactf
The compilation process ends up creating (parfait) objects to represent
things like classes, types and constants. This is done in this layer,
on the way down to MOM (ie not during init)
on the way down to SlotMachine (ie not during init)

View File

@ -30,13 +30,13 @@ module Vool
# When the right hand side is a CallStatement, it must be compiled, before the assign
# is executed
#
# 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.to_slot(compiler)
assign = Mom::SlotLoad.new(self,to,from)
# Derived classes do not implement to_slot, only slot_position
def to_slot(compiler)
to = SlotMachine::SlotDefinition.new(:message , self.slot_position(compiler))
from = @value.to_slot_definition(compiler)
assign = SlotMachine::SlotLoad.new(self,to,from)
return assign unless @value.is_a?(CallStatement)
@value.to_mom(compiler) << assign
@value.to_slot(compiler) << assign
end
end
end

View File

@ -9,8 +9,8 @@ module Vool
def initialize(value)
@value = value
end
def to_slot(_)
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , [])
def to_slot_definition(_)
return SlotMachine::SlotDefinition.new(SlotMachine::IntegerConstant.new(@value) , [])
end
def ct_type
Parfait.object_space.get_type_by_class_name(:Integer)
@ -37,8 +37,8 @@ module Vool
def ct_type
Parfait.object_space.get_type_by_class_name(:True)
end
def to_slot(_)
return Mom::SlotDefinition.new(Parfait.object_space.true_object , [])
def to_slot_definition(_)
return SlotMachine::SlotDefinition.new(Parfait.object_space.true_object , [])
end
def to_s(depth = 0)
"true"
@ -49,8 +49,8 @@ module Vool
def ct_type
Parfait.object_space.get_type_by_class_name(:False)
end
def to_slot(_)
return Mom::SlotDefinition.new(Parfait.object_space.false_object , [])
def to_slot_definition(_)
return SlotMachine::SlotDefinition.new(Parfait.object_space.false_object , [])
end
def to_s(depth = 0)
"false"
@ -61,8 +61,8 @@ module Vool
def ct_type
Parfait.object_space.get_type_by_class_name(:Nil)
end
def to_slot(_)
return Mom::SlotDefinition.new(Parfait.object_space.nil_object , [])
def to_slot_definition(_)
return SlotMachine::SlotDefinition.new(Parfait.object_space.nil_object , [])
end
def to_s(depth = 0)
"nil"
@ -75,9 +75,9 @@ module Vool
def initialize(type = nil)
@my_type = type
end
def to_slot(compiler)
def to_slot_definition(compiler)
@my_type = compiler.receiver_type
Mom::SlotDefinition.new(:message , [:receiver])
SlotMachine::SlotDefinition.new(:message , [:receiver])
end
def ct_type
@my_type
@ -91,8 +91,8 @@ module Vool
def initialize(value)
@value = value
end
def to_slot(_)
return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[])
def to_slot_definition(_)
return SlotMachine::SlotDefinition.new(SlotMachine::StringConstant.new(@value),[])
end
def ct_type
Parfait.object_space.get_type_by_class_name(:Word)

View File

@ -10,8 +10,8 @@ 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 to_slot(_)
Mom::SlotDefinition.new(:message ,[ :return_value])
def to_slot_definition(_)
SlotMachine::SlotDefinition.new(:message ,[ :return_value])
end
def to_s(depth = 0)

View File

@ -42,21 +42,21 @@ module Vool
# Other statements are not yet allowed (baring in mind that attribute
# accessors are transformed to methods in the ruby layer )
#
# As there is no class equivalnet in code, a MomCollection is returned,
# which is just a list of Mom::MethodCompilers
# As there is no class equivalnet in code, a SlotCollection is returned,
# which is just a list of SlotMachine::MethodCompilers
# The compilers help to transform the code further, into Risc next
def to_mom( _ )
def to_slot( _ )
method_compilers = body.statements.collect do |node|
case node
when MethodExpression
node.to_mom(@clazz)
node.to_slot(@clazz)
when ClassMethodExpression
node.to_mom(@clazz.single_class)
node.to_slot(@clazz.single_class)
else
raise "Only methods for now #{node.class}:#{node}"
end
end
Mom::MomCollection.new(method_compilers)
SlotMachine::SlotCollection.new(method_compilers)
end
# goes through the code looking for instance variables and their assignments.

View File

@ -17,7 +17,7 @@ module Vool
vool_m
end
def to_mom(clazz)
def to_slot(clazz)
raise "not singleton #{clazz.class}" unless clazz.class == Parfait::SingletonClass
raise( "no class in #{self}") unless clazz
method = clazz.get_instance_method(name )

View File

@ -10,29 +10,29 @@ module Vool
@if_false = if_false
end
def to_mom( compiler )
true_label = Mom::Label.new( self , "true_label_#{object_id.to_s(16)}")
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)}")
def to_slot( compiler )
true_label = SlotMachine::Label.new( self , "true_label_#{object_id.to_s(16)}")
false_label = SlotMachine::Label.new( self , "false_label_#{object_id.to_s(16)}")
merge_label = SlotMachine::Label.new( self , "merge_label_#{object_id.to_s(16)}")
if @condition.is_a?(CallStatement)
head = @condition.to_mom(compiler)
head = @condition.to_slot(compiler)
head << check_slot(compiler , false_label)
else
head = check_slot(compiler , false_label)
end
head << true_label
head << if_true.to_mom(compiler) if @if_true
head << Mom::Jump.new(merge_label) if @if_false
head << if_true.to_slot(compiler) if @if_true
head << SlotMachine::Jump.new(merge_label) if @if_false
head << false_label
head << if_false.to_mom(compiler) if @if_false
head << if_false.to_slot(compiler) if @if_false
head << merge_label if @if_false
head
end
# create the slot lazily, so to_mom gets called first
# create the slot lazily, so to_slot gets called first
def check_slot(compiler , false_label)
Mom::TruthCheck.new(@condition.to_slot(compiler) , false_label)
SlotMachine::TruthCheck.new(@condition.to_slot_definition(compiler) , false_label)
end
def each(&block)

View File

@ -11,19 +11,19 @@ module Vool
# because of normalization (of send), slot_definition is called first,
# to assign the block to a variable.
#
# This means we do the compiler here (rather than to_mom, which is in
# This means we do the compiler here (rather than to_slot, which is in
# fact never called)
def to_slot(compiler)
def to_slot_definition(compiler)
compile(compiler) unless @parfait_block
return Mom::SlotDefinition.new(Mom::LambdaConstant.new(parfait_block(compiler)) , [])
return SlotMachine::SlotDefinition.new(SlotMachine::LambdaConstant.new(parfait_block(compiler)) , [])
end
# create a block, a compiler for it, comile the bock and add the compiler(code)
# to the method compiler for further processing
def compile( compiler )
parfait_block = self.parfait_block(compiler)
block_compiler = Mom::BlockCompiler.new( parfait_block , compiler.get_method )
head = body.to_mom( block_compiler )
block_compiler = SlotMachine::BlockCompiler.new( parfait_block , compiler.get_method )
head = body.to_slot( block_compiler )
block_compiler.add_code(head)
compiler.add_method_compiler(block_compiler)
nil

View File

@ -6,16 +6,16 @@ module Vool
super(name , SelfExpression.new , arguments)
end
def to_mom(compiler)
def to_slot(compiler)
parts = name.to_s.split("_")
class_name = "Mom::#{parts.collect{|s| s.capitalize}.join}"
class_name = "SlotMachine::#{parts.collect{|s| s.capitalize}.join}"
eval(class_name).new( self , *arguments)
end
# 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 to_slot(_)
Mom::SlotDefinition.new(:message ,[ :return_value])
def to_slot_definition(_)
SlotMachine::SlotDefinition.new(:message ,[ :return_value])
end
def to_s(depth = 0)

View File

@ -22,8 +22,8 @@ module Vool
vool_m
end
# Creates the Mom::MethodCompiler that will do the next step
def to_mom(clazz)
# Creates the SlotMachine::MethodCompiler that will do the next step
def to_slot(clazz)
raise( "no class in #{self}") unless clazz
method = clazz.get_instance_method(@name)
raise( "no method in #{@name} in #{clazz.name}") unless method

View File

@ -16,14 +16,14 @@ module Vool
# To return form a method in mom instructions we only need to do two things:
# - store the given return value, this is a SlotMove
# - activate return sequence (reinstantiate old message and jump to return address)
def to_mom( compiler )
def to_slot( compiler )
if @return_value.is_a?(CallStatement)
ret = @return_value.to_mom(compiler)
ret = @return_value.to_slot(compiler)
ret << slot_load(compiler)
else
ret = slot_load(compiler)
end
ret << Mom::ReturnJump.new(self , compiler.return_label )
ret << SlotMachine::ReturnJump.new(self , compiler.return_label )
end
def to_s(depth = 0)
@ -31,8 +31,8 @@ module Vool
end
def slot_load(compiler)
Mom::SlotLoad.new( self , [:message , :return_value] ,
@return_value.to_slot(compiler) )
SlotMachine::SlotLoad.new( self , [:message , :return_value] ,
@return_value.to_slot_definition(compiler) )
end
end
end

View File

@ -28,7 +28,7 @@ module Vool
# lazy init this, to keep the dependency (which goes to parfait and booting) at bay
def dynamic_call
@dynamic ||= Mom::DynamicCall.new()
@dynamic ||= SlotMachine::DynamicCall.new()
end
# A Send breaks down to 2 steps:
@ -40,7 +40,7 @@ module Vool
# So we check, and if find, add the source (vool_method) to the class and start
# compiling the vool for the receiver_type
#
def to_mom( compiler )
def to_slot( compiler )
@receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)
if(@receiver.ct_type)
method = @receiver.ct_type.get_method(@name)
@ -66,18 +66,18 @@ module Vool
end
def message_setup(compiler,called_method)
setup = Mom::MessageSetup.new( called_method )
mom_receive = @receiver.to_slot(compiler)
setup = SlotMachine::MessageSetup.new( called_method )
mom_receive = @receiver.to_slot_definition(compiler)
arg_target = [:message , :next_message ]
args = []
@arguments.each_with_index do |arg , index| # +1 because of type
args << Mom::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot(compiler))
args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot_definition(compiler))
end
setup << Mom::ArgumentTransfer.new(self, mom_receive , args )
setup << SlotMachine::ArgumentTransfer.new(self, mom_receive , args )
end
def simple_call(compiler, called_method)
message_setup(compiler,called_method) << Mom::SimpleCall.new(called_method)
message_setup(compiler,called_method) << SlotMachine::SimpleCall.new(called_method)
end
# this breaks cleanly into two parts:
@ -91,10 +91,10 @@ module Vool
# if not, change and find method for the type (simple_call to resolve_method)
# conceptually easy in ruby, but we have to compile that "easy" ruby
def cache_check(compiler)
ok = Mom::Label.new(self,"cache_ok_#{self.object_id}")
ok = SlotMachine::Label.new(self,"cache_ok_#{self.object_id}")
check = build_condition(ok, compiler) # if cached_type != current_type
check << Mom::SlotLoad.new(self,[dynamic_call.cache_entry, :cached_type] , receiver_type_definition(compiler))
check << Mom::ResolveMethod.new(self, @name , dynamic_call.cache_entry )
check << SlotMachine::SlotLoad.new(self,[dynamic_call.cache_entry, :cached_type] , receiver_type_definition(compiler))
check << SlotMachine::ResolveMethod.new(self, @name , dynamic_call.cache_entry )
check << ok
end
@ -111,14 +111,14 @@ module Vool
private
def receiver_type_definition(compiler)
defi = @receiver.to_slot(compiler)
defi = @receiver.to_slot_definition(compiler)
defi.slots << :type
defi
end
def build_condition(ok_label, compiler)
cached_type = Mom::SlotDefinition.new(dynamic_call.cache_entry , [:cached_type])
cached_type = SlotMachine::SlotDefinition.new(dynamic_call.cache_entry , [:cached_type])
current_type = receiver_type_definition(compiler)
Mom::NotSameCheck.new(cached_type , current_type, ok_label)
SlotMachine::NotSameCheck.new(cached_type , current_type, ok_label)
end
end
end

View File

@ -11,12 +11,12 @@
# data. Statements represent code whereas Expressions resolve to data.
# (in ruby there are no pure statements, everthing resolves to data)
#
# Vool resolves to Mom in the next step down. But it also the place where we create
# Vool resolves to SlotMachine in the next step down. But it also the place where we create
# Parfait representations for the main oo players, ie classes and methods.
# The protocol is thus two stage:
# - first to_parfait with implicit side-effects of creating parfait objects that
# are added to the Parfait object_space
# - second to_mom , which will return a mom version of the statement. This may be code
# - second to_slot , which will return a mom version of the statement. This may be code
# or a compiler (for methods), or compiler collection (for classes)
#
module Vool
@ -43,7 +43,7 @@ module Vool
#
# The argument given most often is a compiler
# The default implementation (this) is to raise an error
def to_mom( _ )
def to_slot( _ )
raise "Not implemented for #{self}"
end

View File

@ -61,17 +61,17 @@ module Vool
def to_parfait
@statements.collect{|s| s.to_parfait}
end
# to_mom all the statements. Append subsequent ones to the first, and return the
# to_slot all the statements. Append subsequent ones to the first, and return the
# first.
#
# For ClassStatements this creates and returns a MomCompiler
# For ClassStatements this creates and returns a SlotMachineCompiler
#
def to_mom( compiler )
def to_slot( compiler )
raise "Empty list ? #{statements.length}" if empty?
stats = @statements.dup
first = stats.shift.to_mom(compiler)
first = stats.shift.to_slot(compiler)
while( nekst = stats.shift )
next_mom = nekst.to_mom(compiler)
next_mom = nekst.to_slot(compiler)
first.append next_mom
end
first

View File

@ -10,9 +10,9 @@ module Vool
class LocalVariable < Expression
include Named
def to_slot(compiler)
def to_slot_definition(compiler)
slot_def = compiler.slot_type_for(@name)
Mom::SlotDefinition.new(:message , slot_def)
SlotMachine::SlotDefinition.new(:message , slot_def)
end
def to_s(depth = 0)
name.to_s
@ -24,8 +24,8 @@ module Vool
class InstanceVariable < Expression
include Named
def to_slot(_)
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
def to_slot_definition(_)
SlotMachine::SlotDefinition.new(:message , [ :receiver , @name] )
end
# used to collect type information
def add_ivar( array )
@ -51,8 +51,8 @@ module Vool
def ct_type
get_named_class.single_class.instance_type
end
def to_slot(_)
return Mom::SlotDefinition.new( get_named_class, [])
def to_slot_definition(_)
return SlotMachine::SlotDefinition.new( get_named_class, [])
end
def get_named_class
Parfait.object_space.get_class_by_name(self.name)

View File

@ -9,15 +9,15 @@ module Vool
@body = body
end
def to_mom( compiler )
merge_label = Mom::Label.new(self, "merge_label_#{object_id.to_s(16)}")
cond_label = Mom::Label.new(self, "cond_label_#{object_id.to_s(16)}")
def to_slot( compiler )
merge_label = SlotMachine::Label.new(self, "merge_label_#{object_id.to_s(16)}")
cond_label = SlotMachine::Label.new(self, "cond_label_#{object_id.to_s(16)}")
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.to_slot(compiler) , merge_label)
codes << @body.to_mom(compiler)
codes << Mom::Jump.new(cond_label)
codes << @hoisted.to_slot(compiler) if @hoisted
codes << @condition.to_slot(compiler) if @condition.is_a?(SendStatement)
codes << SlotMachine::TruthCheck.new(condition.to_slot_definition(compiler) , merge_label)
codes << @body.to_slot(compiler)
codes << SlotMachine::Jump.new(cond_label)
codes << merge_label
end

View File

@ -5,7 +5,7 @@ module Vool
#
# On the ruby side, normalisation works pretty much the same too.
#
# On the way down to Mom, small differences become abvious, as the block that is
# On the way down to SlotMachine, small differences become abvious, as the block that is
# yielded to is an argument. Whereas in a send it is either statically known
# or resolved and cached. Here it is dynamic, but sort of known dynamic.
# All we do before calling it is check that it is the right type.
@ -14,8 +14,8 @@ module Vool
# A Yield breaks down to 2 steps:
# - Setting up the next message, with receiver, arguments, and (importantly) return address
# - a SimpleCall,
def to_mom( compiler )
@parfait_block = @block.to_mom(compiler) if @block
def to_slot( compiler )
@parfait_block = @block.to_slot(compiler) if @block
@receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)
yield_call(compiler)
end
@ -33,10 +33,10 @@ module Vool
# this needs run-time variable resolution, which is just not done.
# we brace ourselves with the check, and exit (later raise) if . . .
def method_check(compiler)
ok_label = Mom::Label.new(self,"method_ok_#{self.object_id}")
compile_method = Mom::SlotDefinition.new( compiler.get_method , [])
runtime_method = Mom::SlotDefinition.new( :message , [ :method] )
check = Mom::NotSameCheck.new(compile_method , runtime_method, ok_label)
ok_label = SlotMachine::Label.new(self,"method_ok_#{self.object_id}")
compile_method = SlotMachine::SlotDefinition.new( compiler.get_method , [])
runtime_method = SlotMachine::SlotDefinition.new( :message , [ :method] )
check = SlotMachine::NotSameCheck.new(compile_method , runtime_method, ok_label)
# TODO? Maybe create mom instructions for this
#builder = compiler.builder("yield")
#Risc::Macro.exit_sequence(builder)
@ -48,15 +48,15 @@ module Vool
# we do a message setup, arg transfer and the a arg_yield (which is similar to dynamic_call)
def yield_arg_block(compiler)
arg_index = compiler.get_method.arguments_type.get_length - 1
setup = Mom::MessageSetup.new( arg_index )
mom_receive = @receiver.to_slot(compiler)
setup = SlotMachine::MessageSetup.new( arg_index )
mom_receive = @receiver.to_slot_definition(compiler)
arg_target = [:message , :next_message ]
args = []
@arguments.each_with_index do |arg , index| # +1 because of type
args << Mom::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot(compiler))
args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot_definition(compiler))
end
setup << Mom::ArgumentTransfer.new( self , mom_receive , args )
setup << Mom::BlockYield.new( self , arg_index )
setup << SlotMachine::ArgumentTransfer.new( self , mom_receive , args )
setup << SlotMachine::BlockYield.new( self , arg_index )
end
end

View File

@ -15,7 +15,7 @@ time comes to move to rubyx, less work.
ruby test/test_all.rb
''''
### Parfait, Risc , Arm , Mom
### Parfait, Risc , Arm , SlotMachine
Follow the directory structure of the source and may be called unit tests

View File

@ -1,24 +0,0 @@
require_relative "helper"
module Vool
class TestClassStatementMom < MiniTest::Test
include MomCompile
def setup
@ret = compile_mom( as_main("return 1"))
end
def test_return_class
assert_equal Mom::MomCollection , @ret.class
end
def test_has_compilers
assert_equal Mom::MethodCompiler , @ret.method_compilers.class
end
def test_constant
assert @ret.method_compilers.add_constant( Parfait::Integer.new(5) )
end
end
end

View File

@ -6,7 +6,7 @@ module Risc
def setup
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
label = Mom::Label.new( "source_name", "return_label")
label = SlotMachine::Label.new( "source_name", "return_label")
@builder = Risc::MethodCompiler.new( FakeCallable.new ,label).builder("source")
@label = Risc.label("source","name")
@start = @builder.compiler.current

View File

@ -5,8 +5,8 @@ module Risc
include Parfait::MethodHelper
def setup
Parfait.boot!(Parfait.default_test_options)
@method = Mom::MomCollection.compiler_for( :Space , :main,{},{}).callable
@compiler = Risc::MethodCompiler.new( @method , Mom::Label.new( "source_name", "return_label"))
@method = SlotMachine::SlotCollection.compiler_for( :Space , :main,{},{}).callable
@compiler = Risc::MethodCompiler.new( @method , SlotMachine::Label.new( "source_name", "return_label"))
@builder = @compiler.builder(@method)
end
def test_inserts_built

View File

@ -7,7 +7,7 @@ module Risc
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
method = FakeCallable.new
@compiler = Risc::MethodCompiler.new( method, Mom::Label.new( "source_name", "return_label") )
@compiler = Risc::MethodCompiler.new( method, SlotMachine::Label.new( "source_name", "return_label") )
@builder = @compiler.builder(method)
end
def test_list

View File

@ -12,7 +12,7 @@ module Risc
def setup
Parfait.boot!({})
label = Mom::Label.new("hi","ho")
label = SlotMachine::Label.new("hi","ho")
@compiler = FakeCallableCompiler.new(FakeCallable.new , label)
end
def test_ok
@ -25,7 +25,7 @@ module Risc
assert_equal Label , @compiler.current.class
assert_equal "ho" , @compiler.current.name
end
def test_mom
def test_slot
assert @compiler.risc_instructions
end
def test_const

View File

@ -7,7 +7,7 @@ module Risc
def setup
code = in_Test("def meth; @ivar = 5;return ;end")
rubyx = RubyX::RubyXCompiler.new(RubyX.default_test_options)
@compiler = rubyx.ruby_to_mom(code).compilers.to_risc
@compiler = rubyx.ruby_to_slot(code).compilers.to_risc
end
def test_compiles_risc
assert_equal Risc::MethodCompiler , @compiler.class

View File

@ -1,11 +1,11 @@
require_relative "helper"
module Risc
class TestMomCompilerTranslate < MiniTest::Test
include MomCompile
class TestSlotMachineCompilerTranslate < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@comp = compile_slot( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@linker = @comp.to_risc.translate(:interpreter)
end

View File

@ -1,11 +1,11 @@
require_relative "helper"
module Risc
class TestMomCompilerTranslate < MiniTest::Test
include MomCompile
class TestSlotMachineCompilerTranslate < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@comp = compile_slot( "class Space ; def main(); main{return 'Ho'};return 'Hi'; end; end;")
@linker = @comp.to_risc.translate(:interpreter)
end

View File

@ -9,14 +9,14 @@ module RubyX
options = RubyX.default_test_options.merge(options)
RubyXCompiler.new(options).ruby_to_vool(input)
end
def ruby_to_mom(input , options = {})
def ruby_to_slot(input , options = {})
options = RubyX.default_test_options.merge(options)
RubyXCompiler.new(options).ruby_to_mom(input)
RubyXCompiler.new(options).ruby_to_slot(input)
end
def compile_in_test( input , options = {})
vool = ruby_to_vool(in_Test(input) , options)
vool.to_parfait
vool.to_mom(nil)
vool.to_slot(nil)
itest = Parfait.object_space.get_class_by_name(:Test)
assert itest
itest

View File

@ -10,10 +10,10 @@ On the way there, we start by Testing and moving the old ones. Since we want to
to test some methods even after the move, without parsing/processing the whole of parfait
we have to have a method of "injecting" the single? methods.
## Mom level
## SlotMachine level
There a re two test levels to every method. Mom being the first, where we basically just
see if the right Mom instruction has been generated
There a re two test levels to every method. SlotMachine being the first, where we basically just
see if the right SlotMachine instruction has been generated
## Risc

View File

@ -4,10 +4,10 @@ module RubyX
module MacroHelper
def setup
whole ="class Space;def main(arg);return;end;end;" + source
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(whole)
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(whole)
@mom.method_compilers
assert_equal Mom::MomCollection , @mom.class
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::SlotCollection , @mom.class
assert_equal SlotMachine::MethodCompiler , compiler.class
end
def compiler
@mom.method_compilers.last_compiler

View File

@ -15,15 +15,15 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal op , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_op
assert_equal Mom::Comparison , compiler.mom_instructions.next.class
assert_equal op , compiler.mom_instructions.next.operator
assert_equal SlotMachine::Comparison , compiler.slot_instructions.next.class
assert_equal op , compiler.slot_instructions.next.operator
end
def test_risc
assert_equal len , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :div10 , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Div10 , compiler.mom_instructions.next.class
assert_equal SlotMachine::Div10 , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 70 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :div4 , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Div4 , compiler.mom_instructions.next.class
assert_equal SlotMachine::Div4 , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 41 , compiler.to_risc.risc_instructions.length

View File

@ -14,15 +14,15 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal op , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_op
assert_equal Mom::IntOperator , compiler.mom_instructions.next.class
assert_equal op , compiler.mom_instructions.next.operator
assert_equal SlotMachine::IntOperator , compiler.slot_instructions.next.class
assert_equal op , compiler.slot_instructions.next.operator
end
def test_risc
assert_equal 42 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :exit , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Exit , compiler.mom_instructions.next.class
assert_equal SlotMachine::Exit , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 40 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :get_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalWord , compiler.mom_instructions.next.class
assert_equal SlotMachine::GetInternalWord , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 18 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :__init , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Init , compiler.mom_instructions.next.class
assert_equal SlotMachine::Init , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 31 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :method_missing , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::MethodMissing , compiler.mom_instructions.next.class
assert_equal SlotMachine::MethodMissing , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 15 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :set_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::SetInternalWord , compiler.mom_instructions.next.class
assert_equal SlotMachine::SetInternalWord , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 19 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :get_internal_byte , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalByte , compiler.mom_instructions.next.class
assert_equal SlotMachine::GetInternalByte , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 41 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :putstring , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::Putstring , compiler.mom_instructions.next.class
assert_equal SlotMachine::Putstring , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 44 , compiler.to_risc.risc_instructions.length

View File

@ -13,14 +13,14 @@ module RubyX
end
GET
end
def test_mom_meth
def test_slot_meth
assert_equal :set_internal_byte , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
assert_equal 7 , compiler.slot_instructions.length
end
def test_instr_get
assert_equal Mom::SetInternalByte , compiler.mom_instructions.next.class
assert_equal SlotMachine::SetInternalByte , compiler.slot_instructions.next.class
end
def test_risc
assert_equal 20 , compiler.to_risc.risc_instructions.length

View File

@ -8,7 +8,7 @@ Since we need Parfait in the runtime, we need to parse it and compile it.
And since it is early days, we expect errors at every level during this process, which
means testing every layer for every file.
Rather than create parfait tests for every layer (ie in the vool/mom/risc directories)
Rather than create parfait tests for every layer (ie in the vool/slot_machine/risc directories)
we have one file per parfait file here. Each file tests all layers.
The usual workflow is to start with a new file and create tests for vool, mom, risc,binary

View File

@ -27,9 +27,9 @@ module RubyX
assert_equal :Data4 , vool[2].name
assert_equal :Data8 , vool[3].name
end
def test_mom
mom = @compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
def test_slot
mom = @compiler.ruby_to_slot source
assert_equal SlotMachine::SlotCollection , mom.class
end
def test_risc
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)

View File

@ -25,12 +25,12 @@ module RubyX
assert_equal :Data4 , vool[2].name
assert_equal :Data8 , vool[3].name
end
def test_mom
def test_slot
vool = @compiler.ruby_to_vool source
vool.to_parfait
#puts vool
mom = vool.to_mom(nil)
assert_equal Mom::MomCollection , mom.class
mom = vool.to_slot(nil)
assert_equal SlotMachine::SlotCollection , mom.class
end
def est_risc
risc = compiler.ruby_to_risc source

View File

@ -18,9 +18,9 @@ module RubyX
assert_equal Vool::ClassExpression , vool.class
assert_equal :Object , vool.name
end
def test_mom
mom = compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
def test_slot
mom = compiler.ruby_to_slot source
assert_equal SlotMachine::SlotCollection , mom.class
end
def test_risc
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)

View File

@ -1,24 +1,24 @@
require_relative "helper"
module RubyX
class TestRubyXCompilerMom < MiniTest::Test
class TestRubyXCompilerSlotMachine < MiniTest::Test
include ScopeHelper
include RubyXHelper
def test_creates_class_without_deriviation
ruby_to_mom "class Testing ; end"
ruby_to_slot "class Testing ; end"
clazz = Parfait.object_space.get_class_by_name(:Testing)
assert clazz , "No classes created"
assert_equal :Object , clazz.super_class_name
end
def test_creates_class_deriviation
mom = ruby_to_mom "class Testing ; end"
mom = ruby_to_slot "class Testing ; end"
assert mom , "No classes created"
end
def test_creates_class_with_deriviation
ruby_to_mom "class Test2 < List ;end"
ruby_to_slot "class Test2 < List ;end"
clazz = Parfait.object_space.get_class_by_name(:Test2)
assert clazz, "No classes created"
assert_equal :List , clazz.super_class_name

View File

@ -1,13 +1,13 @@
require_relative '../helper'
module Mom
module SlotMachine
class InstructionMock < Instruction
def initialize
super("mocking")
end
end
# Most MomInstructionTests test the risc instructions of the mom instruction
# Most SlotMachineInstructionTests test the risc instructions of the mom instruction
# quite carefully, ie every instruction, every register.
#
# This is done with the assert methods in risc_assert
@ -16,7 +16,7 @@ module Mom
# For working code, one can get a list of those instructions by using the all_str as message
# Most tests will test for length and give the all_str as message to see where it went wrong
# like: assert_equal 8 , all.length , all_str
class MomInstructionTest < MiniTest::Test
class SlotMachineInstructionTest < MiniTest::Test
include Output
def setup
Parfait.boot!(Parfait.default_test_options)

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestArgumentTransfer < MomInstructionTest
module SlotMachine
class TestArgumentTransfer < SlotMachineInstructionTest
def instruction
receiver = SlotDefinition.new(:message , [:receiver])
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TesBlockYield < MomInstructionTest
module SlotMachine
class TesBlockYield < SlotMachineInstructionTest
def instruction
BlockYield.new("source",1)
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestDynamicCall < MomInstructionTest
module SlotMachine
class TestDynamicCall < SlotMachineInstructionTest
def instruction
DynamicCall.new(nil,nil)
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestJump < MomInstructionTest
module SlotMachine
class TestJump < SlotMachineInstructionTest
def instruction
Jump.new( Label.new("ok" , "target"))
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestMessageSetupInt < MomInstructionTest
module SlotMachine
class TestMessageSetupInt < SlotMachineInstructionTest
def instruction
MessageSetup.new( 1 )
end
@ -18,7 +18,7 @@ module Mom
assert_reg_to_slot risc(3) , :r1 , :r2 , 7
end
end
class TestMessageSetupCache < MomInstructionTest
class TestMessageSetupCache < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestNotSameCheck < MomInstructionTest
module SlotMachine
class TestNotSameCheck < SlotMachineInstructionTest
def instruction
target = SlotDefinition.new(:message , :caller)
NotSameCheck.new(target , target , Label.new("ok" , "target"))

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestResolveMethod < MomInstructionTest
module SlotMachine
class TestResolveMethod < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestReturnJump < MomInstructionTest
module SlotMachine
class TestReturnJump < SlotMachineInstructionTest
def instruction
ReturnJump.new("source",Label.new("ok" , "return"))
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestReturnSequence < MomInstructionTest
module SlotMachine
class TestReturnSequence < SlotMachineInstructionTest
def instruction
ReturnSequence.new("source")
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestSimpleCall < MomInstructionTest
module SlotMachine
class TestSimpleCall < SlotMachineInstructionTest
include Parfait::MethodHelper
def instruction

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionBasics < MiniTest::Test
def slot(slot = :caller)

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionConstant < MiniTest::Test
def setup

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionKnown1 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotDefinitionKnown2 < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoadBasics < MiniTest::Test
def test_ins_ok

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoad1 < MiniTest::Test
def setup

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoad2 < MiniTest::Test
def setup

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestSlotLoad3 < MiniTest::Test
include Parfait::MethodHelper

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
class TestSameCheck < MomInstructionTest
module SlotMachine
class TestSameCheck < SlotMachineInstructionTest
def instruction
target = SlotDefinition.new(:message , :caller)
TruthCheck.new(target , Label.new("ok" , "target"))

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntComp1Risc < BootTest
def setup
@method = get_compiler("Integer",:lt)
end
def test_mom_length
def test_slot_length
assert_equal :< , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class
@ -21,9 +21,9 @@ module Mom
def setup
@method = get_compiler("Integer",:gt)
end
def test_mom_length
def test_slot_length
assert_equal :> , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntDiv10Risc < BootTest
def setup
@method = get_compiler("Integer",:div10)
end
def test_mom_length
def test_slot_length
assert_equal :div10 , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntDiv4Risc < BootTest
def setup
@method = get_compiler("Integer",:div4)
end
def test_mom_length
def test_slot_length
assert_equal :div4 , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestObjectExitRisc < BootTest
def setup
super
@method = get_compiler("Object",:exit)
end
def test_mom_length
def test_slot_length
assert_equal :exit , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordGetRisc < BootTest
def setup
super
@method = get_compiler("Word",:get)
end
def test_mom_length
def test_slot_length
assert_equal :get_internal_byte , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordGetRisc < BootTest
def setup
super
@method = get_compiler("Object",:get)
end
def test_mom_length
def test_slot_length
assert_equal :get_internal_word , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,16 +1,16 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestObjectInitRisc < BootTest
def setup
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
coll = compiler.ruby_to_mom( get_preload("Space.main") )
@method = MomCollection.create_init_compiler
coll = compiler.ruby_to_slot( get_preload("Space.main") )
@method = SlotCollection.create_init_compiler
end
def test_mom_length
def test_slot_length
assert_equal :__init__ , @method.callable.name
assert_equal 2 , @method.mom_instructions.length
assert_equal 2 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestObjectMissingRisc < BootTest
def setup
@method = get_compiler("Object",:missing)
end
def test_mom_length
def test_slot_length
assert_equal :method_missing , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestIntOpPl < BootTest
def setup
@method = get_compiler("Integer",:and)
end
def test_mom_length
def test_slot_length
assert_equal :& , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class
@ -21,9 +21,9 @@ module Mom
def setup
@method = get_compiler("Integer",:or)
end
def test_mom_length
def test_slot_length
assert_equal :| , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordPutRisc < BootTest
def setup
@method = get_compiler("Word",:put)
end
def test_mom_length
def test_slot_length
assert_equal :putstring , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,15 +1,15 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordSetRisc < BootTest
def setup
super
@method = get_compiler("Word",:set)
end
def test_mom_length
def test_slot_length
assert_equal :set_internal_byte , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Mom
module SlotMachine
module Builtin
class TestWordSetRisc < BootTest
def setup
@method = get_compiler("Word",:set)
end
def test_mom_length
def test_slot_length
assert_equal :set_internal_byte , @method.callable.name
assert_equal 7 , @method.mom_instructions.length
assert_equal 7 , @method.slot_instructions.length
end
def test_compile
assert_equal Risc::MethodCompiler , @method.to_risc.class

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestBlockCompiler1 < MiniTest::Test
include ScopeHelper

View File

@ -3,13 +3,13 @@ require_relative "helper"
module Vool
class TestBlockArg < MiniTest::Test
include MomCompile
include SlotMachineCompile
def setup
@ret = compile_mom( as_main("self.main {|elem| elem = 5 } "))
@ret = compile_slot( as_main("self.main {|elem| elem = 5 } "))
end
def test_is_compiler
assert_equal Mom::MomCollection , @ret.class
assert_equal SlotMachine::SlotCollection , @ret.class
end
def test_has_method
assert_equal Parfait::CallableMethod , @ret.method_compilers.get_method.class
@ -19,9 +19,9 @@ module Vool
end
end
class TestBlockLocal < MiniTest::Test
include MomCompile
include SlotMachineCompile
def setup
@ret = compile_mom( as_main("self.main {|elem| local = 5 } "))
@ret = compile_slot( as_main("self.main {|elem| local = 5 } "))
@block = @ret.method_compilers.get_method.blocks
end
def test_block_arg_type
@ -38,16 +38,16 @@ module Vool
end
end
class TestBlockMethodArg < MiniTest::Test
include MomCompile
include SlotMachineCompile
def setup
end
def test_method_arg_compiles
ret = compile_mom( as_main("self.main {|elem| arg = 5 } "))
ret = compile_slot( as_main("self.main {|elem| arg = 5 } "))
assert ret
end
def test_method_local_compiles
ret = compile_mom( as_main("local = 5 ; self.main {|elem| local = 10 } "))
ret = compile_slot( as_main("local = 5 ; self.main {|elem| local = 10 } "))
assert ret
end
end

View File

@ -1,5 +1,5 @@
require_relative "helper"
module Mom
module SlotMachine
class FakeCallableCompiler < CallableCompiler
def source_name
"luke"
@ -20,8 +20,8 @@ module Mom
assert_equal Label , @compiler.current.class
assert_equal @compiler.source_name , @compiler.current.name
end
def test_mom
assert @compiler.mom_instructions
def test_slot
assert @compiler.slot_instructions
end
def test_const
assert_equal Array , @compiler.constants.class

View File

@ -0,0 +1,24 @@
require_relative "helper"
module Vool
class TestClassStatementSlotMachine < MiniTest::Test
include SlotMachineCompile
def setup
@ret = compile_slot( as_main("return 1"))
end
def test_return_class
assert_equal SlotMachine::SlotCollection , @ret.class
end
def test_has_compilers
assert_equal SlotMachine::MethodCompiler , @ret.method_compilers.class
end
def test_constant
assert @ret.method_compilers.add_constant( Parfait::Integer.new(5) )
end
end
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Mom
module SlotMachine
class TestInstruction < MiniTest::Test
def test_instantiates

View File

@ -1,6 +1,6 @@
require_relative "helper"
module Mom
module SlotMachine
class TestMethodCompiler < MiniTest::Test
include ScopeHelper
@ -10,7 +10,7 @@ module Mom
def in_test_vool(str)
vool = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(in_Test(str))
vool.to_parfait
vool.to_mom(nil)
vool.to_slot(nil)
vool
end
def create_method(body = "@ivar = 5;return")
@ -62,10 +62,10 @@ module Mom
assert_equal 2 , method.frame_type.variable_index(:a)
end
def constant_setup(input)
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(in_Test(input))
assert_equal Mom::MomCollection , mom.class
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(in_Test(input))
assert_equal SlotMachine::SlotCollection , mom.class
compiler = mom.method_compilers
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::MethodCompiler , compiler.class
compiler
end
def test_return_label

View File

@ -1,34 +1,34 @@
require_relative "helper"
module Mom
class TestMomCollection < MiniTest::Test
include MomCompile
module SlotMachine
class TestSlotCollection < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
@comp = compile_slot( "class Test ; def main(); return 'Hi'; end; end;")
end
def test_class
assert_equal MomCollection , @comp.class
assert_equal SlotCollection , @comp.class
end
def test_compilers
assert_equal 3 , @comp.compilers.num_compilers
end
def test_init_compilers
assert_equal MomCollection , @comp.init_compilers.class
assert_equal SlotCollection , @comp.init_compilers.class
end
def test_compilers_bare
assert_equal 2 , MomCollection.new.compilers.num_compilers
assert_equal 2 , SlotCollection.new.compilers.num_compilers
end
def test_append_class
assert_equal MomCollection, (@comp.append @comp).class
assert_equal SlotCollection, (@comp.append @comp).class
end
end
class TestMomCollectionToRisc < MiniTest::Test
include MomCompile
class TestSlotCollectionToRisc < MiniTest::Test
include SlotMachineCompile
def setup
@comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;")
@comp = compile_slot( "class Space ; def main(); return 'Hi'; end; end;")
@collection = @comp.to_risc()
end
def compiler

View File

@ -30,24 +30,24 @@ module ScopeHelper
end
module VoolCompile
include ScopeHelper
include Mom
include SlotMachine
include Preloader
def compile_main( input , preload = nil)
input = get_preload(preload) + as_main( input )
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
assert collection.is_a?(Mom::MomCollection) , collection.class.name
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(input)
assert collection.is_a?(SlotMachine::SlotCollection) , collection.class.name
compiler = collection.compilers.find_compiler_name(:main)
assert_equal Mom::MethodCompiler , compiler.class
assert_equal SlotMachine::MethodCompiler , compiler.class
compiler
end
def compile_main_block( block_input , method_input = "main_local = 5" , preload = nil)
source = get_preload(preload) + as_main("#{method_input} ; self.main{|val| #{block_input}}")
mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom( source )
mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot( source )
compiler = mom_col.method_compilers.find_compiler_name(:main)
block = mom_col.method_compilers.find_compiler_name(:main_block)
assert block
block.mom_instructions.next
block.slot_instructions.next
end
def check_array( should , is )
index = 0
@ -75,11 +75,11 @@ module VoolCompile
end
module MomCompile
module SlotMachineCompile
include ScopeHelper
def compile_mom(input)
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
def compile_slot(input)
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(input)
end
end

View File

@ -2,7 +2,7 @@ require_relative "helper"
module Vool
class TestClassDef < MiniTest::Test
include Mom
include SlotMachine
include VoolCompile
def class_main
@ -20,8 +20,8 @@ module Vool
def setup
source = "class Integer<Data4;def +(other);X.int_operator(:+);end;end;" + class_main
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(source)
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
end
def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
@ -29,10 +29,10 @@ module Vool
end
def test_any
assert_equal Mom::MessageSetup , @ins.class
assert_equal SlotMachine::MessageSetup , @ins.class
end
def test_no_arg
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
assert_equal SlotMachine::ArgumentTransfer, @ins.next(1).class
assert_equal 0, @ins.next(1).arguments.length
end
def test_call_two

View File

@ -2,7 +2,7 @@ require_relative "helper"
module Vool
class TestClassInstance < MiniTest::Test
include Mom
include SlotMachine
include VoolCompile
def class_main
@ -19,10 +19,10 @@ module Vool
end
def setup
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(class_main)
@compiler = ret.compilers.find_compiler_name(:some_inst)
@main = ret.compilers.find_compiler_name(:main)
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_inst
space_class = Parfait.object_space.get_class
@ -31,7 +31,7 @@ module Vool
assert names.index_of(:inst) , names
end
def test_compiler
assert_equal Mom::MethodCompiler, @compiler.class
assert_equal SlotMachine::MethodCompiler, @compiler.class
assert_equal Parfait::Type, @compiler.callable.self_type.class
assert_equal 6, @compiler.callable.self_type.names.index_of(:inst) , @compiler.callable.self_type.names
end
@ -40,10 +40,10 @@ module Vool
end
def test_main_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, ReturnJump ,
Label, ReturnSequence, Label] , @main.mom_instructions.next
Label, ReturnSequence, Label] , @main.slot_instructions.next
end
def test_main_args
args = @main.mom_instructions.next(2)
args = @main.slot_instructions.next(2)
assert_equal Parfait::Class , args.receiver.known_object.class
assert_equal :Space , args.receiver.known_object.name
assert_equal :some_inst , args.receiver.known_object.type.method_names.first

View File

@ -2,7 +2,7 @@ require_relative "helper"
module Vool
class TestClassSendInherited < MiniTest::Test
include Mom
include SlotMachine
include VoolCompile
def class_main
@ -21,15 +21,15 @@ module Vool
end
def setup
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(class_main)
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
end
def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
ReturnJump,Label, ReturnSequence , Label] , @ins
end
def test_receiver
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
assert_equal SlotMachine::ArgumentTransfer, @ins.next(1).class
assert_equal 0, @ins.next(1).arguments.length
assert_equal SlotDefinition, @ins.next(1).receiver.class
assert_equal Parfait::Class, @ins.next(1).receiver.known_object.class

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Vool
class TestSendClassMom < MiniTest::Test
class TestSendClassSlotMachine < MiniTest::Test
include VoolCompile
def class_main
@ -21,8 +21,8 @@ module Vool
def setup
source = "class Integer < Data4;def +(other);X.int_operator(:+);end;end;" + class_main
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(source)
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
end
def test_array

View File

@ -1,14 +1,14 @@
require_relative "../helper"
module VoolBlocks
class TestAssignMom < MiniTest::Test
class TestAssignSlotMachine < MiniTest::Test
include VoolCompile
def setup
@ins = compile_main_block( "local = 5" )
end
def test_block_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slot_is_set
assert @ins.left
@ -23,17 +23,17 @@ module VoolBlocks
assert @ins.right
end
def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
end
end
class TestAssignMomInstanceToLocal < MiniTest::Test
class TestAssignSlotMachineInstanceToLocal < MiniTest::Test
include VoolCompile
def setup
@ins = compile_main_block( "local = @a" , "@a = 5") #second arg in method scope
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slots_left
assert_equal [:local1] , @ins.left.slots
@ -51,7 +51,7 @@ module VoolBlocks
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slot_is_set
assert @ins.left
@ -61,19 +61,19 @@ module VoolBlocks
end
end
class TestAssignMomToInstance < MiniTest::Test
class TestAssignSlotMachineToInstance < MiniTest::Test
include VoolCompile
def setup
end
def test_assigns_const
@ins = compile_main_block( "@a = 5")
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class , @ins
end
def test_assigns_move
@ins = compile_main_block( "@a = arg")
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotDefinition , @ins.right.class , @ins
end
end

View File

@ -1,7 +1,7 @@
require_relative "../helper"
module VoolBlocks
class TestClassAssignMom < MiniTest::Test
class TestClassAssignSlotMachine < MiniTest::Test
def setup
Parfait.boot!(Parfait.default_test_options)
@ -14,7 +14,7 @@ module VoolBlocks
vool = Ruby::RubyCompiler.compile( as_class_method(source) ).to_vool
vool.to_parfait
begin
vool.to_mom(nil)
vool.to_slot(nil)
rescue => err
assert err.message.include?("Blocks") , err.message
end
@ -22,7 +22,7 @@ module VoolBlocks
def test_assign_compiles
vool = Ruby::RubyCompiler.compile( as_class_method("val = 0") ).to_vool
vool.to_parfait
assert_equal Mom::MomCollection , vool.to_mom(nil).class
assert_equal SlotMachine::SlotCollection , vool.to_slot(nil).class
end
end
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module VoolBlocks
class TestConditionIfMom < MiniTest::Test
class TestConditionIfSlotMachine < MiniTest::Test
include VoolCompile
def setup

View File

@ -1,7 +1,7 @@
require_relative "helper"
module VoolBlocks
class TestSimpleWhileMom < MiniTest::Test
class TestSimpleWhileSlotMachine < MiniTest::Test
include VoolCompile
def setup

View File

@ -4,11 +4,11 @@ module Vool
# relies on @ins and receiver_type method
module SimpleSendHarness
include VoolCompile
include Mom
include SlotMachine
def setup
@compiler = compile_main( send_method , "Integer.div4;Object.get")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_first_not_array

View File

@ -1,12 +1,12 @@
require_relative "../helper"
module Vool
class TestSendCachedSimpleMom < MiniTest::Test
class TestSendCachedSimpleSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "5.div8")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_check_type
assert_equal NotSameCheck , @ins.class , @ins

View File

@ -1,12 +1,12 @@
require_relative "helper"
module Vool
class TestSendArgsSendMom < MiniTest::Test
class TestSendArgsSendSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_array

View File

@ -1,12 +1,12 @@
require_relative "../helper"
module Vool
class TestSendCachedSimpleMom < MiniTest::Test
class TestSendCachedSimpleSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "a = 5; a.div4;return ")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_check_type
assert_equal NotSameCheck , @ins.next(1).class , @ins

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Vool
class TestSendSelfMom < MiniTest::Test
class TestSendSelfSlotMachine < MiniTest::Test
include SimpleSendHarness
def send_method
@ -23,7 +23,7 @@ module Vool
assert_equal :get_internal_word, @ins.next(2).method.name
end
end
class TestSendSelfImplicitMom < TestSendSelfMom
class TestSendSelfImplicitSlotMachine < TestSendSelfSlotMachine
def send_method
"get_internal_word(0)"

View File

@ -1,14 +1,14 @@
require_relative "helper"
module Vool
class TestSendSimpleMom < MiniTest::Test
class TestSendSimpleSlotMachine < MiniTest::Test
include SimpleSendHarness
def send_method
"5.div4;return"
end
def receiver
[Mom::IntegerConstant , 5]
[SlotMachine::IntegerConstant , 5]
end
def test_call_has_right_method
assert_equal :div4, @ins.next(2).method.name

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Vool
class TestSendSimpleArgsMom < MiniTest::Test
class TestSendSimpleArgsSlotMachine < MiniTest::Test
include SimpleSendHarness
def send_method
@ -9,14 +9,14 @@ module Vool
end
def receiver
[Mom::IntegerConstant , 5]
[SlotMachine::IntegerConstant , 5]
end
def test_args_two_move
assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0]
assert_equal :arg2, @ins.next(1).arguments[1].left.slots[1]
end
def test_args_two_str
assert_equal Mom::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class
assert_equal SlotMachine::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
end
def test_array

View File

@ -1,16 +1,16 @@
require_relative "helper"
module Vool
class TestAssignMom < MiniTest::Test
class TestAssignSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "local = 5;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slot_is_set
assert @ins.left
@ -25,19 +25,19 @@ module Vool
assert @ins.right
end
def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
end
end
#otherwise as above, but assigning instance, so should get a SlotLoad
class TestAssignMomInstanceToLocal < MiniTest::Test
class TestAssignSlotMachineInstanceToLocal < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "@a = 5 ; local = @a;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.next.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.next.class , @ins
end
end
@ -47,11 +47,11 @@ module Vool
def setup
@compiler = compile_main( "arg = 5;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slot_is_set
assert @ins.left
@ -64,22 +64,22 @@ module Vool
end
end
class TestAssignMomToInstance < MiniTest::Test
class TestAssignSlotMachineToInstance < MiniTest::Test
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
end
def test_assigns_const
@compiler = compile_main( "@a = 5;return")
@ins = @compiler.mom_instructions.next
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
@ins = @compiler.slot_instructions.next
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class , @ins
end
def test_assigns_move
@compiler = compile_main( "@a = arg;return")
@ins = @compiler.mom_instructions.next
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
@ins = @compiler.slot_instructions.next
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotDefinition , @ins.right.class , @ins
end
end

View File

@ -11,10 +11,10 @@ module Vool
def as_ruby
@ruby = Ruby::RubyCompiler.compile(@code)
end
def as_mom
def as_slot
vool = as_ruby.to_vool
vool.to_parfait
vool.to_mom(nil)
vool.to_slot(nil)
end
def test_boot
assert_equal String , @code.class
@ -36,17 +36,17 @@ module Vool
assert_equal Vool::ReturnStatement , vool.body.first.body.class
assert_equal Vool::MacroExpression , vool.body.first.body.return_value.class
end
def test_mom_basic
mom = as_mom
assert_equal Mom::MomCollection , mom.class
assert_equal Mom::MethodCompiler , mom.method_compilers.class
def test_slot_basic
mom = as_slot
assert_equal SlotMachine::SlotCollection , mom.class
assert_equal SlotMachine::MethodCompiler , mom.method_compilers.class
end
def test_mom_instructions
mom_compiler = as_mom.method_compilers
assert_equal Mom::Label , mom_compiler.mom_instructions.class
assert_equal Mom::IntOperator , mom_compiler.mom_instructions.next.class
assert_equal Mom::SlotLoad , mom_compiler.mom_instructions.next(2).class
assert_equal Mom::ReturnJump , mom_compiler.mom_instructions.next(3).class
def test_slot_instructions
mom_compiler = as_slot.method_compilers
assert_equal SlotMachine::Label , mom_compiler.slot_instructions.class
assert_equal SlotMachine::IntOperator , mom_compiler.slot_instructions.next.class
assert_equal SlotMachine::SlotLoad , mom_compiler.slot_instructions.next(2).class
assert_equal SlotMachine::ReturnJump , mom_compiler.slot_instructions.next(3).class
end
end
end

View File

@ -7,7 +7,7 @@ module Vool
def setup
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
@ins = @compiler.mom_instructions
@ins = @compiler.slot_instructions
end
def test_label

View File

@ -33,15 +33,15 @@ module Vool
m = clazz.single_class.instance_type.get_method(:meth)
assert m , "no type method :meth"
end
def as_mom
def as_slot
@clazz.to_parfait
@clazz.to_mom(nil)
@clazz.to_slot(nil)
end
def test_mom
assert_equal :meth , as_mom.method_compilers.callable.name
def test_slot
assert_equal :meth , as_slot.method_compilers.callable.name
end
def test_mom_frame
callable = as_mom.method_compilers.callable
def test_slot_frame
callable = as_slot.method_compilers.callable
assert callable.frame_type.names.last.to_s.start_with?("tmp_") , "no tmp_ variable #{callable.frame_type.names}"
end
end

View File

@ -7,7 +7,7 @@ module Vool
def setup
@compiler = compile_main( "if(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_condition_compiles_to_check

View File

@ -7,7 +7,7 @@ module Vool
def setup
@compiler = compile_main( "unless(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_condition_compiles_to_check

View File

@ -2,12 +2,12 @@
require_relative "helper"
module Vool
class TestSimpleIfMom < MiniTest::Test
class TestSimpleIfSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_condition_compiles_to_check

View File

@ -1,12 +1,12 @@
require_relative "helper"
module Vool
class TestConditionIfMom < MiniTest::Test
class TestConditionIfSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return" , "Integer.div4")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_condition

View File

@ -1,12 +1,12 @@
require_relative "helper"
module Vool
class TestIvarMom < MiniTest::Test
class TestIvarSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "@a = 5")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_array
@ -26,7 +26,7 @@ module Vool
end
def test_slot_assigns_something
assert @ins.right
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
end
end
end

View File

@ -1,19 +1,19 @@
require_relative "helper"
module Vool
class TestLocalMom < MiniTest::Test
class TestLocalSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "a = 5")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_compiles_not_array
assert Array != @ins.class , @ins
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slot_is_set
assert @ins.left
@ -28,21 +28,21 @@ module Vool
assert @ins.right
end
def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
end
end
class TestArgMom < MiniTest::Test
class TestArgSlotMachine < MiniTest::Test
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_main( "arg = 5")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_compiles
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
end
def test_slot_is_set
assert @ins.left
@ -57,7 +57,7 @@ module Vool
assert @ins.right
end
def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
end
end

View File

@ -1,5 +1,5 @@
require_relative "helper"
module Mom
module SlotMachine
class PlusEquals < Instruction
attr_reader :a , :b
def initialize(source , arg , b)
@ -14,16 +14,16 @@ module Mom
end
module Vool
class TestMacroMom < MiniTest::Test
class TestMacroSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "X.plus_equals(arg,1)")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_compiles
assert_equal Mom::PlusEquals , @ins.class , @ins
assert_equal SlotMachine::PlusEquals , @ins.class , @ins
end
def test_arg1
assert_equal Vool::LocalVariable , @ins.a.class

View File

@ -1,12 +1,12 @@
require_relative "helper"
module Vool
class TestReturnMom < MiniTest::Test
class TestReturnSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "return 5")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_class_compiles
@ -28,7 +28,7 @@ module Vool
assert @ins.right
end
def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
end
def test_second_is_return
assert_equal ReturnJump, @ins.next(1).class
@ -37,12 +37,12 @@ module Vool
check_array [SlotLoad, ReturnJump, Label, ReturnSequence, Label], @ins
end
end
class TestReturnSendMom < MiniTest::Test
class TestReturnSendSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "return 5.div4" , "Integer.div4" )
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_return_is_last

View File

@ -1,12 +1,12 @@
require_relative "helper"
module Vool
class TestSimpleWhileMom < MiniTest::Test
class TestSimpleWhileSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "while(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_compiles_as_while

View File

@ -2,12 +2,12 @@
require_relative "helper"
module Vool
class TestWhileConditionMom < MiniTest::Test
class TestWhileConditionSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4")
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_condition_compiles_to_check

View File

@ -1,12 +1,12 @@
require_relative "helper"
module Vool
class TestYieldArgsSendMom < MiniTest::Test
class TestYieldArgsSendSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "return yield(1)" )
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_array
@ -65,12 +65,12 @@ module Vool
assert_equal ReturnJump, @ins.next(6).class
end
end
class TestYieldNoArgsSendMom < MiniTest::Test
class TestYieldNoArgsSendSlotMachine < MiniTest::Test
include VoolCompile
def setup
@compiler = compile_main( "return yield(some.extra.calls)" )
@ins = @compiler.mom_instructions.next
@ins = @compiler.slot_instructions.next
end
def test_check_label
assert_equal NotSameCheck, @ins.class