+redef class AExternCall
+ fun target_class_name : nullable Symbol do return null
+ fun target_method_name : Symbol is abstract
+
+ redef fun after_typing(v)
+ do
+ var target_class_name = self.target_class_name
+ var target_method_name = self.target_method_name
+
+ var target_class : MMLocalClass
+ var target_method : MMMethod
+
+ # find class
+ # self.target_class_name can be redef'd by sub-classes
+ if target_class_name == null then
+ target_class = v.local_property.local_class
+ else
+ if v.local_property.mmmodule.has_global_class_named( target_class_name ) then
+ var global_class = v.local_property.mmmodule.global_class_named( target_class_name )
+ target_class = v.local_property.mmmodule[ global_class ]
+ else
+ v.error( self, "Error: class {target_class_name.to_s}, not found." )
+ return
+ end
+ end
+
+ if target_class.has_global_property_by_name( target_method_name ) then
+ var global_property = target_class.get_property_by_name( target_method_name )
+
+ var target_property = target_class[global_property]
+
+ if target_property isa MMMethod then
+ target_method = target_property
+ else
+ v.error( self, "Error: property {target_method_name.to_s} is not a method." )
+ return
+ end
+ else
+ v.error( self, "Error: property {target_method_name.to_s} not found in target class." )
+ return
+ end
+
+ var explicit_import = new MMExplicitImport( target_class, target_method )
+ v.local_property.as(MMSrcMethod).explicit_imports.add( explicit_import )
+ end
+end
+
+redef class ALocalPropExternCall
+ redef fun target_class_name do return null
+ redef fun target_method_name do return n_methid.name.as(not null)
+end
+
+redef class ASuperExternCall
+ redef fun after_typing(v)
+ do
+ var precs: Array[MMLocalProperty] = v.local_property.prhe.direct_greaters
+ if not precs.is_empty then
+ v.local_property.need_super = true
+ else
+ v.error(self, "Error: No super method to call for {v.local_property}.")
+ return
+ end
+ end
+end
+
+redef class AFullPropExternCall
+ redef fun target_class_name do return n_classid.to_symbol
+ redef fun target_method_name do return n_methid.name.as(not null)
+end
+
+redef class AInitPropExternCall
+ redef fun target_class_name do return n_classid.to_symbol
+ redef fun target_method_name do return "init".to_symbol
+end
+
+redef class ACastExternCall
+ fun from_type : MMType is abstract
+ fun to_type : MMType is abstract
+
+ redef fun after_typing(v)
+ do
+ if from_type == to_type
+ then
+ v.error( self, "Attepting to cast from and to the same type." )
+ end
+
+ var cast = new MMImportedCast( from_type, to_type )
+ var m = v.local_property
+ assert m isa MMMethod
+ m.explicit_casts.add( cast )
+ end
+end
+
+redef class ACastAsExternCall
+ redef fun from_type do return n_from_type.stype
+ redef fun to_type do return n_to_type.stype
+end
+
+redef class AAsNullableExternCall
+ redef fun from_type do return n_type.stype
+ redef fun to_type do return n_type.stype.as_nullable
+end
+
+redef class AAsNotNullableExternCall
+ redef fun from_type
+ do
+ var t = n_type.stype
+ if t.is_nullable
+ then
+ return t
+ else
+ return t.as_nullable
+ end
+ end
+ redef fun to_type do return n_type.stype.as_notnull
+end
+