diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-22 09:20:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-26 10:04:11 +0000 |
commit | e9b3bdb96e008060a0e78815a3995015e5e4598d (patch) | |
tree | b3213bc461329723e9fd119a65a5556c12209a21 /src/qml/compiler/qv4codegen.cpp | |
parent | 046d1c5db44f409c67244bd70b13077cc03219b2 (diff) | |
download | qtdeclarative-e9b3bdb96e008060a0e78815a3995015e5e4598d.tar.gz |
Various fixes for class support
Add support for a default constructor if none is given.
Fix support for computed method names, by unifying the
handling between static and non static methods. Fix our
table generation, so that we write UINT_MAX as the string
index for undefined strings and not a reference to the
empty string, as that can actually be a valid method
name.
Add support for getter and setter methods in classes.
Change-Id: If52c57d6a67424b0218b86339b95aed9d0351e47
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 2a7c491bd6..cab99b0c21 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -823,8 +823,7 @@ bool Codegen::visit(VariableDeclarationList *) bool Codegen::visit(ClassExpression *ast) { Compiler::Class jsClass; - jsClass.name = ast->name.toString(); - registerString(jsClass.name); + jsClass.nameIndex = registerString(ast->name.toString()); ClassElementList *constructor = nullptr; int nComputedNames = 0; @@ -844,12 +843,13 @@ bool Codegen::visit(ClassExpression *ast) ++nStaticComputedNames; } QString name = p->name->asString(); + uint nameIndex = cname ? UINT_MAX : registerString(name); Compiler::Class::Method::Type type = Compiler::Class::Method::Regular; if (p->type == PatternProperty::Getter) type = Compiler::Class::Method::Getter; else if (p->type == PatternProperty::Setter) type = Compiler::Class::Method::Setter; - Compiler::Class::Method m{ name, type, defineFunction(name, f, f->formals, f->body)}; + Compiler::Class::Method m{ nameIndex, type, static_cast<uint>(defineFunction(name, f, f->formals, f->body)) }; if (member->isStatic) { if (name == QStringLiteral("prototype")) { |