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

Unified Diff: frog/element.dart

Issue 9487012: Avoid mangling the name of native methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 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 | « frog/analyze.dart ('k') | frog/gen.dart » ('j') | frog/world.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/element.dart
diff --git a/frog/element.dart b/frog/element.dart
index f041e3b3b4d64e39df54a317001d033b8de5ae7f..6f6a1223d3c2bd83c85dc093cd483bb2fd2d0749 100644
--- a/frog/element.dart
+++ b/frog/element.dart
@@ -18,7 +18,11 @@ class Element implements Hashable {
Element _enclosingElement;
Element(this.name, this._enclosingElement) {
- _jsname = world.toJsIdentifier(name);
+ if (name !== null) {
+ String mangled = mangleJsName();
+ assert(!mangled.contains(':'));
+ _jsname = mangled;
+ }
}
// TODO - walk tree
@@ -51,6 +55,12 @@ class Element implements Hashable {
void resolve() {}
/**
+ * By default we mangle the JS name of an element to avoid
+ * giving them names that clash with JS keywords.
+ */
+ String mangleJsName() => world.toJsIdentifier(name);
+
+ /**
* Any type parameters that this element defines to setup a generic
* type resolution context. This is currently used for both generic
* types and the semi-magical generic factory methods - but it will
« no previous file with comments | « frog/analyze.dart ('k') | frog/gen.dart » ('j') | frog/world.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698