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

Unified Diff: lib/src/js/printer.dart

Issue 963343002: implement private members, fixes #74 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/_interceptors/_interceptors.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/js/printer.dart
diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart
index 926ba1fe96535ca1a151202cc834fb949fe032f1..5ac0780e0ee07f7d221a7d538a2907805da9edb1 100644
--- a/lib/src/js/printer.dart
+++ b/lib/src/js/printer.dart
@@ -867,21 +867,7 @@ class Printer implements NodeVisitor {
visitNestedExpression(access.receiver, CALL,
newInForInit: inForInit,
newAtStatementBegin: atStatementBegin);
- Node selector = access.selector;
- if (selector is LiteralString) {
- LiteralString selectorString = selector;
- String fieldWithQuotes = selectorString.value;
- if (isValidJavaScriptId(fieldWithQuotes)) {
- if (access.receiver is LiteralNumber) out(" ");
- out(".");
- out(fieldWithQuotes.substring(1, fieldWithQuotes.length - 1));
- return;
- }
- }
- out("[");
- visitNestedExpression(selector, EXPRESSION,
- newInForInit: false, newAtStatementBegin: false);
- out("]");
+ propertyNameOut(access.selector, inAccess: true);
}
visitNamedFunction(NamedFunction namedFunction) {
@@ -1084,13 +1070,14 @@ class Printer implements NodeVisitor {
visitPropertyName(PropertyName node) => propertyNameOut(node);
- void propertyNameOut(Expression node, {bool inMethod: false}) {
- inForInit = false;
- atStatementBegin = false;
+ void propertyNameOut(Expression node, {bool inMethod: false,
+ bool inAccess: false}) {
if (node is LiteralNumber) {
LiteralNumber nameNumber = node;
+ if (inAccess) out('[');
out(nameNumber.value);
+ if (inAccess) out(']');
} else {
String quotedName;
if (node is PropertyName) {
@@ -1100,16 +1087,18 @@ class Printer implements NodeVisitor {
}
if (quotedName != null) {
if (isValidJavaScriptId(quotedName)) {
+ if (inAccess) out('.');
out(quotedName.substring(1, quotedName.length - 1));
} else {
- if (inMethod) out("[");
+ if (inMethod || inAccess) out("[");
out(quotedName);
- if (inMethod) out("]");
+ if (inMethod || inAccess) out("]");
}
} else {
// ComputedPropertyName
out("[");
- visit(node);
+ visitNestedExpression(node, EXPRESSION,
+ newInForInit: false, newAtStatementBegin: false);
out("]");
}
}
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/_interceptors/_interceptors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698