コード例 #1
0
        //  TypeSystem typeSystem;

        public SimpleControlFlow(ILBlock method, GMContext context)
        {
            this.context = context;
            //  this.typeSystem = context.CurrentMethod.Module.TypeSystem;

            foreach (ILLabel target in method.GetSelfAndChildrenRecursive <ILExpression>(e => e.IsBranch()).SelectMany(e => e.GetBranchTargets()))
            {
                labelGlobalRefCount[target] = labelGlobalRefCount.GetOrDefault(target) + 1;
            }
            foreach (ILBasicBlock bb in method.GetSelfAndChildrenRecursive <ILBasicBlock>())
            {
                foreach (ILLabel label in bb.GetChildren().OfType <ILLabel>())
                {
                    labelToBasicBlock[label] = bb;
                }
            }
        }
コード例 #2
0
 public AccountRepository(GMContext context) :
     base(context)
 {
 }
コード例 #3
0
 public StoreDataRepository(GMContext context, IHostEnvironment _hostingEnvironment)
     : base(context)
 {
     HostingEnvironment = _hostingEnvironment;
 }
コード例 #4
0
 public PatientRepository(GMContext context) :
     base(context)
 {
 }
コード例 #5
0
 public SettingsRepository(GMContext context) :
     base(context)
 {
 }
コード例 #6
0
 protected BaseRepository(GMContext context)
 {
     Context = context;
 }
コード例 #7
0
        public ILBlock Build(SortedList <int, Instruction> code, bool optimize, GMContext context)  //  List<string> StringList, List<string> InstanceList = null) //DecompilerContext context)
        {
            if (code.Count == 0)
            {
                return(new ILBlock());
            }
            this.context = context;


            _method       = code;
            this.optimize = optimize;
            List <ILNode> ast = BuildPreAst();

            ILBlock method = new ILBlock();

            method.Body = ast;
            if (context.Debug)
            {
                method.DebugSave("raw_body.txt");
            }
            betteribttest.Dissasembler.Optimize.RemoveRedundantCode(method);
            foreach (var block in method.GetSelfAndChildrenRecursive <ILBlock>())
            {
                Optimize.SplitToBasicBlocks(block);
            }
            if (context.Debug)
            {
                method.DebugSave("basic_blocks.txt");
            }

            new BuildFullAst(method, context).ProcessAllExpressions(method);
            if (context.Debug)
            {
                method.DebugSave("basic_blocks2.txt");
            }
            foreach (ILBlock block in method.GetSelfAndChildrenRecursive <ILBlock>())
            {
                bool modified;
                do
                {
                    modified  = false;
                    modified |= block.RunOptimization(new SimpleControlFlow(method, context).PushEnviromentFix);
                    modified |= block.RunOptimization(new SimpleControlFlow(method, context).SimplifyShortCircuit);
                    modified |= block.RunOptimization(new SimpleControlFlow(method, context).SimplifyTernaryOperator);


                    modified |= block.RunOptimization(new SimpleControlFlow(method, context).JoinBasicBlocks);
                    modified |= block.RunOptimization(Optimize.SimplifyLogicNot);
                } while (modified);
            }
            if (context.Debug)
            {
                method.DebugSave("before_loop.txt");
            }
            foreach (ILBlock block in method.GetSelfAndChildrenRecursive <ILBlock>())
            {
                new LoopsAndConditions().FindLoops(block);
            }
            if (context.Debug)
            {
                method.DebugSave("before_conditions.txt");
            }
            foreach (ILBlock block in method.GetSelfAndChildrenRecursive <ILBlock>())
            {
                new LoopsAndConditions().FindConditions(block);
            }

            FlattenBasicBlocks(method);
            if (context.Debug)
            {
                method.DebugSave("before_gotos.txt");
            }
            Optimize.RemoveRedundantCode(method);
            new GotoRemoval().RemoveGotos(method);
            Optimize.RemoveRedundantCode(method);

            new GotoRemoval().RemoveGotos(method);

            GotoRemoval.RemoveRedundantCode(method);
            new GotoRemoval().RemoveGotos(method);

            if (context.Debug)
            {
                method.DebugSave("final.cpp");
            }
            return(method);
        }