Re: Simplify destructuring for single assignment and identifier cases. (issue 6709068)

13 views
Skip to first unread message

a...@chromium.org

unread,
Oct 22, 2012, 4:34:05 PM10/22/12
to usrb...@yahoo.com, sligh...@google.com, traceur-comp...@googlegroups.com, re...@codereview-hr.appspotmail.com

https://codereview.appspot.com/6709068/diff/1/src/codegeneration/DestructuringTransformer.js
File src/codegeneration/DestructuringTransformer.js (right):

https://codereview.appspot.com/6709068/diff/1/src/codegeneration/DestructuringTransformer.js#newcode242
src/codegeneration/DestructuringTransformer.js:242: var tempIdent_assign
= createAssignmentExpression(tempIdent, rvalue);
no underscores... tempIdentAsign

https://codereview.appspot.com/6709068/diff/1/src/codegeneration/DestructuringTransformer.js#newcode501
src/codegeneration/DestructuringTransformer.js:501: // -
tree.initializer is an IDENTIFIER_EXPRESSION.
Conceptually this could break if the identifier refers to a getter of
the global object. I'd rather be safe here and not do this optimization.

https://codereview.appspot.com/6709068/diff/1/src/codegeneration/DestructuringTransformer.js#newcode503
src/codegeneration/DestructuringTransformer.js:503: // (paren not
necessary)
// Paren not necessary

Skip the parens in the comments

https://codereview.appspot.com/6709068/

a...@chromium.org

unread,
Oct 23, 2012, 10:41:25 AM10/23/12
to usrb...@yahoo.com, sligh...@google.com, traceur-comp...@googlegroups.com, re...@codereview-hr.appspotmail.com
LGTM

I'll clean up the style violations and commit this for you


https://codereview.appspot.com/6709068/diff/4/src/codegeneration/DestructuringTransformer.js
File src/codegeneration/DestructuringTransformer.js (right):

https://codereview.appspot.com/6709068/diff/4/src/codegeneration/DestructuringTransformer.js#newcode245
src/codegeneration/DestructuringTransformer.js:245:
createAssignmentExpression(tempIdent, rvalue));
Fix indentation, indent 4 spaces in this case.

https://codereview.appspot.com/6709068/diff/4/src/codegeneration/DestructuringTransformer.js#newcode524
src/codegeneration/DestructuringTransformer.js:524: initializer =
initializer || createParenExpression(tree.initializer);
Another option is to have another transformation pass that cleans up
paren expressions that do not have a location (generated by us).

https://codereview.appspot.com/6709068/diff/4/test/feature/Destructuring/Simplify.js
File test/feature/Destructuring/Simplify.js (right):

https://codereview.appspot.com/6709068/diff/4/test/feature/Destructuring/Simplify.js#newcode11
test/feature/Destructuring/Simplify.js:11: function check_a() {
No underscores: checkA

https://codereview.appspot.com/6709068/diff/4/test/feature/Destructuring/Simplify.js#newcode46
test/feature/Destructuring/Simplify.js:46: x = { x:{ a:1, b:2, c:3 } };
No space after {
No space before }
Space after :

https://codereview.appspot.com/6709068/diff/4/test/feature/Destructuring/Simplify.js#newcode53
test/feature/Destructuring/Simplify.js:53: x = { x: [1,2,3] };
space after comma

https://codereview.appspot.com/6709068/

a...@chromium.org

unread,
Oct 23, 2012, 10:57:14 AM10/23/12
to usrb...@yahoo.com, sligh...@google.com, traceur-comp...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reply all
Reply to author
Forward
0 new messages