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

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

Issue 957343002: Make use of __proto__ when available. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/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) 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): Share these with js_helper.dart. 7 // TODO(ahe): Share these with js_helper.dart.
8 const FUNCTION_INDEX = 0; 8 const FUNCTION_INDEX = 0;
9 const NAME_INDEX = 1; 9 const NAME_INDEX = 1;
10 const CALL_NAME_INDEX = 2; 10 const CALL_NAME_INDEX = 2;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); 48 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES);
49 jsAst.Expression mangledNamesAccess = 49 jsAst.Expression mangledNamesAccess =
50 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_NAMES); 50 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_NAMES);
51 jsAst.Expression librariesAccess = 51 jsAst.Expression librariesAccess =
52 emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES); 52 emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES);
53 jsAst.Expression metadataAccess = 53 jsAst.Expression metadataAccess =
54 emitter.generateEmbeddedGlobalAccess(embeddedNames.METADATA); 54 emitter.generateEmbeddedGlobalAccess(embeddedNames.METADATA);
55 55
56 jsAst.Statement processClassData = js.statement('''{ 56 jsAst.Statement processClassData = js.statement('''{
57 function processClassData(cls, descriptor, processedClasses) { 57 function processClassData(cls, descriptor, processedClasses) {
58 var newDesc = map(); // Use a slow object. 58 descriptor = convertToSlowObject(descriptor); // Use a slow object.
59 var previousProperty; 59 var previousProperty;
60 var properties = Object.keys(descriptor); 60 var properties = Object.keys(descriptor);
61 for (var i = 0; i < properties.length; i++) { 61 for (var i = 0; i < properties.length; i++) {
62 var property = properties[i]; 62 var property = properties[i];
63 var firstChar = property.substring(0, 1); 63 var firstChar = property.charCodeAt(0);
64 if (property === "static") { 64 if (property === "static") {
65 processStatics(#embeddedStatics[cls] = descriptor[property], 65 processStatics(#embeddedStatics[cls] = descriptor.static,
66 processedClasses); 66 processedClasses);
67 } else if (firstChar === "+") { 67 } else if (firstChar === 43) { // 43 is aka "+".
floitsch 2015/03/09 15:37:09 "is aka" -> "is" or "aka", although that doesn't s
herhut 2015/03/10 12:53:54 Done.
68 mangledNames[previousProperty] = property.substring(1); 68 mangledNames[previousProperty] = property.substring(1);
69 var flag = descriptor[property]; 69 var flag = descriptor[property];
70 if (flag > 0) 70 if (flag > 0)
71 descriptor[previousProperty].$reflectableField = flag; 71 descriptor[previousProperty].$reflectableField = flag;
72 } else if (firstChar === "*") { 72 } else if (firstChar === 42) { // 42 is aka "*"
73 newDesc[previousProperty].$defaultValuesField = descriptor[property]; 73 descriptor[previousProperty].$defaultValuesField = descriptor[property];
74 var optionalMethods = newDesc.$methodsWithOptionalArgumentsField; 74 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField;
75 if (!optionalMethods) { 75 if (!optionalMethods) {
76 newDesc.$methodsWithOptionalArgumentsField = optionalMethods={} 76 descriptor.$methodsWithOptionalArgumentsField = optionalMethods={}
77 } 77 }
78 optionalMethods[property] = previousProperty; 78 optionalMethods[property] = previousProperty;
79 } else { 79 } else {
80 var elem = descriptor[property]; 80 var elem = descriptor[property];
81 if (property !== "${namer.classDescriptorProperty}" && 81 if (property !== "${namer.classDescriptorProperty}" &&
82 elem != null && 82 elem != null &&
83 elem.constructor === Array && 83 elem.constructor === Array &&
84 property !== "<>") { 84 property !== "<>") {
85 addStubs(newDesc, elem, property, false, []); 85 addStubs(descriptor, elem, property, false, []);
86 } else { 86 } else {
87 newDesc[previousProperty = property] = elem; 87 previousProperty = property;
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 /* The 'fields' are either a constructor function or a 92 /* The 'fields' are either a constructor function or a
93 * string encoding fields, constructor and superclass. Gets the 93 * string encoding fields, constructor and superclass. Gets the
94 * superclass and fields in the format 94 * superclass and fields in the format
95 * 'Super;field1,field2' 95 * 'Super;field1,field2'
96 * from the CLASS_DESCRIPTOR_PROPERTY property on the descriptor. 96 * from the CLASS_DESCRIPTOR_PROPERTY property on the descriptor.
97 */ 97 */
98 var classData = newDesc["${namer.classDescriptorProperty}"], 98 var classData = descriptor["${namer.classDescriptorProperty}"],
99 split, supr, fields = classData; 99 split, supr, fields = classData;
100 100
101 if (#hasRetainedMetadata) 101 if (#hasRetainedMetadata)
102 if (typeof classData == "object" && 102 if (typeof classData == "object" &&
103 classData instanceof Array) { 103 classData instanceof Array) {
104 classData = fields = classData[0]; 104 classData = fields = classData[0];
105 } 105 }
106 // ${ClassBuilder.fieldEncodingDescription}. 106 // ${ClassBuilder.fieldEncodingDescription}.
107 var s = fields.split(";"); 107 var s = fields.split(";");
108 fields = s[1] == "" ? [] : s[1].split(","); 108 fields = s[1] == "" ? [] : s[1].split(",");
109 supr = s[0]; 109 supr = s[0];
110 // ${ClassBuilder.functionTypeEncodingDescription}. 110 // ${ClassBuilder.functionTypeEncodingDescription}.
111 split = supr.split(":"); 111 split = supr.split(":");
112 if (split.length == 2) { 112 if (split.length == 2) {
113 supr = split[0]; 113 supr = split[0];
114 var functionSignature = split[1]; 114 var functionSignature = split[1];
115 if (functionSignature) 115 if (functionSignature)
116 newDesc.${namer.operatorSignature} = function(s) { 116 descriptor.${namer.operatorSignature} = function(s) {
117 return function() { 117 return function() {
118 return #metadata[s]; 118 return #metadata[s];
119 }; 119 };
120 }(functionSignature); 120 }(functionSignature);
121 } 121 }
122 122
123 if (supr) processedClasses.pending[cls] = supr; 123 if (supr) processedClasses.pending[cls] = supr;
124 if (#notInCspMode) { 124 if (#notInCspMode) {
125 processedClasses.combinedConstructorFunction += defineClass(cls, fields); 125 processedClasses.combinedConstructorFunction += defineClass(cls, fields);
126 processedClasses.constructorsList.push(cls); 126 processedClasses.constructorsList.push(cls);
127 } 127 }
128 processedClasses.collected[cls] = [globalObject, newDesc]; 128 processedClasses.collected[cls] = [globalObject, descriptor];
129 classes.push(cls); 129 classes.push(cls);
130 } 130 }
131 }''', {'embeddedStatics': staticsAccess, 131 }''', {'embeddedStatics': staticsAccess,
132 'hasRetainedMetadata': backend.hasRetainedMetadata, 132 'hasRetainedMetadata': backend.hasRetainedMetadata,
133 'metadata': metadataAccess, 133 'metadata': metadataAccess,
134 'notInCspMode': !compiler.useContentSecurityPolicy}); 134 'notInCspMode': !compiler.useContentSecurityPolicy});
135 135
136 // TODO(zarah): Remove empty else branches in output when if(#hole) is false. 136 // TODO(zarah): Remove empty else branches in output when if(#hole) is false.
137 jsAst.Statement processStatics = js.statement(''' 137 jsAst.Statement processStatics = js.statement('''
138 function processStatics(descriptor, processedClasses) { 138 function processStatics(descriptor, processedClasses) {
139 var properties = Object.keys(descriptor); 139 var properties = Object.keys(descriptor);
140 for (var i = 0; i < properties.length; i++) { 140 for (var i = 0; i < properties.length; i++) {
141 var property = properties[i]; 141 var property = properties[i];
142 if (property === "${namer.classDescriptorProperty}") continue; 142 if (property === "${namer.classDescriptorProperty}") continue;
143 var element = descriptor[property]; 143 var element = descriptor[property];
144 var firstChar = property.substring(0, 1); 144 var firstChar = property.charCodeAt(0);
145 var previousProperty; 145 var previousProperty;
146 if (firstChar === "+") { 146 if (firstChar === 43) { // 43 is aka "+".
147 mangledGlobalNames[previousProperty] = property.substring(1); 147 mangledGlobalNames[previousProperty] = property.substring(1);
148 var flag = descriptor[property]; 148 var flag = descriptor[property];
149 if (flag > 0) 149 if (flag > 0)
150 descriptor[previousProperty].$reflectableField = flag; 150 descriptor[previousProperty].$reflectableField = flag;
151 if (element && element.length) 151 if (element && element.length)
152 #typeInformation[previousProperty] = element; 152 #typeInformation[previousProperty] = element;
153 } else if (firstChar === "*") { 153 } else if (firstChar === 42) { // 42 is aka "*"
154 globalObject[previousProperty].$defaultValuesField = element; 154 globalObject[previousProperty].$defaultValuesField = element;
155 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField; 155 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField;
156 if (!optionalMethods) { 156 if (!optionalMethods) {
157 descriptor.$methodsWithOptionalArgumentsField = optionalMethods = {} 157 descriptor.$methodsWithOptionalArgumentsField = optionalMethods = {}
158 } 158 }
159 optionalMethods[property] = previousProperty; 159 optionalMethods[property] = previousProperty;
160 } else if (typeof element === "function") { 160 } else if (typeof element === "function") {
161 globalObject[previousProperty = property] = element; 161 globalObject[previousProperty = property] = element;
162 functions.push(property); 162 functions.push(property);
163 #globalFunctions[property] = element; 163 #globalFunctions[property] = element;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 (function() { 482 (function() {
483 var result = $array[$index]; 483 var result = $array[$index];
484 if ($check) { 484 if ($check) {
485 throw new Error( 485 throw new Error(
486 name + ": expected value of type \'$type\' at index " + ($index) + 486 name + ": expected value of type \'$type\' at index " + ($index) +
487 " but got " + (typeof result)); 487 " but got " + (typeof result));
488 } 488 }
489 return result; 489 return result;
490 })()'''; 490 })()''';
491 } 491 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698