Beispiel #1
0
        // IFunctionLookupTable
        public void Build(FunctionBuildController builder)
        {
            // Create the switch that chooses the lambda.
            SwitchBuilder lambdaSwitch = new SwitchBuilder(builder.ActionSet);

            foreach (IFunctionHandler option in _functionHandlers)
            {
                // The action set for the overload.
                ActionSet optionSet = builder.ActionSet.New(builder.ActionSet.IndexAssigner.CreateContained());

                // Go to next case
                lambdaSwitch.NextCase(new V_Number(_identifiers[option.UniqueIdentifier()]));

                // Add the object variables of the selected method.
                var callerObject = ((Element)builder.ActionSet.CurrentObject)[1];

                // Add the class objects.
                option.ContainingType?.AddObjectVariablesToAssigner(callerObject, optionSet.IndexAssigner);

                // then parse the block.
                builder.Subcall(optionSet.SetThis(callerObject).New(builder.ActionSet.CurrentObject), option);
            }

            // Finish the switch.
            lambdaSwitch.Finish(((Element)builder.ActionSet.CurrentObject)[0]);
        }
Beispiel #2
0
        public SwitchBuilder SwitchFor <TProperty>(Expression <Func <TModel, TProperty> > expression)
        {
            SwitchBuilder switchBuilder = Switch();

            switchBuilder.PrepareEditorFor(base.Html, expression);
            return(switchBuilder);
        }
        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder()
        {
            ResolveExpression();
            var builder = new SwitchBuilder();

            Config(builder);
            return(builder);
        }
Beispiel #4
0
        void IWorkshopFunctionController.Build(ActionSet actionSet)
        {
            var returnHandlers = new List <ReturnHandler>();

            // Create the switch that chooses the lambda.
            SwitchBuilder lambdaSwitch = new SwitchBuilder(actionSet);

            for (int i = 0; i < _compatibleLambdas.Count; i++)
            {
                var compatibleLambda = _compatibleLambdas[i];
                _returnRecycler.Reset();

                // Create the return handler for the option.
                ReturnHandler returnHandler = new ReturnHandler(
                    actionSet,
                    compatibleLambda.Runner.ReturnType?.GetGettableAssigner(new AssigningAttributes("lambdaReturnValue", true, false))
                    // Get the IGettable
                    .GetValue(new GettableAssignerValueInfo(actionSet)
                {
                    SetInitialValue       = SetInitialValue.DoNotSet,
                    IndexReferenceCreator = _returnRecycler
                }),
                    compatibleLambda.Runner.ReturnType != null);
                returnHandlers.Add(returnHandler);

                // The action set for the overload.
                ActionSet optionSet = actionSet.ContainVariableAssigner().New(returnHandler).SetThisTypeLinker(compatibleLambda.TypeLinker);

                // Go to next case
                lambdaSwitch.NextCase(Element.Num(compatibleLambda.Identifier));

                // Add the object variables of the selected method.
                var callerObject = ((Element)optionSet.CurrentObject)[1];

                // Add the class objects.
                compatibleLambda.Runner.This?.AddObjectVariablesToAssigner(optionSet.ToWorkshop, callerObject, optionSet.IndexAssigner);

                // Add parameters.
                compatibleLambda.Runner.AddToAssigner(optionSet.IndexAssigner);

                // then parse the block.
                compatibleLambda.Runner.Build(optionSet, returnHandler);
            }

            // Finish the switch.
            lambdaSwitch.Finish(((Element)actionSet.CurrentObject)[0]);

            foreach (var returnHandler in returnHandlers)
            {
                returnHandler.ApplyReturnSkips();
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder()
        {
            ResolveExpression();
            var builder = new SwitchBuilder();

            Config(builder);
            var formControlBuilder = new FormControlBuilder();

            if (formControlBuilder.HasGrid(_config) == false)
            {
                return(builder);
            }
            formControlBuilder.AddLayout(_config);
            formControlBuilder.AppendContent(builder);
            return(formControlBuilder);
        }
 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     this.methodContext = context.get_MethodContext();
     V_0 = context.get_MethodContext().get_Method().get_Module().get_TypeSystem();
     this.logicalBuilderContext     = new LogicalFlowBuilderContext(context.get_MethodContext().get_ControlFlowGraph());
     this.cfgBlockSplitter          = new CFGBlockSplitter(this.logicalBuilderContext);
     this.conditionBuilder          = new ConditionBuilder(this.logicalBuilderContext, V_0);
     this.loopBuilder               = new LoopBuilder(this.logicalBuilderContext, V_0);
     this.switchBuilder             = new SwitchBuilder(this.logicalBuilderContext);
     this.ifBuilder                 = new IfBuilder(this.logicalBuilderContext, this.methodContext.get_Method().get_Module().get_TypeSystem());
     this.followNodeDeterminator    = new FollowNodeDeterminator(V_0);
     this.yieldGuardedBlocksBuilder = new YieldGuardedBlocksBuilder(this.logicalBuilderContext, context);
     this.GetMaxIndexOfBlock();
     this.InitializeTheBlock();
     this.guardedBlocksBuilder = new GuardedBlocksBuilder(this.logicalBuilderContext);
     context.get_MethodContext().set_LogicalConstructsTree(this.BuildLogicalConstructTree());
     context.get_MethodContext().set_LogicalConstructsContext(this.logicalBuilderContext);
     return(body);
 }
        public BlockStatement Process(DecompilationContext context, BlockStatement body)
        {
            this.methodContext = context.MethodContext;
            TypeSystem typeSystem = context.MethodContext.Method.Module.TypeSystem;

            logicalBuilderContext     = new LogicalFlowBuilderContext(context.MethodContext.ControlFlowGraph);
            cfgBlockSplitter          = new CFGBlockSplitter(logicalBuilderContext);
            conditionBuilder          = new ConditionBuilder(logicalBuilderContext, typeSystem);
            loopBuilder               = new LoopBuilder(logicalBuilderContext, typeSystem);
            switchBuilder             = new SwitchBuilder(logicalBuilderContext);
            ifBuilder                 = new IfBuilder(logicalBuilderContext, methodContext.Method.Module.TypeSystem);
            followNodeDeterminator    = new FollowNodeDeterminator(typeSystem);
            yieldGuardedBlocksBuilder = new YieldGuardedBlocksBuilder(logicalBuilderContext, context);

            GetMaxIndexOfBlock();
            InitializeTheBlock();

            guardedBlocksBuilder = new GuardedBlocksBuilder(logicalBuilderContext);

            context.MethodContext.LogicalConstructsTree    = BuildLogicalConstructTree();
            context.MethodContext.LogicalConstructsContext = logicalBuilderContext;

            return(body);
        }
Beispiel #8
0
 // Create the switch that chooses the overload.
 protected override void InitiateSelector() => _selector = new SwitchBuilder(ActionSet);