# The signature of the property (where it is declared)
readable writable attr _signature: MMSignature
+ attr _signatures_cache: HashMap[MMType, MMSignature] = new HashMap[MMType, MMSignature]
+
# Return the adapted signature of self for a receiver of type t
meth signature_for(t: MMType): MMSignature do
- var x = self
- assert x isa MMConcreteProperty
- return x.signature.adaptation_to(t)
+ if t == local_class.get_type then return signature
+
+ if _signatures_cache.has_key(t) then return _signatures_cache[t]
+
+ var res = signature.adaptation_to(t)
+ _signatures_cache[t] = res
+ return res
end
end
return true
end
assert _recv.module == s.recv.module
- assert arity == s.arity
- assert (_return_type == null) == (s.return_type == null)
+ if arity != s.arity or (_return_type == null) != (s.return_type == null) then return false
if _return_type != null and not _return_type < s.return_type then
return false
end
# a double dispatch is needed
meth is_supertype(t: MMType): Bool is abstract
- # Select a method from its name
- meth select_method(name: Symbol): MMMethod
- do
- assert local_class != null
- assert name != null
- var res = select_property(local_class.method(name))
- assert res isa MMMethod
- return res
- end
-
- # Select an attribute from its name
- meth select_attribute(name: Symbol): MMAttribute
- do
- assert name != null
- assert local_class != null
- var res = select_property(local_class.attribute(name))
- assert res isa MMAttribute
- return res
- end
-
- # Select a local property from its global property
- meth select_property(t: MMGlobalProperty): MMLocalProperty is abstract
-
# Adapt self to another module
meth for_module(mod: MMModule): MMType is abstract
return t.local_class.cshe <= _local_class
end
- redef meth select_property(g)
- do
- assert _local_class != null
- if g == null then
- return null
- end
- return _local_class[g]
- end
-
redef meth for_module(mod)
do
var t: MMType = self
redef meth adapt_to(recv) do return self
- redef init(c: MMLocalClass)
+ init(c: MMLocalClass)
do
super(c)
end