make method creation class methods in MethodCompiler

and pass the wish to use main explicitly, which is really a test
feature
This commit is contained in:
Torsten Ruger
2017-01-17 21:23:58 +02:00
parent 0c64e367d5
commit cd211f970f
8 changed files with 21 additions and 22 deletions

View File

@ -11,7 +11,7 @@ module Register
def compiler_for( type , method_name , extra_args = {})
args = {:index => :Integer}.merge( extra_args )
Vm::MethodCompiler.new.create_method(type , method_name , args ).init_method
Vm::MethodCompiler.create_method(type , method_name , args ).init_method
end
# Load the value

View File

@ -6,18 +6,18 @@ module Register
include AST::Sexp
def mod4 context
compiler = Vm::MethodCompiler.new.create_method(:Integer,:mod4 ).init_method
compiler = Vm::MethodCompiler.create_method(:Integer,:mod4 ).init_method
return compiler.method
end
def putint context
compiler = Vm::MethodCompiler.new.create_method(:Integer,:putint ).init_method
compiler = Vm::MethodCompiler.create_method(:Integer,:putint ).init_method
return compiler.method
end
def div10 context
s = "div_10"
compiler = Vm::MethodCompiler.new.create_method(:Integer,:div10 ).init_method
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) )

View File

@ -6,7 +6,7 @@ module Register
# 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.new.create_method(:Kernel,:__init__ )
compiler = Vm::MethodCompiler.create_method(:Kernel,:__init__ )
new_start = Register.label("__init__ start" , "__init__" )
compiler.method.set_instructions( new_start)
compiler.set_current new_start
@ -29,7 +29,7 @@ module Register
end
def exit context
compiler = Vm::MethodCompiler.new.create_method(:Kernel,:exit ).init_method
compiler = Vm::MethodCompiler.create_method(:Kernel,:exit ).init_method
emit_syscall( compiler , :exit )
return compiler.method
end

View File

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

View File

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