Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10452029: Fix bug when a variable is used in try/catch and accessed trough HFieldGet and HFieldSet: reference… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 final JavaScriptBackend backend; 6 final JavaScriptBackend backend;
7 SsaCodeGeneratorTask(JavaScriptBackend backend) 7 SsaCodeGeneratorTask(JavaScriptBackend backend)
8 : this.backend = backend, 8 : this.backend = backend,
9 super(backend.compiler); 9 super(backend.compiler);
10 String get name() => 'SSA code generator'; 10 String get name() => 'SSA code generator';
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 assert(superMethod.kind == ElementKind.GETTER); 1561 assert(superMethod.kind == ElementKind.GETTER);
1562 String methodName = 1562 String methodName =
1563 compiler.namer.getterName(currentLibrary, superMethod.name); 1563 compiler.namer.getterName(currentLibrary, superMethod.name);
1564 buffer.add('$className.prototype.$methodName.call()'); 1564 buffer.add('$className.prototype.$methodName.call()');
1565 } 1565 }
1566 endExpression(JSPrecedence.CALL_PRECEDENCE); 1566 endExpression(JSPrecedence.CALL_PRECEDENCE);
1567 world.registerStaticUse(superMethod); 1567 world.registerStaticUse(superMethod);
1568 } 1568 }
1569 1569
1570 visitFieldGet(HFieldGet node) { 1570 visitFieldGet(HFieldGet node) {
1571 if (node.receiver !== null) { 1571 if (!node.isFromActivation()) {
1572 String name = 1572 String name =
1573 compiler.namer.instanceFieldName(currentLibrary, node.name); 1573 compiler.namer.instanceFieldName(currentLibrary, node.name);
1574 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1574 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1575 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1575 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1576 buffer.add('.'); 1576 buffer.add('.');
1577 buffer.add(name); 1577 buffer.add(name);
1578 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1578 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1579 } else { 1579 } else {
1580 buffer.add(JsNames.getValid(node.name.slowToString())); 1580 String name = temporary(node.receiver);
1581 buffer.add(name);
1581 } 1582 }
1582 } 1583 }
1583 1584
1584 visitFieldSet(HFieldSet node) { 1585 visitFieldSet(HFieldSet node) {
1585 String name; 1586 String name;
1586 if (node.receiver !== null) { 1587 if (!node.isFromActivation()) {
1587 name = 1588 name =
1588 compiler.namer.instanceFieldName(currentLibrary, node.name); 1589 compiler.namer.instanceFieldName(currentLibrary, node.name);
1589 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1590 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1590 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1591 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1591 buffer.add('.'); 1592 buffer.add('.');
1592 buffer.add(name); 1593 buffer.add(name);
1593 } else { 1594 } else {
1594 // TODO(ngeoffray): Remove the 'var' once we don't globally box 1595 // TODO(ngeoffray): Remove the 'var' once we don't globally box
1595 // variables used in a try/catch. 1596 // variables used in a try/catch.
1596 name = JsNames.getValid(node.name.slowToString()); 1597 String name = temporary(node.receiver);
1597 declareVariable(name); 1598 declareVariable(name);
1598 } 1599 }
1599 buffer.add(' = '); 1600 buffer.add(' = ');
1600 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); 1601 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE);
1601 if (node.receiver !== null) { 1602 if (node.receiver !== null) {
1602 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1603 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1603 } 1604 }
1604 } 1605 }
1605 1606
1606 visitForeign(HForeign node) { 1607 visitForeign(HForeign node) {
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 startBailoutSwitch(); 2627 startBailoutSwitch();
2627 } 2628 }
2628 } 2629 }
2629 2630
2630 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2631 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2631 if (labeledBlockInfo.body.start.hasGuards()) { 2632 if (labeledBlockInfo.body.start.hasGuards()) {
2632 endBailoutSwitch(); 2633 endBailoutSwitch();
2633 } 2634 }
2634 } 2635 }
2635 } 2636 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698