Exemplo n.º 1
0
 public static Expression Analyze(AnalysisContext analysisContext, StatementNodeBase node)
 {
     var analyzer = new StatementAnalyzer(analysisContext);
     node.Accept(analyzer);
     if(analyzer._result == null)
         throw new InternalException("StatementAnalyzer did not handle a " + node.GetType() + " which is a descendant of StatementNodeBase");
     return analyzer._result;
 }
        public WhileLoopStatementNode(ExpressionNode conditionExpression, StatementNodeBase body, AttributeNode[] attributes)
            : base(body, attributes)
        {
            if (conditionExpression == null)
                throw new ArgumentNullException("conditionExpression", "The ConditionExpression is null!");

            ConditionExpression = conditionExpression;
            AddChildren(ConditionExpression);
        }
Exemplo n.º 3
0
        public Node PrependStatement(StatementNodeBase[] statements)
        {
            if (statements == null) throw new ArgumentNullException("statements");

            InsertChildren(0, statements);
            Statements.InsertRange(0, statements);

            return this;
        }
Exemplo n.º 4
0
        public WhileLoopStatementNode While(ExpressionNode condition, StatementNodeBase body, AttributeNode[] attributes)
        {
            if (condition == null)
                ThrowHelper.ThrowArgumentNullException(() => condition);

            if (attributes == null)
                ThrowHelper.ThrowArgumentNullException(() => attributes);

            return new WhileLoopStatementNode(condition, body, attributes);
        }
Exemplo n.º 5
0
        protected LoopStatementNodeBase(StatementNodeBase body, IEnumerable<AttributeNode> attributes)
        {
            if (attributes == null)
                ThrowHelper.ThrowArgumentNullException(() => attributes);

            Body = body;
            Attributes = attributes.ToList();

            AddChildren(Body);
            AddChildren(Attributes);
        }
Exemplo n.º 6
0
        public ForeachLoopStatementNode Foreach(string variable, TypeNameNode variableType, ExpressionNode expression, StatementNodeBase body, AttributeNode[] attributes)
        {
            if (string.IsNullOrWhiteSpace(variable))
                ThrowHelper.ThrowException("The 'variable' is blank!");
            if (expression == null)
                ThrowHelper.ThrowArgumentNullException(() => expression);
            if (body == null)
                ThrowHelper.ThrowArgumentNullException(() => body);
            if (attributes == null)
                ThrowHelper.ThrowArgumentNullException(() => attributes);

            return new ForeachLoopStatementNode(variable, variableType, expression, body, attributes);
        }
        public ForeachLoopStatementNode(string variable, TypeNameNode variableType, ExpressionNode expression, StatementNodeBase body, AttributeNode[] attributes)
            : base(body, attributes)
        {
            if (string.IsNullOrWhiteSpace(variable))
                ThrowHelper.ThrowException("The 'variable' is blank!");

            if (expression == null) throw new ArgumentNullException("expression", "The expression is null!");

            if (attributes == null)
                ThrowHelper.ThrowArgumentNullException(() => attributes);

            LoopVariable = new IdentifierExpressionNode(variable);
            Expression = expression;
            LoopVariableType = variableType;

            AddChildren(LoopVariable, LoopVariableType, Expression);
        }
Exemplo n.º 8
0
        public MacroCallExpressionNode MacroCall(string name, StatementNodeBase[] actualParameters)
        {
            if (string.IsNullOrWhiteSpace(name))
                ThrowHelper.ThrowException("The 'name' is blank!");

            if (actualParameters == null)
                ThrowHelper.ThrowArgumentNullException(() => actualParameters);

            return new MacroCallExpressionNode(name, actualParameters);
        }
Exemplo n.º 9
0
 public ForeachLoopStatementNode Foreach(string variable, TypeNameNode variableType, ExpressionNode expression, StatementNodeBase body)
 {
     return Foreach(variable, variableType, expression, body, new AttributeNode[0]);
 }
Exemplo n.º 10
0
        public BlockStatementNode Block(StatementNodeBase[] statements, AttributeNode[] attributes)
        {
            if (statements == null) throw new ArgumentNullException("statements");
            if (attributes == null)
                ThrowHelper.ThrowArgumentNullException(() => attributes);

            return new BlockStatementNode(statements, attributes);
        }
Exemplo n.º 11
0
 public BlockStatementNode Block(StatementNodeBase[] statements)
 {
     return Block(statements, new AttributeNode[0]);
 }