fix redefining typed methods
as happens for predefined Space.main
This commit is contained in:
parent
02c12996b3
commit
769fd71a3d
@ -77,15 +77,16 @@ module Parfait
|
|||||||
def create_method( method_name , arguments , frame)
|
def create_method( method_name , arguments , frame)
|
||||||
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol)
|
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol)
|
||||||
#puts "Self: #{self.class} clazz: #{clazz.name}"
|
#puts "Self: #{self.class} clazz: #{clazz.name}"
|
||||||
found = get_method( method_name )
|
|
||||||
#TODO check types and then what ?
|
|
||||||
return found if found
|
|
||||||
if arguments.is_a?(Hash)
|
|
||||||
raise "May want to get rid of this way"
|
|
||||||
arguments = NamedList.type_for( arguments )
|
|
||||||
end
|
|
||||||
raise "frame must be a type, not:#{frame}" unless frame.is_a?(Type)
|
raise "frame must be a type, not:#{frame}" unless frame.is_a?(Type)
|
||||||
add_method TypedMethod.new( self , method_name , arguments , frame )
|
found = get_method( method_name )
|
||||||
|
if found
|
||||||
|
puts "redefining method #{method_name}" #TODO, this surely must get more complicated
|
||||||
|
raise "attempt to redifine method for different type " unless self == found.for_type
|
||||||
|
found.init(arguments , frame)
|
||||||
|
return found
|
||||||
|
else
|
||||||
|
add_method TypedMethod.new( self , method_name , arguments , frame )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_method( method )
|
def add_method( method )
|
||||||
|
@ -30,10 +30,14 @@ module Parfait
|
|||||||
super()
|
super()
|
||||||
raise "No class #{name}" unless type
|
raise "No class #{name}" unless type
|
||||||
raise "For type, not class #{type}" unless type.is_a?(Type)
|
raise "For type, not class #{type}" unless type.is_a?(Type)
|
||||||
raise "Wrong argument type, expect Type not #{arguments.class}" unless arguments.is_a? Type
|
|
||||||
raise "Wrong frame type, expect Type not #{frame.class}" unless frame.is_a? Type
|
|
||||||
@for_type = type
|
@for_type = type
|
||||||
@name = name
|
@name = name
|
||||||
|
init(arguments, frame)
|
||||||
|
end
|
||||||
|
|
||||||
|
def init(arguments, frame)
|
||||||
|
raise "Wrong argument type, expect Type not #{arguments.class}" unless arguments.is_a? Type
|
||||||
|
raise "Wrong frame type, expect Type not #{frame.class}" unless frame.is_a? Type
|
||||||
@binary = BinaryCode.new 0
|
@binary = BinaryCode.new 0
|
||||||
@arguments = arguments
|
@arguments = arguments
|
||||||
@frame = frame
|
@frame = frame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user