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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart

Issue 47743011: Substitute types in generic superclasses and interfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 7 years, 1 month 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // TODO(ahe): This code should be integrated in CodeEmitterTask.finishClasses. 7 // TODO(ahe): This code should be integrated in CodeEmitterTask.finishClasses.
8 String getReflectionDataParser(String classesCollector, Namer namer) { 8 String getReflectionDataParser(String classesCollector, Namer namer) {
9 String metadataField = '"${namer.metadataField}"'; 9 String metadataField = '"${namer.metadataField}"';
10 String reflectableField = namer.reflectableField; 10 String reflectableField = namer.reflectableField;
11 String defaultValuesField = namer.defaultValuesField; 11 String defaultValuesField = namer.defaultValuesField;
12 String methodsWithOptionalArgumentsField = 12 String methodsWithOptionalArgumentsField =
13 namer.methodsWithOptionalArgumentsField; 13 namer.methodsWithOptionalArgumentsField;
14 return ''' 14 return '''
15 (function (reflectionData) { 15 (function (reflectionData) {
16 ''' 16 '''
17 // [map] returns an object literal that V8 shouldn't try to optimize with a 17 // [map] returns an object literal that V8 shouldn't try to optimize with a
18 // hidden class. This prevents a potential performance problem where V8 tries 18 // hidden class. This prevents a potential performance problem where V8 tries
19 // to build a hidden class for an object used as a hashMap. 19 // to build a hidden class for an object used as a hashMap.
20 ''' 20 '''
21 function map(x){x={x:x};delete x.x;return x} 21 function map(x){x={x:x};delete x.x;return x}
22 if (!init.libraries) init.libraries = []; 22 if (!init.libraries) init.libraries = [];
23 if (!init.mangledNames) init.mangledNames = map(); 23 if (!init.mangledNames) init.mangledNames = map();
24 if (!init.mangledGlobalNames) init.mangledGlobalNames = map(); 24 if (!init.mangledGlobalNames) init.mangledGlobalNames = map();
25 if (!init.statics) init.statics = map(); 25 if (!init.statics) init.statics = map();
26 if (!init.interfaces) init.interfaces = map(); 26 if (!init.typeInformation) init.typeInformation = map();
27 if (!init.globalFunctions) init.globalFunctions = map(); 27 if (!init.globalFunctions) init.globalFunctions = map();
28 var libraries = init.libraries; 28 var libraries = init.libraries;
29 var mangledNames = init.mangledNames; 29 var mangledNames = init.mangledNames;
30 var mangledGlobalNames = init.mangledGlobalNames; 30 var mangledGlobalNames = init.mangledGlobalNames;
31 var hasOwnProperty = Object.prototype.hasOwnProperty; 31 var hasOwnProperty = Object.prototype.hasOwnProperty;
32 var length = reflectionData.length; 32 var length = reflectionData.length;
33 for (var i = 0; i < length; i++) { 33 for (var i = 0; i < length; i++) {
34 var data = reflectionData[i]; 34 var data = reflectionData[i];
35 ''' 35 '''
36 // [data] contains these elements: 36 // [data] contains these elements:
(...skipping 21 matching lines...) Expand all
58 if (!hasOwnProperty.call(descriptor, property)) continue; 58 if (!hasOwnProperty.call(descriptor, property)) continue;
59 if (property === "") continue; 59 if (property === "") continue;
60 var element = descriptor[property]; 60 var element = descriptor[property];
61 var firstChar = property.substring(0, 1); 61 var firstChar = property.substring(0, 1);
62 var previousProperty; 62 var previousProperty;
63 if (firstChar === "+") { 63 if (firstChar === "+") {
64 mangledGlobalNames[previousProperty] = property.substring(1); 64 mangledGlobalNames[previousProperty] = property.substring(1);
65 if (descriptor[property] == 1) ''' // Break long line. 65 if (descriptor[property] == 1) ''' // Break long line.
66 '''descriptor[previousProperty].$reflectableField = 1; 66 '''descriptor[previousProperty].$reflectableField = 1;
67 if (element && element.length) ''' // Break long line. 67 if (element && element.length) ''' // Break long line.
68 '''init.interfaces[previousProperty] = element; 68 '''init.typeInformation[previousProperty] = element;
69 } else if (firstChar === "@") { 69 } else if (firstChar === "@") {
70 property = property.substring(1); 70 property = property.substring(1);
71 ${namer.CURRENT_ISOLATE}[property][$metadataField] = element; 71 ${namer.CURRENT_ISOLATE}[property][$metadataField] = element;
72 } else if (firstChar === "*") { 72 } else if (firstChar === "*") {
73 globalObject[previousProperty].$defaultValuesField = element; 73 globalObject[previousProperty].$defaultValuesField = element;
74 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField; 74 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField;
75 if (!optionalMethods) { 75 if (!optionalMethods) {
76 descriptor.$methodsWithOptionalArgumentsField = optionalMethods = {} 76 descriptor.$methodsWithOptionalArgumentsField = optionalMethods = {}
77 } 77 }
78 optionalMethods[property] = previousProperty; 78 optionalMethods[property] = previousProperty;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 classes.push(property); 110 classes.push(property);
111 } 111 }
112 } 112 }
113 } 113 }
114 processStatics(descriptor); 114 processStatics(descriptor);
115 libraries.push([name, uri, classes, functions, metadata, fields, isRoot, 115 libraries.push([name, uri, classes, functions, metadata, fields, isRoot,
116 globalObject]); 116 globalObject]);
117 } 117 }
118 })'''; 118 })''';
119 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698