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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 12212064: Null diff to AST based version of finishClasses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 function(collectedClasses) { 282 function(collectedClasses) {
283 var hasOwnProperty = Object.prototype.hasOwnProperty; 283 var hasOwnProperty = Object.prototype.hasOwnProperty;
284 for (var cls in collectedClasses) { 284 for (var cls in collectedClasses) {
285 if (hasOwnProperty.call(collectedClasses, cls)) { 285 if (hasOwnProperty.call(collectedClasses, cls)) {
286 var desc = collectedClasses[cls]; 286 var desc = collectedClasses[cls];
287 '''/* The 'fields' are either a constructor function or a string encoding 287 '''/* The 'fields' are either a constructor function or a string encoding
288 fields, constructor and superclass. Get the superclass and the fields 288 fields, constructor and superclass. Get the superclass and the fields
289 in the format Super;field1,field2 from the null-string property on the 289 in the format Super;field1,field2 from the null-string property on the
290 descriptor. */''' 290 descriptor. */'''
291 var fields = desc[''], supr; 291 var fields = desc[''], supr;
292 if (typeof fields == 'string') { 292 if (typeof fields == "string") {
293 var s = fields.split(';'); supr = s[0]; 293 var s = fields.split(";");
294 fields = s[1] == '' ? [] : s[1].split(','); 294 supr = s[0];
295 fields = s[1] == "" ? [] : s[1].split(",");
295 } else { 296 } else {
296 supr = desc['super']; 297 supr = desc.super;
297 } 298 }
298 $isolatePropertiesName[cls] = $defineClassName(cls, fields, desc); 299 $isolatePropertiesName[cls] = $defineClassName(cls, fields, desc);
299 if (supr) $pendingClassesName[cls] = supr; 300 if (supr)
301 $pendingClassesName[cls] = supr;
300 } 302 }
301 } 303 }
302 var pendingClasses = $pendingClassesName; 304 var pendingClasses = $pendingClassesName;
303 '''/* FinishClasses can be called multiple times. This means that we need to 305 '''/* FinishClasses can be called multiple times. This means that we need to
304 clear the pendingClasses property. */''' 306 clear the pendingClasses property. */'''
305 $pendingClassesName = {}; 307 $pendingClassesName = {};
306 var finishedClasses = {}; 308 var finishedClasses = {};
307 function finishClass(cls) { 309 function finishClass(cls) {
308 '''/* Opera does not support 'getOwnPropertyNames'. Therefore we use 310 '''/* Opera does not support 'getOwnPropertyNames'. Therefore we use
309 hasOwnProperty instead. */''' 311 hasOwnProperty instead. */'''
310 var hasOwnProperty = Object.prototype.hasOwnProperty; 312 var hasOwnProperty = Object.prototype.hasOwnProperty;
311 if (hasOwnProperty.call(finishedClasses, cls)) return; 313 if (hasOwnProperty.call(finishedClasses, cls))
314 return;
312 finishedClasses[cls] = true; 315 finishedClasses[cls] = true;
313 var superclass = pendingClasses[cls]; 316 var superclass = pendingClasses[cls];
314 '''/* The superclass is only false (empty string) for Dart's Object class. */''' 317 '''/* The superclass is only false (empty string) for Dart's Object class. */'''
315 if (!superclass) return; 318 if (!superclass)
319 return;
316 finishClass(superclass); 320 finishClass(superclass);
317 var constructor = $isolatePropertiesName[cls]; 321 var constructor = $isolatePropertiesName[cls];
318 var superConstructor = $isolatePropertiesName[superclass]; 322 var superConstructor = $isolatePropertiesName[superclass];
319 var prototype = constructor.prototype; 323 var prototype = constructor.prototype;
320 if ($supportsProtoName) { 324 if ($supportsProtoName) {
321 prototype.__proto__ = superConstructor.prototype; 325 prototype.__proto__ = superConstructor.prototype;
322 prototype.constructor = constructor; 326 prototype.constructor = constructor;
323 } else { 327 } else {
324 function tmp() {}; 328 function tmp() {
329 }
325 tmp.prototype = superConstructor.prototype; 330 tmp.prototype = superConstructor.prototype;
326 var newPrototype = new tmp(); 331 var newPrototype = new tmp();
327 constructor.prototype = newPrototype; 332 constructor.prototype = newPrototype;
328 newPrototype.constructor = constructor; 333 newPrototype.constructor = constructor;
329 for (var member in prototype) { 334 for (var member in prototype) {
330 if (!member) continue; '''/* Short version of: if (member == '') */''' 335 if (!member)
336 continue;'''/* Short version of: if (member == '') */'''
337
331 if (hasOwnProperty.call(prototype, member)) { 338 if (hasOwnProperty.call(prototype, member)) {
332 newPrototype[member] = prototype[member]; 339 newPrototype[member] = prototype[member];
333 } 340 }
334 } 341 }
335 } 342 }
336 } 343 }
337 for (var cls in pendingClasses) finishClass(cls); 344 for (var cls in pendingClasses) {
345 finishClass(cls);
346 }
338 }'''; 347 }''';
339 } 348 }
340 349
341 String get finishIsolateConstructorFunction { 350 String get finishIsolateConstructorFunction {
342 String isolate = namer.isolateName; 351 String isolate = namer.isolateName;
343 // We replace the old Isolate function with a new one that initializes 352 // We replace the old Isolate function with a new one that initializes
344 // all its field with the initial (and often final) value of all globals. 353 // all its field with the initial (and often final) value of all globals.
345 // This has two advantages: 354 // This has two advantages:
346 // 1. the properties are in the object itself (thus avoiding to go through 355 // 1. the properties are in the object itself (thus avoiding to go through
347 // the prototype when looking up globals. 356 // the prototype when looking up globals.
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 """; 2358 """;
2350 const String HOOKS_API_USAGE = """ 2359 const String HOOKS_API_USAGE = """
2351 // The code supports the following hooks: 2360 // The code supports the following hooks:
2352 // dartPrint(message) - if this function is defined it is called 2361 // dartPrint(message) - if this function is defined it is called
2353 // instead of the Dart [print] method. 2362 // instead of the Dart [print] method.
2354 // dartMainRunner(main) - if this function is defined, the Dart [main] 2363 // dartMainRunner(main) - if this function is defined, the Dart [main]
2355 // method will not be invoked directly. 2364 // method will not be invoked directly.
2356 // Instead, a closure that will invoke [main] is 2365 // Instead, a closure that will invoke [main] is
2357 // passed to [dartMainRunner]. 2366 // passed to [dartMainRunner].
2358 """; 2367 """;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698