Exemplo n.º 1
0
        private Cecil.Cil.Instruction GetTarget(string of, IDictionary <Model.Bytecode.Instruction, IList <Mono.Cecil.Cil.Instruction> > map)
        {
            TargetFinder targetFinder = new TargetFinder(map.Keys);

            AnalysisNet.Bytecode.Instruction analysisNetIns = targetFinder.GetTarget(of);
            return(map[analysisNetIns].First());
        }
Exemplo n.º 2
0
        private void TranslatePendingBranches(IDictionary <Model.Bytecode.Instruction, IList <Mono.Cecil.Cil.Instruction> > translated, IList <AnalysisNet.Bytecode.Instruction> pending)
        {
            TargetFinder targetFinder = new TargetFinder(translated.Keys);

            while (pending.Count > 0)
            {
                AnalysisNet.Bytecode.Instruction ins = pending.First();
                pending.Remove(ins);

                if (ins is AnalysisNet.Bytecode.BranchInstruction br)
                {
                    Cecil.Cil.Instruction result = translated[targetFinder.GetTarget(br.Target)].First();
                    translated[br].First().Operand = result;
                }
                else if (ins is AnalysisNet.Bytecode.SwitchInstruction switchIns)
                {
                    for (int idx = 0; idx < switchIns.Targets.Count; idx++)
                    {
                        string target = switchIns.Targets[idx];
                        Cecil.Cil.Instruction   result       = translated[targetFinder.GetTarget(target)].First();
                        Cecil.Cil.Instruction[] cecilTargets = translated[switchIns].First().Operand as Cecil.Cil.Instruction[];
                        cecilTargets[idx] = result;
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }