Change Mom to SlotMachine
rather large commit, but essentially a simple rename Rationale in docs and blogs
This commit is contained in:
parent
fd8a3e9cc5
commit
c43436f35a
@ -30,7 +30,7 @@ guard :minitest , all_on_start: false do # with Minitest::Unit
|
|||||||
[ Dir["test/vool/send/test_*.rb"] ] }
|
[ Dir["test/vool/send/test_*.rb"] ] }
|
||||||
|
|
||||||
# message setup
|
# 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
|
# mains test
|
||||||
watch(%r{^test/mains/source/(.*)\.rb}) { "test/mains/test_interpreted.rb" }
|
watch(%r{^test/mains/source/(.*)\.rb}) { "test/mains/test_interpreted.rb" }
|
||||||
|
14
README.md
14
README.md
@ -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
|
The last rewrite clarified the roles of the different layers
|
||||||
of the system, see below. The overhaul is done and rubyx produces working binaries.
|
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,
|
Currently most basic constructs work to some (usable) degree, ie if, while,
|
||||||
assignment, ivars, calling and dynamic dispatch all work. Simple blocks, those
|
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)
|
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
|
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.
|
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
|
SlotMachine 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.
|
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
|
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.
|
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.
|
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
|
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
|
### 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.
|
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
|
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
|
## Other
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ module Arm
|
|||||||
@source = source
|
@source = source
|
||||||
@next = nekst
|
@next = nekst
|
||||||
return unless source
|
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
|
end
|
||||||
attr_reader :source
|
attr_reader :source
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ module Parfait
|
|||||||
callable_method = self_type.get_method(@name)
|
callable_method = self_type.get_method(@name)
|
||||||
#puts "Using #{name} for #{self_type.object_class.name}.#{self_type.hash}" unless callable_method
|
#puts "Using #{name} for #{self_type.object_class.name}.#{self_type.hash}" unless callable_method
|
||||||
raise "Callable not found #{@name}" unless callable_method
|
raise "Callable not found #{@name}" unless callable_method
|
||||||
compiler = Mom::MethodCompiler.new( callable_method )
|
compiler = SlotMachine::MethodCompiler.new( callable_method )
|
||||||
head = @source.to_mom( compiler )
|
head = @source.to_slot( compiler )
|
||||||
compiler.add_code(head)
|
compiler.add_code(head)
|
||||||
compiler
|
compiler
|
||||||
end
|
end
|
||||||
|
@ -7,9 +7,9 @@ module Risc
|
|||||||
|
|
||||||
attr_reader :block , :risc_instructions , :constants , :in_method
|
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
|
@in_method = in_method
|
||||||
super(block , mom_label)
|
super(block , slot_label)
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_name
|
def source_name
|
||||||
|
@ -204,18 +204,18 @@ module Risc
|
|||||||
# - setting up the next message
|
# - setting up the next message
|
||||||
# - moving receiver (factory) and arguments (none)
|
# - moving receiver (factory) and arguments (none)
|
||||||
# - issuing the call
|
# - 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
|
def call_get_more
|
||||||
factory = Parfait.object_space.get_factory_for( :Integer )
|
factory = Parfait.object_space.get_factory_for( :Integer )
|
||||||
calling = factory.get_type.get_method( :get_more )
|
calling = factory.get_type.get_method( :get_more )
|
||||||
calling = Parfait.object_space.get_method!(:Space,:main) #until we actually parse Factory
|
calling = Parfait.object_space.get_method!(:Space,:main) #until we actually parse Factory
|
||||||
raise "no main defined" unless calling
|
raise "no main defined" unless calling
|
||||||
Mom::MessageSetup.new( calling ).build_with( self )
|
SlotMachine::MessageSetup.new( calling ).build_with( self )
|
||||||
self.build do
|
self.build do
|
||||||
factory_reg! << factory
|
factory_reg! << factory
|
||||||
message[:receiver] << factory_reg
|
message[:receiver] << factory_reg
|
||||||
end
|
end
|
||||||
Mom::SimpleCall.new(calling).to_risc(compiler)
|
SlotMachine::SimpleCall.new(calling).to_risc(compiler)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,12 +14,12 @@ module Risc
|
|||||||
|
|
||||||
# Must pass the callable (method/block)
|
# Must pass the callable (method/block)
|
||||||
# Also start instuction, usually a label is mandatory
|
# Also start instuction, usually a label is mandatory
|
||||||
def initialize( callable , mom_label)
|
def initialize( callable , slot_label)
|
||||||
raise "No method" unless callable
|
raise "No method" unless callable
|
||||||
@callable = callable
|
@callable = callable
|
||||||
@regs = []
|
@regs = []
|
||||||
@constants = []
|
@constants = []
|
||||||
@current = @risc_instructions = mom_label.risc_label(self)
|
@current = @risc_instructions = slot_label.risc_label(self)
|
||||||
reset_regs
|
reset_regs
|
||||||
end
|
end
|
||||||
attr_reader :risc_instructions , :constants , :callable , :current
|
attr_reader :risc_instructions , :constants , :callable , :current
|
||||||
|
@ -8,7 +8,7 @@ module Risc
|
|||||||
#
|
#
|
||||||
# We can load and store their contents, move data between them and
|
# We can load and store their contents, move data between them and
|
||||||
# access (get/set) memory at a constant offset from a register
|
# 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
|
# but we keep the names for better understanding, r2-5 are temporary/scratch
|
||||||
# There is no direct memory access, only through registers
|
# There is no direct memory access, only through registers
|
||||||
# Constants can/must be loaded into registers before use
|
# Constants can/must be loaded into registers before use
|
||||||
@ -27,7 +27,7 @@ module Risc
|
|||||||
@next = nekst
|
@next = nekst
|
||||||
return unless source
|
return unless source
|
||||||
raise "Source must be string or Instruction, not #{source.class}" unless source.is_a?(String) or
|
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
|
end
|
||||||
attr_reader :source
|
attr_reader :source
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ module Risc
|
|||||||
super(source)
|
super(source)
|
||||||
@register = register
|
@register = register
|
||||||
@constant = constant
|
@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)
|
raise "Not register #{register}" unless RegisterValue.look_like_reg(register)
|
||||||
end
|
end
|
||||||
attr_accessor :register , :constant
|
attr_accessor :register , :constant
|
||||||
|
@ -7,8 +7,8 @@ module Risc
|
|||||||
|
|
||||||
# Methods starts with a Label, both in risc and mom.
|
# Methods starts with a Label, both in risc and mom.
|
||||||
# Pass in the callable(method) and the mom label that the method starts with
|
# Pass in the callable(method) and the mom label that the method starts with
|
||||||
def initialize( method , mom_label)
|
def initialize( method , slot_label)
|
||||||
super(method , mom_label)
|
super(method , slot_label)
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_name
|
def source_name
|
||||||
|
@ -24,7 +24,7 @@ module Ruby
|
|||||||
#
|
#
|
||||||
# The next step is then to go to the vool level, which is
|
# The next step is then to go to the vool level, which is
|
||||||
# simpler, and then finally to compile
|
# 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
|
class RubyCompiler < AST::Processor
|
||||||
include AST::Sexp
|
include AST::Sexp
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ require "rx-file"
|
|||||||
require_relative "util"
|
require_relative "util"
|
||||||
require_relative "elf/object_writer"
|
require_relative "elf/object_writer"
|
||||||
require_relative "risc"
|
require_relative "risc"
|
||||||
require_relative "mom/mom"
|
require_relative "slot_machine/slot_machine"
|
||||||
require_relative "arm/arm_machine"
|
require_relative "arm/arm_machine"
|
||||||
require_relative "arm/arm_platform"
|
require_relative "arm/arm_platform"
|
||||||
require_relative "vool/statement"
|
require_relative "vool/statement"
|
||||||
|
@ -35,7 +35,7 @@ module RubyX
|
|||||||
end
|
end
|
||||||
|
|
||||||
# The highest level function creates binary code for the given ruby code
|
# 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.
|
# are created and then assembled into BinaryCode objects.
|
||||||
# (no executable is generated, only the binary code and objects needed for a binary)
|
# (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
|
# Transform the incoming ruby source (string) to mom
|
||||||
#
|
#
|
||||||
# The vool is stored using ruby_to_vool,the to_mom is called
|
# The vool is stored using ruby_to_vool,the to_slot is called
|
||||||
# Return Mom Statement
|
# Return SlotMachine Statement
|
||||||
def ruby_to_mom(ruby)
|
def ruby_to_slot(ruby)
|
||||||
ruby_to_vool(ruby)
|
ruby_to_vool(ruby)
|
||||||
to_mom
|
to_slot
|
||||||
end
|
end
|
||||||
|
|
||||||
# Process previously stored vool source to binary.
|
# Process previously stored vool source to binary.
|
||||||
@ -97,14 +97,14 @@ module RubyX
|
|||||||
# Process previously stored vool source to risc.
|
# Process previously stored vool source to risc.
|
||||||
# return a Risc::RiscCollection , a collection of MethodCompilers
|
# return a Risc::RiscCollection , a collection of MethodCompilers
|
||||||
def to_risc()
|
def to_risc()
|
||||||
mom = to_mom
|
mom = to_slot
|
||||||
mom.to_risc()
|
mom.to_risc()
|
||||||
end
|
end
|
||||||
|
|
||||||
# return mom for the previously stored vool source.
|
# return mom for the previously stored vool source.
|
||||||
def to_mom
|
def to_slot
|
||||||
@vool.to_parfait
|
@vool.to_parfait
|
||||||
@vool.to_mom(nil)
|
@vool.to_slot(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# ruby_to_vool compiles the ruby to ast, and then to vool
|
# ruby_to_vool compiles the ruby to ast, and then to vool
|
||||||
|
@ -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.
|
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.
|
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
|
## 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
|
### 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
|
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.
|
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
|
### Linked list
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
module Mom
|
module SlotMachine
|
||||||
# The Compiler/Collection for the Mom level is a collection of Mom level Method
|
# 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.
|
# compilers These will transform to Risc MethodCompilers on the way down.
|
||||||
#
|
#
|
||||||
# As RubyCompiler pools source at the vool level, when several classes are compiled
|
# 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.
|
# proceeding with translate. Thus we have a append method.
|
||||||
#
|
#
|
||||||
class MomCollection
|
class SlotCollection
|
||||||
attr_reader :method_compilers
|
attr_reader :method_compilers
|
||||||
|
|
||||||
# Initialize with an array of risc MethodCompilers
|
# Initialize with an array of risc MethodCompilers
|
||||||
@ -19,8 +19,8 @@ module Mom
|
|||||||
def init_compilers
|
def init_compilers
|
||||||
return if @init_compilers
|
return if @init_compilers
|
||||||
@init_compilers = true
|
@init_compilers = true
|
||||||
add_compiler MomCollection.create_init_compiler
|
add_compiler SlotCollection.create_init_compiler
|
||||||
add_compiler MomCollection.create_mm_compiler
|
add_compiler SlotCollection.create_mm_compiler
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ module Mom
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Append another MomCompilers method_compilers to this one.
|
# Append another SlotMachineCompilers method_compilers to this one.
|
||||||
def append(collection)
|
def append(collection)
|
||||||
@method_compilers.add_method_compiler( collection.method_compilers)
|
@method_compilers.add_method_compiler( collection.method_compilers)
|
||||||
self
|
self
|
@ -7,12 +7,13 @@
|
|||||||
#
|
#
|
||||||
# ### Instruction based
|
# ### Instruction based
|
||||||
#
|
#
|
||||||
# So a machine rather than a language. No control structures, but compare and jump instructions.
|
# So a machine rather than a language. No control structures, but compare and jump
|
||||||
# No send or call, just objects and jump.
|
# instructions. No send or dynamic call, just objects and jump.
|
||||||
# Machine capabilities (instructions) for basic operations. Use of macros for higher level.
|
# Machine capabilities (instructions) for basic operations.
|
||||||
|
# Use of macros for higher level.
|
||||||
|
|
||||||
require_relative "instruction.rb"
|
require_relative "instruction.rb"
|
||||||
require_relative "mom_collection"
|
require_relative "slot_collection"
|
||||||
require_relative "callable_compiler"
|
require_relative "callable_compiler"
|
||||||
require_relative "method_compiler"
|
require_relative "method_compiler"
|
||||||
require_relative "block_compiler"
|
require_relative "block_compiler"
|
@ -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 a layer with concrete syntax tree, just like the ruby layer above.
|
||||||
Vool is just simplified, without fluff, see below.
|
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,
|
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,
|
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
|
The compilation process ends up creating (parfait) objects to represent
|
||||||
things like classes, types and constants. This is done in this layer,
|
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)
|
||||||
|
@ -30,13 +30,13 @@ module Vool
|
|||||||
# When the right hand side is a CallStatement, it must be compiled, before the assign
|
# When the right hand side is a CallStatement, it must be compiled, before the assign
|
||||||
# is executed
|
# is executed
|
||||||
#
|
#
|
||||||
# Derived classes do not implement to_mom, only slot_position
|
# Derived classes do not implement to_slot, only slot_position
|
||||||
def to_mom(compiler)
|
def to_slot(compiler)
|
||||||
to = Mom::SlotDefinition.new(:message , self.slot_position(compiler))
|
to = SlotMachine::SlotDefinition.new(:message , self.slot_position(compiler))
|
||||||
from = @value.to_slot(compiler)
|
from = @value.to_slot_definition(compiler)
|
||||||
assign = Mom::SlotLoad.new(self,to,from)
|
assign = SlotMachine::SlotLoad.new(self,to,from)
|
||||||
return assign unless @value.is_a?(CallStatement)
|
return assign unless @value.is_a?(CallStatement)
|
||||||
@value.to_mom(compiler) << assign
|
@value.to_slot(compiler) << assign
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,8 +9,8 @@ module Vool
|
|||||||
def initialize(value)
|
def initialize(value)
|
||||||
@value = value
|
@value = value
|
||||||
end
|
end
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , [])
|
return SlotMachine::SlotDefinition.new(SlotMachine::IntegerConstant.new(@value) , [])
|
||||||
end
|
end
|
||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_type_by_class_name(:Integer)
|
Parfait.object_space.get_type_by_class_name(:Integer)
|
||||||
@ -37,8 +37,8 @@ module Vool
|
|||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_type_by_class_name(:True)
|
Parfait.object_space.get_type_by_class_name(:True)
|
||||||
end
|
end
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
return Mom::SlotDefinition.new(Parfait.object_space.true_object , [])
|
return SlotMachine::SlotDefinition.new(Parfait.object_space.true_object , [])
|
||||||
end
|
end
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
"true"
|
"true"
|
||||||
@ -49,8 +49,8 @@ module Vool
|
|||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_type_by_class_name(:False)
|
Parfait.object_space.get_type_by_class_name(:False)
|
||||||
end
|
end
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
return Mom::SlotDefinition.new(Parfait.object_space.false_object , [])
|
return SlotMachine::SlotDefinition.new(Parfait.object_space.false_object , [])
|
||||||
end
|
end
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
"false"
|
"false"
|
||||||
@ -61,8 +61,8 @@ module Vool
|
|||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_type_by_class_name(:Nil)
|
Parfait.object_space.get_type_by_class_name(:Nil)
|
||||||
end
|
end
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
return Mom::SlotDefinition.new(Parfait.object_space.nil_object , [])
|
return SlotMachine::SlotDefinition.new(Parfait.object_space.nil_object , [])
|
||||||
end
|
end
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
"nil"
|
"nil"
|
||||||
@ -75,9 +75,9 @@ module Vool
|
|||||||
def initialize(type = nil)
|
def initialize(type = nil)
|
||||||
@my_type = type
|
@my_type = type
|
||||||
end
|
end
|
||||||
def to_slot(compiler)
|
def to_slot_definition(compiler)
|
||||||
@my_type = compiler.receiver_type
|
@my_type = compiler.receiver_type
|
||||||
Mom::SlotDefinition.new(:message , [:receiver])
|
SlotMachine::SlotDefinition.new(:message , [:receiver])
|
||||||
end
|
end
|
||||||
def ct_type
|
def ct_type
|
||||||
@my_type
|
@my_type
|
||||||
@ -91,8 +91,8 @@ module Vool
|
|||||||
def initialize(value)
|
def initialize(value)
|
||||||
@value = value
|
@value = value
|
||||||
end
|
end
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[])
|
return SlotMachine::SlotDefinition.new(SlotMachine::StringConstant.new(@value),[])
|
||||||
end
|
end
|
||||||
def ct_type
|
def ct_type
|
||||||
Parfait.object_space.get_type_by_class_name(:Word)
|
Parfait.object_space.get_type_by_class_name(:Word)
|
||||||
|
@ -10,8 +10,8 @@ module Vool
|
|||||||
|
|
||||||
# When used as right hand side, this tells what data to move to get the result into
|
# 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
|
# a varaible. It is (off course) the return value of the message
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
Mom::SlotDefinition.new(:message ,[ :return_value])
|
SlotMachine::SlotDefinition.new(:message ,[ :return_value])
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
|
@ -42,21 +42,21 @@ module Vool
|
|||||||
# Other statements are not yet allowed (baring in mind that attribute
|
# Other statements are not yet allowed (baring in mind that attribute
|
||||||
# accessors are transformed to methods in the ruby layer )
|
# accessors are transformed to methods in the ruby layer )
|
||||||
#
|
#
|
||||||
# As there is no class equivalnet in code, a MomCollection is returned,
|
# As there is no class equivalnet in code, a SlotCollection is returned,
|
||||||
# which is just a list of Mom::MethodCompilers
|
# which is just a list of SlotMachine::MethodCompilers
|
||||||
# The compilers help to transform the code further, into Risc next
|
# The compilers help to transform the code further, into Risc next
|
||||||
def to_mom( _ )
|
def to_slot( _ )
|
||||||
method_compilers = body.statements.collect do |node|
|
method_compilers = body.statements.collect do |node|
|
||||||
case node
|
case node
|
||||||
when MethodExpression
|
when MethodExpression
|
||||||
node.to_mom(@clazz)
|
node.to_slot(@clazz)
|
||||||
when ClassMethodExpression
|
when ClassMethodExpression
|
||||||
node.to_mom(@clazz.single_class)
|
node.to_slot(@clazz.single_class)
|
||||||
else
|
else
|
||||||
raise "Only methods for now #{node.class}:#{node}"
|
raise "Only methods for now #{node.class}:#{node}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Mom::MomCollection.new(method_compilers)
|
SlotMachine::SlotCollection.new(method_compilers)
|
||||||
end
|
end
|
||||||
|
|
||||||
# goes through the code looking for instance variables and their assignments.
|
# goes through the code looking for instance variables and their assignments.
|
||||||
|
@ -17,7 +17,7 @@ module Vool
|
|||||||
vool_m
|
vool_m
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_mom(clazz)
|
def to_slot(clazz)
|
||||||
raise "not singleton #{clazz.class}" unless clazz.class == Parfait::SingletonClass
|
raise "not singleton #{clazz.class}" unless clazz.class == Parfait::SingletonClass
|
||||||
raise( "no class in #{self}") unless clazz
|
raise( "no class in #{self}") unless clazz
|
||||||
method = clazz.get_instance_method(name )
|
method = clazz.get_instance_method(name )
|
||||||
|
@ -10,29 +10,29 @@ module Vool
|
|||||||
@if_false = if_false
|
@if_false = if_false
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_mom( compiler )
|
def to_slot( compiler )
|
||||||
true_label = Mom::Label.new( self , "true_label_#{object_id.to_s(16)}")
|
true_label = SlotMachine::Label.new( self , "true_label_#{object_id.to_s(16)}")
|
||||||
false_label = Mom::Label.new( self , "false_label_#{object_id.to_s(16)}")
|
false_label = SlotMachine::Label.new( self , "false_label_#{object_id.to_s(16)}")
|
||||||
merge_label = Mom::Label.new( self , "merge_label_#{object_id.to_s(16)}")
|
merge_label = SlotMachine::Label.new( self , "merge_label_#{object_id.to_s(16)}")
|
||||||
|
|
||||||
if @condition.is_a?(CallStatement)
|
if @condition.is_a?(CallStatement)
|
||||||
head = @condition.to_mom(compiler)
|
head = @condition.to_slot(compiler)
|
||||||
head << check_slot(compiler , false_label)
|
head << check_slot(compiler , false_label)
|
||||||
else
|
else
|
||||||
head = check_slot(compiler , false_label)
|
head = check_slot(compiler , false_label)
|
||||||
end
|
end
|
||||||
head << true_label
|
head << true_label
|
||||||
head << if_true.to_mom(compiler) if @if_true
|
head << if_true.to_slot(compiler) if @if_true
|
||||||
head << Mom::Jump.new(merge_label) if @if_false
|
head << SlotMachine::Jump.new(merge_label) if @if_false
|
||||||
head << false_label
|
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 << merge_label if @if_false
|
||||||
head
|
head
|
||||||
end
|
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)
|
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
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
|
@ -11,19 +11,19 @@ module Vool
|
|||||||
# because of normalization (of send), slot_definition is called first,
|
# because of normalization (of send), slot_definition is called first,
|
||||||
# to assign the block to a variable.
|
# 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)
|
# fact never called)
|
||||||
def to_slot(compiler)
|
def to_slot_definition(compiler)
|
||||||
compile(compiler) unless @parfait_block
|
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
|
end
|
||||||
|
|
||||||
# create a block, a compiler for it, comile the bock and add the compiler(code)
|
# create a block, a compiler for it, comile the bock and add the compiler(code)
|
||||||
# to the method compiler for further processing
|
# to the method compiler for further processing
|
||||||
def compile( compiler )
|
def compile( compiler )
|
||||||
parfait_block = self.parfait_block(compiler)
|
parfait_block = self.parfait_block(compiler)
|
||||||
block_compiler = Mom::BlockCompiler.new( parfait_block , compiler.get_method )
|
block_compiler = SlotMachine::BlockCompiler.new( parfait_block , compiler.get_method )
|
||||||
head = body.to_mom( block_compiler )
|
head = body.to_slot( block_compiler )
|
||||||
block_compiler.add_code(head)
|
block_compiler.add_code(head)
|
||||||
compiler.add_method_compiler(block_compiler)
|
compiler.add_method_compiler(block_compiler)
|
||||||
nil
|
nil
|
||||||
|
@ -6,16 +6,16 @@ module Vool
|
|||||||
super(name , SelfExpression.new , arguments)
|
super(name , SelfExpression.new , arguments)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_mom(compiler)
|
def to_slot(compiler)
|
||||||
parts = name.to_s.split("_")
|
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)
|
eval(class_name).new( self , *arguments)
|
||||||
end
|
end
|
||||||
|
|
||||||
# When used as right hand side, this tells what data to move to get the result into
|
# 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
|
# a varaible. It is (off course) the return value of the message
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
Mom::SlotDefinition.new(:message ,[ :return_value])
|
SlotMachine::SlotDefinition.new(:message ,[ :return_value])
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
|
@ -22,8 +22,8 @@ module Vool
|
|||||||
vool_m
|
vool_m
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates the Mom::MethodCompiler that will do the next step
|
# Creates the SlotMachine::MethodCompiler that will do the next step
|
||||||
def to_mom(clazz)
|
def to_slot(clazz)
|
||||||
raise( "no class in #{self}") unless clazz
|
raise( "no class in #{self}") unless clazz
|
||||||
method = clazz.get_instance_method(@name)
|
method = clazz.get_instance_method(@name)
|
||||||
raise( "no method in #{@name} in #{clazz.name}") unless method
|
raise( "no method in #{@name} in #{clazz.name}") unless method
|
||||||
|
@ -16,14 +16,14 @@ module Vool
|
|||||||
# To return form a method in mom instructions we only need to do two things:
|
# To return form a method in mom instructions we only need to do two things:
|
||||||
# - store the given return value, this is a SlotMove
|
# - store the given return value, this is a SlotMove
|
||||||
# - activate return sequence (reinstantiate old message and jump to return address)
|
# - 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)
|
if @return_value.is_a?(CallStatement)
|
||||||
ret = @return_value.to_mom(compiler)
|
ret = @return_value.to_slot(compiler)
|
||||||
ret << slot_load(compiler)
|
ret << slot_load(compiler)
|
||||||
else
|
else
|
||||||
ret = slot_load(compiler)
|
ret = slot_load(compiler)
|
||||||
end
|
end
|
||||||
ret << Mom::ReturnJump.new(self , compiler.return_label )
|
ret << SlotMachine::ReturnJump.new(self , compiler.return_label )
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
@ -31,8 +31,8 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def slot_load(compiler)
|
def slot_load(compiler)
|
||||||
Mom::SlotLoad.new( self , [:message , :return_value] ,
|
SlotMachine::SlotLoad.new( self , [:message , :return_value] ,
|
||||||
@return_value.to_slot(compiler) )
|
@return_value.to_slot_definition(compiler) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ module Vool
|
|||||||
|
|
||||||
# lazy init this, to keep the dependency (which goes to parfait and booting) at bay
|
# lazy init this, to keep the dependency (which goes to parfait and booting) at bay
|
||||||
def dynamic_call
|
def dynamic_call
|
||||||
@dynamic ||= Mom::DynamicCall.new()
|
@dynamic ||= SlotMachine::DynamicCall.new()
|
||||||
end
|
end
|
||||||
|
|
||||||
# A Send breaks down to 2 steps:
|
# 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
|
# So we check, and if find, add the source (vool_method) to the class and start
|
||||||
# compiling the vool for the receiver_type
|
# 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)
|
@receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)
|
||||||
if(@receiver.ct_type)
|
if(@receiver.ct_type)
|
||||||
method = @receiver.ct_type.get_method(@name)
|
method = @receiver.ct_type.get_method(@name)
|
||||||
@ -66,18 +66,18 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def message_setup(compiler,called_method)
|
def message_setup(compiler,called_method)
|
||||||
setup = Mom::MessageSetup.new( called_method )
|
setup = SlotMachine::MessageSetup.new( called_method )
|
||||||
mom_receive = @receiver.to_slot(compiler)
|
mom_receive = @receiver.to_slot_definition(compiler)
|
||||||
arg_target = [:message , :next_message ]
|
arg_target = [:message , :next_message ]
|
||||||
args = []
|
args = []
|
||||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
@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
|
end
|
||||||
setup << Mom::ArgumentTransfer.new(self, mom_receive , args )
|
setup << SlotMachine::ArgumentTransfer.new(self, mom_receive , args )
|
||||||
end
|
end
|
||||||
|
|
||||||
def simple_call(compiler, called_method)
|
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
|
end
|
||||||
|
|
||||||
# this breaks cleanly into two parts:
|
# 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)
|
# 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
|
# conceptually easy in ruby, but we have to compile that "easy" ruby
|
||||||
def cache_check(compiler)
|
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 = 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 << SlotMachine::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::ResolveMethod.new(self, @name , dynamic_call.cache_entry )
|
||||||
check << ok
|
check << ok
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -111,14 +111,14 @@ module Vool
|
|||||||
|
|
||||||
private
|
private
|
||||||
def receiver_type_definition(compiler)
|
def receiver_type_definition(compiler)
|
||||||
defi = @receiver.to_slot(compiler)
|
defi = @receiver.to_slot_definition(compiler)
|
||||||
defi.slots << :type
|
defi.slots << :type
|
||||||
defi
|
defi
|
||||||
end
|
end
|
||||||
def build_condition(ok_label, compiler)
|
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)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
# data. Statements represent code whereas Expressions resolve to data.
|
# data. Statements represent code whereas Expressions resolve to data.
|
||||||
# (in ruby there are no pure statements, everthing resolves 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.
|
# Parfait representations for the main oo players, ie classes and methods.
|
||||||
# The protocol is thus two stage:
|
# The protocol is thus two stage:
|
||||||
# - first to_parfait with implicit side-effects of creating parfait objects that
|
# - first to_parfait with implicit side-effects of creating parfait objects that
|
||||||
# are added to the Parfait object_space
|
# 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)
|
# or a compiler (for methods), or compiler collection (for classes)
|
||||||
#
|
#
|
||||||
module Vool
|
module Vool
|
||||||
@ -43,7 +43,7 @@ module Vool
|
|||||||
#
|
#
|
||||||
# The argument given most often is a compiler
|
# The argument given most often is a compiler
|
||||||
# The default implementation (this) is to raise an error
|
# The default implementation (this) is to raise an error
|
||||||
def to_mom( _ )
|
def to_slot( _ )
|
||||||
raise "Not implemented for #{self}"
|
raise "Not implemented for #{self}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,17 +61,17 @@ module Vool
|
|||||||
def to_parfait
|
def to_parfait
|
||||||
@statements.collect{|s| s.to_parfait}
|
@statements.collect{|s| s.to_parfait}
|
||||||
end
|
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.
|
# 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?
|
raise "Empty list ? #{statements.length}" if empty?
|
||||||
stats = @statements.dup
|
stats = @statements.dup
|
||||||
first = stats.shift.to_mom(compiler)
|
first = stats.shift.to_slot(compiler)
|
||||||
while( nekst = stats.shift )
|
while( nekst = stats.shift )
|
||||||
next_mom = nekst.to_mom(compiler)
|
next_mom = nekst.to_slot(compiler)
|
||||||
first.append next_mom
|
first.append next_mom
|
||||||
end
|
end
|
||||||
first
|
first
|
||||||
|
@ -10,9 +10,9 @@ module Vool
|
|||||||
|
|
||||||
class LocalVariable < Expression
|
class LocalVariable < Expression
|
||||||
include Named
|
include Named
|
||||||
def to_slot(compiler)
|
def to_slot_definition(compiler)
|
||||||
slot_def = compiler.slot_type_for(@name)
|
slot_def = compiler.slot_type_for(@name)
|
||||||
Mom::SlotDefinition.new(:message , slot_def)
|
SlotMachine::SlotDefinition.new(:message , slot_def)
|
||||||
end
|
end
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
name.to_s
|
name.to_s
|
||||||
@ -24,8 +24,8 @@ module Vool
|
|||||||
|
|
||||||
class InstanceVariable < Expression
|
class InstanceVariable < Expression
|
||||||
include Named
|
include Named
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
SlotMachine::SlotDefinition.new(:message , [ :receiver , @name] )
|
||||||
end
|
end
|
||||||
# used to collect type information
|
# used to collect type information
|
||||||
def add_ivar( array )
|
def add_ivar( array )
|
||||||
@ -51,8 +51,8 @@ module Vool
|
|||||||
def ct_type
|
def ct_type
|
||||||
get_named_class.single_class.instance_type
|
get_named_class.single_class.instance_type
|
||||||
end
|
end
|
||||||
def to_slot(_)
|
def to_slot_definition(_)
|
||||||
return Mom::SlotDefinition.new( get_named_class, [])
|
return SlotMachine::SlotDefinition.new( get_named_class, [])
|
||||||
end
|
end
|
||||||
def get_named_class
|
def get_named_class
|
||||||
Parfait.object_space.get_class_by_name(self.name)
|
Parfait.object_space.get_class_by_name(self.name)
|
||||||
|
@ -9,15 +9,15 @@ module Vool
|
|||||||
@body = body
|
@body = body
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_mom( compiler )
|
def to_slot( compiler )
|
||||||
merge_label = Mom::Label.new(self, "merge_label_#{object_id.to_s(16)}")
|
merge_label = SlotMachine::Label.new(self, "merge_label_#{object_id.to_s(16)}")
|
||||||
cond_label = Mom::Label.new(self, "cond_label_#{object_id.to_s(16)}")
|
cond_label = SlotMachine::Label.new(self, "cond_label_#{object_id.to_s(16)}")
|
||||||
codes = cond_label
|
codes = cond_label
|
||||||
codes << @hoisted.to_mom(compiler) if @hoisted
|
codes << @hoisted.to_slot(compiler) if @hoisted
|
||||||
codes << @condition.to_mom(compiler) if @condition.is_a?(SendStatement)
|
codes << @condition.to_slot(compiler) if @condition.is_a?(SendStatement)
|
||||||
codes << Mom::TruthCheck.new(condition.to_slot(compiler) , merge_label)
|
codes << SlotMachine::TruthCheck.new(condition.to_slot_definition(compiler) , merge_label)
|
||||||
codes << @body.to_mom(compiler)
|
codes << @body.to_slot(compiler)
|
||||||
codes << Mom::Jump.new(cond_label)
|
codes << SlotMachine::Jump.new(cond_label)
|
||||||
codes << merge_label
|
codes << merge_label
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ module Vool
|
|||||||
#
|
#
|
||||||
# On the ruby side, normalisation works pretty much the same too.
|
# 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
|
# 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.
|
# 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.
|
# 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:
|
# A Yield breaks down to 2 steps:
|
||||||
# - Setting up the next message, with receiver, arguments, and (importantly) return address
|
# - Setting up the next message, with receiver, arguments, and (importantly) return address
|
||||||
# - a SimpleCall,
|
# - a SimpleCall,
|
||||||
def to_mom( compiler )
|
def to_slot( compiler )
|
||||||
@parfait_block = @block.to_mom(compiler) if @block
|
@parfait_block = @block.to_slot(compiler) if @block
|
||||||
@receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)
|
@receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)
|
||||||
yield_call(compiler)
|
yield_call(compiler)
|
||||||
end
|
end
|
||||||
@ -33,10 +33,10 @@ module Vool
|
|||||||
# this needs run-time variable resolution, which is just not done.
|
# this needs run-time variable resolution, which is just not done.
|
||||||
# we brace ourselves with the check, and exit (later raise) if . . .
|
# we brace ourselves with the check, and exit (later raise) if . . .
|
||||||
def method_check(compiler)
|
def method_check(compiler)
|
||||||
ok_label = Mom::Label.new(self,"method_ok_#{self.object_id}")
|
ok_label = SlotMachine::Label.new(self,"method_ok_#{self.object_id}")
|
||||||
compile_method = Mom::SlotDefinition.new( compiler.get_method , [])
|
compile_method = SlotMachine::SlotDefinition.new( compiler.get_method , [])
|
||||||
runtime_method = Mom::SlotDefinition.new( :message , [ :method] )
|
runtime_method = SlotMachine::SlotDefinition.new( :message , [ :method] )
|
||||||
check = Mom::NotSameCheck.new(compile_method , runtime_method, ok_label)
|
check = SlotMachine::NotSameCheck.new(compile_method , runtime_method, ok_label)
|
||||||
# TODO? Maybe create mom instructions for this
|
# TODO? Maybe create mom instructions for this
|
||||||
#builder = compiler.builder("yield")
|
#builder = compiler.builder("yield")
|
||||||
#Risc::Macro.exit_sequence(builder)
|
#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)
|
# we do a message setup, arg transfer and the a arg_yield (which is similar to dynamic_call)
|
||||||
def yield_arg_block(compiler)
|
def yield_arg_block(compiler)
|
||||||
arg_index = compiler.get_method.arguments_type.get_length - 1
|
arg_index = compiler.get_method.arguments_type.get_length - 1
|
||||||
setup = Mom::MessageSetup.new( arg_index )
|
setup = SlotMachine::MessageSetup.new( arg_index )
|
||||||
mom_receive = @receiver.to_slot(compiler)
|
mom_receive = @receiver.to_slot_definition(compiler)
|
||||||
arg_target = [:message , :next_message ]
|
arg_target = [:message , :next_message ]
|
||||||
args = []
|
args = []
|
||||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
@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
|
end
|
||||||
setup << Mom::ArgumentTransfer.new( self , mom_receive , args )
|
setup << SlotMachine::ArgumentTransfer.new( self , mom_receive , args )
|
||||||
setup << Mom::BlockYield.new( self , arg_index )
|
setup << SlotMachine::BlockYield.new( self , arg_index )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ time comes to move to rubyx, less work.
|
|||||||
ruby test/test_all.rb
|
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
|
Follow the directory structure of the source and may be called unit tests
|
||||||
|
|
||||||
|
@ -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
|
|
@ -6,7 +6,7 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
Risc.boot!
|
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")
|
@builder = Risc::MethodCompiler.new( FakeCallable.new ,label).builder("source")
|
||||||
@label = Risc.label("source","name")
|
@label = Risc.label("source","name")
|
||||||
@start = @builder.compiler.current
|
@start = @builder.compiler.current
|
||||||
|
@ -5,8 +5,8 @@ module Risc
|
|||||||
include Parfait::MethodHelper
|
include Parfait::MethodHelper
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
@method = Mom::MomCollection.compiler_for( :Space , :main,{},{}).callable
|
@method = SlotMachine::SlotCollection.compiler_for( :Space , :main,{},{}).callable
|
||||||
@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)
|
@builder = @compiler.builder(@method)
|
||||||
end
|
end
|
||||||
def test_inserts_built
|
def test_inserts_built
|
||||||
|
@ -7,7 +7,7 @@ module Risc
|
|||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
Risc.boot!
|
Risc.boot!
|
||||||
method = FakeCallable.new
|
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)
|
@builder = @compiler.builder(method)
|
||||||
end
|
end
|
||||||
def test_list
|
def test_list
|
||||||
|
@ -12,7 +12,7 @@ module Risc
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!({})
|
Parfait.boot!({})
|
||||||
label = Mom::Label.new("hi","ho")
|
label = SlotMachine::Label.new("hi","ho")
|
||||||
@compiler = FakeCallableCompiler.new(FakeCallable.new , label)
|
@compiler = FakeCallableCompiler.new(FakeCallable.new , label)
|
||||||
end
|
end
|
||||||
def test_ok
|
def test_ok
|
||||||
@ -25,7 +25,7 @@ module Risc
|
|||||||
assert_equal Label , @compiler.current.class
|
assert_equal Label , @compiler.current.class
|
||||||
assert_equal "ho" , @compiler.current.name
|
assert_equal "ho" , @compiler.current.name
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_slot
|
||||||
assert @compiler.risc_instructions
|
assert @compiler.risc_instructions
|
||||||
end
|
end
|
||||||
def test_const
|
def test_const
|
||||||
|
@ -7,7 +7,7 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
code = in_Test("def meth; @ivar = 5;return ;end")
|
code = in_Test("def meth; @ivar = 5;return ;end")
|
||||||
rubyx = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
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
|
end
|
||||||
def test_compiles_risc
|
def test_compiles_risc
|
||||||
assert_equal Risc::MethodCompiler , @compiler.class
|
assert_equal Risc::MethodCompiler , @compiler.class
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestMomCompilerTranslate < MiniTest::Test
|
class TestSlotMachineCompilerTranslate < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
|
|
||||||
def setup
|
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)
|
@linker = @comp.to_risc.translate(:interpreter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestMomCompilerTranslate < MiniTest::Test
|
class TestSlotMachineCompilerTranslate < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
|
|
||||||
def setup
|
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)
|
@linker = @comp.to_risc.translate(:interpreter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@ module RubyX
|
|||||||
options = RubyX.default_test_options.merge(options)
|
options = RubyX.default_test_options.merge(options)
|
||||||
RubyXCompiler.new(options).ruby_to_vool(input)
|
RubyXCompiler.new(options).ruby_to_vool(input)
|
||||||
end
|
end
|
||||||
def ruby_to_mom(input , options = {})
|
def ruby_to_slot(input , options = {})
|
||||||
options = RubyX.default_test_options.merge(options)
|
options = RubyX.default_test_options.merge(options)
|
||||||
RubyXCompiler.new(options).ruby_to_mom(input)
|
RubyXCompiler.new(options).ruby_to_slot(input)
|
||||||
end
|
end
|
||||||
def compile_in_test( input , options = {})
|
def compile_in_test( input , options = {})
|
||||||
vool = ruby_to_vool(in_Test(input) , options)
|
vool = ruby_to_vool(in_Test(input) , options)
|
||||||
vool.to_parfait
|
vool.to_parfait
|
||||||
vool.to_mom(nil)
|
vool.to_slot(nil)
|
||||||
itest = Parfait.object_space.get_class_by_name(:Test)
|
itest = Parfait.object_space.get_class_by_name(:Test)
|
||||||
assert itest
|
assert itest
|
||||||
itest
|
itest
|
||||||
|
@ -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
|
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.
|
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
|
There a re two test levels to every method. SlotMachine being the first, where we basically just
|
||||||
see if the right Mom instruction has been generated
|
see if the right SlotMachine instruction has been generated
|
||||||
|
|
||||||
## Risc
|
## Risc
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ module RubyX
|
|||||||
module MacroHelper
|
module MacroHelper
|
||||||
def setup
|
def setup
|
||||||
whole ="class Space;def main(arg);return;end;end;" + source
|
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
|
@mom.method_compilers
|
||||||
assert_equal Mom::MomCollection , @mom.class
|
assert_equal SlotMachine::SlotCollection , @mom.class
|
||||||
assert_equal Mom::MethodCompiler , compiler.class
|
assert_equal SlotMachine::MethodCompiler , compiler.class
|
||||||
end
|
end
|
||||||
def compiler
|
def compiler
|
||||||
@mom.method_compilers.last_compiler
|
@mom.method_compilers.last_compiler
|
||||||
|
@ -15,15 +15,15 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal op , compiler.callable.name
|
assert_equal op , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_op
|
def test_instr_op
|
||||||
assert_equal Mom::Comparison , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::Comparison , compiler.slot_instructions.next.class
|
||||||
assert_equal op , compiler.mom_instructions.next.operator
|
assert_equal op , compiler.slot_instructions.next.operator
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal len , compiler.to_risc.risc_instructions.length
|
assert_equal len , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :div10 , compiler.callable.name
|
assert_equal :div10 , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::Div10 , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::Div10 , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 70 , compiler.to_risc.risc_instructions.length
|
assert_equal 70 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :div4 , compiler.callable.name
|
assert_equal :div4 , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::Div4 , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::Div4 , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 41 , compiler.to_risc.risc_instructions.length
|
assert_equal 41 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -14,15 +14,15 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal op , compiler.callable.name
|
assert_equal op , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_op
|
def test_instr_op
|
||||||
assert_equal Mom::IntOperator , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::IntOperator , compiler.slot_instructions.next.class
|
||||||
assert_equal op , compiler.mom_instructions.next.operator
|
assert_equal op , compiler.slot_instructions.next.operator
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 42 , compiler.to_risc.risc_instructions.length
|
assert_equal 42 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :exit , compiler.callable.name
|
assert_equal :exit , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::Exit , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::Exit , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 40 , compiler.to_risc.risc_instructions.length
|
assert_equal 40 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :get_internal_word , compiler.callable.name
|
assert_equal :get_internal_word , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::GetInternalWord , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::GetInternalWord , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 18 , compiler.to_risc.risc_instructions.length
|
assert_equal 18 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :__init , compiler.callable.name
|
assert_equal :__init , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::Init , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::Init , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 31 , compiler.to_risc.risc_instructions.length
|
assert_equal 31 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :method_missing , compiler.callable.name
|
assert_equal :method_missing , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::MethodMissing , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::MethodMissing , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 15 , compiler.to_risc.risc_instructions.length
|
assert_equal 15 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :set_internal_word , compiler.callable.name
|
assert_equal :set_internal_word , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::SetInternalWord , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::SetInternalWord , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 19 , compiler.to_risc.risc_instructions.length
|
assert_equal 19 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :get_internal_byte , compiler.callable.name
|
assert_equal :get_internal_byte , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::GetInternalByte , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::GetInternalByte , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 41 , compiler.to_risc.risc_instructions.length
|
assert_equal 41 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :putstring , compiler.callable.name
|
assert_equal :putstring , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::Putstring , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::Putstring , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 44 , compiler.to_risc.risc_instructions.length
|
assert_equal 44 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -13,14 +13,14 @@ module RubyX
|
|||||||
end
|
end
|
||||||
GET
|
GET
|
||||||
end
|
end
|
||||||
def test_mom_meth
|
def test_slot_meth
|
||||||
assert_equal :set_internal_byte , compiler.callable.name
|
assert_equal :set_internal_byte , compiler.callable.name
|
||||||
end
|
end
|
||||||
def test_instr_len
|
def test_instr_len
|
||||||
assert_equal 7 , compiler.mom_instructions.length
|
assert_equal 7 , compiler.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_instr_get
|
def test_instr_get
|
||||||
assert_equal Mom::SetInternalByte , compiler.mom_instructions.next.class
|
assert_equal SlotMachine::SetInternalByte , compiler.slot_instructions.next.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
assert_equal 20 , compiler.to_risc.risc_instructions.length
|
assert_equal 20 , compiler.to_risc.risc_instructions.length
|
||||||
|
@ -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
|
And since it is early days, we expect errors at every level during this process, which
|
||||||
means testing every layer for every file.
|
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.
|
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
|
The usual workflow is to start with a new file and create tests for vool, mom, risc,binary
|
||||||
|
@ -27,9 +27,9 @@ module RubyX
|
|||||||
assert_equal :Data4 , vool[2].name
|
assert_equal :Data4 , vool[2].name
|
||||||
assert_equal :Data8 , vool[3].name
|
assert_equal :Data8 , vool[3].name
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_slot
|
||||||
mom = @compiler.ruby_to_mom source
|
mom = @compiler.ruby_to_slot source
|
||||||
assert_equal Mom::MomCollection , mom.class
|
assert_equal SlotMachine::SlotCollection , mom.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)
|
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)
|
||||||
|
@ -25,12 +25,12 @@ module RubyX
|
|||||||
assert_equal :Data4 , vool[2].name
|
assert_equal :Data4 , vool[2].name
|
||||||
assert_equal :Data8 , vool[3].name
|
assert_equal :Data8 , vool[3].name
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_slot
|
||||||
vool = @compiler.ruby_to_vool source
|
vool = @compiler.ruby_to_vool source
|
||||||
vool.to_parfait
|
vool.to_parfait
|
||||||
#puts vool
|
#puts vool
|
||||||
mom = vool.to_mom(nil)
|
mom = vool.to_slot(nil)
|
||||||
assert_equal Mom::MomCollection , mom.class
|
assert_equal SlotMachine::SlotCollection , mom.class
|
||||||
end
|
end
|
||||||
def est_risc
|
def est_risc
|
||||||
risc = compiler.ruby_to_risc source
|
risc = compiler.ruby_to_risc source
|
||||||
|
@ -18,9 +18,9 @@ module RubyX
|
|||||||
assert_equal Vool::ClassExpression , vool.class
|
assert_equal Vool::ClassExpression , vool.class
|
||||||
assert_equal :Object , vool.name
|
assert_equal :Object , vool.name
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_slot
|
||||||
mom = compiler.ruby_to_mom source
|
mom = compiler.ruby_to_slot source
|
||||||
assert_equal Mom::MomCollection , mom.class
|
assert_equal SlotMachine::SlotCollection , mom.class
|
||||||
end
|
end
|
||||||
def test_risc
|
def test_risc
|
||||||
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)
|
risc = compiler.ruby_to_risc( get_preload("Space.main") + source)
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module RubyX
|
module RubyX
|
||||||
class TestRubyXCompilerMom < MiniTest::Test
|
class TestRubyXCompilerSlotMachine < MiniTest::Test
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
include RubyXHelper
|
include RubyXHelper
|
||||||
|
|
||||||
def test_creates_class_without_deriviation
|
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)
|
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
||||||
assert clazz , "No classes created"
|
assert clazz , "No classes created"
|
||||||
assert_equal :Object , clazz.super_class_name
|
assert_equal :Object , clazz.super_class_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_deriviation
|
def test_creates_class_deriviation
|
||||||
mom = ruby_to_mom "class Testing ; end"
|
mom = ruby_to_slot "class Testing ; end"
|
||||||
assert mom , "No classes created"
|
assert mom , "No classes created"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_with_deriviation
|
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)
|
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
||||||
assert clazz, "No classes created"
|
assert clazz, "No classes created"
|
||||||
assert_equal :List , clazz.super_class_name
|
assert_equal :List , clazz.super_class_name
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
require_relative '../helper'
|
require_relative '../helper'
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class InstructionMock < Instruction
|
class InstructionMock < Instruction
|
||||||
def initialize
|
def initialize
|
||||||
super("mocking")
|
super("mocking")
|
||||||
end
|
end
|
||||||
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.
|
# quite carefully, ie every instruction, every register.
|
||||||
#
|
#
|
||||||
# This is done with the assert methods in risc_assert
|
# 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
|
# 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
|
# 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
|
# like: assert_equal 8 , all.length , all_str
|
||||||
class MomInstructionTest < MiniTest::Test
|
class SlotMachineInstructionTest < MiniTest::Test
|
||||||
include Output
|
include Output
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestArgumentTransfer < MomInstructionTest
|
class TestArgumentTransfer < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
receiver = SlotDefinition.new(:message , [:receiver])
|
receiver = SlotDefinition.new(:message , [:receiver])
|
||||||
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )
|
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TesBlockYield < MomInstructionTest
|
class TesBlockYield < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
BlockYield.new("source",1)
|
BlockYield.new("source",1)
|
||||||
end
|
end
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestDynamicCall < MomInstructionTest
|
class TestDynamicCall < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
DynamicCall.new(nil,nil)
|
DynamicCall.new(nil,nil)
|
||||||
end
|
end
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestJump < MomInstructionTest
|
class TestJump < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
Jump.new( Label.new("ok" , "target"))
|
Jump.new( Label.new("ok" , "target"))
|
||||||
end
|
end
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestMessageSetupInt < MomInstructionTest
|
class TestMessageSetupInt < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
MessageSetup.new( 1 )
|
MessageSetup.new( 1 )
|
||||||
end
|
end
|
||||||
@ -18,7 +18,7 @@ module Mom
|
|||||||
assert_reg_to_slot risc(3) , :r1 , :r2 , 7
|
assert_reg_to_slot risc(3) , :r1 , :r2 , 7
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestMessageSetupCache < MomInstructionTest
|
class TestMessageSetupCache < SlotMachineInstructionTest
|
||||||
include Parfait::MethodHelper
|
include Parfait::MethodHelper
|
||||||
|
|
||||||
def instruction
|
def instruction
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestNotSameCheck < MomInstructionTest
|
class TestNotSameCheck < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
target = SlotDefinition.new(:message , :caller)
|
target = SlotDefinition.new(:message , :caller)
|
||||||
NotSameCheck.new(target , target , Label.new("ok" , "target"))
|
NotSameCheck.new(target , target , Label.new("ok" , "target"))
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestResolveMethod < MomInstructionTest
|
class TestResolveMethod < SlotMachineInstructionTest
|
||||||
include Parfait::MethodHelper
|
include Parfait::MethodHelper
|
||||||
|
|
||||||
def instruction
|
def instruction
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestReturnJump < MomInstructionTest
|
class TestReturnJump < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
ReturnJump.new("source",Label.new("ok" , "return"))
|
ReturnJump.new("source",Label.new("ok" , "return"))
|
||||||
end
|
end
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestReturnSequence < MomInstructionTest
|
class TestReturnSequence < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
ReturnSequence.new("source")
|
ReturnSequence.new("source")
|
||||||
end
|
end
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSimpleCall < MomInstructionTest
|
class TestSimpleCall < SlotMachineInstructionTest
|
||||||
include Parfait::MethodHelper
|
include Parfait::MethodHelper
|
||||||
|
|
||||||
def instruction
|
def instruction
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotDefinitionBasics < MiniTest::Test
|
class TestSlotDefinitionBasics < MiniTest::Test
|
||||||
|
|
||||||
def slot(slot = :caller)
|
def slot(slot = :caller)
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
|
|
||||||
class TestSlotDefinitionConstant < MiniTest::Test
|
class TestSlotDefinitionConstant < MiniTest::Test
|
||||||
def setup
|
def setup
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotDefinitionKnown1 < MiniTest::Test
|
class TestSlotDefinitionKnown1 < MiniTest::Test
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotDefinitionKnown2 < MiniTest::Test
|
class TestSlotDefinitionKnown2 < MiniTest::Test
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotLoadBasics < MiniTest::Test
|
class TestSlotLoadBasics < MiniTest::Test
|
||||||
|
|
||||||
def test_ins_ok
|
def test_ins_ok
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotLoad1 < MiniTest::Test
|
class TestSlotLoad1 < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotLoad2 < MiniTest::Test
|
class TestSlotLoad2 < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSlotLoad3 < MiniTest::Test
|
class TestSlotLoad3 < MiniTest::Test
|
||||||
include Parfait::MethodHelper
|
include Parfait::MethodHelper
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestSameCheck < MomInstructionTest
|
class TestSameCheck < SlotMachineInstructionTest
|
||||||
def instruction
|
def instruction
|
||||||
target = SlotDefinition.new(:message , :caller)
|
target = SlotDefinition.new(:message , :caller)
|
||||||
TruthCheck.new(target , Label.new("ok" , "target"))
|
TruthCheck.new(target , Label.new("ok" , "target"))
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestIntComp1Risc < BootTest
|
class TestIntComp1Risc < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Integer",:lt)
|
@method = get_compiler("Integer",:lt)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :< , @method.callable.name
|
assert_equal :< , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||||
@ -21,9 +21,9 @@ module Mom
|
|||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Integer",:gt)
|
@method = get_compiler("Integer",:gt)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :> , @method.callable.name
|
assert_equal :> , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestIntDiv10Risc < BootTest
|
class TestIntDiv10Risc < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Integer",:div10)
|
@method = get_compiler("Integer",:div10)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :div10 , @method.callable.name
|
assert_equal :div10 , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestIntDiv4Risc < BootTest
|
class TestIntDiv4Risc < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Integer",:div4)
|
@method = get_compiler("Integer",:div4)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :div4 , @method.callable.name
|
assert_equal :div4 , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,15 +1,15 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestObjectExitRisc < BootTest
|
class TestObjectExitRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@method = get_compiler("Object",:exit)
|
@method = get_compiler("Object",:exit)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :exit , @method.callable.name
|
assert_equal :exit , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,15 +1,15 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestWordGetRisc < BootTest
|
class TestWordGetRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@method = get_compiler("Word",:get)
|
@method = get_compiler("Word",:get)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :get_internal_byte , @method.callable.name
|
assert_equal :get_internal_byte , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,15 +1,15 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestWordGetRisc < BootTest
|
class TestWordGetRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@method = get_compiler("Object",:get)
|
@method = get_compiler("Object",:get)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :get_internal_word , @method.callable.name
|
assert_equal :get_internal_word , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,16 +1,16 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestObjectInitRisc < BootTest
|
class TestObjectInitRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||||
coll = compiler.ruby_to_mom( get_preload("Space.main") )
|
coll = compiler.ruby_to_slot( get_preload("Space.main") )
|
||||||
@method = MomCollection.create_init_compiler
|
@method = SlotCollection.create_init_compiler
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :__init__ , @method.callable.name
|
assert_equal :__init__ , @method.callable.name
|
||||||
assert_equal 2 , @method.mom_instructions.length
|
assert_equal 2 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestObjectMissingRisc < BootTest
|
class TestObjectMissingRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Object",:missing)
|
@method = get_compiler("Object",:missing)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :method_missing , @method.callable.name
|
assert_equal :method_missing , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestIntOpPl < BootTest
|
class TestIntOpPl < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Integer",:and)
|
@method = get_compiler("Integer",:and)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :& , @method.callable.name
|
assert_equal :& , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||||
@ -21,9 +21,9 @@ module Mom
|
|||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Integer",:or)
|
@method = get_compiler("Integer",:or)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :| , @method.callable.name
|
assert_equal :| , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestWordPutRisc < BootTest
|
class TestWordPutRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Word",:put)
|
@method = get_compiler("Word",:put)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :putstring , @method.callable.name
|
assert_equal :putstring , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,15 +1,15 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestWordSetRisc < BootTest
|
class TestWordSetRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@method = get_compiler("Word",:set)
|
@method = get_compiler("Word",:set)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :set_internal_byte , @method.callable.name
|
assert_equal :set_internal_byte , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
module Builtin
|
module Builtin
|
||||||
class TestWordSetRisc < BootTest
|
class TestWordSetRisc < BootTest
|
||||||
def setup
|
def setup
|
||||||
@method = get_compiler("Word",:set)
|
@method = get_compiler("Word",:set)
|
||||||
end
|
end
|
||||||
def test_mom_length
|
def test_slot_length
|
||||||
assert_equal :set_internal_byte , @method.callable.name
|
assert_equal :set_internal_byte , @method.callable.name
|
||||||
assert_equal 7 , @method.mom_instructions.length
|
assert_equal 7 , @method.slot_instructions.length
|
||||||
end
|
end
|
||||||
def test_compile
|
def test_compile
|
||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestBlockCompiler1 < MiniTest::Test
|
class TestBlockCompiler1 < MiniTest::Test
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
|
|
@ -3,13 +3,13 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestBlockArg < MiniTest::Test
|
class TestBlockArg < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ret = compile_mom( as_main("self.main {|elem| elem = 5 } "))
|
@ret = compile_slot( as_main("self.main {|elem| elem = 5 } "))
|
||||||
end
|
end
|
||||||
def test_is_compiler
|
def test_is_compiler
|
||||||
assert_equal Mom::MomCollection , @ret.class
|
assert_equal SlotMachine::SlotCollection , @ret.class
|
||||||
end
|
end
|
||||||
def test_has_method
|
def test_has_method
|
||||||
assert_equal Parfait::CallableMethod , @ret.method_compilers.get_method.class
|
assert_equal Parfait::CallableMethod , @ret.method_compilers.get_method.class
|
||||||
@ -19,9 +19,9 @@ module Vool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestBlockLocal < MiniTest::Test
|
class TestBlockLocal < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
def setup
|
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
|
@block = @ret.method_compilers.get_method.blocks
|
||||||
end
|
end
|
||||||
def test_block_arg_type
|
def test_block_arg_type
|
||||||
@ -38,16 +38,16 @@ module Vool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestBlockMethodArg < MiniTest::Test
|
class TestBlockMethodArg < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
def test_method_arg_compiles
|
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
|
assert ret
|
||||||
end
|
end
|
||||||
def test_method_local_compiles
|
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
|
assert ret
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,5 +1,5 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
module Mom
|
module SlotMachine
|
||||||
class FakeCallableCompiler < CallableCompiler
|
class FakeCallableCompiler < CallableCompiler
|
||||||
def source_name
|
def source_name
|
||||||
"luke"
|
"luke"
|
||||||
@ -20,8 +20,8 @@ module Mom
|
|||||||
assert_equal Label , @compiler.current.class
|
assert_equal Label , @compiler.current.class
|
||||||
assert_equal @compiler.source_name , @compiler.current.name
|
assert_equal @compiler.source_name , @compiler.current.name
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_slot
|
||||||
assert @compiler.mom_instructions
|
assert @compiler.slot_instructions
|
||||||
end
|
end
|
||||||
def test_const
|
def test_const
|
||||||
assert_equal Array , @compiler.constants.class
|
assert_equal Array , @compiler.constants.class
|
24
test/slot_machine/test_class_statement.rb
Normal file
24
test/slot_machine/test_class_statement.rb
Normal 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
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestInstruction < MiniTest::Test
|
class TestInstruction < MiniTest::Test
|
||||||
|
|
||||||
def test_instantiates
|
def test_instantiates
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestMethodCompiler < MiniTest::Test
|
class TestMethodCompiler < MiniTest::Test
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ module Mom
|
|||||||
def in_test_vool(str)
|
def in_test_vool(str)
|
||||||
vool = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(in_Test(str))
|
vool = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(in_Test(str))
|
||||||
vool.to_parfait
|
vool.to_parfait
|
||||||
vool.to_mom(nil)
|
vool.to_slot(nil)
|
||||||
vool
|
vool
|
||||||
end
|
end
|
||||||
def create_method(body = "@ivar = 5;return")
|
def create_method(body = "@ivar = 5;return")
|
||||||
@ -62,10 +62,10 @@ module Mom
|
|||||||
assert_equal 2 , method.frame_type.variable_index(:a)
|
assert_equal 2 , method.frame_type.variable_index(:a)
|
||||||
end
|
end
|
||||||
def constant_setup(input)
|
def constant_setup(input)
|
||||||
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(in_Test(input))
|
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(in_Test(input))
|
||||||
assert_equal Mom::MomCollection , mom.class
|
assert_equal SlotMachine::SlotCollection , mom.class
|
||||||
compiler = mom.method_compilers
|
compiler = mom.method_compilers
|
||||||
assert_equal Mom::MethodCompiler , compiler.class
|
assert_equal SlotMachine::MethodCompiler , compiler.class
|
||||||
compiler
|
compiler
|
||||||
end
|
end
|
||||||
def test_return_label
|
def test_return_label
|
@ -1,34 +1,34 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Mom
|
module SlotMachine
|
||||||
class TestMomCollection < MiniTest::Test
|
class TestSlotCollection < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
|
|
||||||
def setup
|
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
|
end
|
||||||
|
|
||||||
def test_class
|
def test_class
|
||||||
assert_equal MomCollection , @comp.class
|
assert_equal SlotCollection , @comp.class
|
||||||
end
|
end
|
||||||
def test_compilers
|
def test_compilers
|
||||||
assert_equal 3 , @comp.compilers.num_compilers
|
assert_equal 3 , @comp.compilers.num_compilers
|
||||||
end
|
end
|
||||||
def test_init_compilers
|
def test_init_compilers
|
||||||
assert_equal MomCollection , @comp.init_compilers.class
|
assert_equal SlotCollection , @comp.init_compilers.class
|
||||||
end
|
end
|
||||||
def test_compilers_bare
|
def test_compilers_bare
|
||||||
assert_equal 2 , MomCollection.new.compilers.num_compilers
|
assert_equal 2 , SlotCollection.new.compilers.num_compilers
|
||||||
end
|
end
|
||||||
def test_append_class
|
def test_append_class
|
||||||
assert_equal MomCollection, (@comp.append @comp).class
|
assert_equal SlotCollection, (@comp.append @comp).class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestMomCollectionToRisc < MiniTest::Test
|
class TestSlotCollectionToRisc < MiniTest::Test
|
||||||
include MomCompile
|
include SlotMachineCompile
|
||||||
|
|
||||||
def setup
|
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()
|
@collection = @comp.to_risc()
|
||||||
end
|
end
|
||||||
def compiler
|
def compiler
|
@ -30,24 +30,24 @@ module ScopeHelper
|
|||||||
end
|
end
|
||||||
module VoolCompile
|
module VoolCompile
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
include Mom
|
include SlotMachine
|
||||||
include Preloader
|
include Preloader
|
||||||
|
|
||||||
def compile_main( input , preload = nil)
|
def compile_main( input , preload = nil)
|
||||||
input = get_preload(preload) + as_main( input )
|
input = get_preload(preload) + as_main( input )
|
||||||
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
|
collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(input)
|
||||||
assert collection.is_a?(Mom::MomCollection) , collection.class.name
|
assert collection.is_a?(SlotMachine::SlotCollection) , collection.class.name
|
||||||
compiler = collection.compilers.find_compiler_name(:main)
|
compiler = collection.compilers.find_compiler_name(:main)
|
||||||
assert_equal Mom::MethodCompiler , compiler.class
|
assert_equal SlotMachine::MethodCompiler , compiler.class
|
||||||
compiler
|
compiler
|
||||||
end
|
end
|
||||||
def compile_main_block( block_input , method_input = "main_local = 5" , preload = nil)
|
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}}")
|
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)
|
compiler = mom_col.method_compilers.find_compiler_name(:main)
|
||||||
block = mom_col.method_compilers.find_compiler_name(:main_block)
|
block = mom_col.method_compilers.find_compiler_name(:main_block)
|
||||||
assert block
|
assert block
|
||||||
block.mom_instructions.next
|
block.slot_instructions.next
|
||||||
end
|
end
|
||||||
def check_array( should , is )
|
def check_array( should , is )
|
||||||
index = 0
|
index = 0
|
||||||
@ -75,11 +75,11 @@ module VoolCompile
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module MomCompile
|
module SlotMachineCompile
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
|
|
||||||
def compile_mom(input)
|
def compile_slot(input)
|
||||||
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
|
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestClassDef < MiniTest::Test
|
class TestClassDef < MiniTest::Test
|
||||||
include Mom
|
include SlotMachine
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def class_main
|
def class_main
|
||||||
@ -20,8 +20,8 @@ module Vool
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
source = "class Integer<Data4;def +(other);X.int_operator(:+);end;end;" + class_main
|
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)
|
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(source)
|
||||||
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
|
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||||
@ -29,10 +29,10 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_any
|
def test_any
|
||||||
assert_equal Mom::MessageSetup , @ins.class
|
assert_equal SlotMachine::MessageSetup , @ins.class
|
||||||
end
|
end
|
||||||
def test_no_arg
|
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
|
assert_equal 0, @ins.next(1).arguments.length
|
||||||
end
|
end
|
||||||
def test_call_two
|
def test_call_two
|
||||||
|
@ -2,7 +2,7 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestClassInstance < MiniTest::Test
|
class TestClassInstance < MiniTest::Test
|
||||||
include Mom
|
include SlotMachine
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def class_main
|
def class_main
|
||||||
@ -19,10 +19,10 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
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)
|
@compiler = ret.compilers.find_compiler_name(:some_inst)
|
||||||
@main = ret.compilers.find_compiler_name(:main)
|
@main = ret.compilers.find_compiler_name(:main)
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_class_inst
|
def test_class_inst
|
||||||
space_class = Parfait.object_space.get_class
|
space_class = Parfait.object_space.get_class
|
||||||
@ -31,7 +31,7 @@ module Vool
|
|||||||
assert names.index_of(:inst) , names
|
assert names.index_of(:inst) , names
|
||||||
end
|
end
|
||||||
def test_compiler
|
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 Parfait::Type, @compiler.callable.self_type.class
|
||||||
assert_equal 6, @compiler.callable.self_type.names.index_of(:inst) , @compiler.callable.self_type.names
|
assert_equal 6, @compiler.callable.self_type.names.index_of(:inst) , @compiler.callable.self_type.names
|
||||||
end
|
end
|
||||||
@ -40,10 +40,10 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_main_array
|
def test_main_array
|
||||||
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, ReturnJump ,
|
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, ReturnJump ,
|
||||||
Label, ReturnSequence, Label] , @main.mom_instructions.next
|
Label, ReturnSequence, Label] , @main.slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_main_args
|
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 Parfait::Class , args.receiver.known_object.class
|
||||||
assert_equal :Space , args.receiver.known_object.name
|
assert_equal :Space , args.receiver.known_object.name
|
||||||
assert_equal :some_inst , args.receiver.known_object.type.method_names.first
|
assert_equal :some_inst , args.receiver.known_object.type.method_names.first
|
||||||
|
@ -2,7 +2,7 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestClassSendInherited < MiniTest::Test
|
class TestClassSendInherited < MiniTest::Test
|
||||||
include Mom
|
include SlotMachine
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def class_main
|
def class_main
|
||||||
@ -21,15 +21,15 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
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)
|
||||||
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
|
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,
|
||||||
ReturnJump,Label, ReturnSequence , Label] , @ins
|
ReturnJump,Label, ReturnSequence , Label] , @ins
|
||||||
end
|
end
|
||||||
def test_receiver
|
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 0, @ins.next(1).arguments.length
|
||||||
assert_equal SlotDefinition, @ins.next(1).receiver.class
|
assert_equal SlotDefinition, @ins.next(1).receiver.class
|
||||||
assert_equal Parfait::Class, @ins.next(1).receiver.known_object.class
|
assert_equal Parfait::Class, @ins.next(1).receiver.known_object.class
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendClassMom < MiniTest::Test
|
class TestSendClassSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def class_main
|
def class_main
|
||||||
@ -21,8 +21,8 @@ module Vool
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
source = "class Integer < Data4;def +(other);X.int_operator(:+);end;end;" + class_main
|
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)
|
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(source)
|
||||||
@ins = ret.compilers.find_compiler_name(:main).mom_instructions.next
|
@ins = ret.compilers.find_compiler_name(:main).slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_array
|
def test_array
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "../helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module VoolBlocks
|
module VoolBlocks
|
||||||
class TestAssignMom < MiniTest::Test
|
class TestAssignSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ins = compile_main_block( "local = 5" )
|
@ins = compile_main_block( "local = 5" )
|
||||||
end
|
end
|
||||||
def test_block_compiles
|
def test_block_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slot_is_set
|
def test_slot_is_set
|
||||||
assert @ins.left
|
assert @ins.left
|
||||||
@ -23,17 +23,17 @@ module VoolBlocks
|
|||||||
assert @ins.right
|
assert @ins.right
|
||||||
end
|
end
|
||||||
def test_slot_assigns_int
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
class TestAssignSlotMachineInstanceToLocal < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
def setup
|
def setup
|
||||||
@ins = compile_main_block( "local = @a" , "@a = 5") #second arg in method scope
|
@ins = compile_main_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||||
end
|
end
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slots_left
|
def test_slots_left
|
||||||
assert_equal [:local1] , @ins.left.slots
|
assert_equal [:local1] , @ins.left.slots
|
||||||
@ -51,7 +51,7 @@ module VoolBlocks
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slot_is_set
|
def test_slot_is_set
|
||||||
assert @ins.left
|
assert @ins.left
|
||||||
@ -61,19 +61,19 @@ module VoolBlocks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestAssignMomToInstance < MiniTest::Test
|
class TestAssignSlotMachineToInstance < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
def test_assigns_const
|
def test_assigns_const
|
||||||
@ins = compile_main_block( "@a = 5")
|
@ins = compile_main_block( "@a = 5")
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class , @ins
|
||||||
end
|
end
|
||||||
def test_assigns_move
|
def test_assigns_move
|
||||||
@ins = compile_main_block( "@a = arg")
|
@ins = compile_main_block( "@a = arg")
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
assert_equal SlotMachine::SlotDefinition , @ins.right.class , @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "../helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module VoolBlocks
|
module VoolBlocks
|
||||||
class TestClassAssignMom < MiniTest::Test
|
class TestClassAssignSlotMachine < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
@ -14,7 +14,7 @@ module VoolBlocks
|
|||||||
vool = Ruby::RubyCompiler.compile( as_class_method(source) ).to_vool
|
vool = Ruby::RubyCompiler.compile( as_class_method(source) ).to_vool
|
||||||
vool.to_parfait
|
vool.to_parfait
|
||||||
begin
|
begin
|
||||||
vool.to_mom(nil)
|
vool.to_slot(nil)
|
||||||
rescue => err
|
rescue => err
|
||||||
assert err.message.include?("Blocks") , err.message
|
assert err.message.include?("Blocks") , err.message
|
||||||
end
|
end
|
||||||
@ -22,7 +22,7 @@ module VoolBlocks
|
|||||||
def test_assign_compiles
|
def test_assign_compiles
|
||||||
vool = Ruby::RubyCompiler.compile( as_class_method("val = 0") ).to_vool
|
vool = Ruby::RubyCompiler.compile( as_class_method("val = 0") ).to_vool
|
||||||
vool.to_parfait
|
vool.to_parfait
|
||||||
assert_equal Mom::MomCollection , vool.to_mom(nil).class
|
assert_equal SlotMachine::SlotCollection , vool.to_slot(nil).class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module VoolBlocks
|
module VoolBlocks
|
||||||
class TestConditionIfMom < MiniTest::Test
|
class TestConditionIfSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module VoolBlocks
|
module VoolBlocks
|
||||||
class TestSimpleWhileMom < MiniTest::Test
|
class TestSimpleWhileSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@ -4,11 +4,11 @@ module Vool
|
|||||||
# relies on @ins and receiver_type method
|
# relies on @ins and receiver_type method
|
||||||
module SimpleSendHarness
|
module SimpleSendHarness
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
include Mom
|
include SlotMachine
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( send_method , "Integer.div4;Object.get")
|
@compiler = compile_main( send_method , "Integer.div4;Object.get")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_first_not_array
|
def test_first_not_array
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "../helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendCachedSimpleMom < MiniTest::Test
|
class TestSendCachedSimpleSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "5.div8")
|
@compiler = compile_main( "5.div8")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_check_type
|
def test_check_type
|
||||||
assert_equal NotSameCheck , @ins.class , @ins
|
assert_equal NotSameCheck , @ins.class , @ins
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendArgsSendMom < MiniTest::Test
|
class TestSendArgsSendSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4")
|
@compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_array
|
def test_array
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "../helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendCachedSimpleMom < MiniTest::Test
|
class TestSendCachedSimpleSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "a = 5; a.div4;return ")
|
@compiler = compile_main( "a = 5; a.div4;return ")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_check_type
|
def test_check_type
|
||||||
assert_equal NotSameCheck , @ins.next(1).class , @ins
|
assert_equal NotSameCheck , @ins.next(1).class , @ins
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendSelfMom < MiniTest::Test
|
class TestSendSelfSlotMachine < MiniTest::Test
|
||||||
include SimpleSendHarness
|
include SimpleSendHarness
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
@ -23,7 +23,7 @@ module Vool
|
|||||||
assert_equal :get_internal_word, @ins.next(2).method.name
|
assert_equal :get_internal_word, @ins.next(2).method.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestSendSelfImplicitMom < TestSendSelfMom
|
class TestSendSelfImplicitSlotMachine < TestSendSelfSlotMachine
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
"get_internal_word(0)"
|
"get_internal_word(0)"
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendSimpleMom < MiniTest::Test
|
class TestSendSimpleSlotMachine < MiniTest::Test
|
||||||
include SimpleSendHarness
|
include SimpleSendHarness
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
"5.div4;return"
|
"5.div4;return"
|
||||||
end
|
end
|
||||||
def receiver
|
def receiver
|
||||||
[Mom::IntegerConstant , 5]
|
[SlotMachine::IntegerConstant , 5]
|
||||||
end
|
end
|
||||||
def test_call_has_right_method
|
def test_call_has_right_method
|
||||||
assert_equal :div4, @ins.next(2).method.name
|
assert_equal :div4, @ins.next(2).method.name
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendSimpleArgsMom < MiniTest::Test
|
class TestSendSimpleArgsSlotMachine < MiniTest::Test
|
||||||
include SimpleSendHarness
|
include SimpleSendHarness
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
@ -9,14 +9,14 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def receiver
|
def receiver
|
||||||
[Mom::IntegerConstant , 5]
|
[SlotMachine::IntegerConstant , 5]
|
||||||
end
|
end
|
||||||
def test_args_two_move
|
def test_args_two_move
|
||||||
assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0]
|
assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0]
|
||||||
assert_equal :arg2, @ins.next(1).arguments[1].left.slots[1]
|
assert_equal :arg2, @ins.next(1).arguments[1].left.slots[1]
|
||||||
end
|
end
|
||||||
def test_args_two_str
|
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
|
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestAssignMom < MiniTest::Test
|
class TestAssignSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "local = 5;return")
|
@compiler = compile_main( "local = 5;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slot_is_set
|
def test_slot_is_set
|
||||||
assert @ins.left
|
assert @ins.left
|
||||||
@ -25,19 +25,19 @@ module Vool
|
|||||||
assert @ins.right
|
assert @ins.right
|
||||||
end
|
end
|
||||||
def test_slot_assigns_int
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
#otherwise as above, but assigning instance, so should get a SlotLoad
|
#otherwise as above, but assigning instance, so should get a SlotLoad
|
||||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
class TestAssignSlotMachineInstanceToLocal < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "@a = 5 ; local = @a;return")
|
@compiler = compile_main( "@a = 5 ; local = @a;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.next.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.next.class , @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -47,11 +47,11 @@ module Vool
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "arg = 5;return")
|
@compiler = compile_main( "arg = 5;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slot_is_set
|
def test_slot_is_set
|
||||||
assert @ins.left
|
assert @ins.left
|
||||||
@ -64,22 +64,22 @@ module Vool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestAssignMomToInstance < MiniTest::Test
|
class TestAssignSlotMachineToInstance < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
end
|
end
|
||||||
def test_assigns_const
|
def test_assigns_const
|
||||||
@compiler = compile_main( "@a = 5;return")
|
@compiler = compile_main( "@a = 5;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class , @ins
|
||||||
end
|
end
|
||||||
def test_assigns_move
|
def test_assigns_move
|
||||||
@compiler = compile_main( "@a = arg;return")
|
@compiler = compile_main( "@a = arg;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
assert_equal SlotMachine::SlotDefinition , @ins.right.class , @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ module Vool
|
|||||||
def as_ruby
|
def as_ruby
|
||||||
@ruby = Ruby::RubyCompiler.compile(@code)
|
@ruby = Ruby::RubyCompiler.compile(@code)
|
||||||
end
|
end
|
||||||
def as_mom
|
def as_slot
|
||||||
vool = as_ruby.to_vool
|
vool = as_ruby.to_vool
|
||||||
vool.to_parfait
|
vool.to_parfait
|
||||||
vool.to_mom(nil)
|
vool.to_slot(nil)
|
||||||
end
|
end
|
||||||
def test_boot
|
def test_boot
|
||||||
assert_equal String , @code.class
|
assert_equal String , @code.class
|
||||||
@ -36,17 +36,17 @@ module Vool
|
|||||||
assert_equal Vool::ReturnStatement , vool.body.first.body.class
|
assert_equal Vool::ReturnStatement , vool.body.first.body.class
|
||||||
assert_equal Vool::MacroExpression , vool.body.first.body.return_value.class
|
assert_equal Vool::MacroExpression , vool.body.first.body.return_value.class
|
||||||
end
|
end
|
||||||
def test_mom_basic
|
def test_slot_basic
|
||||||
mom = as_mom
|
mom = as_slot
|
||||||
assert_equal Mom::MomCollection , mom.class
|
assert_equal SlotMachine::SlotCollection , mom.class
|
||||||
assert_equal Mom::MethodCompiler , mom.method_compilers.class
|
assert_equal SlotMachine::MethodCompiler , mom.method_compilers.class
|
||||||
end
|
end
|
||||||
def test_mom_instructions
|
def test_slot_instructions
|
||||||
mom_compiler = as_mom.method_compilers
|
mom_compiler = as_slot.method_compilers
|
||||||
assert_equal Mom::Label , mom_compiler.mom_instructions.class
|
assert_equal SlotMachine::Label , mom_compiler.slot_instructions.class
|
||||||
assert_equal Mom::IntOperator , mom_compiler.mom_instructions.next.class
|
assert_equal SlotMachine::IntOperator , mom_compiler.slot_instructions.next.class
|
||||||
assert_equal Mom::SlotLoad , mom_compiler.mom_instructions.next(2).class
|
assert_equal SlotMachine::SlotLoad , mom_compiler.slot_instructions.next(2).class
|
||||||
assert_equal Mom::ReturnJump , mom_compiler.mom_instructions.next(3).class
|
assert_equal SlotMachine::ReturnJump , mom_compiler.slot_instructions.next(3).class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ module Vool
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
|
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
|
||||||
@ins = @compiler.mom_instructions
|
@ins = @compiler.slot_instructions
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_label
|
def test_label
|
||||||
|
@ -33,15 +33,15 @@ module Vool
|
|||||||
m = clazz.single_class.instance_type.get_method(:meth)
|
m = clazz.single_class.instance_type.get_method(:meth)
|
||||||
assert m , "no type method :meth"
|
assert m , "no type method :meth"
|
||||||
end
|
end
|
||||||
def as_mom
|
def as_slot
|
||||||
@clazz.to_parfait
|
@clazz.to_parfait
|
||||||
@clazz.to_mom(nil)
|
@clazz.to_slot(nil)
|
||||||
end
|
end
|
||||||
def test_mom
|
def test_slot
|
||||||
assert_equal :meth , as_mom.method_compilers.callable.name
|
assert_equal :meth , as_slot.method_compilers.callable.name
|
||||||
end
|
end
|
||||||
def test_mom_frame
|
def test_slot_frame
|
||||||
callable = as_mom.method_compilers.callable
|
callable = as_slot.method_compilers.callable
|
||||||
assert callable.frame_type.names.last.to_s.start_with?("tmp_") , "no tmp_ variable #{callable.frame_type.names}"
|
assert callable.frame_type.names.last.to_s.start_with?("tmp_") , "no tmp_ variable #{callable.frame_type.names}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ module Vool
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "if(@a) ; @a = 5 ; end;return")
|
@compiler = compile_main( "if(@a) ; @a = 5 ; end;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_condition_compiles_to_check
|
def test_condition_compiles_to_check
|
||||||
|
@ -7,7 +7,7 @@ module Vool
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "unless(@a) ; @a = 5 ; end;return")
|
@compiler = compile_main( "unless(@a) ; @a = 5 ; end;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_condition_compiles_to_check
|
def test_condition_compiles_to_check
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSimpleIfMom < MiniTest::Test
|
class TestSimpleIfSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
|
@compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_condition_compiles_to_check
|
def test_condition_compiles_to_check
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestConditionIfMom < MiniTest::Test
|
class TestConditionIfSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return" , "Integer.div4")
|
@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
|
end
|
||||||
|
|
||||||
def test_condition
|
def test_condition
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestIvarMom < MiniTest::Test
|
class TestIvarSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "@a = 5")
|
@compiler = compile_main( "@a = 5")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_array
|
def test_array
|
||||||
@ -26,7 +26,7 @@ module Vool
|
|||||||
end
|
end
|
||||||
def test_slot_assigns_something
|
def test_slot_assigns_something
|
||||||
assert @ins.right
|
assert @ins.right
|
||||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
assert_equal SlotMachine::IntegerConstant , @ins.right.known_object.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestLocalMom < MiniTest::Test
|
class TestLocalSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "a = 5")
|
@compiler = compile_main( "a = 5")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_compiles_not_array
|
def test_compiles_not_array
|
||||||
assert Array != @ins.class , @ins
|
assert Array != @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slot_is_set
|
def test_slot_is_set
|
||||||
assert @ins.left
|
assert @ins.left
|
||||||
@ -28,21 +28,21 @@ module Vool
|
|||||||
assert @ins.right
|
assert @ins.right
|
||||||
end
|
end
|
||||||
def test_slot_assigns_int
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestArgMom < MiniTest::Test
|
class TestArgSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
@compiler = compile_main( "arg = 5")
|
@compiler = compile_main( "arg = 5")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
assert_equal SlotMachine::SlotLoad , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_slot_is_set
|
def test_slot_is_set
|
||||||
assert @ins.left
|
assert @ins.left
|
||||||
@ -57,7 +57,7 @@ module Vool
|
|||||||
assert @ins.right
|
assert @ins.right
|
||||||
end
|
end
|
||||||
def test_slot_assigns_int
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
module Mom
|
module SlotMachine
|
||||||
class PlusEquals < Instruction
|
class PlusEquals < Instruction
|
||||||
attr_reader :a , :b
|
attr_reader :a , :b
|
||||||
def initialize(source , arg , b)
|
def initialize(source , arg , b)
|
||||||
@ -14,16 +14,16 @@ module Mom
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestMacroMom < MiniTest::Test
|
class TestMacroSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "X.plus_equals(arg,1)")
|
@compiler = compile_main( "X.plus_equals(arg,1)")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::PlusEquals , @ins.class , @ins
|
assert_equal SlotMachine::PlusEquals , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_arg1
|
def test_arg1
|
||||||
assert_equal Vool::LocalVariable , @ins.a.class
|
assert_equal Vool::LocalVariable , @ins.a.class
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestReturnMom < MiniTest::Test
|
class TestReturnSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "return 5")
|
@compiler = compile_main( "return 5")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
@ -28,7 +28,7 @@ module Vool
|
|||||||
assert @ins.right
|
assert @ins.right
|
||||||
end
|
end
|
||||||
def test_slot_assigns_int
|
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
|
||||||
def test_second_is_return
|
def test_second_is_return
|
||||||
assert_equal ReturnJump, @ins.next(1).class
|
assert_equal ReturnJump, @ins.next(1).class
|
||||||
@ -37,12 +37,12 @@ module Vool
|
|||||||
check_array [SlotLoad, ReturnJump, Label, ReturnSequence, Label], @ins
|
check_array [SlotLoad, ReturnJump, Label, ReturnSequence, Label], @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestReturnSendMom < MiniTest::Test
|
class TestReturnSendSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "return 5.div4" , "Integer.div4" )
|
@compiler = compile_main( "return 5.div4" , "Integer.div4" )
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_return_is_last
|
def test_return_is_last
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSimpleWhileMom < MiniTest::Test
|
class TestSimpleWhileSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "while(@a) ; @a = 5 ; end;return")
|
@compiler = compile_main( "while(@a) ; @a = 5 ; end;return")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_compiles_as_while
|
def test_compiles_as_while
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestWhileConditionMom < MiniTest::Test
|
class TestWhileConditionSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4")
|
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_condition_compiles_to_check
|
def test_condition_compiles_to_check
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestYieldArgsSendMom < MiniTest::Test
|
class TestYieldArgsSendSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "return yield(1)" )
|
@compiler = compile_main( "return yield(1)" )
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_array
|
def test_array
|
||||||
@ -65,12 +65,12 @@ module Vool
|
|||||||
assert_equal ReturnJump, @ins.next(6).class
|
assert_equal ReturnJump, @ins.next(6).class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestYieldNoArgsSendMom < MiniTest::Test
|
class TestYieldNoArgsSendSlotMachine < MiniTest::Test
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@compiler = compile_main( "return yield(some.extra.calls)" )
|
@compiler = compile_main( "return yield(some.extra.calls)" )
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.slot_instructions.next
|
||||||
end
|
end
|
||||||
def test_check_label
|
def test_check_label
|
||||||
assert_equal NotSameCheck, @ins.class
|
assert_equal NotSameCheck, @ins.class
|
||||||
|
Loading…
Reference in New Issue
Block a user