rename typed_method to callable_method

seems to make the essence clearer
also extracted base class
This commit is contained in:
Torsten Ruger
2018-07-07 09:11:09 +03:00
parent acd5cd8f30
commit 9005513368
28 changed files with 146 additions and 142 deletions

View File

@ -6,7 +6,7 @@ It is the other side of the parfait coin, part of the runtime.
The functions are organised by their respective classes and get loaded in boot_classes! ,
right at the start. (see register/boot.rb)
These functions return their code, ie a Parfait::TypedMethod with a MethodSource object,
These functions return their code, ie a Parfait::CallableMethod with a MethodSource object,
which can then be called by ruby code as if it were a "normal" function.
A normal ruby function is one that is parsed and transformed to code. But not all

View File

@ -35,11 +35,11 @@ module Risc
return true if objekt.is_a? Fixnum
return true if objekt.is_a?( Risc::Label)
#puts message(objekt , depth)
#puts "ADD #{objekt.inspect}, #{objekt.name}" if objekt.is_a? Parfait::TypedMethod
#puts "ADD #{objekt.inspect}, #{objekt.name}" if objekt.is_a? Parfait::CallableMethod
unless objekt.is_a?( Parfait::Object) or objekt.is_a?( Symbol)
raise "adding non parfait #{objekt.class}:#{objekt}"
end
#raise "Method #{objekt.name}" if objekt.is_a? Parfait::TypedMethod
#raise "Method #{objekt.name}" if objekt.is_a? Parfait::CallableMethod
Position.get_or_create(objekt)
true
end

View File

@ -27,7 +27,7 @@ module Risc
@next = nekst
return unless source
raise "Source must be string or Instruction, not #{source.class}" unless source.is_a?(String) or
source.is_a?(Mom::Instruction) or source.is_a?(Parfait::TypedMethod)
source.is_a?(Mom::Instruction) or source.is_a?(Parfait::CallableMethod)
end
attr_reader :source

View File

@ -115,48 +115,56 @@ module Parfait
# superclasses other than default object
def self.super_class_names
{ Data4: :DataObject , Data8: :DataObject ,Data16: :DataObject ,
{ Data4: :DataObject ,
Data8: :DataObject ,
Data16: :DataObject ,
Data32: :DataObject ,
BinaryCode: :Data16 , Integer: :Data4 , Word: :Data8 ,
Object: :BasicObject, List: :Data16 , ReturnAddress: :Integer}
BinaryCode: :Data16 ,
Integer: :Data4 ,
Word: :Data8 ,
List: :Data16 ,
CallableMethod: :Callable,
ReturnAddress: :Integer}
end
# the function really just returns a constant (just avoiding the constant)
# unfortuantely that constant condenses every detail about the system, class names
# and all instance variable names. Really have to find a better way
def self.type_names
{ Word: {char_length: :Integer , next_word: :Word} ,
List: {indexed_length: :Integer , next_list: :List} ,
Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
return_address: :Integer, return_value: :Object,
caller: :Message , name: :Word , arguments: :NamedList },
Integer: {next_integer: :Integer},
ReturnAddress: {next_integer: :ReturnAddress},
DataObject: {},
Data4: {},
Data8: {},
TrueClass: {},
FalseClass: {},
NilClass: {},
Object: {},
BinaryCode: {next: :BinaryCode} ,
Space: {classes: :Dictionary , types: :Dictionary ,
next_message: :Message , messages: :Message ,
next_integer: :Integer, integers: :Integer ,
next_address: :ReturnAddress ,addresses: :ReturnAddress ,
true_object: :TrueClass, false_object: :FalseClass , nil_object: :NilClass},
NamedList: {},
Type: {names: :List , types: :List ,
object_class: :Class, methods: :TypedMethod } ,
Class: {instance_methods: :List, instance_type: :Type,
name: :Word, super_class_name: :Word },
Dictionary: {keys: :List , values: :List } ,
CacheEntry: {cached_type: :Type , cached_method: :TypedMethod } ,
TypedMethod: {name: :Word, risc_instructions: :Object,
cpu_instructions: :Object, binary: :BinaryCode,
arguments_type: :Type , self_type: :Type, frame_type: :Type ,
next_method: :TypedMethod} ,
VoolMethod: { name: :Word , args_type: :Type , frame_type: :Type } ,
{BinaryCode: {next: :BinaryCode} ,
CacheEntry: {cached_type: :Type , cached_method: :CallableMethod } ,
Callable: {binary: :BinaryCode,next: :Callable ,
arguments_type: :Type , self_type: :Type, frame_type: :Type } ,
CallableMethod: {name: :Word, binary: :BinaryCode,
arguments_type: :Type , self_type: :Type, frame_type: :Type ,
next: :CallableMethod} ,
Class: {instance_methods: :List, instance_type: :Type,
name: :Word, super_class_name: :Word },
DataObject: {},
Data4: {},
Data8: {},
Data16: {},
Dictionary: {keys: :List , values: :List } ,
Integer: {next_integer: :Integer},
FalseClass: {},
List: {indexed_length: :Integer , next_list: :List} ,
Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
return_address: :Integer, return_value: :Object,
caller: :Message , name: :Word , arguments: :NamedList },
NamedList: {},
NilClass: {},
Object: {},
ReturnAddress: {next_integer: :ReturnAddress},
Space: {classes: :Dictionary , types: :Dictionary ,
next_message: :Message , messages: :Message ,
next_integer: :Integer, integers: :Integer ,
next_address: :ReturnAddress ,addresses: :ReturnAddress ,
true_object: :TrueClass, false_object: :FalseClass , nil_object: :NilClass},
TrueClass: {},
Type: {names: :List , types: :List ,
object_class: :Class, methods: :CallableMethod } ,
VoolMethod: { name: :Word , args_type: :Type , frame_type: :Type } ,
Word: {char_length: :Integer , next_word: :Word} ,
}
end
end