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

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

Issue 1207823005: dart2js: Also use new abstract names in csp mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « pkg/compiler/lib/src/js_emitter/old_emitter/class_emitter.dart ('k') | 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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 if (library == compiler.mainApp) { 1011 if (library == compiler.mainApp) {
1012 parts.add(js.number(1)); 1012 parts.add(js.number(1));
1013 } 1013 }
1014 1014
1015 return new jsAst.ArrayInitializer(parts); 1015 return new jsAst.ArrayInitializer(parts);
1016 } 1016 }
1017 1017
1018 void assemblePrecompiledConstructor(OutputUnit outputUnit, 1018 void assemblePrecompiledConstructor(OutputUnit outputUnit,
1019 jsAst.Name constructorName, 1019 jsAst.Name constructorName,
1020 jsAst.Expression constructorAst, 1020 jsAst.Expression constructorAst,
1021 List<String> fields) { 1021 List<jsAst.Name> fields) {
1022 cspPrecompiledFunctionFor(outputUnit).add( 1022 cspPrecompiledFunctionFor(outputUnit).add(
1023 new jsAst.FunctionDeclaration(constructorName, constructorAst)); 1023 new jsAst.FunctionDeclaration(constructorName, constructorAst));
1024 1024
1025 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME; 1025 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME;
1026 bool hasIsolateSupport = compiler.hasIsolateSupport; 1026 bool hasIsolateSupport = compiler.hasIsolateSupport;
1027 jsAst.Node fieldNamesArray = 1027 jsAst.Node fieldNamesArray;
1028 hasIsolateSupport ? js.stringArray(fields) : new jsAst.LiteralNull(); 1028 if (hasIsolateSupport) {
1029 fieldNamesArray = js.concatenateStrings(
1030 js.joinLiterals(fields, js.stringPart(",")),
1031 addQuotes: true);
1032 } else {
1033 fieldNamesArray = new jsAst.LiteralNull();
1034 }
1029 1035
1030 cspPrecompiledFunctionFor(outputUnit).add(js.statement(r''' 1036 cspPrecompiledFunctionFor(outputUnit).add(js.statement(r'''
1031 { 1037 {
1032 #constructorName.#typeNameProperty = #constructorNameString; 1038 #constructorName.#typeNameProperty = #constructorNameString;
1033 // IE does not have a name property. 1039 // IE does not have a name property.
1034 if (!("name" in #constructorName)) 1040 if (!("name" in #constructorName))
1035 #constructorName.name = #constructorNameString; 1041 #constructorName.name = #constructorNameString;
1036 $desc = $collectedClasses$.#constructorName[1]; 1042 $desc = $collectedClasses$.#constructorName[1];
1037 #constructorName.prototype = $desc; 1043 #constructorName.prototype = $desc;
1038 ''' /* next string is not a raw string */ ''' 1044 ''' /* next string is not a raw string */ '''
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 builder.superName = namer.className(compiler.objectClass); 1083 builder.superName = namer.className(compiler.objectClass);
1078 jsAst.Node declaration = builder.toObjectInitializer(); 1084 jsAst.Node declaration = builder.toObjectInitializer();
1079 jsAst.Name mangledName = namer.globalPropertyName(typedef); 1085 jsAst.Name mangledName = namer.globalPropertyName(typedef);
1080 String reflectionName = getReflectionName(typedef, mangledName); 1086 String reflectionName = getReflectionName(typedef, mangledName);
1081 getElementDescriptor(library, mainFragment) 1087 getElementDescriptor(library, mainFragment)
1082 ..addProperty(mangledName, declaration) 1088 ..addProperty(mangledName, declaration)
1083 ..addPropertyByName("+$reflectionName", js.string('')); 1089 ..addPropertyByName("+$reflectionName", js.string(''));
1084 // Also emit a trivial constructor for CSP mode. 1090 // Also emit a trivial constructor for CSP mode.
1085 jsAst.Name constructorName = mangledName; 1091 jsAst.Name constructorName = mangledName;
1086 jsAst.Expression constructorAst = js('function() {}'); 1092 jsAst.Expression constructorAst = js('function() {}');
1087 List<String> fieldNames = []; 1093 List<jsAst.Name> fieldNames = [];
1088 assemblePrecompiledConstructor(mainOutputUnit, 1094 assemblePrecompiledConstructor(mainOutputUnit,
1089 constructorName, 1095 constructorName,
1090 constructorAst, 1096 constructorAst,
1091 fieldNames); 1097 fieldNames);
1092 } 1098 }
1093 } 1099 }
1094 1100
1095 jsAst.Statement buildGlobalObjectSetup(bool isProgramSplit) { 1101 jsAst.Statement buildGlobalObjectSetup(bool isProgramSplit) {
1096 List<jsAst.Statement> parts = <jsAst.Statement>[]; 1102 List<jsAst.Statement> parts = <jsAst.Statement>[];
1097 1103
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2007 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2002 if (element.isInstanceMember) { 2008 if (element.isInstanceMember) {
2003 cachedClassBuilders.remove(element.enclosingClass); 2009 cachedClassBuilders.remove(element.enclosingClass);
2004 2010
2005 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2011 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2006 2012
2007 } 2013 }
2008 } 2014 }
2009 } 2015 }
2010 } 2016 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/class_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698