internal static Constructor CreateConstructor(Class declaringType, string name, NativeFunction function) { Constructor ctor = new Constructor(); ctor.Name = name; ctor.Function = function; if (function != null) { function["m"] = var.Cast<Constructor>(ctor); } ctor.DeclaringClass = declaringType; declaringType.Constructors.Push(ctor); return ctor; }
// TODO: This method breaks XaeiO.Compiler2 // NOTE: root cause is the implicit cast from NativeArray<Constructor> to Constructor[] /*private static Constructor BadGetDefaultConstructor(Class klass) { Constructor[] constructors = klass.Constructors; for (int i = 0; i < constructors.Length; i++) { Constructor constructor = constructors[i]; if (constructor.Parameters.Length == 0) { return constructor; } } return null; }*/ private static object CreateInstance(Constructor constructor) { Logging.Debug("Creating object through reflection: " + constructor); XaeiOSObject obj = GenerateCodeForNewObject(constructor.DeclaringClass.VTable); // TODO: initialize fields TrampolineInvokeConstructor(constructor, obj, new object[0]); return obj; }
public static object TrampolineInvokeConstructor(Constructor constructor, object self, object[] args) { TempHackGenerateCodeForTrampolineInvokeMethod(constructor.Function, self, args); // we should never get here! throw new ExecutionEngineException("Trampoline for constructor " + constructor + " failed"); }
public RuntimeConstructorInfo(Constructor constructor, RuntimeType declaringType) { _constructor = constructor; _declaringType = declaringType; }