diff --git a/lib/risc/callable_compiler.rb b/lib/risc/callable_compiler.rb index 1700e235..bec24927 100644 --- a/lib/risc/callable_compiler.rb +++ b/lib/risc/callable_compiler.rb @@ -3,7 +3,8 @@ module Risc # CallableCompiler is used to generate risc instructions. It is an abstact base # class shared by BlockCompiler and MethodCompiler - # - risc_instructions: The sequence of risc level instructions that mom was compiled to + # - risc_instructions: The sequence of risc level instructions that slot machine was + # compiled to # Instructions derive from class Instruction and form a linked list # - constants is an array of Parfait objects that need to be available # - callable is a Method of Block diff --git a/lib/risc/method_compiler.rb b/lib/risc/method_compiler.rb index 85a37d75..325fa8a0 100644 --- a/lib/risc/method_compiler.rb +++ b/lib/risc/method_compiler.rb @@ -5,8 +5,8 @@ module Risc class MethodCompiler < CallableCompiler - # Methods starts with a Label, both in risc and mom. - # Pass in the callable(method) and the mom label that the method starts with + # Methods starts with a Label, both in risc and slot. + # Pass in the callable(method) and the slot label that the method starts with def initialize( method , slot_label) super(method , slot_label) end diff --git a/lib/rubyx/rubyx_compiler.rb b/lib/rubyx/rubyx_compiler.rb index 1fcbb16d..705d5e4e 100644 --- a/lib/rubyx/rubyx_compiler.rb +++ b/lib/rubyx/rubyx_compiler.rb @@ -4,7 +4,7 @@ module RubyX # Layers are: # - ruby , always needed as input, string # - vool - intermediate language layer - # - mom - intermediate machine layer + # - slot_machine - intermediate machine layer # - risc - "last" intermediate machine layer # - target - arm or interpreter binary code # - binary - "linked" code, everything need to create an elf binary @@ -65,7 +65,7 @@ module RubyX to_risc() end - # Transform the incoming ruby source (string) to mom + # Transform the incoming ruby source (string) to slot # # The vool is stored using ruby_to_vool,the to_slot is called # Return SlotMachine Statement @@ -97,11 +97,11 @@ module RubyX # Process previously stored vool source to risc. # return a Risc::RiscCollection , a collection of MethodCompilers def to_risc() - mom = to_slot - mom.to_risc() + slot = to_slot + slot.to_risc() end - # return mom for the previously stored vool source. + # return slot_machine for the previously stored vool source. def to_slot @vool.to_parfait @vool.to_slot(nil) diff --git a/lib/slot_machine/README.md b/lib/slot_machine/README.md index 13016e44..8f3cecc4 100644 --- a/lib/slot_machine/README.md +++ b/lib/slot_machine/README.md @@ -1,4 +1,4 @@ -# SlotMachine , Minimal Object Machine +# SlotMachine 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. @@ -48,7 +48,7 @@ no registers (one could see the current message as the only register) ### Instruction based -So mom is a machine layer, rather than a language. +So SlotMachine is a machine layer, rather than a language. No control structures, but compare and jump instructions. No send or call, just objects and jump. diff --git a/lib/slot_machine/block_compiler.rb b/lib/slot_machine/block_compiler.rb index 0fdabd7d..3cfba0e0 100644 --- a/lib/slot_machine/block_compiler.rb +++ b/lib/slot_machine/block_compiler.rb @@ -1,10 +1,10 @@ -module Mom +module SlotMachine # A BlockCompiler is much like a MehtodCompiler, exept for blocks # class BlockCompiler < CallableCompiler - attr_reader :block , :mom_instructions + attr_reader :block , :slot_instructions alias :block :callable def initialize( block , method) @@ -17,7 +17,7 @@ module Mom end def to_risc - risc_compiler = Risc::BlockCompiler.new(@callable , @method , mom_instructions) + risc_compiler = Risc::BlockCompiler.new(@callable , @method , slot_instructions) instructions_to_risc(risc_compiler) #recursive blocks not done risc_compiler diff --git a/lib/slot_machine/callable_compiler.rb b/lib/slot_machine/callable_compiler.rb index 76df5ee4..13805a4c 100644 --- a/lib/slot_machine/callable_compiler.rb +++ b/lib/slot_machine/callable_compiler.rb @@ -1,9 +1,9 @@ -module Mom +module SlotMachine - # CallableCompiler is used to generate mom instructions. It is an abstact base + # CallableCompiler is used to generate slot instructions. It is an abstact base # class shared by BlockCompiler and MethodCompiler - # - mom_instructions: The sequence of mom level instructions that mom was compiled to + # - slot_instructions: The sequence of slot level instructions that was compiled to # Instructions derive from class Instruction and form a linked list class CallableCompiler @@ -12,17 +12,17 @@ module Mom def initialize( callable ) @callable = callable @constants = [] - @mom_instructions = Label.new(source_name, source_name) - @current = start = @mom_instructions + @slot_instructions = Label.new(source_name, source_name) + @current = start = @slot_instructions add_code Label.new( source_name, "return_label") - add_code Mom::ReturnSequence.new(source_name) + add_code SlotMachine::ReturnSequence.new(source_name) add_code Label.new( source_name, "unreachable") @current = start end - attr_reader :mom_instructions , :constants , :callable , :current + attr_reader :slot_instructions , :constants , :callable , :current def return_label - @mom_instructions.each do |ins| + @slot_instructions.each do |ins| next unless ins.is_a?(Label) return ins if ins.name == "return_label" end @@ -43,7 +43,7 @@ module Mom # add a risc instruction after the current (insertion point) # the added instruction will become the new insertion point def add_code( instruction ) - raise "Not an instruction:#{instruction.to_s}:#{instruction.class.name}" unless instruction.is_a?(Mom::Instruction) + raise "Not an instruction:#{instruction.to_s}:#{instruction.class.name}" unless instruction.is_a?(SlotMachine::Instruction) new_current = instruction.last #after insertion this point is lost @current.insert(instruction) #insert after current @current = new_current @@ -60,10 +60,10 @@ module Mom # convert al instruction to risc # method is called by Method/BlockCompiler from to_risc def instructions_to_risc(risc_compiler) - instruction = mom_instructions.next + instruction = slot_instructions.next while( instruction ) - raise "whats this a #{instruction}" unless instruction.is_a?(Mom::Instruction) - #puts "adding mom #{instruction.to_s}:#{instruction.next.to_s}" + raise "whats this a #{instruction}" unless instruction.is_a?(SlotMachine::Instruction) + #puts "adding slot #{instruction.to_s}:#{instruction.next.to_s}" risc_compiler.reset_regs instruction.to_risc( risc_compiler ) #puts "adding risc #{risc.to_s}:#{risc.next.to_s}" diff --git a/lib/slot_machine/instruction.rb b/lib/slot_machine/instruction.rb index c09ed54f..9c2302de 100644 --- a/lib/slot_machine/instruction.rb +++ b/lib/slot_machine/instruction.rb @@ -1,14 +1,14 @@ -module Mom +module SlotMachine - # Base class for MOM instructions + # Base class for SlotMachine instructions # At the base class level instructions are a linked list. # - # Mom::Instructions are created by the Vool level as an intermediate step + # SlotMachine::Instructions are created by the Vool level as an intermediate step # towards the next level down, the Risc level. - # Mom and Risc are both abstract machines (ie have instructions), so both + # SlotMachine and Risc are both abstract machines (ie have instructions), so both # share the linked list functionality (In Util::List) # - # To convert a Mom instruction to it's Risc equivalent to_risc is called + # To convert a SlotMachine instruction to it's Risc equivalent to_risc is called # class Instruction include Util::List @@ -26,7 +26,7 @@ module Mom # to_risc, like the name says, converts the instruction to it's Risc equivalent. # The Risc machine is basically a simple register machine (kind of arm). - # In other words Mom is the higher abstraction and so mom instructions convert + # In other words SlotMachine is the higher abstraction and so slot instructions convert # to many (1-10) risc instructions # # The argument that is passed is a MethodCompiler, which has the method and some diff --git a/lib/slot_machine/instruction/argument_transfer.rb b/lib/slot_machine/instruction/argument_transfer.rb index 1ca7c993..68575cbc 100644 --- a/lib/slot_machine/instruction/argument_transfer.rb +++ b/lib/slot_machine/instruction/argument_transfer.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # Transering the arguments from the current frame into the next frame # diff --git a/lib/slot_machine/instruction/basic_values.rb b/lib/slot_machine/instruction/basic_values.rb index ec5a7270..ea5da0c5 100644 --- a/lib/slot_machine/instruction/basic_values.rb +++ b/lib/slot_machine/instruction/basic_values.rb @@ -1,5 +1,5 @@ -module Mom - # just name scoping the same stuff to mom +module SlotMachine + # just name scoping the same stuff to slot # so we know we are on the way down, keeping our layers seperated # and we can put constant adding into the to_risc methods (instead of on vool classes) class Constant diff --git a/lib/slot_machine/instruction/block_yield.rb b/lib/slot_machine/instruction/block_yield.rb index 8ab2c03b..a68dc563 100644 --- a/lib/slot_machine/instruction/block_yield.rb +++ b/lib/slot_machine/instruction/block_yield.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # A BlockYield calls an argument block. All we need to know is the index # of the argument, and the rest is almost as simple as a SimpleCall diff --git a/lib/slot_machine/instruction/check.rb b/lib/slot_machine/instruction/check.rb index 447c4f4f..213e938a 100644 --- a/lib/slot_machine/instruction/check.rb +++ b/lib/slot_machine/instruction/check.rb @@ -1,6 +1,6 @@ -module Mom +module SlotMachine - # A base class for conditions in MOM + # A base class for conditions in SlotMachine # Checks (if in code, compare in assm) jump or not, depending # The logic we choose is closer to the code logic (the asm is reversed) # When we write an if, the true is the next code, so the Check logic is @@ -9,7 +9,7 @@ module Mom # check does not pass # Note: In assembler a branch on 0 does just that, it branches if the condition # is met. This means that the asm implementation is somewhat the reverse - # of the Mom names. But it's easier to understand (imho) + # of the SlotMachine names. But it's easier to understand (imho) class Check < Instruction attr_reader :false_jump def initialize(false_jump) diff --git a/lib/slot_machine/instruction/dynamic_call.rb b/lib/slot_machine/instruction/dynamic_call.rb index 0b5ddadf..26d82cf9 100644 --- a/lib/slot_machine/instruction/dynamic_call.rb +++ b/lib/slot_machine/instruction/dynamic_call.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # A dynamic call calls a method at runtime. This off course implies that we don't know the # method at compile time and so must "find" it. Resolving, or finding the method, is a diff --git a/lib/slot_machine/instruction/jump.rb b/lib/slot_machine/instruction/jump.rb index 8e93b1c1..f1748e22 100644 --- a/lib/slot_machine/instruction/jump.rb +++ b/lib/slot_machine/instruction/jump.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # Branch jump to the Label given # Eg used at the end of while or end of if_true branch diff --git a/lib/slot_machine/instruction/label.rb b/lib/slot_machine/instruction/label.rb index 8958a7e2..88636f3f 100644 --- a/lib/slot_machine/instruction/label.rb +++ b/lib/slot_machine/instruction/label.rb @@ -1,6 +1,6 @@ -module Mom +module SlotMachine - # A Label is the only legal target for a branch (in Mom, in Risc a BinaryCode is ok too) + # A Label is the only legal target for a branch (in SlotMachine, in Risc a BinaryCode is ok too) # # In the dynamic view (runtime) where the instructions form a graph, # branches fan out, Labels collect. In other words a branch is the place where @@ -8,7 +8,7 @@ module Mom # # A Label has a name which is mainly used for debugging. # - # A Mom::Label converts one2one to a Risc::Label. So in a way it could not be more + # A SlotMachine::Label converts one2one to a Risc::Label. So in a way it could not be more # simple. # Alas, since almost by definition several roads lead to this label, all those # several converted instructions must also point to the identical label on the diff --git a/lib/slot_machine/instruction/message_setup.rb b/lib/slot_machine/instruction/message_setup.rb index 9463ae66..268003ba 100644 --- a/lib/slot_machine/instruction/message_setup.rb +++ b/lib/slot_machine/instruction/message_setup.rb @@ -1,6 +1,6 @@ -module Mom +module SlotMachine - # As reminder: a statically resolved call (the simplest one) becomes three Mom Instructions. + # As reminder: a statically resolved call (the simplest one) becomes three SlotMachine Instructions. # Ie: MessageSetup,ArgumentTransfer,SimpleCall # # MessageSetup does Setup before a call can be made, acquiring and filling the message diff --git a/lib/slot_machine/instruction/not_same_check.rb b/lib/slot_machine/instruction/not_same_check.rb index 9d71abe5..c2cca3f4 100644 --- a/lib/slot_machine/instruction/not_same_check.rb +++ b/lib/slot_machine/instruction/not_same_check.rb @@ -1,12 +1,12 @@ -module Mom +module SlotMachine - # Mom internal check, as the name says to see if two values are not the same + # SlotMachine internal check, as the name says to see if two values are not the same # In other words, we this checks identity, bit-values, pointers # # The values that are compared are defined as SlotDefinitions, ie can be anything # available to the machine through frame message or self # - # Acording to Mom::Check logic, we jump to the given label is the values are the same + # Acording to SlotMachine::Check logic, we jump to the given label is the values are the same # class NotSameCheck < Check attr_reader :left , :right diff --git a/lib/slot_machine/instruction/resolve_method.rb b/lib/slot_machine/instruction/resolve_method.rb index ae1dbb39..10077ce1 100644 --- a/lib/slot_machine/instruction/resolve_method.rb +++ b/lib/slot_machine/instruction/resolve_method.rb @@ -1,7 +1,7 @@ -module Mom +module SlotMachine # Dynamic method resolution is at the heart of a dynamic language, and here - # is the Mom level instruction to do it. + # is the SlotMachine level instruction to do it. # # When the static type can not be determined a CacheEntry is used to store # type and method of the resolved method. The CacheEntry is shared with diff --git a/lib/slot_machine/instruction/return_jump.rb b/lib/slot_machine/instruction/return_jump.rb index c4bd8fbc..c36d899a 100644 --- a/lib/slot_machine/instruction/return_jump.rb +++ b/lib/slot_machine/instruction/return_jump.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # the return jump jumps to the return label # the method setup is such that there is exactly one return_label in a method diff --git a/lib/slot_machine/instruction/return_sequence.rb b/lib/slot_machine/instruction/return_sequence.rb index 63c43926..448728a5 100644 --- a/lib/slot_machine/instruction/return_sequence.rb +++ b/lib/slot_machine/instruction/return_sequence.rb @@ -1,11 +1,11 @@ -module Mom +module SlotMachine # The ReturnSequence models the return from a method. # # This involves the jump to the return address stored in the message, and # the reinstantiation of the previous message. # - # The machine (mom) only ever "knows" one message, the current message. + # The (slot) machine only ever "knows" one message, the current message. # Messages are a double linked list, calling involves going forward, # returning means going back. # diff --git a/lib/slot_machine/instruction/simple_call.rb b/lib/slot_machine/instruction/simple_call.rb index 98bfbb3c..fd853ea3 100644 --- a/lib/slot_machine/instruction/simple_call.rb +++ b/lib/slot_machine/instruction/simple_call.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # A SimpleCall is just that, a simple call. This could be called a function call too, # meaning we managed to resolve the function at compile time and all we have to do is diff --git a/lib/slot_machine/instruction/slot_definition.rb b/lib/slot_machine/instruction/slot_definition.rb index 6b19b6f1..6aaddf01 100644 --- a/lib/slot_machine/instruction/slot_definition.rb +++ b/lib/slot_machine/instruction/slot_definition.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # A SlotDefinition defines a slot. A bit like a variable name but for objects. # # PS: for the interested: A "developement" of Smalltalk was the diff --git a/lib/slot_machine/instruction/slot_load.rb b/lib/slot_machine/instruction/slot_load.rb index 90acd847..3d3f2b3c 100644 --- a/lib/slot_machine/instruction/slot_load.rb +++ b/lib/slot_machine/instruction/slot_load.rb @@ -1,9 +1,9 @@ -module Mom +module SlotMachine # SlotLoad is for moving data into a slot, either from another slot, or constant # A Slot is basically an instance variable, but it must be of known type # - # The value loaded (the right hand side) can be a constant (Mom::Constant) or come from + # The value loaded (the right hand side) can be a constant (SlotMachine::Constant) or come from # another Slot (SlotDefinition) # # The Slot on the left hand side is always a SlotDefinition. @@ -21,9 +21,9 @@ module Mom # @left: A SlotDefinition, or an array that can be passed to the constructor of the # SlotDefinition (see there) # - # @right: A SlotDefinition with slots or a Mom::Constant - # original_source: optinally another mom instruction that will be passed down to created - # risc instructions. (Because SlotLoad is often used internally in mom) + # @right: A SlotDefinition with slots or a SlotMachine::Constant + # original_source: optinally another slot_machine instruction that will be passed down + # to created risc instructions. (Because SlotLoad is often used internally) class SlotLoad < Instruction attr_reader :left , :right , :original_source @@ -33,7 +33,7 @@ module Mom @left , @right = left , right @left = SlotDefinition.new(@left.shift , @left) if @left.is_a? Array @right = SlotDefinition.new(@right.shift , @right) if @right.is_a? Array - raise "right not Mom, #{@right.to_s}" unless @right.is_a?( SlotDefinition ) + raise "right not SlotMachine, #{@right.to_s}" unless @right.is_a?( SlotDefinition ) @original_source = original_source || self end diff --git a/lib/slot_machine/instruction/truth_check.rb b/lib/slot_machine/instruction/truth_check.rb index fd1ff99e..c2bac6b0 100644 --- a/lib/slot_machine/instruction/truth_check.rb +++ b/lib/slot_machine/instruction/truth_check.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # The funny thing about the ruby truth is that it is anything but false or nil # diff --git a/lib/slot_machine/macro/comparison.rb b/lib/slot_machine/macro/comparison.rb index 70e33619..81dfdb2e 100644 --- a/lib/slot_machine/macro/comparison.rb +++ b/lib/slot_machine/macro/comparison.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class Comparison < Macro attr_reader :operator def initialize(name , operator) diff --git a/lib/slot_machine/macro/div10.rb b/lib/slot_machine/macro/div10.rb index cde977eb..320047bc 100644 --- a/lib/slot_machine/macro/div10.rb +++ b/lib/slot_machine/macro/div10.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class Div10 < Macro def to_risc(compiler) s = "div_10 " diff --git a/lib/slot_machine/macro/div4.rb b/lib/slot_machine/macro/div4.rb index 6b1c5ccd..52302f06 100644 --- a/lib/slot_machine/macro/div4.rb +++ b/lib/slot_machine/macro/div4.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class Div4 < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) diff --git a/lib/slot_machine/macro/exit.rb b/lib/slot_machine/macro/exit.rb index 38572aa2..be9f1741 100644 --- a/lib/slot_machine/macro/exit.rb +++ b/lib/slot_machine/macro/exit.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class Exit < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) diff --git a/lib/slot_machine/macro/get_internal_byte.rb b/lib/slot_machine/macro/get_internal_byte.rb index deaf8fd6..509d0d6c 100644 --- a/lib/slot_machine/macro/get_internal_byte.rb +++ b/lib/slot_machine/macro/get_internal_byte.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class GetInternalByte < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) diff --git a/lib/slot_machine/macro/get_internal_word.rb b/lib/slot_machine/macro/get_internal_word.rb index 331b76dd..1a38b7f9 100644 --- a/lib/slot_machine/macro/get_internal_word.rb +++ b/lib/slot_machine/macro/get_internal_word.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class GetInternalWord < Macro def to_risc(compiler) compiler.builder(compiler.source).build do diff --git a/lib/slot_machine/macro/init.rb b/lib/slot_machine/macro/init.rb index 7614d45e..bdbe54a9 100644 --- a/lib/slot_machine/macro/init.rb +++ b/lib/slot_machine/macro/init.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine # Init "method" is the first thing that happens in the machine # There is an inital jump to it, but that's it, no setup, no nothing # @@ -20,7 +20,7 @@ module Mom end builder.reset_names # Set up the call to main, with space as receiver - Mom::MessageSetup.new(main).build_with( builder ) + SlotMachine::MessageSetup.new(main).build_with( builder ) builder.build do message << message[:next_message] space? << Parfait.object_space diff --git a/lib/slot_machine/macro/macro.rb b/lib/slot_machine/macro/macro.rb index e1084f4c..689beb32 100644 --- a/lib/slot_machine/macro/macro.rb +++ b/lib/slot_machine/macro/macro.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class Macro < Instruction def to_s diff --git a/lib/slot_machine/macro/method_missing.rb b/lib/slot_machine/macro/method_missing.rb index 7bb32a28..d9d0f4b5 100644 --- a/lib/slot_machine/macro/method_missing.rb +++ b/lib/slot_machine/macro/method_missing.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class MethodMissing < Macro attr_reader :name diff --git a/lib/slot_machine/macro/object.rb b/lib/slot_machine/macro/object.rb index fea4c03d..ef1920f9 100644 --- a/lib/slot_machine/macro/object.rb +++ b/lib/slot_machine/macro/object.rb @@ -1,3 +1,3 @@ -module Mom +module SlotMachine end diff --git a/lib/slot_machine/macro/operator.rb b/lib/slot_machine/macro/operator.rb index 1c7d58f7..38c2ac5c 100644 --- a/lib/slot_machine/macro/operator.rb +++ b/lib/slot_machine/macro/operator.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class IntOperator < Macro attr_reader :operator def initialize(name , operator) diff --git a/lib/slot_machine/macro/putstring.rb b/lib/slot_machine/macro/putstring.rb index 695eeccc..8be01a91 100644 --- a/lib/slot_machine/macro/putstring.rb +++ b/lib/slot_machine/macro/putstring.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class Putstring < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) @@ -7,7 +7,7 @@ module Mom word! << message[:receiver] integer! << word[Parfait::Word.get_length_index] end - Mom::Macro.emit_syscall( builder , :putstring ) + SlotMachine::Macro.emit_syscall( builder , :putstring ) compiler end end diff --git a/lib/slot_machine/macro/set_internal_byte.rb b/lib/slot_machine/macro/set_internal_byte.rb index ab4f3d70..71312937 100644 --- a/lib/slot_machine/macro/set_internal_byte.rb +++ b/lib/slot_machine/macro/set_internal_byte.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class SetInternalByte < Macro def to_risc(compiler) compiler.builder(compiler.source).build do diff --git a/lib/slot_machine/macro/set_internal_word.rb b/lib/slot_machine/macro/set_internal_word.rb index 4cbbb498..524e233b 100644 --- a/lib/slot_machine/macro/set_internal_word.rb +++ b/lib/slot_machine/macro/set_internal_word.rb @@ -1,4 +1,4 @@ -module Mom +module SlotMachine class SetInternalWord < Macro def to_risc(compiler) compiler.builder(compiler.source).build do diff --git a/lib/slot_machine/method_compiler.rb b/lib/slot_machine/method_compiler.rb index 85c56c05..20b9cf98 100644 --- a/lib/slot_machine/method_compiler.rb +++ b/lib/slot_machine/method_compiler.rb @@ -1,6 +1,6 @@ -module Mom +module SlotMachine - # MethodCompiler is used to generate Mom instructions for methods + # MethodCompiler is used to generate SlotMachine instructions for methods # and to instantiate the methods correctly. class MethodCompiler < CallableCompiler @@ -25,7 +25,7 @@ module Mom # drop down to risc by converting this compilers instructions to risc. # and the doing the same for any block_compilers def to_risc - risc_compiler = Risc::MethodCompiler.new(@callable , mom_instructions) + risc_compiler = Risc::MethodCompiler.new(@callable , slot_instructions) instructions_to_risc(risc_compiler) risc_compiler end @@ -83,8 +83,8 @@ module Mom # Only for init, as init has no return # kind of private def _reset_for_init - @mom_instructions = Label.new(source_name, source_name) - @current = @mom_instructions + @slot_instructions = Label.new(source_name, source_name) + @current = @slot_instructions end end diff --git a/lib/slot_machine/slot_collection.rb b/lib/slot_machine/slot_collection.rb index b72ed38a..905daa4c 100644 --- a/lib/slot_machine/slot_collection.rb +++ b/lib/slot_machine/slot_collection.rb @@ -3,7 +3,7 @@ module SlotMachine # compilers These will transform to Risc MethodCompilers on the way down. # # As RubyCompiler pools source at the vool level, when several classes are compiled - # from vool to mom, several SlotMachineCompilers get instantiated. They must be merged before + # from vool to slot, several SlotMachineCompilers get instantiated. They must be merged before # proceeding with translate. Thus we have a append method. # class SlotCollection @@ -49,8 +49,8 @@ module SlotMachine def to_risc( ) init_compilers riscs =[] - @method_compilers.each_compiler do | mom_c | - riscs << mom_c.to_risc + @method_compilers.each_compiler do | slot_c | + riscs << slot_c.to_risc end # to_risc all compilers # for each suffling constnts and fist label, then all instructions (see below) diff --git a/lib/vool/return_statement.rb b/lib/vool/return_statement.rb index cd5e90c9..85401795 100644 --- a/lib/vool/return_statement.rb +++ b/lib/vool/return_statement.rb @@ -13,7 +13,7 @@ module Vool end # Since the return is normalized to only allow simple values it is simple. - # To return form a method in mom instructions we only need to do two things: + # To return form a method in slot_machine instructions we only need to do two things: # - store the given return value, this is a SlotMove # - activate return sequence (reinstantiate old message and jump to return address) def to_slot( compiler ) diff --git a/lib/vool/send_statement.rb b/lib/vool/send_statement.rb index 6e66e19a..9bf4cf3a 100644 --- a/lib/vool/send_statement.rb +++ b/lib/vool/send_statement.rb @@ -67,13 +67,13 @@ module Vool def message_setup(compiler,called_method) setup = SlotMachine::MessageSetup.new( called_method ) - mom_receive = @receiver.to_slot_definition(compiler) + slot_receive = @receiver.to_slot_definition(compiler) arg_target = [:message , :next_message ] args = [] @arguments.each_with_index do |arg , index| # +1 because of type args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot_definition(compiler)) end - setup << SlotMachine::ArgumentTransfer.new(self, mom_receive , args ) + setup << SlotMachine::ArgumentTransfer.new(self, slot_receive , args ) end def simple_call(compiler, called_method) diff --git a/lib/vool/statement.rb b/lib/vool/statement.rb index 7c0daee8..8dab4ebb 100644 --- a/lib/vool/statement.rb +++ b/lib/vool/statement.rb @@ -16,7 +16,7 @@ # The protocol is thus two stage: # - first to_parfait with implicit side-effects of creating parfait objects that # are added to the Parfait object_space -# - second to_slot , which will return a mom version of the statement. This may be code +# - second to_slot , which will return a slot version of the statement. This may be code # or a compiler (for methods), or compiler collection (for classes) # module Vool @@ -38,8 +38,8 @@ module Vool raise "Called when it shouldn't #{self.class}" end - # create mom version of the statement, this is often code, that is added to the - # compiler, but for methods it is a compiler and for classes a collection of those. + # create slot_machine version of the statement, this is often code, that is added + # to the compiler, but for methods it is a compiler and for classes a collection of those. # # The argument given most often is a compiler # The default implementation (this) is to raise an error diff --git a/lib/vool/statements.rb b/lib/vool/statements.rb index b3170593..b570d7eb 100644 --- a/lib/vool/statements.rb +++ b/lib/vool/statements.rb @@ -71,8 +71,8 @@ module Vool stats = @statements.dup first = stats.shift.to_slot(compiler) while( nekst = stats.shift ) - next_mom = nekst.to_slot(compiler) - first.append next_mom + next_slot = nekst.to_slot(compiler) + first.append next_slot end first end diff --git a/lib/vool/yield_statement.rb b/lib/vool/yield_statement.rb index 8d132664..be6ce139 100644 --- a/lib/vool/yield_statement.rb +++ b/lib/vool/yield_statement.rb @@ -37,7 +37,7 @@ module Vool compile_method = SlotMachine::SlotDefinition.new( compiler.get_method , []) runtime_method = SlotMachine::SlotDefinition.new( :message , [ :method] ) check = SlotMachine::NotSameCheck.new(compile_method , runtime_method, ok_label) - # TODO? Maybe create mom instructions for this + # TODO? Maybe create slot instructions for this #builder = compiler.builder("yield") #Risc::Macro.exit_sequence(builder) #check << builder.built @@ -49,13 +49,13 @@ module Vool def yield_arg_block(compiler) arg_index = compiler.get_method.arguments_type.get_length - 1 setup = SlotMachine::MessageSetup.new( arg_index ) - mom_receive = @receiver.to_slot_definition(compiler) + slot_receive = @receiver.to_slot_definition(compiler) arg_target = [:message , :next_message ] args = [] @arguments.each_with_index do |arg , index| # +1 because of type args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot_definition(compiler)) end - setup << SlotMachine::ArgumentTransfer.new( self , mom_receive , args ) + setup << SlotMachine::ArgumentTransfer.new( self , slot_receive , args ) setup << SlotMachine::BlockYield.new( self , arg_index ) end diff --git a/test/risc/interpreter/calling/test_plus.rb b/test/risc/interpreter/calling/test_plus.rb index fdd757cf..3fedca28 100644 --- a/test/risc/interpreter/calling/test_plus.rb +++ b/test/risc/interpreter/calling/test_plus.rb @@ -9,7 +9,7 @@ module Risc @string_input = as_main("return 5 + 5") super end -#FIXME should be mom macro test, no need to interpret +#FIXME should be macro test, no need to interpret def test_chain #show_main_ticks # get output of what is check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5 diff --git a/test/rubyx/macro/README.md b/test/rubyx/macro/README.md index 6e81d946..57069391 100644 --- a/test/rubyx/macro/README.md +++ b/test/rubyx/macro/README.md @@ -1,18 +1,7 @@ -## Pre - testing builtin - -In the process of moving builtin from mom to parfait. Considering we started at risc, this -is progress. - -Builtin methods should (will) use the Macro idea to actually become code and land in -the parfait code. - -On the way there, we start by Testing and moving the old ones. Since we want to be able -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. ## SlotMachine level -There a re two test levels to every method. SlotMachine being the first, where we basically just +There are two test levels to every method. SlotMachine being the first, where we basically just see if the right SlotMachine instruction has been generated ## Risc diff --git a/test/rubyx/macro/helper.rb b/test/rubyx/macro/helper.rb index 04acfc6d..5f73094c 100644 --- a/test/rubyx/macro/helper.rb +++ b/test/rubyx/macro/helper.rb @@ -4,13 +4,13 @@ module RubyX module MacroHelper def setup whole ="class Space;def main(arg);return;end;end;" + source - @mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(whole) - @mom.method_compilers - assert_equal SlotMachine::SlotCollection , @mom.class + @slot = RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(whole) + @slot.method_compilers + assert_equal SlotMachine::SlotCollection , @slot.class assert_equal SlotMachine::MethodCompiler , compiler.class end def compiler - @mom.method_compilers.last_compiler + @slot.method_compilers.last_compiler end end diff --git a/test/rubyx/parfait/README.md b/test/rubyx/parfait/README.md index 2cf08b1b..833e0413 100644 --- a/test/rubyx/parfait/README.md +++ b/test/rubyx/parfait/README.md @@ -11,7 +11,7 @@ means testing every layer for every file. Rather than create parfait tests for every layer (ie in the vool/slot_machine/risc directories) we have one file per parfait file here. Each file tests all layers. -The usual workflow is to start with a new file and create tests for vool, mom, risc,binary +The usual workflow is to start with a new file and create tests for vool, slot_machine, risc,binary in that order. Possibly fixing the compiler on the way. Then adding the file to the RubyXCompiler parfait load list. diff --git a/test/rubyx/parfait/test_data_object.rb b/test/rubyx/parfait/test_data_object.rb index 48818aed..98626348 100644 --- a/test/rubyx/parfait/test_data_object.rb +++ b/test/rubyx/parfait/test_data_object.rb @@ -28,8 +28,8 @@ module RubyX assert_equal :Data8 , vool[3].name end def test_slot - mom = @compiler.ruby_to_slot source - assert_equal SlotMachine::SlotCollection , mom.class + slot = @compiler.ruby_to_slot source + assert_equal SlotMachine::SlotCollection , slot.class end def test_risc risc = compiler.ruby_to_risc( get_preload("Space.main") + source) diff --git a/test/rubyx/parfait/test_integer.rb b/test/rubyx/parfait/test_integer.rb index a33facfc..dfbb155f 100644 --- a/test/rubyx/parfait/test_integer.rb +++ b/test/rubyx/parfait/test_integer.rb @@ -29,8 +29,8 @@ module RubyX vool = @compiler.ruby_to_vool source vool.to_parfait #puts vool - mom = vool.to_slot(nil) - assert_equal SlotMachine::SlotCollection , mom.class + slot = vool.to_slot(nil) + assert_equal SlotMachine::SlotCollection , slot.class end def est_risc risc = compiler.ruby_to_risc source diff --git a/test/rubyx/parfait/test_object.rb b/test/rubyx/parfait/test_object.rb index d0f43445..df4843b8 100644 --- a/test/rubyx/parfait/test_object.rb +++ b/test/rubyx/parfait/test_object.rb @@ -19,8 +19,8 @@ module RubyX assert_equal :Object , vool.name end def test_slot - mom = compiler.ruby_to_slot source - assert_equal SlotMachine::SlotCollection , mom.class + slot = compiler.ruby_to_slot source + assert_equal SlotMachine::SlotCollection , slot.class end def test_risc risc = compiler.ruby_to_risc( get_preload("Space.main") + source) diff --git a/test/rubyx/test_rubyx_compiler1.rb b/test/rubyx/test_rubyx_compiler1.rb index 940dafdd..e7aba112 100644 --- a/test/rubyx/test_rubyx_compiler1.rb +++ b/test/rubyx/test_rubyx_compiler1.rb @@ -13,8 +13,8 @@ module RubyX end def test_creates_class_deriviation - mom = ruby_to_slot "class Testing ; end" - assert mom , "No classes created" + slot = ruby_to_slot "class Testing ; end" + assert slot , "No classes created" end def test_creates_class_with_deriviation diff --git a/test/slot_machine/instruction/helper.rb b/test/slot_machine/instruction/helper.rb index bab01a63..38bd1f76 100644 --- a/test/slot_machine/instruction/helper.rb +++ b/test/slot_machine/instruction/helper.rb @@ -7,7 +7,7 @@ module SlotMachine end end - # Most SlotMachineInstructionTests test the risc instructions of the mom instruction + # Most SlotMachineInstructionTests test the risc instructions of the slot instruction # quite carefully, ie every instruction, every register. # # This is done with the assert methods in risc_assert diff --git a/test/slot_machine/macro/helper.rb b/test/slot_machine/macro/helper.rb index 7a2dd9a4..fd37eba9 100644 --- a/test/slot_machine/macro/helper.rb +++ b/test/slot_machine/macro/helper.rb @@ -1,13 +1,13 @@ require_relative "../helper" -module Mom +module SlotMachine module Builtin class BootTest < MiniTest::Test include Preloader def get_compiler(clazz , name) compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options) - coll = compiler.ruby_to_mom( get_preload("Space.main;#{clazz}.#{name}") ) + coll = compiler.ruby_to_slot( get_preload("Space.main;#{clazz}.#{name}") ) @method = coll.method_compilers.last_compiler @method end diff --git a/test/slot_machine/test_method_compiler.rb b/test/slot_machine/test_method_compiler.rb index 6eb6d456..44280fef 100644 --- a/test/slot_machine/test_method_compiler.rb +++ b/test/slot_machine/test_method_compiler.rb @@ -62,9 +62,9 @@ module SlotMachine assert_equal 2 , method.frame_type.variable_index(:a) end def constant_setup(input) - mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(in_Test(input)) - assert_equal SlotMachine::SlotCollection , mom.class - compiler = mom.method_compilers + slot = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot(in_Test(input)) + assert_equal SlotMachine::SlotCollection , slot.class + compiler = slot.method_compilers assert_equal SlotMachine::MethodCompiler , compiler.class compiler end diff --git a/test/support/compiling.rb b/test/support/compiling.rb index fbc46c8d..dc4588ae 100644 --- a/test/support/compiling.rb +++ b/test/support/compiling.rb @@ -43,9 +43,9 @@ module VoolCompile end def compile_main_block( block_input , method_input = "main_local = 5" , preload = nil) source = get_preload(preload) + as_main("#{method_input} ; self.main{|val| #{block_input}}") - mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot( source ) - compiler = mom_col.method_compilers.find_compiler_name(:main) - block = mom_col.method_compilers.find_compiler_name(:main_block) + slot_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_slot( source ) + compiler = slot_col.method_compilers.find_compiler_name(:main) + block = slot_col.method_compilers.find_compiler_name(:main_block) assert block block.slot_instructions.next end diff --git a/test/vool/test_builtin.rb b/test/vool/test_builtin.rb index 3e6d219d..26d3323e 100644 --- a/test/vool/test_builtin.rb +++ b/test/vool/test_builtin.rb @@ -37,16 +37,16 @@ module Vool assert_equal Vool::MacroExpression , vool.body.first.body.return_value.class end def test_slot_basic - mom = as_slot - assert_equal SlotMachine::SlotCollection , mom.class - assert_equal SlotMachine::MethodCompiler , mom.method_compilers.class + slot = as_slot + assert_equal SlotMachine::SlotCollection , slot.class + assert_equal SlotMachine::MethodCompiler , slot.method_compilers.class end def test_slot_instructions - mom_compiler = as_slot.method_compilers - assert_equal SlotMachine::Label , mom_compiler.slot_instructions.class - assert_equal SlotMachine::IntOperator , mom_compiler.slot_instructions.next.class - assert_equal SlotMachine::SlotLoad , mom_compiler.slot_instructions.next(2).class - assert_equal SlotMachine::ReturnJump , mom_compiler.slot_instructions.next(3).class + slot_compiler = as_slot.method_compilers + assert_equal SlotMachine::Label , slot_compiler.slot_instructions.class + assert_equal SlotMachine::IntOperator , slot_compiler.slot_instructions.next.class + assert_equal SlotMachine::SlotLoad , slot_compiler.slot_instructions.next(2).class + assert_equal SlotMachine::ReturnJump , slot_compiler.slot_instructions.next(3).class end end end