diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2017-06-21 12:30:23 +0200 |
|---|---|---|
| committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-06-21 10:36:20 +0000 |
| commit | 46a7856a906875d66148d90e37ce6d343295cffa (patch) | |
| tree | e6931ae45975cc8f15bf255d595f4f9790986d76 /src/qml/compiler/qv4codegen.cpp | |
| parent | 6757fdad7164870bb324ddc00df577c0aa04dfe8 (diff) | |
Fix recursive array definitions
Make sure '[[1, 2], 3]' produces the correct result.
Change-Id: I95efcf4cab20badfffd31429a57fb73cdf241518
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
| -rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 1cd9940b0c..d276a9d477 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1327,9 +1327,13 @@ bool Codegen::visit(ArrayLiteral *ast) TempScope scope(this); int argc = 0; + Reference _args[16]; + Reference *args = _args; + if (_variableEnvironment->maxNumberOfArguments > 16) + args = new Reference[_variableEnvironment->maxNumberOfArguments]; auto undefined = [this](){ return Reference::fromConst(this, Encode::undefined()); }; - auto push = [this, &argc](const Reference &arg) { - Reference::fromTemp(this, argc).store(arg); + auto push = [this, &argc, args](const Reference &arg) { + args[argc] = arg; argc += 1; }; @@ -1346,6 +1350,9 @@ bool Codegen::visit(ArrayLiteral *ast) for (Elision *elision = ast->elision; elision; elision = elision->next) push(undefined()); + for (int i = 0; i < argc; ++i) + Reference::fromTemp(this, i).store(args[i]); + Instruction::CallBuiltinDefineArray call; call.argc = argc; call.args = 0; @@ -1353,6 +1360,8 @@ bool Codegen::visit(ArrayLiteral *ast) bytecodeGenerator->addInstruction(call); _expr.result = result; + if (args != _args) + delete [] args; return false; } |
