diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-27 10:40:28 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-27 10:40:28 (GMT) |
commit | c8f180e7023308b8a051b53943b9a088a7f0c427 (patch) | |
tree | 12fbbccc818670fd4c982bd5f42723477aab2833 /src/declarative/qml/qmlscriptparser.cpp | |
parent | 0a6df63c7150f0010b08ce2ba08a492cd129a96f (diff) | |
download | Qt-c8f180e7023308b8a051b53943b9a088a7f0c427.zip Qt-c8f180e7023308b8a051b53943b9a088a7f0c427.tar.gz Qt-c8f180e7023308b8a051b53943b9a088a7f0c427.tar.bz2 |
Small cleanups
Diffstat (limited to 'src/declarative/qml/qmlscriptparser.cpp')
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index b862953..b1ffc98 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -597,7 +597,7 @@ QmlParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr) } } - return QmlParser::Variant(asString(expr), expr); + return QmlParser::Variant(asString(expr), expr); } } @@ -716,33 +716,44 @@ bool ProcessAST::visit(AST::UiSourceElement *node) QmlScriptParser::QmlScriptParser() -: root(0) +: root(0), data(0) { } QmlScriptParser::~QmlScriptParser() { + clear(); } -bool QmlScriptParser::parse(const QByteArray &data, const QUrl &url) +class QmlScriptParserJsASTData +{ +public: + QmlScriptParserJsASTData(const QString &filename) + : nodePool(filename, &engine) {} + + Engine engine; + NodePool nodePool; +}; + +bool QmlScriptParser::parse(const QByteArray &qmldata, const QUrl &url) { #ifdef Q_ENABLE_PERFORMANCE_LOG QFxPerfTimer<QFxPerf::QmlParsing> pt; #endif + clear(); + const QString fileName = url.toString(); - QTextStream stream(data, QIODevice::ReadOnly); + QTextStream stream(qmldata, QIODevice::ReadOnly); const QString code = stream.readAll(); - Engine engine; - - NodePool nodePool(fileName, &engine); + data = new QmlScriptParserJsASTData(fileName); - Lexer lexer(&engine); + Lexer lexer(&data->engine); lexer.setCode(code, /*line = */ 1); - Parser parser(&engine); + Parser parser(&data->engine); if (! parser.parse() || !_errors.isEmpty()) { @@ -808,6 +819,11 @@ void QmlScriptParser::clear() _nameSpacePaths.clear(); _typeNames.clear(); _errors.clear(); + + if (data) { + delete data; + data = 0; + } } int QmlScriptParser::findOrCreateTypeId(const QString &name) |