Exemplo n.º 1
0
 public IWorkshopTree ToWorkshop(ActionSet actionSet) => ValueExpression.Parse(actionSet);
Exemplo n.º 2
0
 private static IWorkshopTree GenericSort <T>(ActionSet actionSet, MethodCall methodCall) where T : Element, new() => Element.Part <T>(actionSet.CurrentObject, ((ILambdaInvocable)methodCall.ParameterValues[0]).Invoke(actionSet, new V_ArrayElement()));
Exemplo n.º 3
0
 public IWorkshopTree Parse(ActionSet actionSet) => Expression.Parse(actionSet);
 public SkipStartMarker(ActionSet actionSet, string comment = null)
 {
     ActionSet = actionSet;
     Comment   = comment;
 }
Exemplo n.º 5
0
 public ForBuilder(ActionSet actionSet, string variableName, Element end)
 {
     Variable   = actionSet.VarCollection.Assign(variableName, actionSet.IsGlobal, false);
     _actionSet = actionSet;
     _end       = end;
 }
Exemplo n.º 6
0
 public IWorkshopTree Invoke(ActionSet actionSet, params IWorkshopTree[] parameterValues) => _constFunctionInvoker.Invoke(actionSet, parameterValues);
 public IWorkshopTree Parse(ActionSet actionSet, IWorkshopTree[] parameters) => new V_String(String, ParameterValues.Select(pv => (Element)pv.Parse(actionSet, parameters)).ToArray());
 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);
 }
 public virtual void Parse(ActionSet actionSet, IWorkshopTree[] parameterValues, object[] additionalParameterData)
 {
 }
Exemplo n.º 10
0
 public void Translate(ActionSet actionSet)
 {
     ParseTree(actionSet, false);
 }
Exemplo n.º 11
0
        public ExpressionTreeParseResult ParseTree(ActionSet actionSet, bool expectingValue)
        {
            IGettable        resultingVariable = null; // The resulting variable.
            IWorkshopTree    target            = null; // The resulting player.
            IWorkshopTree    result            = null; // The resulting value.
            VarIndexAssigner currentAssigner   = actionSet.IndexAssigner;
            IWorkshopTree    currentObject     = null;

            Element[] resultIndex = new Element[0];

            for (int i = 0; i < Tree.Length; i++)
            {
                bool          isLast  = i == Tree.Length - 1;
                IWorkshopTree current = null;
                if (Tree[i] is CallVariableAction)
                {
                    var callVariableAction = (CallVariableAction)Tree[i];

                    var reference = currentAssigner[callVariableAction.Calling];
                    current = reference.GetVariable((Element)target);

                    resultIndex = new Element[callVariableAction.Index.Length];
                    for (int ai = 0; ai < callVariableAction.Index.Length; ai++)
                    {
                        var workshopIndex = callVariableAction.Index[ai].Parse(actionSet);
                        resultIndex[ai] = (Element)workshopIndex;
                        current         = Element.Part <V_ValueInArray>(current, workshopIndex);
                    }

                    // If this is the last node in the tree, set the resulting variable.
                    if (isLast)
                    {
                        resultingVariable = reference;
                    }
                }
                else
                {
                    var newCurrent = Tree[i].Parse(actionSet.New(currentAssigner).New(currentObject));
                    if (newCurrent != null)
                    {
                        current     = newCurrent;
                        resultIndex = new Element[0];
                    }
                }

                if (Tree[i].Type() == null)
                {
                    // If this isn't the last in the tree, set it as the target.
                    if (!isLast)
                    {
                        target = current;
                    }
                    currentObject = null;
                }
                else
                {
                    var type = Tree[i].Type();

                    currentObject   = current;
                    currentAssigner = actionSet.IndexAssigner.CreateContained();
                    type.AddObjectVariablesToAssigner(currentObject, currentAssigner);
                }

                result = current;
            }

            if (result == null && expectingValue)
            {
                throw new Exception("Expression tree result is null");
            }
            return(new ExpressionTreeParseResult(result, resultIndex, target, resultingVariable));
        }
Exemplo n.º 12
0
 public IWorkshopTree Parse(ActionSet actionSet)
 {
     return(ParseTree(actionSet, true).Result);
 }
