コード例 #1
0
ファイル: StatementAnalyzer.cs プロジェクト: dlurton/Happy
 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;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        public Node PrependStatement(StatementNodeBase[] statements)
        {
            if (statements == null) throw new ArgumentNullException("statements");

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

            return this;
        }
コード例 #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);
        }
コード例 #5
0
        protected LoopStatementNodeBase(StatementNodeBase body, IEnumerable<AttributeNode> attributes)
        {
            if (attributes == null)
                ThrowHelper.ThrowArgumentNullException(() => attributes);

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

            AddChildren(Body);
            AddChildren(Attributes);
        }
コード例 #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);
        }
コード例 #7
0
        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);
        }
コード例 #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);
        }
コード例 #9
0
 public ForeachLoopStatementNode Foreach(string variable, TypeNameNode variableType, ExpressionNode expression, StatementNodeBase body)
 {
     return Foreach(variable, variableType, expression, body, new AttributeNode[0]);
 }
コード例 #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);
        }
コード例 #11
0
 public BlockStatementNode Block(StatementNodeBase[] statements)
 {
     return Block(statements, new AttributeNode[0]);
 }