Esempio n. 1
0
        // Token: 0x06002164 RID: 8548 RVA: 0x00093278 File Offset: 0x00092278
        public static void Main2(string[] args)
        {
            StackEmulator.InitStack();
            StackEmulator.PushValue(1);
            StackEmulator.Dup();
            int num = StackEmulator.PopValue();

            StackEmulator.PushValue(2);
            int num2 = StackEmulator.PopValue();
            int num3 = StackEmulator.PopValue();

            Console.WriteLine("Hello World!");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Esempio n. 2
0
        public int EmulateExpression(int ins_index, ref int local_value1, ref int local_value2)
        {
            int result = -1;

            for (int i = ins_index; i < this.instructions.Count; i++)
            {
                if (this.instructions[i].IsStloc())
                {
                    Local local = this.instructions[i].GetLocal(this.method.Body.Variables);
                    if (local == this.local_variable1)
                    {
                        local_value1 = StackEmulator.PopValue();
                    }
                    if (local == this.local_variable2)
                    {
                        local_value2 = StackEmulator.PopValue();
                    }
                }
                if (this.instructions[i].IsLdloc())
                {
                    Local local = this.instructions[i].GetLocal(this.method.Body.Variables);
                    if (local == this.local_variable1)
                    {
                        StackEmulator.PushValue(local_value1);
                    }
                    if (local == this.local_variable2)
                    {
                        StackEmulator.PushValue(local_value2);
                    }
                }
                if (this.instructions[i].IsLdcI4())
                {
                    int num = this.instructions[i].GetLdcI4Value();
                    StackEmulator.PushValue(num);
                }
                if (this.IsArithmetic(this.instructions[i]))
                {
                    int value  = StackEmulator.PopValue();
                    int value2 = StackEmulator.PopValue();
                    int value3 = this.CalculateArithmetic(value2, value, this.instructions[i]);
                    StackEmulator.PushValue(value3);
                }
                if (this.instructions[i].OpCode == OpCodes.Neg)
                {
                    int num = StackEmulator.PopValue();
                    num = -num;
                    StackEmulator.PushValue(num);
                }
                if (this.instructions[i].OpCode == OpCodes.Not)
                {
                    int num = StackEmulator.PopValue();
                    num = ~num;
                    StackEmulator.PushValue(num);
                }
                if (this.instructions[i].OpCode == OpCodes.Dup)
                {
                    StackEmulator.Dup();
                }
                if (this.instructions[i].OpCode == OpCodes.Switch)
                {
                    result = StackEmulator.PopValue();
                    break;
                }
            }
            return(result);
        }