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

Side by Side Diff: lib/compiler/implementation/namer.dart

Issue 10363002: Create isolate constructor dynamically. (Closed) Base URL: https://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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Assigns JavaScript identifiers to Dart variables, class-names and members. 6 * Assigns JavaScript identifiers to Dart variables, class-names and members.
7 */ 7 */
8 class Namer { 8 class Namer {
9 final Compiler compiler; 9 final Compiler compiler;
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 Map<Element, String> globals; 24 Map<Element, String> globals;
25 Map<String, int> usedGlobals; 25 Map<String, int> usedGlobals;
26 26
27 Namer(this.compiler) 27 Namer(this.compiler)
28 : globals = new Map<Element, String>(), 28 : globals = new Map<Element, String>(),
29 usedGlobals = new Map<String, int>(); 29 usedGlobals = new Map<String, int>();
30 30
31 final String CURRENT_ISOLATE = "\$"; 31 final String CURRENT_ISOLATE = "\$";
32 final String ISOLATE = "Isolate"; 32 final String ISOLATE = "Isolate";
33 final String INITIAL_STATICS = "\$initialStatics";
33 34
34 35
35 String closureInvocationName(Selector selector) { 36 String closureInvocationName(Selector selector) {
36 // TODO(floitsch): mangle, while not conflicting with instance names. 37 // TODO(floitsch): mangle, while not conflicting with instance names.
37 return instanceMethodInvocationName(null, CLOSURE_INVOCATION_NAME, 38 return instanceMethodInvocationName(null, CLOSURE_INVOCATION_NAME,
38 selector); 39 selector);
39 } 40 }
40 41
41 String privateName(LibraryElement lib, SourceString name) { 42 String privateName(LibraryElement lib, SourceString name) {
42 if (name.isPrivate()) { 43 if (name.isPrivate()) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 globals[element] = result; 183 globals[element] = result;
183 return result; 184 return result;
184 185
185 default: 186 default:
186 compiler.internalError('getName for unknown kind: ${element.kind}', 187 compiler.internalError('getName for unknown kind: ${element.kind}',
187 node: element.parseNode(compiler)); 188 node: element.parseNode(compiler));
188 } 189 }
189 } 190 }
190 } 191 }
191 192
193 String initialStaticsAccess(Element element) {
194 return "$ISOLATE.$INITIAL_STATICS.${getName(element)}";
195 }
196
192 String isolateAccess(Element element) { 197 String isolateAccess(Element element) {
193 return "$CURRENT_ISOLATE.${getName(element)}"; 198 return "$CURRENT_ISOLATE.${getName(element)}";
194 } 199 }
195 200
196 String isolatePropertyAccess(Element element) {
197 return "$ISOLATE.prototype.${getName(element)}";
198 }
199
200 String isolateBailoutAccess(Element element) { 201 String isolateBailoutAccess(Element element) {
201 return '${isolateAccess(element)}\$bailout'; 202 return '${isolateAccess(element)}\$bailout';
202 } 203 }
203 204
204 String operatorIs(Element element) { 205 String operatorIs(Element element) {
205 return 'is\$${getName(element)}'; 206 return 'is\$${getName(element)}';
206 } 207 }
207 208
208 String safeName(String name) { 209 String safeName(String name) {
209 if (jsReserved.contains(name) || name.startsWith('\$')) { 210 if (jsReserved.contains(name) || name.startsWith('\$')) {
210 name = "\$$name"; 211 name = "\$$name";
211 assert(!jsReserved.contains(name)); 212 assert(!jsReserved.contains(name));
212 } 213 }
213 return name; 214 return name;
214 } 215 }
215 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698