# The closure parameters
readable var _closures: Array[MMClosure] = new Array[MMClosure]
+ # Return the closure named 'name'. Null if no such a closure exists.
+ fun closure_named(name: Symbol): nullable MMClosure
+ do
+ for c in _closures do
+ if c.name == name then return c
+ end
+ return null
+ end
+
# Number of parameters
fun arity: Int
do
if self == s then
return true
end
- assert _recv.module == s.recv.module
+ assert _recv.mmmodule == s.recv.mmmodule
var rt = _return_type
var srt = s.return_type
if arity != s.arity or (rt == null) != (srt == null) then return false
end
s.append("({a.join(",")})")
end
- if _return_type != null then
- s.append(": {_return_type}")
- end
+ var rt = _return_type
+ if rt != null then s.append(": {rt}")
return s.to_s
end
if _recv == r then
return self
end
- var mod = r.module
+ var mod = r.mmmodule
var p = new Array[MMType]
for i in _params do
p.add(i.for_module(mod).adapt_to(r))
# A closure in a signature
class MMClosure
+ # The name of the closure (without the !)
+ readable var _name: Symbol
+
# The signature of the closure
readable var _signature: MMSignature
# Adapt the signature to a different receiver
fun adaptation_to(r: MMType): MMClosure
do
- return new MMClosure(_signature.adaptation_to(r), _is_break, _is_optional)
+ return new MMClosure(_name, _signature.adaptation_to(r), _is_break, _is_optional)
end
- init(s: MMSignature, is_break: Bool, is_optional: Bool)
+ init(name: Symbol, s: MMSignature, is_break: Bool, is_optional: Bool)
do
+ _name = name
_signature = s
_is_break = is_break
_is_optional = is_optional
do
var sig = _signature.not_for_self
if sig != _signature then
- return new MMClosure(sig, _is_break, _is_optional)
+ return new MMClosure(_name, sig, _is_break, _is_optional)
else
return self
end
fun inheriter: MMType do return _inheriter.as(not null)
fun is_reffinement: Bool do
- return stype.module != stype.module
+ return stype.mmmodule != stype.mmmodule
end
fun is_specialisation: Bool do
# Note that static type a related to a specific module
abstract class MMType
# The module where self makes sence
- fun module: MMModule is abstract
+ fun mmmodule: MMModule is abstract
# The local class that self direclty or indirectly refers to
fun local_class: MMLocalClass is abstract
end
class MMNullableType
-special MMType
+ super MMType
var _base_type: MMType
redef fun is_valid do return _base_type.is_valid
redef fun is_nullable: Bool do return true
redef fun as_nullable do return self
init(t: MMType) do _base_type = t
- redef fun module do return _base_type.module
+ redef fun mmmodule do return _base_type.mmmodule
redef fun local_class do return _base_type.local_class
end
class MMTypeClass
-special MMType
+ super MMType
redef readable var _local_class: MMLocalClass
- redef fun module do return _local_class.module end
+ redef fun mmmodule do return _local_class.mmmodule end
redef fun <(t) do return t.is_supertype(self)
redef fun to_s
end
class MMTypeSimpleClass
-special MMTypeClass
+ super MMTypeClass
redef fun is_supertype(t)
do
return t.local_class.cshe <= _local_class
redef fun for_module(mod)
do
var t: MMType = self
- if module != mod then
+ if mmmodule != mod then
t = _local_class.for_module(mod).get_type
end
return t
# The type of null
class MMTypeNone
-special MMType
- redef readable var _module: MMModule
+ super MMType
+ redef readable var _mmmodule: MMModule
redef fun is_nullable: Bool do return true
redef fun <(t) do return t isa MMTypeNone or t isa MMNullableType
redef fun to_s do return "null"
redef fun as_nullable do return self
redef fun as_notnull do abort
- private init(m: MMModule) do _module = m
+ private init(m: MMModule) do _mmmodule = m
end
redef class MMModule