/// <summary> /// Emit wrapper. /// </summary> private void emitWrapper(PERWAPI.MethodDef main, int paramLen) { // use explicit param count, and clear code this.paramLen = paramLen; this.code = null; int numArgs = isStatic && !self ? paramLen : paramLen+1; // TODO - this code probably isn't quite right, since it looks // like we generate local variables even when they might not be // used. Doesn't hurt anything, but is probably more efficient // if we could determine that from the fcode. // define our locals int numLocals = method.m_paramCount - paramLen; string[] localNames = new string[numLocals]; string[] localTypes = new string[numLocals]; for (int i=paramLen; i<method.m_paramCount; i++) { localNames[i-paramLen] = method.m_vars[i].name; localTypes[i-paramLen] = emit.nname(method.m_vars[i].type); } // emit code PERWAPI.CILInstructions code = doEmit(localNames, localTypes); // push arguments passed thru pushArgs(code, !(isStatic && !self), paramLen); // emit default arguments FCodeEmit.Reg[] regs = FCodeEmit.initRegs(emit.pod, isStatic, method.m_vars); int maxLocals = method.maxLocals(); int maxStack = 16; // TODO - add additional default expr stack height for (int i=paramLen; i<method.m_paramCount; i++) { FCodeEmit ce = new FCodeEmit(emit, method.m_vars[i].def, code, regs, emit.pod.typeRef(method.m_ret)); ce.paramCount = numArgs; ce.vars = method.m_vars; ce.isStatic = isStatic; // TODO - is this correct? ce.emit(false); // don't emit debug s cope for wrappers maxStack = System.Math.Max(maxStack, 2+i+8); } // TODO //code.maxLocals = maxLocals; //code.maxStack = maxStack; // call master implementation if (isStatic) code.MethInst(PERWAPI.MethodOp.call, main); else code.MethInst(PERWAPI.MethodOp.callvirt, main); // return code.Inst(PERWAPI.Op.ret); }
/// <summary> /// Emit wrapper. /// </summary> private void emitWrapper(PERWAPI.MethodDef main, int paramLen) { // use explicit param count, and clear code this.paramLen = paramLen; this.code = null; int numArgs = isStatic && !self ? paramLen : paramLen + 1; // TODO - this code probably isn't quite right, since it looks // like we generate local variables even when they might not be // used. Doesn't hurt anything, but is probably more efficient // if we could determine that from the fcode. // define our locals int numLocals = method.m_paramCount - paramLen; string[] localNames = new string[numLocals]; string[] localTypes = new string[numLocals]; for (int i = paramLen; i < method.m_paramCount; i++) { localNames[i - paramLen] = method.m_vars[i].name; localTypes[i - paramLen] = emit.nname(method.m_vars[i].type); } // emit code PERWAPI.CILInstructions code = doEmit(localNames, localTypes); // push arguments passed thru pushArgs(code, !(isStatic && !self), paramLen); // emit default arguments FCodeEmit.Reg[] regs = FCodeEmit.initRegs(emit.pod, isStatic, method.m_vars); int maxLocals = method.maxLocals(); int maxStack = 16; // TODO - add additional default expr stack height for (int i = paramLen; i < method.m_paramCount; i++) { FCodeEmit ce = new FCodeEmit(emit, method.m_vars[i].def, code, regs, emit.pod.typeRef(method.m_ret)); ce.paramCount = numArgs; ce.vars = method.m_vars; ce.isStatic = isStatic; // TODO - is this correct? ce.emit(false); // don't emit debug s cope for wrappers maxStack = System.Math.Max(maxStack, 2 + i + 8); } // TODO //code.maxLocals = maxLocals; //code.maxStack = maxStack; // call master implementation if (isStatic) { code.MethInst(PERWAPI.MethodOp.call, main); } else { code.MethInst(PERWAPI.MethodOp.callvirt, main); } // return code.Inst(PERWAPI.Op.ret); }