remove method_compiler init method
as init is really just adding a label it is done in the method (thus mixing the levels, “polluting” parfait with risc, but there must be change coming that way anyway)
This commit is contained in:
parent
3bd23cee28
commit
eb7713a9f3
@ -12,7 +12,7 @@ module Risc
|
|||||||
def compiler_for( type , method_name , arguments , locals = {})
|
def compiler_for( type , method_name , arguments , locals = {})
|
||||||
frame = Parfait::NamedList.type_for( locals ) #TODO fix locals passing/ using in builtin
|
frame = Parfait::NamedList.type_for( locals ) #TODO fix locals passing/ using in builtin
|
||||||
args = Parfait::NamedList.type_for( arguments )
|
args = Parfait::NamedList.type_for( arguments )
|
||||||
Risc::MethodCompiler.create_method(type , method_name , args, frame ).init_method
|
Risc::MethodCompiler.create_method(type , method_name , args, frame )
|
||||||
end
|
end
|
||||||
|
|
||||||
# Load the value
|
# Load the value
|
||||||
|
@ -9,10 +9,6 @@ module Risc
|
|||||||
def __init__ context
|
def __init__ context
|
||||||
compiler = Risc::MethodCompiler.create_method(:Kernel,:__init__ ,
|
compiler = Risc::MethodCompiler.create_method(:Kernel,:__init__ ,
|
||||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||||
new_start = Risc.label("__init__ start" , "__init__" )
|
|
||||||
compiler.method.set_instructions( new_start)
|
|
||||||
compiler.set_current( new_start ) #thus abandoning standard method setup
|
|
||||||
|
|
||||||
space = Parfait.object_space
|
space = Parfait.object_space
|
||||||
space_reg = compiler.use_reg(:Space) #Set up the Space as self upon init
|
space_reg = compiler.use_reg(:Space) #Set up the Space as self upon init
|
||||||
compiler.add_load_constant("__init__ load Space", space , space_reg)
|
compiler.add_load_constant("__init__ load Space", space , space_reg)
|
||||||
|
@ -16,7 +16,7 @@ module Risc
|
|||||||
@method = method
|
@method = method
|
||||||
@type = method.for_type
|
@type = method.for_type
|
||||||
end
|
end
|
||||||
@current = @method.instructions
|
@current = @method.risc_instructions
|
||||||
end
|
end
|
||||||
attr_reader :type , :method
|
attr_reader :type , :method
|
||||||
|
|
||||||
@ -41,17 +41,6 @@ module Risc
|
|||||||
self.new(method)
|
self.new(method)
|
||||||
end
|
end
|
||||||
|
|
||||||
# add method entry and exit code. Mainly save_return for the enter and
|
|
||||||
# message shuffle and FunctionReturn for the return
|
|
||||||
# return self for chaining
|
|
||||||
def init_method
|
|
||||||
source = "_init_method"
|
|
||||||
name = "#{method.for_type.name}.#{method.name}"
|
|
||||||
@current = @method.set_instructions( Risc.label(source, name))
|
|
||||||
@current << Risc.label( source, "unreachable")
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_known(name)
|
def add_known(name)
|
||||||
case name
|
case name
|
||||||
when :receiver
|
when :receiver
|
||||||
|
@ -32,7 +32,7 @@ module Vool
|
|||||||
@clazz.add_method( method )
|
@clazz.add_method( method )
|
||||||
typed_method = method.create_parfait_method(clazz.instance_type)
|
typed_method = method.create_parfait_method(clazz.instance_type)
|
||||||
head = @body.to_mom( typed_method )
|
head = @body.to_mom( typed_method )
|
||||||
compiler = Risc::MethodCompiler.new( typed_method ).init_method
|
compiler = Risc::MethodCompiler.new( typed_method )
|
||||||
compiler.add_mom(head)
|
compiler.add_mom(head)
|
||||||
head # return for testing
|
head # return for testing
|
||||||
end
|
end
|
||||||
|
@ -63,7 +63,7 @@ end
|
|||||||
|
|
||||||
module CleanCompile
|
module CleanCompile
|
||||||
def clean_compile(clazz_name , method_name , args , statements)
|
def clean_compile(clazz_name , method_name , args , statements)
|
||||||
compiler = Vm::MethodCompiler.create_method(clazz_name,method_name,args ).init_method
|
compiler = Vm::MethodCompiler.create_method(clazz_name,method_name,args )
|
||||||
compiler.process( Vm.ast_to_code( statements ) )
|
compiler.process( Vm.ast_to_code( statements ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user