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

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

Issue 160343002: Implement reflection on annotations of parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 6 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
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 var isAccessor = (requiredParameterInfo & 1) === 1; 91 var isAccessor = (requiredParameterInfo & 1) === 1;
92 var isSetter = requiredParameterInfo === 3; 92 var isSetter = requiredParameterInfo === 3;
93 var isGetter = requiredParameterInfo === 1; 93 var isGetter = requiredParameterInfo === 1;
94 var optionalParameterInfo = ${readInt("array", "1")}; 94 var optionalParameterInfo = ${readInt("array", "1")};
95 var optionalParameterCount = optionalParameterInfo >> 1; 95 var optionalParameterCount = optionalParameterInfo >> 1;
96 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1; 96 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1;
97 var isIntercepted =''' // Break long line. 97 var isIntercepted =''' // Break long line.
98 ''' requiredParameterCount + optionalParameterCount != funcs[0].length; 98 ''' requiredParameterCount + optionalParameterCount != funcs[0].length;
99 var functionTypeIndex = ${readFunctionType("array", "2")}; 99 var functionTypeIndex = ${readFunctionType("array", "2")};
100 var isReflectable =''' // Break long line. 100 var isReflectable =''' // Break long line.
101 ''' array.length > requiredParameterCount + optionalParameterCount + 3; 101 ''' array.length > 3 * optionalParameterCount + ''' // Break
102 '''2 * requiredParameterCount + 3
102 if (getterStubName) { 103 if (getterStubName) {
103 f = tearOff(funcs, array, isStatic, name, isIntercepted); 104 f = tearOff(funcs, array, isStatic, name, isIntercepted);
104 ''' 105 '''
105 /* Used to create an isolate using spawnFunction.*/ 106 /* Used to create an isolate using spawnFunction.*/
106 ''' 107 '''
107 if (isStatic) init.globalFunctions[name] = f; 108 if (isStatic) init.globalFunctions[name] = f;
108 originalDescriptor[getterStubName] = descriptor[getterStubName] = f; 109 originalDescriptor[getterStubName] = descriptor[getterStubName] = f;
109 funcs.push(f); 110 funcs.push(f);
110 if (getterStubName) functions.push(getterStubName); 111 if (getterStubName) functions.push(getterStubName);
111 f.\$stubName = getterStubName; 112 f.\$stubName = getterStubName;
112 f.\$callName = null; 113 f.\$callName = null;
113 } 114 }
114 if (isReflectable) { 115 if (isReflectable) {
115 for (var i = 0; i < funcs.length; i++) { 116 for (var i = 0; i < funcs.length; i++) {
116 funcs[i].$reflectableField = 1; 117 funcs[i].$reflectableField = 1;
117 funcs[i].$reflectionInfoField = array; 118 funcs[i].$reflectionInfoField = array;
118 } 119 }
119 } 120 }
120 if (isReflectable) { 121 if (isReflectable) {
121 var unmangledNameIndex =''' // Break long line. 122 var unmangledNameIndex =''' // Break long line.
122 ''' optionalParameterCount * 2 + requiredParameterCount + 3; 123 ''' 3 * optionalParameterCount + 2 * requiredParameterCount + 3;
123 var unmangledName = ${readString("array", "unmangledNameIndex")}; 124 var unmangledName = ${readString("array", "unmangledNameIndex")};
124 var reflectionName =''' // Break long line. 125 var reflectionName =''' // Break long line.
125 ''' unmangledName + ":" + requiredParameterCount +''' // Break long line. 126 ''' unmangledName + ":" + requiredParameterCount +''' // Break long line.
126 ''' ":" + optionalParameterCount; 127 ''' ":" + optionalParameterCount;
127 if (isGetter) { 128 if (isGetter) {
128 reflectionName = unmangledName; 129 reflectionName = unmangledName;
129 } else if (isSetter) { 130 } else if (isSetter) {
130 reflectionName = unmangledName + "="; 131 reflectionName = unmangledName + "=";
131 } 132 }
132 if (isStatic) { 133 if (isStatic) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 (function() { 344 (function() {
344 var result = $array[$index]; 345 var result = $array[$index];
345 if ($check) { 346 if ($check) {
346 throw new Error( 347 throw new Error(
347 name + ": expected value of type \'$type\' at index " + ($index) + 348 name + ": expected value of type \'$type\' at index " + ($index) +
348 " but got " + (typeof result)); 349 " but got " + (typeof result));
349 } 350 }
350 return result; 351 return result;
351 })()'''; 352 })()''';
352 } 353 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_emitter/container_builder.dart ('k') | sdk/lib/_internal/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698