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);
        }
Example #2
0
        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;
        }
Example #3
0
        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;
        }
Example #4
0
 public GetVariable(IReadOnlyVariable variable)
 {
     this.Variable = variable;
 }
Example #5
0
 public Assignment(IReadOnlyVariable toVariable)
 {
     AssignedTo = toVariable;
 }
 public static IGetVariableStatement CreateVariable(IReadOnlyVariable variable)
 {
     return new GetVariable(variable);
 }