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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 797513004: Emit either csp or non-csp versions of the program. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 6 years 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 | pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 var pendingClasses = Object.create(null); 483 var pendingClasses = Object.create(null);
484 var allClasses = #allClasses; 484 var allClasses = #allClasses;
485 var constructors; 485 var constructors;
486 486
487 if (#debugFastObjects) 487 if (#debugFastObjects)
488 print("Number of classes: " + 488 print("Number of classes: " +
489 Object.getOwnPropertyNames(\$\$).length); 489 Object.getOwnPropertyNames(\$\$).length);
490 490
491 var hasOwnProperty = Object.prototype.hasOwnProperty; 491 var hasOwnProperty = Object.prototype.hasOwnProperty;
492 492
493 if (typeof dart_precompiled == "function") { 493 if (#inCspMode) {
494 constructors = dart_precompiled(collectedClasses); 494 constructors = dart_precompiled(collectedClasses);
495 } else { 495 }
496
497 if (#notInCspMode) {
496 var combinedConstructorFunction = 498 var combinedConstructorFunction =
497 "function \$reflectable(fn){fn.$reflectableField=1;return fn};\\n"+ 499 "function \$reflectable(fn){fn.$reflectableField=1;return fn};\\n"+
498 "var \$desc;\\n"; 500 "var \$desc;\\n";
499 var constructorsList = []; 501 var constructorsList = [];
500 } 502 }
501 503
502 for (var cls in collectedClasses) { 504 for (var cls in collectedClasses) {
503 var desc = collectedClasses[cls]; 505 var desc = collectedClasses[cls];
504 if (desc instanceof Array) desc = desc[1]; 506 if (desc instanceof Array) desc = desc[1];
505 507
(...skipping 16 matching lines...) Expand all
522 split = supr.split(":"); 524 split = supr.split(":");
523 if (split.length == 2) { 525 if (split.length == 2) {
524 supr = split[0]; 526 supr = split[0];
525 var functionSignature = split[1]; 527 var functionSignature = split[1];
526 if (functionSignature) 528 if (functionSignature)
527 desc.$signaturePropertyName = (function(s) { 529 desc.$signaturePropertyName = (function(s) {
528 return function(){ return #metadata[s]; }; 530 return function(){ return #metadata[s]; };
529 })(functionSignature); 531 })(functionSignature);
530 } 532 }
531 533
532 if (typeof dart_precompiled != "function") { 534 if (#notInCspMode) {
533 combinedConstructorFunction += defineClass(cls, fields); 535 combinedConstructorFunction += defineClass(cls, fields);
534 constructorsList.push(cls); 536 constructorsList.push(cls);
535 } 537 }
536 if (supr) pendingClasses[cls] = supr; 538 if (supr) pendingClasses[cls] = supr;
537 } 539 }
538 540
539 if (typeof dart_precompiled != "function") { 541 if (#notInCspMode) {
540 combinedConstructorFunction += 542 combinedConstructorFunction +=
541 "return [\\n " + constructorsList.join(",\\n ") + "\\n]"; 543 "return [\\n " + constructorsList.join(",\\n ") + "\\n]";
542 var constructors = 544 var constructors =
543 new Function("\$collectedClasses", combinedConstructorFunction) 545 new Function("\$collectedClasses", combinedConstructorFunction)
544 (collectedClasses); 546 (collectedClasses);
545 combinedConstructorFunction = null; 547 combinedConstructorFunction = null;
546 } 548 }
547 549
548 for (var i = 0; i < constructors.length; i++) { 550 for (var i = 0; i < constructors.length; i++) {
549 var constructor = constructors[i]; 551 var constructor = constructors[i];
550 var cls = constructor.name; 552 var cls = constructor.name;
551 var desc = collectedClasses[cls]; 553 var desc = collectedClasses[cls];
552 var globalObject = isolateProperties; 554 var globalObject = isolateProperties;
(...skipping 13 matching lines...) Expand all
566 568
567 #trivialNsmHandlers; 569 #trivialNsmHandlers;
568 570
569 for (var cls in pendingClasses) finishClass(cls); 571 for (var cls in pendingClasses) finishClass(cls);
570 }''', { 'allClasses': allClassesAccess, 572 }''', { 'allClasses': allClassesAccess,
571 'debugFastObjects': DEBUG_FAST_OBJECTS, 573 'debugFastObjects': DEBUG_FAST_OBJECTS,
572 'hasRetainedMetadata': backend.hasRetainedMetadata, 574 'hasRetainedMetadata': backend.hasRetainedMetadata,
573 'metadata': metadataAccess, 575 'metadata': metadataAccess,
574 'isTreeShakingDisabled': backend.isTreeShakingDisabled, 576 'isTreeShakingDisabled': backend.isTreeShakingDisabled,
575 'finishClassFunction': buildFinishClass(), 577 'finishClassFunction': buildFinishClass(),
576 'trivialNsmHandlers': nsmEmitter.buildTrivialNsmHandlers()}); 578 'trivialNsmHandlers': nsmEmitter.buildTrivialNsmHandlers(),
579 'inCspMode': compiler.useContentSecurityPolicy,
580 'notInCspMode': !compiler.useContentSecurityPolicy});
577 } 581 }
578 582
579 jsAst.Node optional(bool condition, jsAst.Node node) { 583 jsAst.Node optional(bool condition, jsAst.Node node) {
580 return condition ? node : new jsAst.EmptyStatement(); 584 return condition ? node : new jsAst.EmptyStatement();
581 } 585 }
582 586
583 jsAst.Statement buildFinishClass() { 587 jsAst.Statement buildFinishClass() {
584 String specProperty = '"${namer.nativeSpecProperty}"'; // "%" 588 String specProperty = '"${namer.nativeSpecProperty}"'; // "%"
585 589
586 jsAst.Expression finishedClassesAccess = 590 jsAst.Expression finishedClassesAccess =
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2267 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2264 if (element.isInstanceMember) { 2268 if (element.isInstanceMember) {
2265 cachedClassBuilders.remove(element.enclosingClass); 2269 cachedClassBuilders.remove(element.enclosingClass);
2266 2270
2267 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2271 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2268 2272
2269 } 2273 }
2270 } 2274 }
2271 } 2275 }
2272 } 2276 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698