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
        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 #3
0
        // Finalize the switch.
        protected override void Completed()
        {
            ClassData classData = ActionSet.Translate.DeltinScript.GetComponent <ClassData>();

            _selector.Finish(Element.ValueInArray(classData.ClassIndexes.GetVariable(), ActionSet.CurrentObject));
        }