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

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

Issue 1151813002: dart2js: Fix emitting in csp mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« 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) 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 471
472 jsAst.Statement buildCspPrecompiledFunctionFor( 472 jsAst.Statement buildCspPrecompiledFunctionFor(
473 OutputUnit outputUnit) { 473 OutputUnit outputUnit) {
474 if (compiler.useContentSecurityPolicy) { 474 if (compiler.useContentSecurityPolicy) {
475 // TODO(ahe): Compute a hash code. 475 // TODO(ahe): Compute a hash code.
476 // TODO(sigurdm): Avoid this precompiled function. Generated 476 // TODO(sigurdm): Avoid this precompiled function. Generated
477 // constructor-functions and getter/setter functions can be stored in the 477 // constructor-functions and getter/setter functions can be stored in the
478 // library-description table. Setting properties on these can be moved to 478 // library-description table. Setting properties on these can be moved to
479 // finishClasses. 479 // finishClasses.
480 return js.statement(''' 480 return js.statement(r"""
481 # = function (\$collectedClasses) { 481 #precompiled = function ($collectedClasses$) {
482 var \$desc; 482 #norename;
483 #; 483 var $desc;
484 return #; 484 #functions;
485 };''', 485 return #result;
486 [generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED), 486 };""",
487 cspPrecompiledFunctionFor(outputUnit), 487 {'norename': new jsAst.Comment("// ::norenaming:: "),
488 new jsAst.ArrayInitializer( 488 'precompiled': generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED),
489 cspPrecompiledConstructorNamesFor(outputUnit))]); 489 'functions': cspPrecompiledFunctionFor(outputUnit),
490 'result': new jsAst.ArrayInitializer(
491 cspPrecompiledConstructorNamesFor(outputUnit))});
490 } else { 492 } else {
491 return js.comment("Constructors are generated at runtime."); 493 return js.comment("Constructors are generated at runtime.");
492 } 494 }
493 } 495 }
494 496
495 void assembleClass(Class cls, ClassBuilder enclosingBuilder, 497 void assembleClass(Class cls, ClassBuilder enclosingBuilder,
496 Fragment fragment) { 498 Fragment fragment) {
497 ClassElement classElement = cls.element; 499 ClassElement classElement = cls.element;
498 compiler.withCurrentElement(classElement, () { 500 compiler.withCurrentElement(classElement, () {
499 if (compiler.hasIncrementalSupport) { 501 if (compiler.hasIncrementalSupport) {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME; 1039 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME;
1038 bool hasIsolateSupport = compiler.hasIsolateSupport; 1040 bool hasIsolateSupport = compiler.hasIsolateSupport;
1039 jsAst.Node fieldNamesArray = 1041 jsAst.Node fieldNamesArray =
1040 hasIsolateSupport ? js.stringArray(fields) : new jsAst.LiteralNull(); 1042 hasIsolateSupport ? js.stringArray(fields) : new jsAst.LiteralNull();
1041 1043
1042 cspPrecompiledFunctionFor(outputUnit).add(js.statement(r''' 1044 cspPrecompiledFunctionFor(outputUnit).add(js.statement(r'''
1043 { 1045 {
1044 #constructorName.#typeNameProperty = #constructorNameString; 1046 #constructorName.#typeNameProperty = #constructorNameString;
1045 if (!"name" in #constructorName) 1047 if (!"name" in #constructorName)
1046 #constructorName.name = #constructorNameString; 1048 #constructorName.name = #constructorNameString;
1047 $desc = $collectedClasses.#constructorName[1]; 1049 $desc = $collectedClasses$.#constructorName[1];
1048 #constructorName.prototype = $desc; 1050 #constructorName.prototype = $desc;
1049 ''' /* next string is not a raw string */ ''' 1051 ''' /* next string is not a raw string */ '''
1050 if (#hasIsolateSupport) { 1052 if (#hasIsolateSupport) {
1051 #constructorName.$fieldNamesProperty = #fieldNamesArray; 1053 #constructorName.$fieldNamesProperty = #fieldNamesArray;
1052 } 1054 }
1053 }''', 1055 }''',
1054 {"constructorName": constructorName, 1056 {"constructorName": constructorName,
1055 "typeNameProperty": typeNameProperty, 1057 "typeNameProperty": typeNameProperty,
1056 "constructorNameString": js.string(constructorName), 1058 "constructorNameString": js.string(constructorName),
1057 "hasIsolateSupport": hasIsolateSupport, 1059 "hasIsolateSupport": hasIsolateSupport,
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 if (#isProgramSplit) { 1383 if (#isProgramSplit) {
1382 #globalsHolder.#isolateName = #isolateName; 1384 #globalsHolder.#isolateName = #isolateName;
1383 #globalsHolder.#initName = #initName; 1385 #globalsHolder.#initName = #initName;
1384 #globalsHolder.#setupProgramName = #setupProgramName; 1386 #globalsHolder.#setupProgramName = #setupProgramName;
1385 } 1387 }
1386 1388
1387 init(); 1389 init();
1388 1390
1389 #mangledNames; 1391 #mangledNames;
1390 1392
1393 #cspPrecompiledFunctions;
1394
1391 #setupProgram; 1395 #setupProgram;
1392 1396
1393 #functionThatReturnsNull; 1397 #functionThatReturnsNull;
1394 1398
1395 // The argument to reflectionDataParser is assigned to a temporary 'dart' 1399 // The argument to reflectionDataParser is assigned to a temporary 'dart'
1396 // so that 'dart.' will appear as the prefix to dart methods in stack 1400 // so that 'dart.' will appear as the prefix to dart methods in stack
1397 // traces and profile entries. 1401 // traces and profile entries.
1398 var dart = #descriptors; 1402 var dart = #descriptors;
1399 1403
1400 #setupProgramName(dart, 0); 1404 #setupProgramName(dart, 0);
1401 1405
1402 #cspPrecompiledFunctions;
1403
1404 #getInterceptorMethods; 1406 #getInterceptorMethods;
1405 #oneShotInterceptors; 1407 #oneShotInterceptors;
1406 1408
1407 #makeConstantList; 1409 #makeConstantList;
1408 1410
1409 // We abuse the short name used for the isolate here to store 1411 // We abuse the short name used for the isolate here to store
1410 // the isolate properties. This is safe as long as the real isolate 1412 // the isolate properties. This is safe as long as the real isolate
1411 // object does not exist yet. 1413 // object does not exist yet.
1412 var ${namer.currentIsolate} = #isolatePropertiesName; 1414 var ${namer.currentIsolate} = #isolatePropertiesName;
1413 1415
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 1965 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
1964 if (element.isInstanceMember) { 1966 if (element.isInstanceMember) {
1965 cachedClassBuilders.remove(element.enclosingClass); 1967 cachedClassBuilders.remove(element.enclosingClass);
1966 1968
1967 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 1969 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
1968 1970
1969 } 1971 }
1970 } 1972 }
1971 } 1973 }
1972 } 1974 }
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