rename for_type to self_type

and split a base class off TypedMethod
This commit is contained in:
Torsten Ruger
2018-07-06 20:01:17 +03:00
parent 3f80953385
commit acd5cd8f30
19 changed files with 103 additions and 75 deletions

View File

@ -135,7 +135,7 @@ module Risc
def add_known(name)
case name
when :receiver
ret = compiler.use_reg compiler.method.for_type
ret = compiler.use_reg compiler.method.self_type
add_slot_to_reg(" load self" , :message , :receiver , ret )
return ret
when :space
@ -184,7 +184,7 @@ module Risc
when :arguments
type = compiler.method.arguments_type
when :receiver
type = compiler.method.for_type
type = compiler.method.self_type
when Parfait::Object
type = Parfait.object_space.get_class_by_name( object.class.name.split("::").last.to_sym).instance_type
when Symbol

View File

@ -63,7 +63,7 @@ module Risc
message[:receiver] << space
end
exit_label = Risc.label(compiler.method , "#{compiler.method.for_type.object_class.name}.#{compiler.method.name}" )
exit_label = Risc.label(compiler.method , "#{compiler.method.self_type.object_class.name}.#{compiler.method.name}" )
ret_tmp = compiler.use_reg(:Label)
builder.build do
add_load_constant("__init__ load return", exit_label , ret_tmp)

View File

@ -14,7 +14,7 @@ module Risc
def initialize( method )
@regs = []
@method = method
name = "#{method.for_type.name}.#{method.name}"
name = "#{method.self_type.name}.#{method.name}"
@risc_instructions = Risc.label(name, name)
@risc_instructions << Risc.label( name, "unreachable")
@current = @risc_instructions
@ -25,12 +25,12 @@ module Risc
# helper method for builtin mainly
# the class_name is a symbol, which is resolved to the instance_type of that class
#
# return compiler_for_type with the resolved type
# return compiler_self_type with the resolved type
#
def self.compiler_for_class( class_name , method_name , args , frame )
raise "create_method #{class_name}.#{class_name.class}" unless class_name.is_a? Symbol
clazz = Parfait.object_space.get_class_by_name! class_name
compiler_for_type( clazz.instance_type , method_name , args , frame)
compiler_self_type( clazz.instance_type , method_name , args , frame)
end
# create a method for the given type ( Parfait type object)
@ -38,7 +38,7 @@ module Risc
# args a hash that will be converted to a type
# the created method is set as the current and the given type too
# return the compiler
def self.compiler_for_type( type , method_name , args , frame)
def self.compiler_self_type( type , method_name , args , frame)
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
raise "Args must be Type #{args}" unless args.is_a?(Parfait::Type)
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol

View File

@ -154,7 +154,7 @@ module Parfait
CacheEntry: {cached_type: :Type , cached_method: :TypedMethod } ,
TypedMethod: {name: :Word, risc_instructions: :Object,
cpu_instructions: :Object, binary: :BinaryCode,
arguments_type: :Type , for_type: :Type, frame_type: :Type ,
arguments_type: :Type , self_type: :Type, frame_type: :Type ,
next_method: :TypedMethod} ,
VoolMethod: { name: :Word , args_type: :Type , frame_type: :Type } ,
}