Beispiel #1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private static void EmitCallTarget(ILGenerator il, IOperand target)
        {
            target.EmitTarget(il);

            if (target.OperandType.IsValueType)
            {
                if (target is ICanEmitAddress)
                {
                    target.EmitAddress(il);
                }
                else
                {
                    target.EmitLoad(il);

                    var temp = il.DeclareLocal(target.OperandType);
                    il.Emit(OpCodes.Stloc, temp);
                    il.Emit(OpCodes.Ldloca, (short)temp.LocalIndex);
                }

                il.Emit(OpCodes.Constrained, target.OperandType);
            }
            else
            {
                target.EmitLoad(il);
            }
        }