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

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

Issue 2482923002: Use `Function` as function type syntax.
Patch Set: Created 4 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
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 // Function signatures used in the generation of runtime type information.
8 typedef void FunctionTypeSignatureEmitter(
9 Element method, FunctionType methodType);
10
11 typedef void SubstitutionEmitter(Element element, {bool emitNull});
12
13 class TypeTestProperties { 7 class TypeTestProperties {
14 /// The index of the function type into the metadata. 8 /// The index of the function type into the metadata.
15 /// 9 ///
16 /// If the class doesn't have a function type this field is `null`. 10 /// If the class doesn't have a function type this field is `null`.
17 /// 11 ///
18 /// If the is tests were generated with `storeFunctionTypeInMetadata` set to 12 /// If the is tests were generated with `storeFunctionTypeInMetadata` set to
19 /// `false`, this field is `null`, and the [properties] contain a property 13 /// `false`, this field is `null`, and the [properties] contain a property
20 /// that encodes the function type. 14 /// that encodes the function type.
21 jsAst.Expression functionTypeIndex; 15 jsAst.Expression functionTypeIndex;
22 16
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 146
153 /** 147 /**
154 * Generate "is tests" for [cls] itself, and the "is tests" for the 148 * Generate "is tests" for [cls] itself, and the "is tests" for the
155 * classes it implements and type argument substitution functions for these 149 * classes it implements and type argument substitution functions for these
156 * tests. We don't need to add the "is tests" of the super class because 150 * tests. We don't need to add the "is tests" of the super class because
157 * they will be inherited at runtime, but we may need to generate the 151 * they will be inherited at runtime, but we may need to generate the
158 * substitutions, because they may have changed. 152 * substitutions, because they may have changed.
159 */ 153 */
160 void _generateIsTestsOn( 154 void _generateIsTestsOn(
161 ClassElement cls, 155 ClassElement cls,
162 void generateIsTest(Element element), 156 void Function(Element) generateIsTest,
163 FunctionTypeSignatureEmitter generateFunctionTypeSignature, 157 void Function(Element method, FunctionType methodType)
164 SubstitutionEmitter generateSubstitution, 158 generateFunctionTypeSignature,
159 void Function(Element, {bool emitNull}) generateSubstitution,
165 void emitTypeCheck(TypeCheck check)) { 160 void emitTypeCheck(TypeCheck check)) {
166 Setlet<Element> generated = new Setlet<Element>(); 161 Setlet<Element> generated = new Setlet<Element>();
167 162
168 if (checkedClasses.contains(cls)) { 163 if (checkedClasses.contains(cls)) {
169 generateIsTest(cls); 164 generateIsTest(cls);
170 generateSubstitution(cls); 165 generateSubstitution(cls);
171 generated.add(cls); 166 generated.add(cls);
172 } 167 }
173 168
174 // Precomputed is checks. 169 // Precomputed is checks.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 _generateInterfacesIsTests(interfaceType.element, generateIsTest, 257 _generateInterfacesIsTests(interfaceType.element, generateIsTest,
263 generateSubstitution, generated); 258 generateSubstitution, generated);
264 } 259 }
265 } 260 }
266 261
267 /** 262 /**
268 * Generate "is tests" where [cls] is being implemented. 263 * Generate "is tests" where [cls] is being implemented.
269 */ 264 */
270 void _generateInterfacesIsTests( 265 void _generateInterfacesIsTests(
271 ClassElement cls, 266 ClassElement cls,
272 void generateIsTest(ClassElement element), 267 void Function(ClassElement) generateIsTest,
273 SubstitutionEmitter generateSubstitution, 268 void Function(Element, {bool emitNull}) generateSubstitution,
274 Set<Element> alreadyGenerated) { 269 Set<Element> alreadyGenerated) {
270
275 void tryEmitTest(ClassElement check) { 271 void tryEmitTest(ClassElement check) {
276 if (!alreadyGenerated.contains(check) && checkedClasses.contains(check)) { 272 if (!alreadyGenerated.contains(check) && checkedClasses.contains(check)) {
277 alreadyGenerated.add(check); 273 alreadyGenerated.add(check);
278 generateIsTest(check); 274 generateIsTest(check);
279 generateSubstitution(check); 275 generateSubstitution(check);
280 } 276 }
281 } 277 }
282 278
283 tryEmitTest(cls); 279 tryEmitTest(cls);
284 280
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 331 }
336 jsAst.Expression convertRtiToRuntimeType = backend.emitter 332 jsAst.Expression convertRtiToRuntimeType = backend.emitter
337 .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType); 333 .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType);
338 334
339 return new StubMethod( 335 return new StubMethod(
340 name, 336 name,
341 js('function () { return #(#) }', 337 js('function () { return #(#) }',
342 [convertRtiToRuntimeType, computeTypeVariable])); 338 [convertRtiToRuntimeType, computeTypeVariable]));
343 } 339 }
344 } 340 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart ('k') | pkg/compiler/lib/src/kernel/kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698