GetStelemOpCode() protected static method

protected static GetStelemOpCode ( Type elementType ) : OpCode
elementType IKVM.Reflection.Type
return System.Reflection.Emit.OpCode
Exemplo n.º 1
0
        public void EmitArgs(CodeGen g, Operand[] args)
        {
            if (args.Length != appliedSignature.Length)
            {
                throw new InvalidOperationException();
            }

            if (IsExpanded)
            {
                int  fixedCount = methodSignature.Length - 1;
                Type expType    = methodSignature[fixedCount].GetElementType();

                for (int i = 0; i < fixedCount; i++)
                {
                    EmitArg(g, i, args[i]);
                }

                int arrayLen = args.Length - methodSignature.Length - 1;
                g.EmitI4Helper(arrayLen);
                g.IL.Emit(OpCodes.Newarr, expType);
                OpCode stelemCode = CodeGen.GetStelemOpCode(expType);
                for (int i = 0; i < arrayLen; i++)
                {
                    g.IL.Emit(OpCodes.Dup);
                    g.EmitI4Helper(i);
                    if (stelemCode == OpCodes.Stobj)
                    {
                        g.IL.Emit(OpCodes.Ldelema, expType);
                    }
                    EmitArg(g, fixedCount + i, args[fixedCount + i]);
                    if (stelemCode == OpCodes.Stobj)
                    {
                        g.IL.Emit(OpCodes.Stobj, expType);
                    }
                    else
                    {
                        g.IL.Emit(stelemCode);
                    }
                }
            }
            else
            {
                for (int i = 0; i < args.Length; i++)
                {
                    EmitArg(g, i, args[i]);
                }
            }
        }