stash old vm

moving on to getting mom to work and can’t have both
interpreter and elf broke, about 100 tests  went
This commit is contained in:
Torsten Ruger
2018-03-11 17:02:42 +05:30
parent f7aac1d1a4
commit 5fe0ba06ab
56 changed files with 80 additions and 143 deletions

View File

@ -4,14 +4,14 @@ module Risc
module CompileHelper
def self_and_int_arg(compiler , source)
me = compiler.process( Vm::Tree::KnownName.new( :self) )
me = compiler.add_known( :self )
int_arg = load_int_arg_at(compiler , source , 1 )
return me , int_arg
end
def compiler_for( type , method_name , extra_args = {})
args = {:index => :Integer}.merge( extra_args )
Vm::MethodCompiler.create_method(type , method_name , args ).init_method
Risc::MethodCompiler.create_method(type , method_name , args ).init_method
end
# Load the value

View File

@ -6,22 +6,23 @@ module Risc
include AST::Sexp
def mod4 context
compiler = Vm::MethodCompiler.create_method(:Integer,:mod4 ).init_method
compiler = Risc::MethodCompiler.create_method(:Integer,:mod4 ).init_method
return compiler.method
end
def putint context
compiler = Vm::MethodCompiler.create_method(:Integer,:putint ).init_method
compiler = Risc::MethodCompiler.create_method(:Integer,:putint ).init_method
return compiler.method
end
def div10 context
s = "div_10"
compiler = Vm::MethodCompiler.create_method(:Integer,:div10 ).init_method
me = compiler.process( Vm::Tree::KnownName.new( :self) )
tmp = compiler.process( Vm::Tree::KnownName.new( :self) )
q = compiler.process( Vm::Tree::KnownName.new( :self) )
const = compiler.process( Vm::Tree::IntegerExpression.new(1) )
compiler = Risc::MethodCompiler.create_method(:Integer,:div10 ).init_method
me = compiler.add_known( :self )
tmp = compiler.add_known( :self )
q = compiler.add_known( :self )
const = compiler.use_reg :Integer , 1
compiler.add_load_constant( s, 1 , const )
# int tmp = self >> 1
compiler.add_code Risc.op( s , ">>" , tmp , const)
# int q = self >> 2

View File

@ -6,7 +6,7 @@ module Risc
# it isn't really a function, ie it is jumped to (not called), exits and may not return
# so it is responsible for initial setup
def __init__ context
compiler = Vm::MethodCompiler.create_method(:Kernel,:__init__ )
compiler = Risc::MethodCompiler.create_method(:Kernel,:__init__ )
new_start = Risc.label("__init__ start" , "__init__" )
compiler.method.set_instructions( new_start)
compiler.set_current new_start
@ -29,7 +29,7 @@ module Risc
end
def exit context
compiler = Vm::MethodCompiler.create_method(:Kernel,:exit ).init_method
compiler = Risc::MethodCompiler.create_method(:Kernel,:exit ).init_method
emit_syscall( compiler , :exit )
return compiler.method
end

View File

@ -9,7 +9,7 @@ module Risc
# main entry point, ie __init__ calls this
# defined here as empty, to be redefined
def main context
compiler = Vm::MethodCompiler.create_method(:Space , :main ).init_method
compiler = Risc::MethodCompiler.create_method(:Space , :main ).init_method
return compiler.method
end

View File

@ -7,7 +7,7 @@ module Risc
include CompileHelper
def putstring context
compiler = Vm::MethodCompiler.create_method(:Word , :putstring ).init_method
compiler = Risc::MethodCompiler.create_method(:Word , :putstring ).init_method
compiler.add_slot_to_reg( "putstring" , :message , :receiver , :new_message )
index = Parfait::Word.get_length_index
reg = RiscValue.new(:r2 , :Integer)