Example #1
0
 private SsaVariable GetVariableFromLoadAddressInstruction(Instruction loadAddressInstruction)
 {
     if (loadAddressInstruction.OpCode == OpCodes.Ldloca)
     {
         return(ssaForm.GetOriginalVariable((VariableReference)loadAddressInstruction.Operand));
     }
     else
     {
         Debug.Assert(loadAddressInstruction.OpCode == OpCodes.Ldarga);
         return(ssaForm.GetOriginalVariable((ParameterReference)loadAddressInstruction.Operand));
     }
 }
Example #2
0
        void DetermineOperands(int stackSize, Instruction inst, int popCount, int pushCount, out SsaVariable target, out SsaVariable[] operands)
        {
            switch (inst.OpCode.Code)
            {
            case Code.Ldarg:
                operands = new SsaVariable[] { ssaForm.GetOriginalVariable((ParameterReference)inst.Operand) };
                target   = stackLocations[stackSize];
                break;

            case Code.Starg:
                operands = new SsaVariable[] { stackLocations[stackSize] };
                target   = ssaForm.GetOriginalVariable((ParameterReference)inst.Operand);
                break;

            case Code.Ldloc:
                operands = new SsaVariable[] { ssaForm.GetOriginalVariable((VariableReference)inst.Operand) };
                target   = stackLocations[stackSize];
                break;

            case Code.Stloc:
                operands = new SsaVariable[] { stackLocations[stackSize] };
                target   = ssaForm.GetOriginalVariable((VariableReference)inst.Operand);
                break;

            case Code.Dup:
                operands = new SsaVariable[] { stackLocations[stackSize] };
                target   = stackLocations[stackSize + 1];
                break;

            default:
                operands = new SsaVariable[popCount];
                for (int i = 0; i < popCount; i++)
                {
                    operands[i] = stackLocations[stackSize + i];
                }

                switch (pushCount)
                {
                case 0:
                    target = null;
                    break;

                case 1:
                    target = stackLocations[stackSize];
                    break;

                default:
                    throw new NotSupportedException("unsupported pushCount=" + pushCount);
                }
                break;
            }
        }