rename singleton_class to single_class and misc
was clashing with real ruby method name also many superclass mismatch fixes some misc
This commit is contained in:
@ -52,7 +52,6 @@ module Parfait
|
||||
|
||||
def get_instance_method( fname )
|
||||
raise "get_instance_method #{fname}.#{fname.class}" unless fname.is_a?(Symbol)
|
||||
#if we had a hash this would be easier. Detect or find would help too
|
||||
@instance_methods.find {|m| m.name == fname }
|
||||
end
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
module Parfait
|
||||
class Class < Behaviour
|
||||
|
||||
attr_reader :name , :super_class_name , :singleton_class
|
||||
attr_reader :name , :super_class_name , :single_class
|
||||
|
||||
def self.type_length
|
||||
6
|
||||
@ -30,7 +30,7 @@ module Parfait
|
||||
super(instance_type)
|
||||
@name = name
|
||||
@super_class_name = superclass
|
||||
@singleton_class = SingletonClass.new( self , self.type || @name)
|
||||
@single_class = SingletonClass.new( self , self.type || @name)
|
||||
end
|
||||
|
||||
def rxf_reference_name
|
||||
|
@ -51,7 +51,7 @@ module Parfait
|
||||
classes.each do |name , cl|
|
||||
object_type = Parfait.object_space.get_type_by_class_name(name)
|
||||
raise "nil type" unless object_type
|
||||
cl.singleton_class.instance_eval{ @instance_type = class_type}
|
||||
cl.single_class.instance_eval{ @instance_type = class_type}
|
||||
cl.instance_eval{ @instance_type = object_type}
|
||||
cl.instance_eval{ @super_class_name = super_names[name] || :Object}
|
||||
object_type.instance_eval{ @object_class = cl }
|
||||
@ -79,6 +79,9 @@ module Parfait
|
||||
Data16: :DataObject ,
|
||||
Data32: :DataObject ,
|
||||
BinaryCode: :Data32 ,
|
||||
TrueClass: :Data4 ,
|
||||
FalseClass: :Data4 ,
|
||||
NilClass: :Data4 ,
|
||||
Integer: :Data4 ,
|
||||
Word: :Data8 ,
|
||||
List: :Data16 ,
|
||||
@ -106,7 +109,7 @@ module Parfait
|
||||
arguments_type: :Type , self_type: :Type, frame_type: :Type ,
|
||||
name: :Word , blocks: :Block} ,
|
||||
Class: {instance_methods: :List, instance_type: :Type,
|
||||
name: :Word, super_class_name: :Word , singleton_class: :SingletonClass},
|
||||
name: :Word, super_class_name: :Word , single_class: :SingletonClass},
|
||||
DataObject: {},
|
||||
Data4: {},
|
||||
Data8: {},
|
||||
|
@ -71,7 +71,11 @@ module Ruby
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
at_depth(depth , "class #{name}" , @body.to_s(depth + 1) , "end")
|
||||
at_depth(depth , "class #{name} #{super_s}\n#{@body.to_s(depth + 1)}\nend")
|
||||
end
|
||||
# deriviation if apropriate
|
||||
def super_s
|
||||
@super_class_name ? " < #{@super_class_name}" : ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ module Ruby
|
||||
|
||||
def to_s(depth = 0)
|
||||
arg_str = @args.collect{|a| a.to_s}.join(', ')
|
||||
at_depth(depth , "def #{name}(#{arg_str})" , @body.to_s(depth + 1) , "end")
|
||||
at_depth(depth , "def #{name}(#{arg_str})\n #{@body.to_s(1)}\nend")
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ module Vool
|
||||
when MethodExpression
|
||||
node.to_mom(@clazz)
|
||||
when ClassMethodExpression
|
||||
node.to_mom(@clazz.singleton_class)
|
||||
node.to_mom(@clazz.single_class)
|
||||
else
|
||||
raise "Only methods for now #{node.class}:#{node}"
|
||||
end
|
||||
@ -78,7 +78,7 @@ module Vool
|
||||
when MethodExpression
|
||||
target = @clazz
|
||||
when ClassMethodExpression
|
||||
target = @clazz.singleton_class
|
||||
target = @clazz.single_class
|
||||
else
|
||||
raise "Only methods for now #{node.class}:#{node}"
|
||||
end
|
||||
|
@ -12,11 +12,11 @@ module Vool
|
||||
# Must pass in the actual Parfait class (default nil is just to conform to api)
|
||||
def to_parfait( clazz = nil )
|
||||
raise "No class given to class method #{name}" unless clazz
|
||||
clazz.add_instance_method_for(name , make_arg_type , make_frame , body )
|
||||
clazz.single_class.add_instance_method_for(name , make_arg_type , make_frame , body )
|
||||
end
|
||||
|
||||
def to_mom(clazz)
|
||||
raise "not singleton" unless clazz.class == Parfait::SingletonClass
|
||||
raise "not singleton #{clazz.class}" unless clazz.class == Parfait::SingletonClass
|
||||
raise( "no class in #{self}") unless clazz
|
||||
method = clazz.get_instance_method(name )
|
||||
raise( "no class method in #{@name} in #{clazz}") unless method
|
||||
|
@ -49,7 +49,7 @@ module Vool
|
||||
class ModuleName < Expression
|
||||
include Named
|
||||
def ct_type
|
||||
get_named_class.singleton_class.instance_type
|
||||
get_named_class.single_class.instance_type
|
||||
end
|
||||
def to_slot(_)
|
||||
return Mom::SlotDefinition.new( get_named_class, [])
|
||||
|
Reference in New Issue
Block a user