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

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

Issue 217963002: Allow getField of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address typo-comment. Created 6 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
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/js_helper.dart » ('j') | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 var optionalParameterCount = optionalParameterInfo >> 1; 98 var optionalParameterCount = optionalParameterInfo >> 1;
99 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1; 99 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1;
100 var isIntercepted =''' // Break long line. 100 var isIntercepted =''' // Break long line.
101 ''' requiredParameterCount + optionalParameterCount != funcs[0].length; 101 ''' requiredParameterCount + optionalParameterCount != funcs[0].length;
102 var functionTypeIndex = ${readFunctionType("array", "2")}; 102 var functionTypeIndex = ${readFunctionType("array", "2")};
103 var unmangledNameIndex = $unmangledNameIndex; 103 var unmangledNameIndex = $unmangledNameIndex;
104 var isReflectable = array.length > unmangledNameIndex; 104 var isReflectable = array.length > unmangledNameIndex;
105 105
106 if (getterStubName) { 106 if (getterStubName) {
107 f = tearOff(funcs, array, isStatic, name, isIntercepted); 107 f = tearOff(funcs, array, isStatic, name, isIntercepted);
108 f.getterStub = true;
108 ''' 109 '''
109 /* Used to create an isolate using spawnFunction.*/ 110 /* Used to create an isolate using spawnFunction.*/
110 ''' 111 '''
111 if (isStatic) init.globalFunctions[name] = f; 112 if (isStatic) init.globalFunctions[name] = f;
112 originalDescriptor[getterStubName] = descriptor[getterStubName] = f; 113 originalDescriptor[getterStubName] = descriptor[getterStubName] = f;
113 funcs.push(f); 114 funcs.push(f);
114 if (getterStubName) functions.push(getterStubName); 115 if (getterStubName) functions.push(getterStubName);
115 f.\$stubName = getterStubName; 116 f.\$stubName = getterStubName;
116 f.\$callName = null; 117 f.\$callName = null;
118 if (isIntercepted) init.interceptedNames[getterStubName] = true;
117 } 119 }
118 if (isReflectable) { 120 if (isReflectable) {
119 for (var i = 0; i < funcs.length; i++) { 121 for (var i = 0; i < funcs.length; i++) {
120 funcs[i].$reflectableField = 1; 122 funcs[i].$reflectableField = 1;
121 funcs[i].$reflectionInfoField = array; 123 funcs[i].$reflectionInfoField = array;
122 } 124 }
123 } 125 var mangledNames = isStatic ? init.mangledGlobalNames : init.mangledNames;
124 if (isReflectable) {
125 var unmangledName = ${readString("array", "unmangledNameIndex")}; 126 var unmangledName = ${readString("array", "unmangledNameIndex")};
126 var reflectionName =''' // Break long line. 127 '''
127 ''' unmangledName + ":" + requiredParameterCount +''' // Break long line. 128 // The function is either a getter, a setter, or a method.
129 // If it is a method, it might also have a tear-off closure.
130 // The unmangledName is the same as the getter-name.
131 '''
132 var reflectionName = unmangledName;
133 if (getterStubName) mangledNames[getterStubName] = reflectionName;
134 if (isSetter) {
135 reflectionName += "=";
136 } else if (!isGetter) {
137 reflectionName += ":" + requiredParameterCount +''' // Break long line.
128 ''' ":" + optionalParameterCount; 138 ''' ":" + optionalParameterCount;
129 if (isGetter) {
130 reflectionName = unmangledName;
131 } else if (isSetter) {
132 reflectionName = unmangledName + "=";
133 } 139 }
134 if (isStatic) { 140 mangledNames[name] = reflectionName;
135 init.mangledGlobalNames[name] = reflectionName;
136 } else {
137 init.mangledNames[name] = reflectionName;
138 }
139 funcs[0].$reflectionNameField = reflectionName; 141 funcs[0].$reflectionNameField = reflectionName;
140 funcs[0].$metadataIndexField = unmangledNameIndex + 1; 142 funcs[0].$metadataIndexField = unmangledNameIndex + 1;
141 if (optionalParameterCount) descriptor[unmangledName + "*"] = funcs[0]; 143 if (optionalParameterCount) descriptor[unmangledName + "*"] = funcs[0];
142 } 144 }
143 } 145 }
144 '''; 146 ''';
145 147
146 String tearOff = ''' 148 String tearOff = '''
147 function tearOffGetterNoCsp(funcs, reflectionInfo, name, isIntercepted) { 149 function tearOffGetterNoCsp(funcs, reflectionInfo, name, isIntercepted) {
148 return isIntercepted 150 return isIntercepted
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 String init = ''' 195 String init = '''
194 var functionCounter = 0; 196 var functionCounter = 0;
195 var tearOffGetter = (typeof dart_precompiled == "function") 197 var tearOffGetter = (typeof dart_precompiled == "function")
196 ? tearOffGetterCsp : tearOffGetterNoCsp; 198 ? tearOffGetterCsp : tearOffGetterNoCsp;
197 if (!init.libraries) init.libraries = []; 199 if (!init.libraries) init.libraries = [];
198 if (!init.mangledNames) init.mangledNames = map(); 200 if (!init.mangledNames) init.mangledNames = map();
199 if (!init.mangledGlobalNames) init.mangledGlobalNames = map(); 201 if (!init.mangledGlobalNames) init.mangledGlobalNames = map();
200 if (!init.statics) init.statics = map(); 202 if (!init.statics) init.statics = map();
201 if (!init.typeInformation) init.typeInformation = map(); 203 if (!init.typeInformation) init.typeInformation = map();
202 if (!init.globalFunctions) init.globalFunctions = map(); 204 if (!init.globalFunctions) init.globalFunctions = map();
205 if (!init.interceptedNames) init.interceptedNames = map();
203 var libraries = init.libraries; 206 var libraries = init.libraries;
204 var mangledNames = init.mangledNames; 207 var mangledNames = init.mangledNames;
205 var mangledGlobalNames = init.mangledGlobalNames; 208 var mangledGlobalNames = init.mangledGlobalNames;
206 var hasOwnProperty = Object.prototype.hasOwnProperty; 209 var hasOwnProperty = Object.prototype.hasOwnProperty;
207 var length = reflectionData.length; 210 var length = reflectionData.length;
208 for (var i = 0; i < length; i++) { 211 for (var i = 0; i < length; i++) {
209 var data = reflectionData[i]; 212 var data = reflectionData[i];
210 ''' 213 '''
211 // [data] contains these elements: 214 // [data] contains these elements:
212 // 0. The library name (not unique). 215 // 0. The library name (not unique).
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 (function() { 351 (function() {
349 var result = $array[$index]; 352 var result = $array[$index];
350 if ($check) { 353 if ($check) {
351 throw new Error( 354 throw new Error(
352 name + ": expected value of type \'$type\' at index " + ($index) + 355 name + ": expected value of type \'$type\' at index " + ($index) +
353 " but got " + (typeof result)); 356 " but got " + (typeof result));
354 } 357 }
355 return result; 358 return result;
356 })()'''; 359 })()''';
357 } 360 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698