end
class MMParam
- readable var _mmtype: MMType
- readable var _name: Symbol
+ var mmtype: MMType
+ var name: Symbol writable
init ( t : MMType, n : Symbol )
do
- _mmtype = t
- _name = n
+ mmtype = t
+ name = n
end
redef fun to_s do return "{name}: {mmtype}"
end
end
+
+redef class MMExplicitImport
+ var signature : MMSignature
+
+ redef init( local_class : MMLocalClass, meth : MMMethod )
+ do
+ super
+ signature = meth.signature.adaptation_to( local_class.get_type )
+ end
+end
+
# A closure in a signature
class MMClosure
# The name of the closure (without the !)
# 'c' Must be a super-class of self
# Example:
# class A[E]
- # class B[F] special A[F]
- # class C[G] special B[String]
- # class D special C[Float]
+ # class B[F] super A[F]
+ # class C[G] super B[String]
+ # class D super C[Float]
# 'A[Int]'.upcast_for('A') -> 'A[Int]'
# 'A[Int]'.upcast_for('B') -> abort
# 'B[Int]'.upcast_for('B') -> 'B[Int]'
class MMNullableType
super MMType
- var _base_type: MMType
+ readable 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_notnull do return _base_type
end
end
-class MMTypeClass
+abstract class MMTypeClass
super MMType
redef readable var _local_class: MMLocalClass
redef fun mmmodule do return _local_class.mmmodule end
return class_by_name(once ("Bool".to_symbol)).get_type
end
end
+
+# Explicitly imported cast
+class MMImportedCast
+ readable var _from : MMType
+ readable var _to : MMType
+
+ fun is_about_nullable_only : Bool
+ do
+ return ( _from.is_nullable and _to.as_nullable == _from ) or
+ ( _to.is_nullable and _from.as_nullable == _to )
+ end
+
+ fun is_not_null_to_nullable : Bool
+ do
+ return not _from.is_nullable and _to.is_nullable
+ end
+
+ fun is_nullable_to_not_null : Bool
+ do
+ return _from.is_nullable and not _to.is_nullable
+ end
+
+ redef fun == ( o )
+ do
+ return o isa MMImportedCast and
+ o.from == from and o.to == to
+ end
+end
+
+# Method local properties
+redef class MMMethod
+ # casts explicitely imported to be available from native implementation
+ fun explicit_casts : Set[ MMImportedCast ] is abstract
+end