Starting to fix resolve mechanism

resolve had the wrong approach, sort of class based oo
It took methods from "derived" types and just used them
To be correct, those methods would have to be recompiled for the current type, rubyx is type, not class based.
Started on that, still soe strange hang though

Later, type and method analysis may reveal "compatible" types (down only off course) where one could use the exact same code, but that is phase 2
This commit is contained in:
2019-09-29 12:06:37 +03:00
parent 1e5073200c
commit 17f87f7464
9 changed files with 51 additions and 38 deletions

View File

@ -60,12 +60,23 @@ module Parfait
raise "resolve_method #{m_name}.#{m_name.class}" unless m_name.is_a?(Symbol)
method = get_instance_method(m_name)
return method if method
if( super_class_name && super_class_name != :Object )
method = @super_class.resolve_method(m_name)
if( s_class = super_class )
method = s_class.resolve_method(m_name)
end
method
end
# assume resolving is needed, ie getting has failed, raise if it hasnt
def resolve_method!( m_name )
method = get_instance_method(m_name)
if method
tm = @instance_type.method_names
raise "resolve_method #{name}.#{m_name} has #{tm}"
end
return nil unless( s_class = super_class )
s_class.resolve_method(m_name)
end
# adding an instance changes the instance_type to include that variable
def add_instance_variable( name , type)
@instance_type = @instance_type.add_instance_variable( name , type )