gets rid of soml-parser completely
This commit is contained in:
parent
4cd979e3e9
commit
ca4bdcc528
2
Gemfile
2
Gemfile
@ -6,8 +6,6 @@ gem "ast" , :github => "whitequark/ast" , branch: :master
|
|||||||
gem "rake"
|
gem "rake"
|
||||||
gem "rye"
|
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" , :github => "salama/salama-object-file"
|
||||||
#gem "salama-object-file" , :path => "../salama-object-file"
|
#gem "salama-object-file" , :path => "../salama-object-file"
|
||||||
gem "salama-arm" , :github => "salama/salama-arm"
|
gem "salama-arm" , :github => "salama/salama-arm"
|
||||||
|
12
Gemfile.lock
12
Gemfile.lock
@ -10,14 +10,6 @@ GIT
|
|||||||
specs:
|
specs:
|
||||||
salama-object-file (0.3.0)
|
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
|
GIT
|
||||||
remote: git://github.com/whitequark/ast.git
|
remote: git://github.com/whitequark/ast.git
|
||||||
revision: 3814fb102af82a30bf334005ebe17332744f9dad
|
revision: 3814fb102af82a30bf334005ebe17332744f9dad
|
||||||
@ -104,6 +96,9 @@ GEM
|
|||||||
simplecov-html (~> 0.10.0)
|
simplecov-html (~> 0.10.0)
|
||||||
simplecov-html (0.10.0)
|
simplecov-html (0.10.0)
|
||||||
slop (3.6.0)
|
slop (3.6.0)
|
||||||
|
soml-parser (0.5.0)
|
||||||
|
ast (~> 2.1.0)
|
||||||
|
parslet (~> 1.7.1)
|
||||||
storable (0.8.9)
|
storable (0.8.9)
|
||||||
sysinfo (0.8.1)
|
sysinfo (0.8.1)
|
||||||
drydock
|
drydock
|
||||||
@ -126,7 +121,6 @@ DEPENDENCIES
|
|||||||
salama!
|
salama!
|
||||||
salama-arm!
|
salama-arm!
|
||||||
salama-object-file!
|
salama-object-file!
|
||||||
soml-parser!
|
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.13.5
|
1.13.5
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
require "register/padding"
|
require "register/padding"
|
||||||
require "register/positioned"
|
require "register/positioned"
|
||||||
require "typed/parfait"
|
|
||||||
require "register/machine"
|
|
||||||
|
|
||||||
require "typed/compiler"
|
require "typed/compiler"
|
||||||
|
|
||||||
|
require "typed/parfait"
|
||||||
|
require "register/machine"
|
||||||
|
|
||||||
class Fixnum
|
class Fixnum
|
||||||
def fits_u8?
|
def fits_u8?
|
||||||
|
@ -18,10 +18,10 @@ module Register
|
|||||||
def div10 context
|
def div10 context
|
||||||
s = "div_10"
|
s = "div_10"
|
||||||
compiler = Typed::Compiler.new.create_method(:Integer,:div10 ).init_method
|
compiler = Typed::Compiler.new.create_method(:Integer,:div10 ).init_method
|
||||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
me = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
tmp = compiler.process( Soml::NameExpression.new( :self) )
|
tmp = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
q = compiler.process( Soml::NameExpression.new( :self) )
|
q = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
const = compiler.process( Soml::IntegerExpression.new(1) )
|
const = compiler.process( Typed::IntegerExpression.new(1) )
|
||||||
# int tmp = self >> 1
|
# int tmp = self >> 1
|
||||||
compiler.add_code Register.op( s , ">>" , tmp , const)
|
compiler.add_code Register.op( s , ">>" , tmp , const)
|
||||||
# int q = self >> 2
|
# int q = self >> 2
|
||||||
|
@ -13,7 +13,7 @@ module Register
|
|||||||
compiler = Typed::Compiler.new.create_method(:Object , :get_internal_word , {:index => :Integer}).init_method
|
compiler = Typed::Compiler.new.create_method(:Object , :get_internal_word , {:index => :Integer}).init_method
|
||||||
source = "get_internal_word"
|
source = "get_internal_word"
|
||||||
#Load self by "calling" on_name
|
#Load self by "calling" on_name
|
||||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
me = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
# Load the argument
|
# Load the argument
|
||||||
index = compiler.use_reg :Integer
|
index = compiler.use_reg :Integer
|
||||||
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
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
|
{:index => :Integer, :value => :Object} ).init_method
|
||||||
source = "set_internal_word"
|
source = "set_internal_word"
|
||||||
#Load self by "calling" on_name
|
#Load self by "calling" on_name
|
||||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
me = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
# Load the index
|
# Load the index
|
||||||
index = compiler.use_reg :Integer
|
index = compiler.use_reg :Integer
|
||||||
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
||||||
|
@ -20,7 +20,7 @@ module Register
|
|||||||
compiler = Typed::Compiler.new.create_method(:Word , :get_internal_byte , {:index => :Integer }).init_method
|
compiler = Typed::Compiler.new.create_method(:Word , :get_internal_byte , {:index => :Integer }).init_method
|
||||||
source = "get_internal_word"
|
source = "get_internal_word"
|
||||||
#Load self by "calling" on_name
|
#Load self by "calling" on_name
|
||||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
me = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
# Load the argument
|
# Load the argument
|
||||||
index = compiler.use_reg :Integer
|
index = compiler.use_reg :Integer
|
||||||
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
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
|
{:index => :Integer, :value => :Integer } ).init_method
|
||||||
source = "set_internal_word"
|
source = "set_internal_word"
|
||||||
#Load self by "calling" on_name
|
#Load self by "calling" on_name
|
||||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
me = compiler.process( Typed::NameExpression.new( :self) )
|
||||||
# Load the index
|
# Load the index
|
||||||
index = compiler.use_reg :Integer
|
index = compiler.use_reg :Integer
|
||||||
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
||||||
|
@ -19,7 +19,7 @@ module Register
|
|||||||
@source = source
|
@source = source
|
||||||
@next = nekst
|
@next = nekst
|
||||||
return unless source
|
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
|
end
|
||||||
attr_reader :source
|
attr_reader :source
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require 'parslet/convenience'
|
require 'parslet/convenience'
|
||||||
require_relative "collector"
|
require_relative "collector"
|
||||||
|
|
||||||
module Register
|
module Register
|
||||||
# The Register Machine is an abstraction of the register level. This is seperate from the
|
# The Register Machine is an abstraction of the register level. This is seperate from the
|
||||||
# actual assembler level to allow for several cpu architectures.
|
# actual assembler level to allow for several cpu architectures.
|
||||||
|
@ -2,7 +2,8 @@ require 'parslet'
|
|||||||
|
|
||||||
require "logging"
|
require "logging"
|
||||||
require "elf/object_writer"
|
require "elf/object_writer"
|
||||||
require 'soml-parser'
|
require "ast"
|
||||||
|
|
||||||
AST::Node.class_eval do
|
AST::Node.class_eval do
|
||||||
def first
|
def first
|
||||||
children.first
|
children.first
|
||||||
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||||||
class Message < Object
|
|
||||||
|
|
||||||
end
|
|
@ -1,6 +0,0 @@
|
|||||||
class Type < Object
|
|
||||||
field Class object_class
|
|
||||||
field List instance_methods
|
|
||||||
field Integer indexed_length
|
|
||||||
|
|
||||||
end
|
|
@ -32,7 +32,7 @@ module Typed
|
|||||||
# Helper function to create a new compiler and compie the statement(s)
|
# Helper function to create a new compiler and compie the statement(s)
|
||||||
def self.compile statement
|
def self.compile statement
|
||||||
compiler = Compiler.new
|
compiler = Compiler.new
|
||||||
code = Soml.ast_to_code statement
|
code = Typed.ast_to_code statement
|
||||||
compiler.process code
|
compiler.process code
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ module Typed
|
|||||||
# Dispatches `code` according to it's class name, for class NameExpression
|
# Dispatches `code` according to it's class name, for class NameExpression
|
||||||
# a method named `on_NameExpression` is invoked with one argument, the `code`
|
# 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)
|
def process(code)
|
||||||
name = code.class.name.split("::").last
|
name = code.class.name.split("::").last
|
||||||
# Invoke a specific handler
|
# Invoke a specific handler
|
||||||
@ -173,23 +173,11 @@ module Typed
|
|||||||
raise "space is a reserved name" if name == :space
|
raise "space is a reserved name" if name == :space
|
||||||
name
|
name
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative "ast_helper"
|
require_relative "ast_helper"
|
||||||
|
require_relative "ast/code"
|
||||||
require_relative "compiler/assignment"
|
require_relative "compiler/assignment"
|
||||||
require_relative "compiler/basic_values"
|
require_relative "compiler/basic_values"
|
||||||
require_relative "compiler/call_site"
|
require_relative "compiler/call_site"
|
||||||
|
@ -9,7 +9,7 @@ module Typed
|
|||||||
name_s = no_space( statement.name.value )
|
name_s = no_space( statement.name.value )
|
||||||
@method.ensure_local( name_s, statement.type ) unless( @method.has_arg(name_s))
|
@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)
|
# 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
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,6 @@ module RuntimeTests
|
|||||||
|
|
||||||
def load_program
|
def load_program
|
||||||
@machine = Register.machine.boot
|
@machine = Register.machine.boot
|
||||||
Typed::Compiler.load_parfait
|
|
||||||
@machine.parse_and_compile main()
|
@machine.parse_and_compile main()
|
||||||
@machine.collect
|
@machine.collect
|
||||||
end
|
end
|
||||||
@ -59,7 +58,7 @@ module RuntimeTests
|
|||||||
machine , port = rest.to_s.split(":")
|
machine , port = rest.to_s.split(":")
|
||||||
make_box machine , port , user
|
make_box machine , port , user
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_box machine = nil , port = nil , user = nil
|
def make_box machine = nil , port = nil , user = nil
|
||||||
@@conn = Rye::Box.new(machine || "localhost" , :port => (port || 2222) , :user => (user || "pi"))
|
@@conn = Rye::Box.new(machine || "localhost" , :port => (port || 2222) , :user => (user || "pi"))
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,8 @@ module BenchTests
|
|||||||
def setup
|
def setup
|
||||||
@stdout = ""
|
@stdout = ""
|
||||||
@machine = Register.machine.boot
|
@machine = Register.machine.boot
|
||||||
Typed::Compiler.load_parfait
|
# Typed::Compiler.load_parfait
|
||||||
|
# most interesting parts saved as interger/word .soml in this dir
|
||||||
end
|
end
|
||||||
|
|
||||||
def main
|
def main
|
||||||
|
@ -17,8 +17,7 @@ require "minitest/autorun"
|
|||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))
|
||||||
|
|
||||||
was = require 'salama'
|
require 'salama'
|
||||||
puts "loaded #{was}"
|
|
||||||
|
|
||||||
class Ignored
|
class Ignored
|
||||||
def == other
|
def == other
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
require_relative "../helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
Register.machine.boot unless Register.machine.booted
|
Register.machine.boot unless Register.machine.booted
|
||||||
|
Loading…
x
Reference in New Issue
Block a user