diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-21 22:57:07 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-26 10:04:04 +0000 |
commit | 5faf2e9a693d10e1e689c42deec911083a35ddb2 (patch) | |
tree | 58d56608b05274c89139175b6664d7157437aa7e /src/qml/compiler/qv4compilerscanfunctions.cpp | |
parent | b797006c4491127f5c34f8eca49c6d1d576941db (diff) |
Properly distinguish between class expressions and declarations
Introduce both types in the AST, and handle them properly
in the code generator.
Change-Id: I754ac0976de69009bdb8b203d890e4ec0ad03b30
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index eda0102844..8b8c385b84 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -226,6 +226,21 @@ bool ScanFunctions::visit(FunctionExpression *ast) bool ScanFunctions::visit(ClassExpression *ast) { + enterEnvironment(ast, ContextType::Block, QStringLiteral("%Class")); + _context->isStrict = true; + _context->hasNestedFunctions = true; + if (!ast->name.isEmpty()) + _context->addLocalVar(ast->name.toString(), Context::VariableDeclaration, AST::VariableScope::Let); + return true; +} + +void ScanFunctions::endVisit(ClassExpression *) +{ + leaveEnvironment(); +} + +bool ScanFunctions::visit(ClassDeclaration *ast) +{ if (!ast->name.isEmpty()) _context->addLocalVar(ast->name.toString(), Context::VariableDeclaration, AST::VariableScope::Let); @@ -237,7 +252,7 @@ bool ScanFunctions::visit(ClassExpression *ast) return true; } -void ScanFunctions::endVisit(ClassExpression *) +void ScanFunctions::endVisit(ClassDeclaration *) { leaveEnvironment(); } |