diff --git a/Gemfile b/Gemfile index c446e0fc..33424ac2 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,6 @@ gem "ast" , :github => "whitequark/ast" , branch: :master gem "rake" gem "rye" -gem "soml-parser" , :github => "salama/soml-parser" -#gem "soml-parser" , :path => "../soml-parser" gem "salama-object-file" , :github => "salama/salama-object-file" #gem "salama-object-file" , :path => "../salama-object-file" gem "salama-arm" , :github => "salama/salama-arm" diff --git a/Gemfile.lock b/Gemfile.lock index 4e4c7f2d..83a08ea7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,14 +10,6 @@ GIT specs: salama-object-file (0.3.0) -GIT - remote: git://github.com/salama/soml-parser.git - revision: 5c03db709fa3a326288a57a65643bd9ddf905bec - specs: - soml-parser (0.5.0) - ast (~> 2.1.0) - parslet (~> 1.7.1) - GIT remote: git://github.com/whitequark/ast.git revision: 3814fb102af82a30bf334005ebe17332744f9dad @@ -104,6 +96,9 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.0) slop (3.6.0) + soml-parser (0.5.0) + ast (~> 2.1.0) + parslet (~> 1.7.1) storable (0.8.9) sysinfo (0.8.1) drydock @@ -126,7 +121,6 @@ DEPENDENCIES salama! salama-arm! salama-object-file! - soml-parser! BUNDLED WITH 1.13.5 diff --git a/lib/register.rb b/lib/register.rb index e478175b..55fbca3a 100644 --- a/lib/register.rb +++ b/lib/register.rb @@ -1,10 +1,9 @@ require "register/padding" require "register/positioned" -require "typed/parfait" -require "register/machine" - require "typed/compiler" +require "typed/parfait" +require "register/machine" class Fixnum def fits_u8? diff --git a/lib/register/builtin/integer.rb b/lib/register/builtin/integer.rb index d9751b46..eb0f0394 100644 --- a/lib/register/builtin/integer.rb +++ b/lib/register/builtin/integer.rb @@ -18,10 +18,10 @@ module Register def div10 context s = "div_10" compiler = Typed::Compiler.new.create_method(:Integer,:div10 ).init_method - me = compiler.process( Soml::NameExpression.new( :self) ) - tmp = compiler.process( Soml::NameExpression.new( :self) ) - q = compiler.process( Soml::NameExpression.new( :self) ) - const = compiler.process( Soml::IntegerExpression.new(1) ) + me = compiler.process( Typed::NameExpression.new( :self) ) + tmp = compiler.process( Typed::NameExpression.new( :self) ) + q = compiler.process( Typed::NameExpression.new( :self) ) + const = compiler.process( Typed::IntegerExpression.new(1) ) # int tmp = self >> 1 compiler.add_code Register.op( s , ">>" , tmp , const) # int q = self >> 2 diff --git a/lib/register/builtin/object.rb b/lib/register/builtin/object.rb index 2fa4ab0e..94bb7ad3 100644 --- a/lib/register/builtin/object.rb +++ b/lib/register/builtin/object.rb @@ -13,7 +13,7 @@ module Register compiler = Typed::Compiler.new.create_method(:Object , :get_internal_word , {:index => :Integer}).init_method source = "get_internal_word" #Load self by "calling" on_name - me = compiler.process( Soml::NameExpression.new( :self) ) + me = compiler.process( Typed::NameExpression.new( :self) ) # Load the argument index = compiler.use_reg :Integer compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index ) @@ -31,7 +31,7 @@ module Register {:index => :Integer, :value => :Object} ).init_method source = "set_internal_word" #Load self by "calling" on_name - me = compiler.process( Soml::NameExpression.new( :self) ) + me = compiler.process( Typed::NameExpression.new( :self) ) # Load the index index = compiler.use_reg :Integer compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index ) diff --git a/lib/register/builtin/word.rb b/lib/register/builtin/word.rb index 0783004b..fb1658f8 100644 --- a/lib/register/builtin/word.rb +++ b/lib/register/builtin/word.rb @@ -20,7 +20,7 @@ module Register compiler = Typed::Compiler.new.create_method(:Word , :get_internal_byte , {:index => :Integer }).init_method source = "get_internal_word" #Load self by "calling" on_name - me = compiler.process( Soml::NameExpression.new( :self) ) + me = compiler.process( Typed::NameExpression.new( :self) ) # Load the argument index = compiler.use_reg :Integer compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index ) @@ -39,7 +39,7 @@ module Register {:index => :Integer, :value => :Integer } ).init_method source = "set_internal_word" #Load self by "calling" on_name - me = compiler.process( Soml::NameExpression.new( :self) ) + me = compiler.process( Typed::NameExpression.new( :self) ) # Load the index index = compiler.use_reg :Integer compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index ) diff --git a/lib/register/instruction.rb b/lib/register/instruction.rb index c85b855b..3e53acb2 100644 --- a/lib/register/instruction.rb +++ b/lib/register/instruction.rb @@ -19,7 +19,7 @@ module Register @source = source @next = nekst return unless source - raise "Source must be string or ast node, not #{source.class}" unless source.is_a?(String) or source.is_a?(Soml::Code) + raise "Source must be string or ast node, not #{source.class}" unless source.is_a?(String) or source.is_a?(Typed::Code) end attr_reader :source diff --git a/lib/register/machine.rb b/lib/register/machine.rb index 6341f3bf..f4d55b9a 100644 --- a/lib/register/machine.rb +++ b/lib/register/machine.rb @@ -1,5 +1,6 @@ require 'parslet/convenience' require_relative "collector" + module Register # The Register Machine is an abstraction of the register level. This is seperate from the # actual assembler level to allow for several cpu architectures. diff --git a/lib/salama.rb b/lib/salama.rb index be9f0175..a6a58eeb 100644 --- a/lib/salama.rb +++ b/lib/salama.rb @@ -2,7 +2,8 @@ require 'parslet' require "logging" require "elf/object_writer" -require 'soml-parser' +require "ast" + AST::Node.class_eval do def first children.first diff --git a/lib/soml/parfait/class.soml b/lib/soml/parfait/class.soml deleted file mode 100644 index 9f61d600..00000000 --- a/lib/soml/parfait/class.soml +++ /dev/null @@ -1,11 +0,0 @@ -class Class < Object - field List instance_methods - field Type instance_type - field Word name - field Word super_class_name - - - Word get_name() - return self.name - end -end diff --git a/lib/soml/parfait/message.soml b/lib/soml/parfait/message.soml deleted file mode 100644 index f2055d03..00000000 --- a/lib/soml/parfait/message.soml +++ /dev/null @@ -1,3 +0,0 @@ -class Message < Object - -end diff --git a/lib/soml/parfait/type.soml b/lib/soml/parfait/type.soml deleted file mode 100644 index af2be14d..00000000 --- a/lib/soml/parfait/type.soml +++ /dev/null @@ -1,6 +0,0 @@ -class Type < Object - field Class object_class - field List instance_methods - field Integer indexed_length - -end diff --git a/lib/typed/compiler.rb b/lib/typed/compiler.rb index 9a20b8e8..bc6f5ce6 100644 --- a/lib/typed/compiler.rb +++ b/lib/typed/compiler.rb @@ -32,7 +32,7 @@ module Typed # Helper function to create a new compiler and compie the statement(s) def self.compile statement compiler = Compiler.new - code = Soml.ast_to_code statement + code = Typed.ast_to_code statement compiler.process code end @@ -51,7 +51,7 @@ module Typed # Dispatches `code` according to it's class name, for class NameExpression # a method named `on_NameExpression` is invoked with one argument, the `code` # - # @param [Soml::Code, nil] code + # @param [Typed::Code, nil] code def process(code) name = code.class.name.split("::").last # Invoke a specific handler @@ -173,23 +173,11 @@ module Typed raise "space is a reserved name" if name == :space name end - - # load the soml files from parfait directory - # Need to remove this and put it back into ruby code - def self.load_parfait - ["word","class","type","message" ,"integer", "object"].each do |o| - str = File.open(File.expand_path("parfait/#{o}.soml", File.dirname(__FILE__))).read - syntax = Parser::Salama.new.parse_with_debug(str, reporter: Parslet::ErrorReporter::Deepest.new) - parts = Parser::Transform.new.apply(syntax) - code = Soml.ast_to_code parts - self.new.process( code ) - end - end - end end require_relative "ast_helper" +require_relative "ast/code" require_relative "compiler/assignment" require_relative "compiler/basic_values" require_relative "compiler/call_site" diff --git a/lib/typed/compiler/field_def.rb b/lib/typed/compiler/field_def.rb index 348d8f41..8bd373ce 100644 --- a/lib/typed/compiler/field_def.rb +++ b/lib/typed/compiler/field_def.rb @@ -9,7 +9,7 @@ module Typed name_s = no_space( statement.name.value ) @method.ensure_local( name_s, statement.type ) unless( @method.has_arg(name_s)) # if there is a value assigned, process it as am assignemnt statement (kind of call on_assign) - process( Soml::Assignment.new(statement.name , statement.value ) ) if statement.value + process( Typed::Assignment.new(statement.name , statement.value ) ) if statement.value return nil end end diff --git a/stash/soml/helper.rb b/stash/soml/helper.rb index 3d1ec0e0..9b0c2405 100644 --- a/stash/soml/helper.rb +++ b/stash/soml/helper.rb @@ -22,7 +22,6 @@ module RuntimeTests def load_program @machine = Register.machine.boot - Typed::Compiler.load_parfait @machine.parse_and_compile main() @machine.collect end @@ -59,7 +58,7 @@ module RuntimeTests machine , port = rest.to_s.split(":") make_box machine , port , user end - + def make_box machine = nil , port = nil , user = nil @@conn = Rye::Box.new(machine || "localhost" , :port => (port || 2222) , :user => (user || "pi")) end diff --git a/test/bench/soml/helper.rb b/test/bench/soml/helper.rb index dde47c56..57fd80e5 100644 --- a/test/bench/soml/helper.rb +++ b/test/bench/soml/helper.rb @@ -9,7 +9,8 @@ module BenchTests def setup @stdout = "" @machine = Register.machine.boot - Typed::Compiler.load_parfait + # Typed::Compiler.load_parfait + # most interesting parts saved as interger/word .soml in this dir end def main diff --git a/lib/soml/parfait/integer.soml b/test/bench/soml/integer.soml similarity index 100% rename from lib/soml/parfait/integer.soml rename to test/bench/soml/integer.soml diff --git a/lib/soml/parfait/object.soml b/test/bench/soml/object.soml similarity index 100% rename from lib/soml/parfait/object.soml rename to test/bench/soml/object.soml diff --git a/lib/soml/parfait/word.soml b/test/bench/soml/word.soml similarity index 100% rename from lib/soml/parfait/word.soml rename to test/bench/soml/word.soml diff --git a/test/helper.rb b/test/helper.rb index cd637cd0..5865a77f 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -17,8 +17,7 @@ require "minitest/autorun" $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test')) -was = require 'salama' -puts "loaded #{was}" +require 'salama' class Ignored def == other diff --git a/test/typed/helper.rb b/test/typed/helper.rb index fba6a8b9..7b962a8d 100644 --- a/test/typed/helper.rb +++ b/test/typed/helper.rb @@ -1,2 +1,3 @@ require_relative "../helper" + Register.machine.boot unless Register.machine.booted