protected override RoutineDelegate GenerateArglessStub() { ClrMethod clr_method = ClrMethod; Debug.Assert(clr_method != null, "CLR method should be fully reflected"); #if DEBUG_METHOD_STUBS AssemblyName name = new AssemblyName("MethodStub_" + clr_method.ToString().Replace(':', '_')); AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save, "C:\\Temp"); ModuleBuilder mb = ab.DefineDynamicModule(name.Name, name.Name + ".dll"); TypeBuilder tb = mb.DefineType(clr_method.Name.ToString()); MethodBuilder mmb = tb.DefineMethod("<^MethodStub>", PhpFunctionUtils.DynamicStubAttributes, CallingConventions.Standard, Types.Object[0], Types.Object_PhpStack); ILEmitter tmpil = new ILEmitter(mmb); IndexedPlace tmpinstance = new IndexedPlace(PlaceHolder.Argument, 0); IndexedPlace tmpstack = new IndexedPlace(PlaceHolder.Argument, 1); clr_method.EmitArglessStub(tmpil, tmpstack, tmpinstance); tb.CreateType(); ab.Save(name.Name + ".dll"); #endif #if SILVERLIGHT DynamicMethod stub = new DynamicMethod("<^>." + clr_method.Name.Value, Types.Object[0], Types.Object_PhpStack); #else DynamicMethod stub = new DynamicMethod("<^>." + clr_method.Name.Value, PhpFunctionUtils.DynamicStubAttributes, CallingConventions.Standard, Types.Object[0], Types.Object_PhpStack, this.declaringType.RealType, true); #endif ILEmitter il = new ILEmitter(stub); IndexedPlace instance = new IndexedPlace(PlaceHolder.Argument, 0); IndexedPlace stack = new IndexedPlace(PlaceHolder.Argument, 1); clr_method.EmitArglessStub(il, stack, instance); // TODO: is it possible to drop the member? // the compiler may get activated: // member = null; this.arglessStubMethod = stub; return((RoutineDelegate)stub.CreateDelegate(typeof(RoutineDelegate))); }