/// <summary>Calls the method.</summary>
        private IWorkshopTree ParseCall(ActionSet actionSet, MethodCall methodCall)
        {
            // Create the array used for continuing after a recursive call.
            continueArray = actionSet.VarCollection.Assign("_" + method.Name + "_recursiveContinue", actionSet.IsGlobal, false);
            nextContinue  = actionSet.VarCollection.Assign("_" + method.Name + "_nextContinue", actionSet.IsGlobal, true);
            actionSet.InitialSet().AddAction(continueArray.SetVariable(new V_EmptyArray()));

            ReturnHandler returnHandler = methodCall.ReturnHandler ?? new ReturnHandler(actionSet, method.Name, method.multiplePaths);

            this.returnHandler = returnHandler;

            DefinedMethod.AssignParameters(actionSet, method.ParameterVars, methodCall.ParameterValues, true);

            actionSet.AddAction(Element.Part <A_While>(new V_True()));

            continueAt = new SkipStartMarker(actionSet);
            continueAt.SetSkipCount((Element)nextContinue.GetVariable());
            actionSet.AddAction(continueAt);

            method.block.Translate(actionSet);

            PopParameterStacks(actionSet);

            // Pop the continueArray.
            actionSet.AddAction(Element.Part <A_SkipIf>(new V_Compare(
                                                            Element.Part <V_CountOf>(continueArray.GetVariable()),
                                                            Operators.Equal,
                                                            new V_Number(0)
                                                            ), new V_Number(3)));

            actionSet.AddAction(nextContinue.SetVariable(Element.Part <V_LastOf>(continueArray.GetVariable())));
            actionSet.AddAction(continueArray.ModifyVariable(Operation.RemoveFromArrayByIndex, Element.Part <V_CountOf>(continueArray.GetVariable()) - 1));

            actionSet.AddAction(endOfMethod);
            actionSet.AddAction(new A_End());

            actionSet.AddAction(nextContinue.SetVariable(0));

            return(returnHandler.GetReturnedValue());
        }
Пример #2
0
 public override void Parse(ActionSet actionSet, IWorkshopTree[] parameterValues)
 {
     actionSet = actionSet.New(actionSet.IndexAssigner.CreateContained());
     DefinedMethod.AssignParameters(actionSet, ParameterVars, parameterValues);
     Block.Translate(actionSet);
 }
 public override void Parse(ActionSet actionSet, IWorkshopTree[] parameterValues, object[] additionalParameterData)
 {
     actionSet = actionSet.New(actionSet.IndexAssigner.CreateContained()).PackThis();
     DefinedMethod.AssignParameters(actionSet, ParameterVars, parameterValues);
     Block.Translate(actionSet);
 }