move compiler to typed
starting to get rid of soml, bit by bit
This commit is contained in:
parent
c3a28d2abc
commit
da553f996f
@ -3,7 +3,7 @@ require "register/positioned"
|
||||
require "typed/parfait"
|
||||
require "register/machine"
|
||||
|
||||
require "soml/compiler"
|
||||
require "typed/compiler"
|
||||
|
||||
|
||||
class Fixnum
|
||||
|
@ -6,18 +6,18 @@ module Register
|
||||
include AST::Sexp
|
||||
|
||||
def mod4 context
|
||||
compiler = Soml::Compiler.new.create_method(:Integer,:mod4 ).init_method
|
||||
compiler = Typed::Compiler.new.create_method(:Integer,:mod4 ).init_method
|
||||
return compiler.method
|
||||
end
|
||||
def putint context
|
||||
compiler = Soml::Compiler.new.create_method(:Integer,:putint ).init_method
|
||||
compiler = Typed::Compiler.new.create_method(:Integer,:putint ).init_method
|
||||
return compiler.method
|
||||
end
|
||||
|
||||
|
||||
def div10 context
|
||||
s = "div_10"
|
||||
compiler = Soml::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) )
|
||||
tmp = compiler.process( Soml::NameExpression.new( :self) )
|
||||
q = compiler.process( Soml::NameExpression.new( :self) )
|
||||
|
@ -7,7 +7,7 @@ module Register
|
||||
# so it is responsible for initial setup
|
||||
def __init__ context
|
||||
source = "__init__"
|
||||
compiler = Soml::Compiler.new.create_method(:Kernel,:__init__ )
|
||||
compiler = Typed::Compiler.new.create_method(:Kernel,:__init__ )
|
||||
# no method enter or return (automatically added), remove
|
||||
new_start = Label.new(source , source )
|
||||
compiler.method.instructions = new_start
|
||||
@ -34,7 +34,7 @@ module Register
|
||||
end
|
||||
|
||||
def exit context
|
||||
compiler = Soml::Compiler.new.create_method(:Kernel,:exit ).init_method
|
||||
compiler = Typed::Compiler.new.create_method(:Kernel,:exit ).init_method
|
||||
emit_syscall( compiler , :exit )
|
||||
return compiler.method
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ module Register
|
||||
# return is stored in return_value
|
||||
# (this method returns a new method off course, like all builtin)
|
||||
def get_internal_word context
|
||||
compiler = Soml::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"
|
||||
#Load self by "calling" on_name
|
||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
||||
@ -27,7 +27,7 @@ module Register
|
||||
# self[index] = val basically. Index is the first arg , value the second
|
||||
# no return
|
||||
def set_internal_word context
|
||||
compiler = Soml::Compiler.new.create_method(:Object , :set_internal_word ,
|
||||
compiler = Typed::Compiler.new.create_method(:Object , :set_internal_word ,
|
||||
{:index => :Integer, :value => :Object} ).init_method
|
||||
source = "set_internal_word"
|
||||
#Load self by "calling" on_name
|
||||
|
@ -9,7 +9,7 @@ module Register
|
||||
# main entry point, ie __init__ calls this
|
||||
# defined here as empty, to be redefined
|
||||
def main context
|
||||
compiler = Soml::Compiler.new.create_method(:Space , :main ).init_method
|
||||
compiler = Typed::Compiler.new.create_method(:Space , :main ).init_method
|
||||
return compiler.method
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module Register
|
||||
include AST::Sexp
|
||||
|
||||
def putstring context
|
||||
compiler = Soml::Compiler.new.create_method(:Word , :putstring ).init_method
|
||||
compiler = Typed::Compiler.new.create_method(:Word , :putstring ).init_method
|
||||
compiler.add_code Register.get_slot( "putstring" , :message , :receiver , :new_message )
|
||||
index = Parfait::Word.get_length_index
|
||||
reg = RegisterValue.new(:r2 , :Integer)
|
||||
@ -17,7 +17,7 @@ module Register
|
||||
# self[index] basically. Index is the first arg > 0
|
||||
# return (and word sized int) is stored in return_value
|
||||
def get_internal_byte context
|
||||
compiler = Soml::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"
|
||||
#Load self by "calling" on_name
|
||||
me = compiler.process( Soml::NameExpression.new( :self) )
|
||||
@ -35,7 +35,7 @@ module Register
|
||||
# value the second
|
||||
# no return
|
||||
def set_internal_byte context
|
||||
compiler = Soml::Compiler.new.create_method(:Word , :set_internal_byte ,
|
||||
compiler = Typed::Compiler.new.create_method(:Word , :set_internal_byte ,
|
||||
{:index => :Integer, :value => :Integer } ).init_method
|
||||
source = "set_internal_word"
|
||||
#Load self by "calling" on_name
|
||||
|
@ -74,7 +74,7 @@ module Register
|
||||
syntax = Parser::Salama.new.parse_with_debug(bytes, reporter: Parslet::ErrorReporter::Deepest.new)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
#puts parts.inspect
|
||||
Soml.compile( parts )
|
||||
Typed.compile( parts )
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
# Compiling is the conversion of the AST into 2 things:
|
||||
# - code (ie sequences of Instructions inside Methods)
|
||||
# - an object graph containing all the Methods, their classes and Constants
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_Assignment statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
# collection of the simple ones, int and strings and such
|
||||
|
||||
Compiler.class_eval do
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_CallSite statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_ClassField statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_ClassStatement statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
# attr_reader :values
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_FieldAccess statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
include AST::Sexp
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_FunctionStatement statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
# an if evaluates the condition and jumps to the true block if true
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
# attr_reader :name
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_OperatorExpression statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_ReturnStatement statement
|
@ -1,4 +1,5 @@
|
||||
module Soml
|
||||
module Typed
|
||||
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_statements statement
|
@ -1,4 +1,4 @@
|
||||
module Soml
|
||||
module Typed
|
||||
Compiler.class_eval do
|
||||
|
||||
def on_WhileStatement statement
|
@ -1,7 +1,7 @@
|
||||
require_relative '../../helper'
|
||||
require 'parslet/convenience'
|
||||
|
||||
Soml::Compiler.class_eval do
|
||||
Typed::Compiler.class_eval do
|
||||
def set_main main
|
||||
@clazz = Register.machine.space.get_class_by_name :Object
|
||||
@method = main
|
||||
@ -23,7 +23,7 @@ module ExpressionHelper
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
codes = Soml.ast_to_code parts
|
||||
#puts parts.inspect
|
||||
compiler = Soml::Compiler.new
|
||||
compiler = Typed::Compiler.new
|
||||
set_main(compiler)
|
||||
produced = compiler.process( codes )
|
||||
assert @output , "No output given"
|
||||
|
@ -22,7 +22,7 @@ module RuntimeTests
|
||||
|
||||
def load_program
|
||||
@machine = Register.machine.boot
|
||||
Soml::Compiler.load_parfait
|
||||
Typed::Compiler.load_parfait
|
||||
@machine.parse_and_compile main()
|
||||
@machine.collect
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ module ParfaitTests
|
||||
def setup
|
||||
@stdout = ""
|
||||
@machine = Register.machine.boot
|
||||
Soml::Compiler.load_parfait
|
||||
Typed::Compiler.load_parfait
|
||||
end
|
||||
|
||||
def main
|
||||
|
@ -9,7 +9,7 @@ module BenchTests
|
||||
def setup
|
||||
@stdout = ""
|
||||
@machine = Register.machine.boot
|
||||
Soml::Compiler.load_parfait
|
||||
Typed::Compiler.load_parfait
|
||||
end
|
||||
|
||||
def main
|
||||
|
@ -8,7 +8,7 @@ module Ticker
|
||||
syntax = Parser::Salama.new.parse_with_debug(@string_input, reporter: Parslet::ErrorReporter::Deepest.new)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
#puts parts.inspect
|
||||
Soml.compile( parts )
|
||||
Typed.compile( parts )
|
||||
machine.collect
|
||||
@interpreter = Register::Interpreter.new
|
||||
@interpreter.start Register.machine.init
|
||||
|
Loading…
Reference in New Issue
Block a user