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

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

Issue 954253002: dart2js: add compiler builtins to the core-runtime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move more foreigns to builtins. Created 5 years, 8 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) 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 @override 262 @override
263 jsAst.PropertyAccess interceptorClassAccess(ClassElement element) { 263 jsAst.PropertyAccess interceptorClassAccess(ClassElement element) {
264 return globalPropertyAccess(element); 264 return globalPropertyAccess(element);
265 } 265 }
266 266
267 @override 267 @override
268 jsAst.PropertyAccess typeAccess(Element element) { 268 jsAst.PropertyAccess typeAccess(Element element) {
269 return globalPropertyAccess(element); 269 return globalPropertyAccess(element);
270 } 270 }
271 271
272 @override
273 jsAst.Template templateForBuiltin(JsBuiltin builtin) {
274 switch (builtin) {
275 case JsBuiltin.dartObjectConstructor:
276 return jsAst.js.expressionTemplateYielding(
277 typeAccess(compiler.objectClass));
278
279 case JsBuiltin.isFunctionType:
280 return backend.rti.representationGenerator.templateForIsFunctionType;
281
282 case JsBuiltin.isFunctionTypeLiteral:
283 String functionClassName =
284 backend.namer.runtimeTypeName(compiler.functionClass);
285 return jsAst.js.expressionTemplateFor(
286 '#.$typeNameProperty === "$functionClassName"');
287
288 case JsBuiltin.typeName:
289 return jsAst.js.expressionTemplateFor("#.$typeNameProperty");
290
291 case JsBuiltin.rawRuntimeType:
292 return jsAst.js.expressionTemplateFor("#.constructor");
293
294 case JsBuiltin.createFunctionType:
295 return backend.rti.representationGenerator
296 .templateForCreateFunctionType;
297
298 default:
299 compiler.internalError(NO_LOCATION_SPANNABLE,
300 "Unhandled Builtin: $builtin");
301 return null;
302 }
303 }
304
272 List<jsAst.Statement> buildTrivialNsmHandlers(){ 305 List<jsAst.Statement> buildTrivialNsmHandlers(){
273 return nsmEmitter.buildTrivialNsmHandlers(); 306 return nsmEmitter.buildTrivialNsmHandlers();
274 } 307 }
275 308
276 jsAst.Statement buildNativeInfoHandler( 309 jsAst.Statement buildNativeInfoHandler(
277 jsAst.Expression infoAccess, 310 jsAst.Expression infoAccess,
278 jsAst.Expression constructorAccess, 311 jsAst.Expression constructorAccess,
279 jsAst.Expression subclassReadGenerator(jsAst.Expression subclass), 312 jsAst.Expression subclassReadGenerator(jsAst.Expression subclass),
280 jsAst.Expression interceptorsByTagAccess, 313 jsAst.Expression interceptorsByTagAccess,
281 jsAst.Expression leafTagsAccess) { 314 jsAst.Expression leafTagsAccess) {
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 new jsAst.FunctionDeclaration( 1041 new jsAst.FunctionDeclaration(
1009 new jsAst.VariableDeclaration(constructorName), constructorAst)); 1042 new jsAst.VariableDeclaration(constructorName), constructorAst));
1010 1043
1011 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME; 1044 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME;
1012 bool hasIsolateSupport = compiler.hasIsolateSupport; 1045 bool hasIsolateSupport = compiler.hasIsolateSupport;
1013 jsAst.Node fieldNamesArray = 1046 jsAst.Node fieldNamesArray =
1014 hasIsolateSupport ? js.stringArray(fields) : new jsAst.LiteralNull(); 1047 hasIsolateSupport ? js.stringArray(fields) : new jsAst.LiteralNull();
1015 1048
1016 cspPrecompiledFunctionFor(outputUnit).add(js.statement(r''' 1049 cspPrecompiledFunctionFor(outputUnit).add(js.statement(r'''
1017 { 1050 {
1018 #constructorName.builtin$cls = #constructorNameString; 1051 #constructorName.#typeNameProperty = #constructorNameString;
1019 if (!"name" in #constructorName) 1052 if (!"name" in #constructorName)
1020 #constructorName.name = #constructorNameString; 1053 #constructorName.name = #constructorNameString;
1021 $desc = $collectedClasses.#constructorName[1]; 1054 $desc = $collectedClasses.#constructorName[1];
1022 #constructorName.prototype = $desc; 1055 #constructorName.prototype = $desc;
1023 ''' /* next string is not a raw string */ ''' 1056 ''' /* next string is not a raw string */ '''
1024 if (#hasIsolateSupport) { 1057 if (#hasIsolateSupport) {
1025 #constructorName.$fieldNamesProperty = #fieldNamesArray; 1058 #constructorName.$fieldNamesProperty = #fieldNamesArray;
1026 } 1059 }
1027 }''', 1060 }''',
1028 {"constructorName": constructorName, 1061 {"constructorName": constructorName,
1062 "typeNameProperty": typeNameProperty,
1029 "constructorNameString": js.string(constructorName), 1063 "constructorNameString": js.string(constructorName),
1030 "hasIsolateSupport": hasIsolateSupport, 1064 "hasIsolateSupport": hasIsolateSupport,
1031 "fieldNamesArray": fieldNamesArray})); 1065 "fieldNamesArray": fieldNamesArray}));
1032 1066
1033 cspPrecompiledConstructorNamesFor(outputUnit).add(js('#', constructorName)); 1067 cspPrecompiledConstructorNamesFor(outputUnit).add(js('#', constructorName));
1034 } 1068 }
1035 1069
1036 void emitTypedefs() { 1070 void emitTypedefs() {
1037 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; 1071 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
1038 1072
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 1910 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
1877 if (element.isInstanceMember) { 1911 if (element.isInstanceMember) {
1878 cachedClassBuilders.remove(element.enclosingClass); 1912 cachedClassBuilders.remove(element.enclosingClass);
1879 1913
1880 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 1914 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
1881 1915
1882 } 1916 }
1883 } 1917 }
1884 } 1918 }
1885 } 1919 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698