/// <summary> /// Adds the class objects to the index assigner. /// </summary> /// <param name="source">The source of the type.</param> /// <param name="assigner">The assigner that the object variables will be added to.</param> public void AddObjectVariablesToAssigner(IndexReference source, VarIndexAssigner assigner) { for (int i = 0; i < objectVariables.Count; i++) { assigner.Add(objectVariables[i], source.CreateChild(i)); } }
public ActionSet New(VarIndexAssigner indexAssigner) { var newActionSet = Clone(); newActionSet.IndexAssigner = indexAssigner ?? throw new ArgumentNullException(nameof(indexAssigner)); return(newActionSet); }
public VarIndexAssigner CreateContained() { VarIndexAssigner newAssigner = new VarIndexAssigner(this); children.Add(newAssigner); return(newAssigner); }
public override void AddObjectVariablesToAssigner(IWorkshopTree reference, VarIndexAssigner assigner) { Extends?.AddObjectVariablesToAssigner(reference, assigner); for (int i = 0; i < ObjectVariables.Count; i++) { ObjectVariables[i].AddToAssigner((Element)reference, assigner); } }
public override void AddObjectVariablesToAssigner(IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(X, Element.Part <V_XOf>(reference)); assigner.Add(Y, Element.Part <V_YOf>(reference)); assigner.Add(Z, Element.Part <V_ZOf>(reference)); assigner.Add(HorizontalAngle, Element.Part <V_HorizontalAngleFromDirection>(reference)); assigner.Add(VerticalAngle, Element.Part <V_VerticalAngleFromDirection>(reference)); }
public bool TryGet(IIndexReferencer var, out IGettable gettable) { VarIndexAssigner current = this; while (current != null) { if (current.references.ContainsKey(var)) { gettable = current.references[var]; return(true); } current = current.parent; } gettable = null; return(false); }
public IGettable this[IIndexReferencer var] { get { VarIndexAssigner current = this; while (current != null) { if (current.references.ContainsKey(var)) { return(current.references[var]); } current = current.parent; } throw new Exception(string.Format("The variable {0} is not assigned to an index.", var.Name)); } private set {} }
public VarIndexAssigner CopyAll(VarIndexAssigner other) { var current = other; while (current != null) { // Copy references foreach (var reference in current.references) { if (!references.ContainsKey(reference.Key)) { references.Add(reference.Key, reference.Value); } } current = current.parent; } return(this); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(X, Element.XOf(reference)); assigner.Add(Y, Element.YOf(reference)); assigner.Add(Z, Element.ZOf(reference)); assigner.Add(Magnitude, Element.MagnitudeOf(reference)); assigner.Add(HorizontalAngle, Element.Part("Horizontal Angle From Direction", reference)); assigner.Add(VerticalAngle, Element.Part("Vertical Angle From Direction", reference)); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(Opposite, Element.Part("Opposite Team Of", reference)); assigner.Add(Score, Element.Part("Team Score", reference)); assigner.Add(OnDefense, Element.Part("Is Team On Defense", reference)); assigner.Add(OnOffense, Element.Part("Is Team On Offense", reference)); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { var functionHandler = ArrayOfType.ArrayHandler.GetFunctionHandler(); assigner.Add(_length, functionHandler.Length(reference)); assigner.Add(_first, functionHandler.FirstOf(reference)); assigner.Add(_last, functionHandler.LastOf(reference)); }
public void AddToAssigner(Element reference, VarIndexAssigner assigner) { assigner.Add(Variable, ArrayStore.CreateChild(reference)); }
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)); }
/// <summary>Adds the class objects to the index assigner.</summary> /// <param name="source">The source of the type.</param> /// <param name="assigner">The assigner that the object variables will be added to.</param> public virtual void AddObjectVariablesToAssigner(IWorkshopTree reference, VarIndexAssigner assigner) { }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { foreach (CodeType included in IncludedTypes) { included.AddObjectVariablesToAssigner(toWorkshop, reference, assigner); } }
public void AddVariableInstancesToAssigner(IVariableInstance[] variables, IWorkshopTree reference, VarIndexAssigner assigner) { var gettables = GetVariableGettables(variables, reference); for (int i = 0; i < variables.Length; i++) { assigner.Add(variables[i].Provider, gettables[i]); } }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(_length, Element.Part("String Length", reference)); }
public ActionSet New(VarIndexAssigner indexAssigner) => new ActionSet(this)
public override void AddObjectVariablesToAssigner(IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(_length, Element.Part <V_CountOf>(reference)); assigner.Add(_last, Element.Part <V_LastOf>(reference)); assigner.Add(_first, Element.Part <V_FirstOf>(reference)); }
private VarIndexAssigner(VarIndexAssigner parent) { this.parent = parent; }
/// <summary>Adds the ObjectVariable to a variable assigner.</summary> public void AddToAssigner(VarIndexAssigner assigner, ToWorkshop toWorkshop, IWorkshopTree reference) => assigner.Add(Variable.Provider, GetGettable(toWorkshop, reference));