public static ForeachStatement Foreach(this BlockStatement blockStatement, string itemName, Expression expression,
                                           Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            var foreachStatement = new ForeachStatement(new NameElement(itemName), expression, nestedBlockStatement);
            blockStatement.AddStatement(foreachStatement);
            return foreachStatement;
        }
        public static IfStatement If(this BlockStatement blockStatement, Expression expression,
                                     Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            var ifStatement = new IfStatement(expression, nestedBlockStatement);
            blockStatement.AddStatement(ifStatement);
            return ifStatement;
        }
Exemplo n.º 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="translationUnit"></param>
 /// <param name="method"></param>
 /// <returns></returns>
 public static VariableDeclarationTranslationUnit AddVariable(this MethodDeclarationTranslationUnit translationUnit, string type, string name)
 {
     var variableDeclaration = VariableDeclarationTranslationUnit.Create(
         type != null ? TypeIdentifierTranslationUnit.Number : null, IdentifierTranslationUnit.Create(name));
     translationUnit.AddStatement(variableDeclaration);
     return variableDeclaration;
 }
        public static WhileStatement While(this BlockStatement blockStatement, Expression expression,
                                           Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            var whileStatement = new WhileStatement(expression, nestedBlockStatement);
            blockStatement.AddStatement(whileStatement);
            return whileStatement;
        }
 public static Statement Statement(this BlockStatement blockStatement, Statement statement)
 {
     blockStatement.AddStatement(statement);
     return statement;
 }
 public static Statement Statement(this BlockStatement blockStatement, Expression expression)
 {
     var statement = expression.AsStatement();
     blockStatement.AddStatement(statement);
     return statement;
 }
 public static ReturnStatement Return(this BlockStatement blockStatement, Expression expression)
 {
     var returnStatement = new ReturnStatement(expression);
     blockStatement.AddStatement(returnStatement);
     return returnStatement;
 }
 public static ForStatement For(this BlockStatement blockStatement, int init)
 {
     var forStatement = new ForStatement { InitValue = init };
     blockStatement.AddStatement(forStatement);
     return forStatement;
 }
 public static DeclarationStatement Declare(this BlockStatement blockStatement, ReferenceExpression refExpression)
 {
     var declarationStatement = new DeclarationStatement(refExpression);
     blockStatement.AddStatement(declarationStatement.Semicolon());
     return declarationStatement;
 }
Exemplo n.º 10
0
 public static SingleComment Comment(this BlockStatement blockStatement, string comment)
 {
     var singleComment = new SingleComment(comment);
     blockStatement.AddStatement(singleComment);
     return singleComment;
 }
Exemplo n.º 11
0
 public static AssignmentExpression Assign(this BlockStatement blockStatement, Expression expression)
 {
     var assignmentExpression = new AssignmentExpression {RightSide = expression};
     blockStatement.AddStatement(assignmentExpression.AsStatement());
     return assignmentExpression;
 }
Exemplo n.º 12
0
 public static YieldReturnStatement YieldReturn(this BlockStatement blockStatement, Expression expression)
 {
     var yieldReturnStatement = new YieldReturnStatement(expression);
     blockStatement.AddStatement(yieldReturnStatement);
     return yieldReturnStatement;
 }