gets rid of soml-parser completely

This commit is contained in:
Torsten Ruger 2016-12-08 20:13:08 +02:00
parent 4cd979e3e9
commit ca4bdcc528
21 changed files with 26 additions and 65 deletions

View File

@ -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"

View File

@ -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

View File

@ -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?

View File

@ -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

View File

@ -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 )

View File

@ -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 )

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -1,3 +0,0 @@
class Message < Object
end

View File

@ -1,6 +0,0 @@
class Type < Object
field Class object_class
field List instance_methods
field Integer indexed_length
end

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,2 +1,3 @@
require_relative "../helper"
Register.machine.boot unless Register.machine.booted