Fanx.Emit.FTypeEmit.emitInstanceInit C# (CSharp) Méthode

emitInstanceInit() protected méthode

protected emitInstanceInit ( FMethod m ) : void
m Fanx.Fcode.FMethod
Résultat void
        protected virtual void emitInstanceInit(FMethod m)
        {
            hasInstanceInit = true;
              PERWAPI.CILInstructions code = ctor.CreateCodeBuffer();

              // initalize code to call super
              code.Inst(PERWAPI.Op.ldarg_0);

              // if closure, push FuncType static field
              if (funcType != null)
              {
            code.FieldInst(PERWAPI.FieldOp.ldsfld, typeField);
            PERWAPI.Method baseCtor = emitter.findMethod(baseClassName, ".ctor",
              new string[] { "Fan.Sys.FuncType" }, "System.Void");
            baseCtor.AddCallConv(PERWAPI.CallConv.Instance); // if stub, make sure instance callconv
            code.MethInst(PERWAPI.MethodOp.call, baseCtor);
              }
              else
              {
            PERWAPI.Method baseCtor = emitter.findMethod(baseClassName, ".ctor",
              new string[0], "System.Void");
            baseCtor.AddCallConv(PERWAPI.CallConv.Instance); // if stub, make sure instance callconv
            code.MethInst(PERWAPI.MethodOp.call, baseCtor);
              }

              // make peer
              if (isNative)
              {
            //code.op(ALOAD_0);  // for putfield
            //code.op(DUP);      // for arg to make
            //code.op2(INVOKESTATIC, method(selfName + "Peer.make(L" + className + ";)L" + className + "Peer;"));
            //code.op2(PUTFIELD, peerField.ref());

            code.Inst(PERWAPI.Op.ldarg_0);
            code.Inst(PERWAPI.Op.dup);
            PERWAPI.Method peerMake = emitter.findMethod(className + "Peer", "make",
              new string[] { className }, className + "Peer");
            code.MethInst(PERWAPI.MethodOp.call, peerMake);
            code.FieldInst(PERWAPI.FieldOp.stfld, peerField);
              }

              if (m == null)
            code.Inst(PERWAPI.Op.ret);
              else
            new FCodeEmit(this, m, code).emit();
        }