C++: Add support for C++11 range-based 'for' loops

Change-Id: I7eef048a7952a79f031ae3d0abba68e3c5ffbfb8
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Flex Ferrum
2012-02-19 16:33:25 +04:00
committed by Roberto Raggi
parent 7f943caedb
commit da2aa0df72
21 changed files with 328 additions and 5 deletions

View File

@@ -669,6 +669,27 @@ ForeachStatementAST *ForeachStatementAST::clone(MemoryPool *pool) const
return ast;
}
RangeBasedForStatementAST *RangeBasedForStatementAST::clone(MemoryPool *pool) const
{
RangeBasedForStatementAST *ast = new (pool) RangeBasedForStatementAST;
ast->for_token = for_token;
ast->lparen_token = lparen_token;
for (SpecifierListAST *iter = type_specifier_list, **ast_iter = &ast->type_specifier_list;
iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
*ast_iter = new (pool) SpecifierListAST((iter->value) ? iter->value->clone(pool) : 0);
if (declarator)
ast->declarator = declarator->clone(pool);
if (initializer)
ast->initializer = initializer->clone(pool);
ast->colon_token = colon_token;
if (expression)
ast->expression = expression->clone(pool);
ast->rparen_token = rparen_token;
if (statement)
ast->statement = statement->clone(pool);
return ast;
}
ForStatementAST *ForStatementAST::clone(MemoryPool *pool) const
{
ForStatementAST *ast = new (pool) ForStatementAST;