summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-10-15 08:18:09 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-10-15 08:18:09 (GMT)
commit2967e68f9a3bae4f5a2865ac901b08d8b6f0f0f1 (patch)
tree7e15c43425202356ede76efc6a290b85fe36db9d /src
parent9182a60aabaedf7d0b7278544920c546cb89e461 (diff)
downloadQt-2967e68f9a3bae4f5a2865ac901b08d8b6f0f0f1.zip
Qt-2967e68f9a3bae4f5a2865ac901b08d8b6f0f0f1.tar.gz
Qt-2967e68f9a3bae4f5a2865ac901b08d8b6f0f0f1.tar.bz2
Simplified the bindings rewriter.
The rewriter needs to know if an ExpressionStatement is part of a loop and an integer is definitely enough for that.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlrewrite.cpp27
-rw-r--r--src/declarative/qml/qmlrewrite_p.h2
2 files changed, 15 insertions, 14 deletions
diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp
index 19b88cc..43b2529 100644
--- a/src/declarative/qml/qmlrewrite.cpp
+++ b/src/declarative/qml/qmlrewrite.cpp
@@ -71,6 +71,7 @@ QString RewriteBinding::rewrite(QString code, unsigned position,
TextWriter w;
_writer = &w;
_position = position;
+ _inLoop = 0;
accept(node);
@@ -111,7 +112,7 @@ bool RewriteBinding::visit(AST::Block *ast)
bool RewriteBinding::visit(AST::ExpressionStatement *ast)
{
- if (_loopStack.isEmpty()) {
+ if (! _inLoop) {
unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
_writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
}
@@ -121,68 +122,68 @@ bool RewriteBinding::visit(AST::ExpressionStatement *ast)
bool RewriteBinding::visit(AST::DoWhileStatement *ast)
{
- _loopStack.append(ast);
+ ++_inLoop;
return true;
}
void RewriteBinding::endVisit(AST::DoWhileStatement *)
{
- _loopStack.removeLast();
+ --_inLoop;
}
bool RewriteBinding::visit(AST::WhileStatement *ast)
{
- _loopStack.append(ast);
+ ++_inLoop;
return true;
}
void RewriteBinding::endVisit(AST::WhileStatement *)
{
- _loopStack.removeLast();
+ --_inLoop;
}
bool RewriteBinding::visit(AST::ForStatement *ast)
{
- _loopStack.append(ast);
+ ++_inLoop;
return true;
}
void RewriteBinding::endVisit(AST::ForStatement *)
{
- _loopStack.removeLast();
+ --_inLoop;
}
bool RewriteBinding::visit(AST::LocalForStatement *ast)
{
- _loopStack.append(ast);
+ ++_inLoop;
return true;
}
void RewriteBinding::endVisit(AST::LocalForStatement *)
{
- _loopStack.removeLast();
+ --_inLoop;
}
bool RewriteBinding::visit(AST::ForEachStatement *ast)
{
- _loopStack.append(ast);
+ ++_inLoop;
return true;
}
void RewriteBinding::endVisit(AST::ForEachStatement *)
{
- _loopStack.removeLast();
+ --_inLoop;
}
bool RewriteBinding::visit(AST::LocalForEachStatement *ast)
{
- _loopStack.append(ast);
+ ++_inLoop;
return true;
}
void RewriteBinding::endVisit(AST::LocalForEachStatement *)
{
- _loopStack.removeLast();
+ --_inLoop;
}
} // namespace QmlRewrite
diff --git a/src/declarative/qml/qmlrewrite_p.h b/src/declarative/qml/qmlrewrite_p.h
index 449b219..59057d5 100644
--- a/src/declarative/qml/qmlrewrite_p.h
+++ b/src/declarative/qml/qmlrewrite_p.h
@@ -99,7 +99,7 @@ protected:
virtual void endVisit(AST::LocalForEachStatement *ast);
private:
- QList<AST::Statement *> _loopStack;
+ int _inLoop;
};
} // namespace QmlRewrite