Exemplo n.º 13
0
        public void TranslateSkip(ActionSet actionSet)
        {
            // Create the skip for the start of the if statement.
            SkipStartMarker ifStart = new SkipStartMarker(actionSet, Expression.Parse(actionSet));

            actionSet.AddAction(ifStart);

            // Translate the if block.
            Block.Translate(actionSet);

            // 'block caps' are skips that are added to the end of the if block and each else-if block.
            // The skips skip to the end of the entire if/else-if/else.
            List <SkipStartMarker> blockCaps = new List <SkipStartMarker>();

            // Add the if cap if there is an else block or there is an else-if block.
            if (ElseBlock != null || ElseIfs.Length > 0)
            {
                SkipStartMarker ifCap = new SkipStartMarker(actionSet);
                actionSet.AddAction(ifCap);
                blockCaps.Add(ifCap);
            }

            // Marks the end of the if statement. If the if-condition is false, `ifStart` will skip to here.
            SkipEndMarker ifEnd = new SkipEndMarker();

            actionSet.AddAction(ifEnd);

            // Set the if-skip's count.
            ifStart.SetEndMarker(ifEnd);

            // Get the else-ifs.
            for (int i = 0; i < ElseIfs.Length; i++)
            {
                // This will equal true if this is at the last else-if and there is no else.
                bool isLast = i == ElseIfs.Length - 1 && ElseBlock == null;

                // Create the skip for the start of the else-if.
                SkipStartMarker elseIfStart = new SkipStartMarker(actionSet, ElseIfs[i].Expression.Parse(actionSet));
                actionSet.AddAction(elseIfStart);

                // Translate the else-if block.
                ElseIfs[i].Block.Translate(actionSet);

                // If this is not the last block in the entire if/else-if/else list, add the 'block cap'.
                if (!isLast)
                {
                    SkipStartMarker elseIfCap = new SkipStartMarker(actionSet);
                    actionSet.AddAction(elseIfCap);
                    blockCaps.Add(elseIfCap);
                }

                // Marks the end of the else-if statement. If the condition is false, `elseIfStart` will skip to here.
                SkipEndMarker elseIfEnd = new SkipEndMarker();
                actionSet.AddAction(elseIfEnd);
                elseIfStart.SetEndMarker(elseIfEnd);
            }

            // If there is an else block, translate it.
            if (ElseBlock != null)
            {
                ElseBlock.Translate(actionSet);
            }

            // contextCap marks the end of the entire if/else-if/list.
            SkipEndMarker contextCap = new SkipEndMarker();

            actionSet.AddAction(contextCap);

            // Set all the block caps so they skip to the end of the list.
            foreach (var blockCap in blockCaps)
            {
                blockCap.SetEndMarker(contextCap);
            }
        }
 public virtual IWorkshopTree Parse(ActionSet actionSet, IExpression expression, object additionalParameterData) => expression.Parse(actionSet);
 public IWorkshopTree Parse(ActionSet actionSet) => actionSet.This;
Exemplo n.º 16
0
 public virtual IWorkshopTree Parse(ActionSet actionSet, IExpression expression, bool asElement) => expression.Parse(actionSet, asElement);
 public IWorkshopTree Parse(ActionSet actionSet)
 {
     return(new V_Null());
 }
 public virtual void Parse(ActionSet actionSet, WorkshopParameter[] parameters)
 {
 }
 public IWorkshopTree Parse(ActionSet actionSet) => String.Parse(actionSet, FormatParameters.Select(fp => fp.Parse(actionSet)).ToArray());
 public void Translate(ActionSet actionSet)
 {
     Loop.AddContinue(actionSet, Comment);
 }
 public SkipStartMarker(ActionSet actionSet, IWorkshopTree condition, string comment = null)
 {
     ActionSet = actionSet;
     Condition = condition;
     Comment   = comment;
 }
 public void Translate(ActionSet actionSet)
 {
     BreakContainer.AddBreak(actionSet, Comment);
 }
 public IWorkshopTree Parse(ActionSet actionSet) => throw new Exception("Cannot parse internal variables.");
 public IWorkshopTree Parse(ActionSet actionSet)
 {
     return(new V_Number(Value));
 }
 public abstract IWorkshopTree Parse(ActionSet actionSet, MethodCall methodCall);
 public IWorkshopTree Parse(ActionSet actionSet) => Element.TernaryConditional(Condition.Parse(actionSet), Consequent.Parse(actionSet), Alternative.Parse(actionSet));
Exemplo n.º 27
0
 // Struct as workshop value.
 public IWorkshopTree Parse(ActionSet actionSet) => new StructAssigner(Type, new StructAssigningAttributes(), false).GetValues(actionSet);
 public IWorkshopTree Parse(ActionSet actionSet) => null;
Exemplo n.º 29
0
 public IWorkshopTree Parse(ActionSet actionSet) => Element.Part <V_Not>(Expression.Parse(actionSet));
Exemplo n.º 30
0
 public override void Return()
 {
     ActionSet.AddAction(Element.Part <A_Abort>());
 }