diff --git a/lib/mom.rb b/lib/mom.rb index 3a07947f..798e634c 100644 --- a/lib/mom.rb +++ b/lib/mom.rb @@ -1,6 +1,6 @@ # 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. -# +# # ### Tree based: So almost 1-1 from vool # # ### Use object memory : object to object transfer + no registers @@ -14,4 +14,5 @@ module Mom end -require_relative "mom/instruction.rb" +require_relative "mom/instruction/instruction.rb" +require_relative "mom/statement/statement.rb" diff --git a/lib/mom/README.md b/lib/mom/README.md index c25a0fb5..d04e9346 100644 --- a/lib/mom/README.md +++ b/lib/mom/README.md @@ -62,7 +62,7 @@ To make the transition even easier, it is done in two steps. ## 1. Everything but control structures -So we go from language to machine as the first step, in terms of memory instructions. +wSo we go from language to machine as the first step, in terms of memory instructions. Memory gets moved around between the main machine objects (frames and messages). But control structures stay "intact", so we stay at tree structure @@ -77,4 +77,4 @@ After this, it is quite trivial to translate to risc, as it mostly expands instr I hope that in the future this simple 2 stage pipeline will expand into more steps. This is the ideal layer to do code analysis and meaningful optimisations, as one can still -understand what is going on in higher terms. +understand what is going on in higher terms. diff --git a/lib/mom/argument_transfer.rb b/lib/mom/instruction/argument_transfer.rb similarity index 100% rename from lib/mom/argument_transfer.rb rename to lib/mom/instruction/argument_transfer.rb diff --git a/lib/mom/basic_values.rb b/lib/mom/instruction/basic_values.rb similarity index 100% rename from lib/mom/basic_values.rb rename to lib/mom/instruction/basic_values.rb diff --git a/lib/mom/dynamic_call.rb b/lib/mom/instruction/dynamic_call.rb similarity index 100% rename from lib/mom/dynamic_call.rb rename to lib/mom/instruction/dynamic_call.rb diff --git a/lib/mom/instruction.rb b/lib/mom/instruction/instruction.rb similarity index 91% rename from lib/mom/instruction.rb rename to lib/mom/instruction/instruction.rb index 5b5ed6ee..56f3d23d 100644 --- a/lib/mom/instruction.rb +++ b/lib/mom/instruction/instruction.rb @@ -17,7 +17,7 @@ module Mom @name = name end def to_risc(compiler) - Risc::Label.new(self,name) + Risc::Label.new(self,name) end end end @@ -32,4 +32,3 @@ require_relative "slot_load" require_relative "return_sequence" require_relative "message_setup" require_relative "argument_transfer" -require_relative "statement" diff --git a/lib/mom/jump.rb b/lib/mom/instruction/jump.rb similarity index 100% rename from lib/mom/jump.rb rename to lib/mom/instruction/jump.rb diff --git a/lib/mom/message_setup.rb b/lib/mom/instruction/message_setup.rb similarity index 100% rename from lib/mom/message_setup.rb rename to lib/mom/instruction/message_setup.rb diff --git a/lib/mom/not_same_check.rb b/lib/mom/instruction/not_same_check.rb similarity index 100% rename from lib/mom/not_same_check.rb rename to lib/mom/instruction/not_same_check.rb diff --git a/lib/mom/return_sequence.rb b/lib/mom/instruction/return_sequence.rb similarity index 100% rename from lib/mom/return_sequence.rb rename to lib/mom/instruction/return_sequence.rb diff --git a/lib/mom/simple_call.rb b/lib/mom/instruction/simple_call.rb similarity index 100% rename from lib/mom/simple_call.rb rename to lib/mom/instruction/simple_call.rb diff --git a/lib/mom/slot_load.rb b/lib/mom/instruction/slot_load.rb similarity index 100% rename from lib/mom/slot_load.rb rename to lib/mom/instruction/slot_load.rb diff --git a/lib/mom/truth_check.rb b/lib/mom/instruction/truth_check.rb similarity index 100% rename from lib/mom/truth_check.rb rename to lib/mom/instruction/truth_check.rb diff --git a/lib/mom/if_statement.rb b/lib/mom/statement/if_statement.rb similarity index 100% rename from lib/mom/if_statement.rb rename to lib/mom/statement/if_statement.rb diff --git a/lib/mom/statement/statement.rb b/lib/mom/statement/statement.rb new file mode 100644 index 00000000..c5379986 --- /dev/null +++ b/lib/mom/statement/statement.rb @@ -0,0 +1,15 @@ +module Mom + class Statement + include Common::List + # flattening will change the structure from a tree to a linked list (and use + # nekst to do so) + def flatten(options = {}) + raise "not implemented for #{self}" + end + end + +end + +require_relative "statements" +require_relative "if_statement" +require_relative "while_statement" diff --git a/lib/mom/statement.rb b/lib/mom/statement/statements.rb similarity index 59% rename from lib/mom/statement.rb rename to lib/mom/statement/statements.rb index 9b7cc8d1..6ec80161 100644 --- a/lib/mom/statement.rb +++ b/lib/mom/statement/statements.rb @@ -1,13 +1,4 @@ module Mom - class Statement - include Common::List - # flattening will change the structure from a tree to a linked list (and use - # nekst to do so) - def flatten(options = {}) - raise "not implemented for #{self}" - end - end - class Statements < Statement include Common::Statements @@ -26,8 +17,4 @@ module Mom } end end - end - -require_relative "if_statement" -require_relative "while_statement" diff --git a/lib/mom/while_statement.rb b/lib/mom/statement/while_statement.rb similarity index 100% rename from lib/mom/while_statement.rb rename to lib/mom/statement/while_statement.rb