public void Setup() { IExpression expression = CreationUtilities.CreateExpression(); variable1 = GlobalContext.Instance.AddVariable("MyVariable", KnownTypes.Int); assignment = expression.SetAsAssignment(variable1); variable2 = GlobalContext.Instance.AddVariable("MyVariable2", KnownTypes.Int); }
public IAssignment SetAsAssignment(IReadOnlyVariable assignTo) { if (ComponentsHead != null) throw new InvalidOperationException("The expression has already been set! It cannot be set twice."); if (assignTo == null) throw new ArgumentNullException(); //TODO: check that the context can access this variable... Assignment assignment = new Assignment(assignTo); this.ComponentsHead = assignment; return assignment; }
public IDeclaration SetAsDeclaration(string variableName, IReadOnlyType type, out IReadOnlyVariable variableCreated) { if (ComponentsHead != null) throw new InvalidOperationException("The expression has already been set! It cannot be set twice."); if (variableName == null || type == null) throw new ArgumentNullException(); if (owningContext.ContainsVariable(variableName)) throw new InvalidOperationException("A variable with that name already exists!"); variableCreated = owningContext.AddVariable(variableName, type); Declaration declaration = new Declaration(variableName, type); this.ComponentsHead = declaration; return declaration; }
public GetVariable(IReadOnlyVariable variable) { this.Variable = variable; }
public Assignment(IReadOnlyVariable toVariable) { AssignedTo = toVariable; }
public static IGetVariableStatement CreateVariable(IReadOnlyVariable variable) { return new GetVariable(variable); }