Deconstructed parameters aren't being placed in the correct scope
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Feb 2014 22:43:28 +0000 (22:43 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Feb 2014 22:43:28 +0000 (22:43 +0000)
commit43fdf9a8271ba20e9c16fa07c3317f0015780d98
treeeb332d9de8665c715cd0e8fe247be77b3928e949
parent6fbecdf75c27e47bf6770e0c4117cbca7746548e
Deconstructed parameters aren't being placed in the correct scope
https://bugs.webkit.org/show_bug.cgi?id=128126

Reviewed by Antti Koivisto.

Source/JavaScriptCore:

Make sure we declare the bound parameter names as variables when
we reparse.  In the BytecodeGenerator we now also directly ensure
that bound parameters are placed in the symbol table of the function
we're currently compiling.  We then delay binding until just before
we start codegen for the body of the function so that we can ensure
the function has completely initialised all scope details.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::BytecodeGenerator):
* bytecompiler/BytecodeGenerator.h:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::Parser):
(JSC::Parser<LexerType>::createBindingPattern):

LayoutTests:

Added tests for correct behaviour.

* js/deconstructing-parameters-should-be-locals-expected.txt: Added.
* js/deconstructing-parameters-should-be-locals.html: Added.
* js/script-tests/deconstructing-parameters-should-be-locals.js: Added.
(description.value.string_appeared_here.readDeconstructedParameter):
(overwriteDeconstructedParameter):
(readCapturedDeconstructedParameter):
(overwriteCapturedDeconstructedParameter):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163328 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/js/deconstructing-parameters-should-be-locals-expected.txt [new file with mode: 0644]
LayoutTests/js/deconstructing-parameters-should-be-locals.html [new file with mode: 0644]
LayoutTests/js/script-tests/deconstructing-parameters-should-be-locals.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/parser/Parser.cpp