From 61a504c4273d01aecf1a149f5d9d8a3ab5e354c3 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 18 Mar 2010 15:21:07 +0100 Subject: Ensure that the memory pool can be reused after a rewind and get rid of the segmented array. --- src/shared/cplusplus/Parser.cpp | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src/shared/cplusplus/Parser.cpp') diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index ce5afdd5fa..39af8bc96b 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -190,30 +190,6 @@ inline bool isRightAssociative(int tokenKind) return true; \ } -class Parser::Rewind -{ - Parser *_parser; - MemoryPool::State _state; - -public: - inline Rewind(Parser *parser) - : _parser(parser) {} - - inline void operator()(unsigned tokenIndex) - { rewind(tokenIndex); } - - inline void mark() - { _state = _parser->_pool->state(); } - - inline void rewind(unsigned tokenIndex) - { - _parser->rewind(tokenIndex); - - if (_state.isValid()) - _parser->_pool->rewind(_state); - } -}; - Parser::Parser(TranslationUnit *unit) : _translationUnit(unit), _control(_translationUnit->control()), @@ -2476,8 +2452,8 @@ bool Parser::parseExpressionStatement(StatementAST *&node) ExpressionAST *expression = 0; MemoryPool *oldPool = _pool; - MemoryPool tmp; - _pool = &tmp; + _pool = &_tempPool; + RecursiveMemoryPool rec(&_tempPool); if (parseExpression(expression)) { ExpressionStatementAST *ast = new (oldPool) ExpressionStatementAST; ast->expression = expression->clone(oldPool); -- cgit v1.2.1