diff --git a/README.md b/README.md index 4b15bb6c..37e8ff9d 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ Salama is about native code generation in and of ruby. It is probably best to read the [The Book](http://dancinglightning.gitbooks.io/the-object-machine/content/) first. -The current third rewrite adds a system language, with the idea of compiling ruby to that language, Phisol. -The original ruby parser has been remodeled to parse Phisol and later we will use whitequarks -parser to parse ruby. Then it will be ruby --> Phisol --> assembler --> binary . +The current third rewrite adds a system language, with the idea of compiling ruby to that language, Soml. +The original ruby parser has been remodeled to parse Soml and later we will use whitequarks +parser to parse ruby. Then it will be ruby --> Soml --> assembler --> binary . ## Done @@ -69,11 +69,11 @@ As said, "Hello world" comes out and does use syscall 4. Also the program stops by syscall exit. The full list is on the net and involves mostly just work. -### Parse Phisol +### Parse Soml -Parse Phisol, using Parslet. This has been separated out as it's own gem, [salama-reader](https://github.com/salama/salama-reader). +Parse Soml, using Parslet. This has been separated out as it's own gem, [salama-reader](https://github.com/salama/salama-reader). -Phisol is now fully typed (all variables, arguments and return). Also it has statements, unlike ruby +Soml is now fully typed (all variables, arguments and return). Also it has statements, unlike ruby where everything is an statements. Statements have no value. Otherwise it is quite basic, and it's main purpose is to have an oo system language to compile to. @@ -108,11 +108,11 @@ exchange format, have the core read that, and use the mechanism to achieve langu ## Status -Currently all the work is on the Phisol front. Also documenting the *small* change of a new language. +Currently all the work is on the Soml front. Also documenting the *small* change of a new language. -I'll do some simple string and fibo examples in Phisol next. +I'll do some simple string and fibo examples in Soml next. -Next will be the multiple return feature and then to try to compile ruby to Phisol. +Next will be the multiple return feature and then to try to compile ruby to Soml. ## Future diff --git a/lib/parfait/README.md b/lib/parfait/README.md index 60c4714c..22cd15c8 100644 --- a/lib/parfait/README.md +++ b/lib/parfait/README.md @@ -1,7 +1,15 @@ +## Notice of change + +The stuff below, like the whole of Parfait, was written before soml. Ie before there was a seperate +language to compile a higher language to. Soml is not so dynamic, could do without much of the +ObjectSpace that is the core of Parfait. + +So things will change. How will become clear when soml is finished. + ### Parfait: a thin layer Parfait is the run-time of the **vm**. -To be more precise, it is that part of the run-time needed to boot ruby. +To be more precise, it is that part of the run-time needed to boot soml. The run-time needs to contain quite a lot of functionality for a dynamic system. And a large part of that functionality must actually be used at compile time too. @@ -10,7 +18,7 @@ We reuse the Parfait code at compile-time, to create the data for the compiled v To do this the vm (re) defines the object memory (in parfait_adapter). To do the actual compiling we parse and compile the parfait code and inline it to -appropriate places (ie send, get_instance_variable etc). We have to inline to avoid recursion. +appropriate places. A work in progress that started from here : http://salama.github.io/2014/06/10/more-clarity.html went on here http://salama.github.io/2014/07/05/layers-vs-passes.html @@ -25,31 +33,9 @@ It's too simple: just slips off the mind like a fish into water. Parfait has a brother, the Builtin module. Builtin contains everything that can not be coded in ruby, but we still need (things like List access). -#### Example: Message send - -It felt a little stupid that it took me so long to notice that sending a message is very closely -related to the existing ruby method Object.send - -Off course Object.send takes symbol and the arguments and has the receiver, so all the elements of our -Message are there. And the process that Object.send needs to do is exactly that: -send that message, ie find the correct method according to the old walk up the inheritance tree rules and dispatch it. - -And as all this happens at runtime, "all" we have to do is code this logic. And since it is at runtime, -we can do it in ruby (as i said, this get's compiled and run, just like the program). - -But what about the infinite loop problem: - -There was a little step left out: Off course the method gets compiled at compile-time and so -we don't just blindly dispatch: we catch the simple cases that we know about: -layout, type instance variables and compile time known functions. -Part of those are some that we just don't allow to be overridden. - -Also what in ruby is object.send is Message.send in salama, as it is the message we are sending and -which defines all the data we need (not the object). The object receives, it does not send. - ### Vm vs language- core -Parfait is not the language (ie ruby) core library. Core library functionality differs between +Parfait is not the language core library. Core library functionality differs between languages and so the language core lib must be on top of the vm parfait. To make this point clear, i have started using different names for the core classes. Hopefully @@ -57,8 +43,3 @@ more sensible ones, ie List instead of Array, Dictionary instead of Hash. Also Parfait is meant to be as thin as humanly possibly, so extra (nice to have) functionality will be in future modules. - -So the Namespace of the Runtime is actually Parfait (not nothing as in ruby). -Only in the require does one later have to be clever and see which vm one is running in and either -require or not. Maybe one doesn't even have to be so clever, we'll see (as requiring an existing -module should result in noop) diff --git a/lib/parfait/frame.rb b/lib/parfait/frame.rb index 707fa602..ef501cc6 100644 --- a/lib/parfait/frame.rb +++ b/lib/parfait/frame.rb @@ -5,21 +5,12 @@ # It allows for access to those variables basically # A Message and a Frame make up the two sides of message passing: -# A Message (see details there) is created by the sender and control is transferred +# A Message (see details there) is created by the caller and control is transferred # A Frame is created by the receiver # PS: it turns out that both messages and frames are created at compile, not run-time, and # just constantly reused. Each message has a frame object ready and ist also linked # to the next message. -# The better way to say above is that a messages is *used* by the caller, and a frame by the callee. - -# In static languages these two objects are one, because the method is known at compile time. -# In that case the whole frame is usually on the stack, for leaves even omitted and all data is -# held in registers -# -# In a dynamic language the method is dynamically resolved, and so the size of the frame is not -# know to the caller -# Also exceptions (with the possibility of retry) and the idea of being able to take and store -# bindings make it, to say the very least, unsensibly tricky to store them on the stack. So we don't. +# The better way to say above is that a message is *used* by the caller, and a frame by the callee. # Also at runtime Messages and Frames remain completely "normal" objects. Ie have layouts and so on. # Which resolves the dichotomy of objects on the stack or heap. Sama sama. diff --git a/lib/register.rb b/lib/register.rb index ff66e621..da8fca0c 100644 --- a/lib/register.rb +++ b/lib/register.rb @@ -5,7 +5,7 @@ require "register/positioned" require "register/padding" require "register/parfait_adapter" -require "phisol/compiler" +require "soml/compiler" require "register/method_source" diff --git a/lib/register/README.md b/lib/register/README.md index 0290528d..1ad80a20 100644 --- a/lib/register/README.md +++ b/lib/register/README.md @@ -5,7 +5,7 @@ The RegisterMachine, is an abstract machine with registers. Think of it as an ar normal instruction names. It is not however an abstraction of existing hardware, but only of that subset that we need. -Our primary objective is to compile Phisol to this level, so the register machine has: +Our primary objective is to compile Soml to this level, so the register machine has: - object access instructions - object load - object oriented call semantics diff --git a/lib/register/builtin/README.md b/lib/register/builtin/README.md index b28691bc..3d26e838 100644 --- a/lib/register/builtin/README.md +++ b/lib/register/builtin/README.md @@ -17,8 +17,8 @@ Slightly more here : http://salama.github.io/2014/06/10/more-clarity.html (then The Builtin module is scattered into several files, but that is just so the file doesn't get too long. -Note: This is about to change slightly with the arrival of Phisol. Phisol is a lower level function, +Note: This is about to change slightly with the arrival of Soml. Soml is a lower level function, and as such there is not much that we need that can not be expressed in it. My current thinking -is that i can code anything in Phisol and will only need the Phisol instruction set. +is that i can code anything in Soml and will only need the Soml instruction set. So this whole Builtin approach may blow over in the next months. It had already become clear that -mostly this was going to be about memory access, which in Phisol is part of the language. +mostly this was going to be about memory access, which in Soml is part of the language. diff --git a/lib/register/machine.rb b/lib/register/machine.rb index fcd66962..aba85cfb 100644 --- a/lib/register/machine.rb +++ b/lib/register/machine.rb @@ -128,7 +128,7 @@ module Register syntax = @parser.parse_with_debug(bytes) parts = Parser::Transform.new.apply(syntax) #puts parts.inspect - Phisol::Compiler.compile( parts ) + Soml::Compiler.compile( parts ) end private diff --git a/lib/phisol/ast_helper.rb b/lib/soml/ast_helper.rb similarity index 100% rename from lib/phisol/ast_helper.rb rename to lib/soml/ast_helper.rb diff --git a/lib/phisol/compiler.rb b/lib/soml/compiler.rb similarity index 99% rename from lib/phisol/compiler.rb rename to lib/soml/compiler.rb index b6ad1f6f..dd78597c 100644 --- a/lib/phisol/compiler.rb +++ b/lib/soml/compiler.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml class Compiler < AST::Processor def initialize() diff --git a/lib/phisol/compiler/README.md b/lib/soml/compiler/README.md similarity index 79% rename from lib/phisol/compiler/README.md rename to lib/soml/compiler/README.md index ba3eac76..f657c9d2 100644 --- a/lib/phisol/compiler/README.md +++ b/lib/soml/compiler/README.md @@ -23,7 +23,7 @@ The compiler has a method for each type for ast, named along on_xxx with xxx as #### Compiler holds scope -The Compiler instance can hold arbitrary scope needed during the compilation. Since we compile Phisol +The Compiler instance can hold arbitrary scope needed during the compilation. Since we compile Soml (a static language) things have become more simple. A class statement sets the current @clazz scope , a method definition the @method. @@ -45,22 +45,13 @@ The general structure of the instructions is a graph Since the machine is virtual, we have to define it, and since it is oo we define it in objects. Also it is important to define how instructions operate, which is is in a physical machine would -be by changing the contents of registers or some stack. +be by changing the contents of registers or some stack. Our machine is not a register machine, but an object machine: it operates directly on objects and -also has no separate stack, only objects. There are a number of objects which are accessible, -and one can think of these (their addresses) as register contents. -(And one wouldn't be far off as that is the implementation.) +also has no separate stack, only objects. There is only one object which is accessible, +basically meaning pinned to a register, the Message. -The objects the machine works on are: - -- Message -- Frame -- Self -- NewMessage - -and working on means, these are the only objects which the machine accesses. -Ie all others would have to be moved first. +One can think of the Message as an oo replacement of the stack. When a Method needs to make a call, it creates a NewMessage object. Messages contain return addresses (yes, plural) and arguments. @@ -69,10 +60,10 @@ The important thing here is that Messages and Frames are normal objects. ### Distinctly future proof -Phisol is designed to be used as an implementation language for a higher oo language. Some, or +Soml is designed to be used as an implementation language for a higher oo language. Some, or even many, features may not make sense on their own. But these features, like several return addresses, are important to implement the higher language. -In fact, Phisol's main purpose is not even to be written. The main purpose is to have a language to +In fact, Soml's main purpose is not even to be written. The main purpose is to have a language to compile ruby to. In the same way that the assembler layer in salama is not designed to be written, we just need it to create our layers. diff --git a/lib/phisol/compiler/assignment.rb b/lib/soml/compiler/assignment.rb similarity index 98% rename from lib/phisol/compiler/assignment.rb rename to lib/soml/compiler/assignment.rb index c328427a..507297e3 100644 --- a/lib/phisol/compiler/assignment.rb +++ b/lib/soml/compiler/assignment.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_assignment statement diff --git a/lib/phisol/compiler/basic_values.rb b/lib/soml/compiler/basic_values.rb similarity index 99% rename from lib/phisol/compiler/basic_values.rb rename to lib/soml/compiler/basic_values.rb index ed34ecd1..590c24ff 100644 --- a/lib/phisol/compiler/basic_values.rb +++ b/lib/soml/compiler/basic_values.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml # collection of the simple ones, int and strings and such Compiler.class_eval do diff --git a/lib/phisol/compiler/call_site.rb b/lib/soml/compiler/call_site.rb similarity index 99% rename from lib/phisol/compiler/call_site.rb rename to lib/soml/compiler/call_site.rb index c24cfccc..fee216b5 100644 --- a/lib/phisol/compiler/call_site.rb +++ b/lib/soml/compiler/call_site.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_call statement diff --git a/lib/phisol/compiler/class_field.rb b/lib/soml/compiler/class_field.rb similarity index 97% rename from lib/phisol/compiler/class_field.rb rename to lib/soml/compiler/class_field.rb index 42a66c15..48a1fb2b 100644 --- a/lib/phisol/compiler/class_field.rb +++ b/lib/soml/compiler/class_field.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_class_field statement diff --git a/lib/phisol/compiler/class_statement.rb b/lib/soml/compiler/class_statement.rb similarity index 96% rename from lib/phisol/compiler/class_statement.rb rename to lib/soml/compiler/class_statement.rb index 64fef059..f6c6f933 100644 --- a/lib/phisol/compiler/class_statement.rb +++ b/lib/soml/compiler/class_statement.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_class statement diff --git a/lib/phisol/compiler/collections.rb b/lib/soml/compiler/collections.rb similarity index 93% rename from lib/phisol/compiler/collections.rb rename to lib/soml/compiler/collections.rb index 8f3a5075..8a2473e2 100644 --- a/lib/phisol/compiler/collections.rb +++ b/lib/soml/compiler/collections.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do # attr_reader :values diff --git a/lib/phisol/compiler/field_access.rb b/lib/soml/compiler/field_access.rb similarity index 98% rename from lib/phisol/compiler/field_access.rb rename to lib/soml/compiler/field_access.rb index 7c950852..9a07f216 100644 --- a/lib/phisol/compiler/field_access.rb +++ b/lib/soml/compiler/field_access.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_field_access statement diff --git a/lib/phisol/compiler/field_def.rb b/lib/soml/compiler/field_def.rb similarity index 97% rename from lib/phisol/compiler/field_def.rb rename to lib/soml/compiler/field_def.rb index da5a78dd..faf7db9f 100644 --- a/lib/phisol/compiler/field_def.rb +++ b/lib/soml/compiler/field_def.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do include AST::Sexp diff --git a/lib/phisol/compiler/function_definition.rb b/lib/soml/compiler/function_definition.rb similarity index 99% rename from lib/phisol/compiler/function_definition.rb rename to lib/soml/compiler/function_definition.rb index 5db7622a..a01e199e 100644 --- a/lib/phisol/compiler/function_definition.rb +++ b/lib/soml/compiler/function_definition.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_function statement diff --git a/lib/phisol/compiler/if_statement.rb b/lib/soml/compiler/if_statement.rb similarity index 99% rename from lib/phisol/compiler/if_statement.rb rename to lib/soml/compiler/if_statement.rb index 7a98fe06..7c153287 100644 --- a/lib/phisol/compiler/if_statement.rb +++ b/lib/soml/compiler/if_statement.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do # if - attr_reader :cond, :if_true, :if_false diff --git a/lib/phisol/compiler/name_expression.rb b/lib/soml/compiler/name_expression.rb similarity index 98% rename from lib/phisol/compiler/name_expression.rb rename to lib/soml/compiler/name_expression.rb index bdc55295..5d553d5a 100644 --- a/lib/phisol/compiler/name_expression.rb +++ b/lib/soml/compiler/name_expression.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do # attr_reader :name diff --git a/lib/phisol/compiler/operator_value.rb b/lib/soml/compiler/operator_value.rb similarity index 98% rename from lib/phisol/compiler/operator_value.rb rename to lib/soml/compiler/operator_value.rb index 6615624a..3bc2e48c 100644 --- a/lib/phisol/compiler/operator_value.rb +++ b/lib/soml/compiler/operator_value.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_operator_value statement diff --git a/lib/phisol/compiler/return_statement.rb b/lib/soml/compiler/return_statement.rb similarity index 91% rename from lib/phisol/compiler/return_statement.rb rename to lib/soml/compiler/return_statement.rb index 53548ff0..e895f850 100644 --- a/lib/phisol/compiler/return_statement.rb +++ b/lib/soml/compiler/return_statement.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do # return attr_reader :statement diff --git a/lib/phisol/compiler/statement_list.rb b/lib/soml/compiler/statement_list.rb similarity index 89% rename from lib/phisol/compiler/statement_list.rb rename to lib/soml/compiler/statement_list.rb index 38b84384..a146413c 100644 --- a/lib/phisol/compiler/statement_list.rb +++ b/lib/soml/compiler/statement_list.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_statements statement diff --git a/lib/phisol/compiler/while_statement.rb b/lib/soml/compiler/while_statement.rb similarity index 98% rename from lib/phisol/compiler/while_statement.rb rename to lib/soml/compiler/while_statement.rb index 32a4def8..0434b414 100644 --- a/lib/phisol/compiler/while_statement.rb +++ b/lib/soml/compiler/while_statement.rb @@ -1,4 +1,4 @@ -module Phisol +module Soml Compiler.class_eval do def on_while_statement statement diff --git a/stash/constants.rb b/stash/constants.rb index 61369b14..55762625 100644 --- a/stash/constants.rb +++ b/stash/constants.rb @@ -13,7 +13,7 @@ module Register # derived classes are Boot/Meta Class and StringConstant class ObjectConstant < Constant # def type -# Phisol::Reference +# Soml::Reference # end def clazz raise "abstract #{self}" diff --git a/test/compiler/expressions/compiler_helper.rb b/test/compiler/expressions/compiler_helper.rb index 9a2df2a0..2d4df114 100644 --- a/test/compiler/expressions/compiler_helper.rb +++ b/test/compiler/expressions/compiler_helper.rb @@ -1,7 +1,7 @@ require_relative '../../helper' require 'parslet/convenience' -Phisol::Compiler.class_eval do +Soml::Compiler.class_eval do def set_main main @clazz = Register.machine.space.get_class_by_name :Object @method = main @@ -21,7 +21,7 @@ module CompilerHelper syntax = parser.parse_with_debug(@string_input) parts = Parser::Transform.new.apply(syntax) #puts parts.inspect - compiler = Phisol::Compiler.new + compiler = Soml::Compiler.new set_main(compiler) produced = compiler.process( parts ) assert @output , "No output given" diff --git a/test/interpreter/test_add.rb b/test/interpreter/test_add.rb index 96378cb8..bbd6b2b4 100644 --- a/test/interpreter/test_add.rb +++ b/test/interpreter/test_add.rb @@ -18,7 +18,7 @@ class AddTest < MiniTest::Test s(:int, 5), s(:int, 7))))))) - Phisol::Compiler.compile( code ) + Soml::Compiler.compile( code ) machine.collect @interpreter = Interpreter::Interpreter.new @interpreter.start Register.machine.init diff --git a/test/interpreter/test_if.rb b/test/interpreter/test_if.rb index ec09f990..fbe49a2c 100644 --- a/test/interpreter/test_if.rb +++ b/test/interpreter/test_if.rb @@ -24,10 +24,10 @@ HERE syntax = Parser::Salama.new.parse_with_debug(@string_input) parts = Parser::Transform.new.apply(syntax) #puts parts.inspect - Phisol::Compiler.compile( parts ) + Soml::Compiler.compile( parts ) machine.collect # statements = Register.machine.boot.parse_and_compile @string_input - # Phisol::Compiler.compile( statements , Register.machine.space.get_main ) + # Soml::Compiler.compile( statements , Register.machine.space.get_main ) @interpreter = Interpreter::Interpreter.new @interpreter.start Register.machine.init #show_ticks # get output of what is diff --git a/test/interpreter/test_puti.rb b/test/interpreter/test_puti.rb index cb06a123..e87ae8c2 100644 --- a/test/interpreter/test_puti.rb +++ b/test/interpreter/test_puti.rb @@ -52,10 +52,10 @@ HERE syntax = Parser::Salama.new.parse_with_debug(@string_input) parts = Parser::Transform.new.apply(syntax) #puts parts.inspect - Phisol::Compiler.compile( parts ) + Soml::Compiler.compile( parts ) machine.collect # statements = Register.machine.boot.parse_and_compile @string_input -# Phisol::Compiler.compile( statements , Register.machine.space.get_main ) +# Soml::Compiler.compile( statements , Register.machine.space.get_main ) @interpreter = Interpreter::Interpreter.new @interpreter.start Register.machine.init #show_ticks # get output of what is diff --git a/test/interpreter/test_puts.rb b/test/interpreter/test_puts.rb index f3feb3fc..234be081 100644 --- a/test/interpreter/test_puts.rb +++ b/test/interpreter/test_puts.rb @@ -18,7 +18,7 @@ class TestPuts < MiniTest::Test s(:receiver, s(:string, "Hello again"))))))) - Phisol::Compiler.compile( code ) + Soml::Compiler.compile( code ) machine.collect @interpreter = Interpreter::Interpreter.new @interpreter.start Register.machine.init