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; }
/// <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; }
public static SingleComment Comment(this BlockStatement blockStatement, string comment) { var singleComment = new SingleComment(comment); blockStatement.AddStatement(singleComment); return singleComment; }
public static AssignmentExpression Assign(this BlockStatement blockStatement, Expression expression) { var assignmentExpression = new AssignmentExpression {RightSide = expression}; blockStatement.AddStatement(assignmentExpression.AsStatement()); return assignmentExpression; }
public static YieldReturnStatement YieldReturn(this BlockStatement blockStatement, Expression expression) { var yieldReturnStatement = new YieldReturnStatement(expression); blockStatement.AddStatement(yieldReturnStatement); return yieldReturnStatement; }