Ejemplo n.º 1
0
        public void Scramble(out Blockss incGroups)
        {
            Blockss groups = new Blockss();

            foreach (var group in blocks)
            {
                groups.blocks.Insert(generator.Generate <int>(GeneratorType.Integer, groups.blocks.Count), group);
            }
            incGroups = groups;
        }
Ejemplo n.º 2
0
        public Blockss GetBlocks(MethodDef method)
        {
            Blockss blocks = new Blockss();
            Block   block  = new Block();
            int     Id     = 0;
            int     usage  = 0;

            block.ID = Id;
            Id++;
            block.nextBlock = block.ID + 1;
            block.instructions.Add(Instruction.Create(OpCodes.Nop));
            blocks.blocks.Add(block);
            block = new Block();
            foreach (Instruction instruction in method.Body.Instructions)
            {
                int pops = 0;
                int stacks;
                instruction.CalculateStackUsage(out stacks, out pops);
                block.instructions.Add(instruction);
                usage += stacks - pops;
                if (stacks == 0)
                {
                    if (instruction.OpCode != OpCodes.Nop)
                    {
                        if (usage == 0 || instruction.OpCode == OpCodes.Ret)
                        {
                            block.ID = Id;
                            Id++;
                            block.nextBlock = block.ID + 1;
                            blocks.blocks.Add(block);
                            block = new Block();
                        }
                    }
                }
            }
            return(blocks);
        }