summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlscriptparser.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-28 22:39:31 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-28 22:39:31 (GMT)
commit9065cdc07a6745fc269d7ec3aba457d48858267c (patch)
treeb81bea64284189e4c4dd87c1a89d098b9574cc73 /src/declarative/qml/qmlscriptparser.cpp
parentad269e8e6f85a99c48180f6b9e9b51891accfc45 (diff)
parent1090d5d1fad890d9f43e87e19277e1f624921d6d (diff)
downloadQt-9065cdc07a6745fc269d7ec3aba457d48858267c.zip
Qt-9065cdc07a6745fc269d7ec3aba457d48858267c.tar.gz
Qt-9065cdc07a6745fc269d7ec3aba457d48858267c.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml/qmlscriptparser.cpp')
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 5c5b25e..75c81a7 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -532,6 +532,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
if (node->expression) { // default value
property.defaultValue = new Property;
+ property.defaultValue->parent = _stateStack.top().object;
Value *value = new Value;
value->location = location(node->expression->firstSourceLocation(),
node->expression->lastSourceLocation());
@@ -587,7 +588,7 @@ QmlParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
if (lit->suffix == AST::NumericLiteral::noSuffix)
return QmlParser::Variant(lit->value, asString(expr));
else
- return QmlParser::Variant(asString(expr), QmlParser::Variant::Script);
+ return QmlParser::Variant(asString(expr), expr);
} else {
@@ -597,7 +598,7 @@ QmlParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
}
}
- return QmlParser::Variant(asString(expr), QmlParser::Variant::Script);
+ return QmlParser::Variant(asString(expr), expr);
}
}
@@ -620,8 +621,8 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
primitive = getVariant(stmt->expression);
} else { // do binding
- primitive = QmlParser::Variant(asString(node->statement),
- QmlParser::Variant::Script);
+ primitive = QmlParser::Variant(asString(node->statement),
+ node->statement);
}
Value *v = new Value;
@@ -716,33 +717,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 +820,11 @@ void QmlScriptParser::clear()
_nameSpacePaths.clear();
_typeNames.clear();
_errors.clear();
+
+ if (data) {
+ delete data;
+ data = 0;
+ }
}
int QmlScriptParser::findOrCreateTypeId(const QString &name)