aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler/qv4codegen_p.h')
-rw-r--r--src/qml/compiler/qv4codegen_p.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 742ee79648..239ed5c4b9 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -141,10 +141,14 @@ protected:
VariableDeclaration,
FunctionDefinition
};
+
struct Member {
MemberType type;
int index;
AST::FunctionExpression *function;
+ AST::VariableDeclaration::VariableScope scope;
+
+ bool isLexicallyScoped() const { return this->scope != AST::VariableDeclaration::FunctionScope; }
};
typedef QMap<QString, Member> MemberMap;
@@ -191,6 +195,18 @@ protected:
return (*it).index;
}
+ bool memberInfo(const QString &name, const Member **m) const
+ {
+ Q_ASSERT(m);
+ MemberMap::const_iterator it = members.find(name);
+ if (it == members.end()) {
+ *m = 0;
+ return false;
+ }
+ *m = &(*it);
+ return true;
+ }
+
bool lookupMember(const QString &name, Environment **scope, int *index, int *distance)
{
Environment *it = this;
@@ -206,7 +222,7 @@ protected:
return false;
}
- void enter(const QString &name, MemberType type, AST::FunctionExpression *function = 0)
+ void enter(const QString &name, MemberType type, AST::VariableDeclaration::VariableScope scope, AST::FunctionExpression *function = 0)
{
if (! name.isEmpty()) {
if (type != FunctionDefinition) {
@@ -220,8 +236,10 @@ protected:
m.index = -1;
m.type = type;
m.function = function;
+ m.scope = scope;
members.insert(name, m);
} else {
+ Q_ASSERT(scope == (*it).scope);
if ((*it).type <= type) {
(*it).type = type;
(*it).function = function;
@@ -448,7 +466,7 @@ protected:
QV4::IR::BasicBlock *_block;
QV4::IR::BasicBlock *_exitBlock;
unsigned _returnAddress;
- Environment *_env;
+ Environment *_variableEnvironment;
Loop *_loop;
AST::LabelledStatement *_labelledStatement;
ScopeAndFinally *_scopeAndFinally;
@@ -526,7 +544,7 @@ protected:
// fields:
Codegen *_cg;
const QString _sourceCode;
- Environment *_env;
+ Environment *_variableEnvironment;
QStack<Environment *> _envStack;
bool _allowFuncDecls;