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

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

Issue 2439573003: Experiment with new function-type syntax.
Patch Set: Change a few more typedefs. Created 4 years, 2 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
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 144
151 /** 145 /**
152 * Generate "is tests" for [cls] itself, and the "is tests" for the 146 * Generate "is tests" for [cls] itself, and the "is tests" for the
153 * classes it implements and type argument substitution functions for these 147 * classes it implements and type argument substitution functions for these
154 * tests. We don't need to add the "is tests" of the super class because 148 * tests. We don't need to add the "is tests" of the super class because
155 * they will be inherited at runtime, but we may need to generate the 149 * they will be inherited at runtime, but we may need to generate the
156 * substitutions, because they may have changed. 150 * substitutions, because they may have changed.
157 */ 151 */
158 void _generateIsTestsOn( 152 void _generateIsTestsOn(
159 ClassElement cls, 153 ClassElement cls,
160 void generateIsTest(Element element), 154 (Element) -> void generateIsTest,
161 FunctionTypeSignatureEmitter generateFunctionTypeSignature, 155 (Element method, FunctionType methodType) -> void
162 SubstitutionEmitter generateSubstitution, 156 generateFunctionTypeSignature,
157 (Element, {bool emitNull}) -> void generateSubstitution,
163 void emitTypeCheck(TypeCheck check)) { 158 void emitTypeCheck(TypeCheck check)) {
164 Setlet<Element> generated = new Setlet<Element>(); 159 Setlet<Element> generated = new Setlet<Element>();
165 160
166 if (checkedClasses.contains(cls)) { 161 if (checkedClasses.contains(cls)) {
167 generateIsTest(cls); 162 generateIsTest(cls);
168 generateSubstitution(cls); 163 generateSubstitution(cls);
169 generated.add(cls); 164 generated.add(cls);
170 } 165 }
171 166
172 // Precomputed is checks. 167 // Precomputed is checks.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 _generateInterfacesIsTests(interfaceType.element, generateIsTest, 255 _generateInterfacesIsTests(interfaceType.element, generateIsTest,
261 generateSubstitution, generated); 256 generateSubstitution, generated);
262 } 257 }
263 } 258 }
264 259
265 /** 260 /**
266 * Generate "is tests" where [cls] is being implemented. 261 * Generate "is tests" where [cls] is being implemented.
267 */ 262 */
268 void _generateInterfacesIsTests( 263 void _generateInterfacesIsTests(
269 ClassElement cls, 264 ClassElement cls,
270 void generateIsTest(ClassElement element), 265 ClassElement -> void generateIsTest,
271 SubstitutionEmitter generateSubstitution, 266 (Element, {bool emitNull}) -> void generateSubstitution,
272 Set<Element> alreadyGenerated) { 267 Set<Element> alreadyGenerated) {
268
273 void tryEmitTest(ClassElement check) { 269 void tryEmitTest(ClassElement check) {
274 if (!alreadyGenerated.contains(check) && checkedClasses.contains(check)) { 270 if (!alreadyGenerated.contains(check) && checkedClasses.contains(check)) {
275 alreadyGenerated.add(check); 271 alreadyGenerated.add(check);
276 generateIsTest(check); 272 generateIsTest(check);
277 generateSubstitution(check); 273 generateSubstitution(check);
278 } 274 }
279 } 275 }
280 276
281 tryEmitTest(cls); 277 tryEmitTest(cls);
282 278
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 329 }
334 jsAst.Expression convertRtiToRuntimeType = backend.emitter 330 jsAst.Expression convertRtiToRuntimeType = backend.emitter
335 .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType); 331 .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType);
336 332
337 return new StubMethod( 333 return new StubMethod(
338 name, 334 name,
339 js('function () { return #(#) }', 335 js('function () { return #(#) }',
340 [convertRtiToRuntimeType, computeTypeVariable])); 336 [convertRtiToRuntimeType, computeTypeVariable]));
341 } 337 }
342 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698