OLD | NEW |
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. | 7 // Function signatures used in the generation of runtime type information. |
8 typedef void FunctionTypeSignatureEmitter( | 8 typedef void FunctionTypeSignatureEmitter( |
9 Element method, FunctionType methodType); | 9 Element method, FunctionType methodType); |
10 | 10 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } | 313 } |
314 | 314 |
315 StubMethod _generateTypeVariableReader( | 315 StubMethod _generateTypeVariableReader( |
316 ClassElement cls, TypeVariableElement element) { | 316 ClassElement cls, TypeVariableElement element) { |
317 jsAst.Name name = namer.nameForReadTypeVariable(element); | 317 jsAst.Name name = namer.nameForReadTypeVariable(element); |
318 int index = element.index; | 318 int index = element.index; |
319 jsAst.Expression computeTypeVariable; | 319 jsAst.Expression computeTypeVariable; |
320 | 320 |
321 Substitution substitution = | 321 Substitution substitution = |
322 backend.rti.getSubstitution(cls, element.typeDeclaration); | 322 backend.rti.getSubstitution(cls, element.typeDeclaration); |
| 323 jsAst.Name rtiFieldName = backend.namer.rtiFieldName; |
323 if (substitution != null) { | 324 if (substitution != null) { |
324 computeTypeVariable = js( | 325 computeTypeVariable = js(r'#.apply(null, this.#)', [ |
325 r'#.apply(null, this.$builtinTypeInfo)', | 326 backend.rtiEncoder.getSubstitutionCodeForVariable(substitution, index), |
326 backend.rtiEncoder | 327 rtiFieldName |
327 .getSubstitutionCodeForVariable(substitution, index)); | 328 ]); |
328 } else { | 329 } else { |
329 // TODO(ahe): These can be generated dynamically. | 330 // TODO(ahe): These can be generated dynamically. |
330 computeTypeVariable = js( | 331 computeTypeVariable = js(r'this.# && this.#[#]', |
331 r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', | 332 [rtiFieldName, rtiFieldName, js.number(index)]); |
332 js.number(index)); | |
333 } | 333 } |
334 jsAst.Expression convertRtiToRuntimeType = backend.emitter | 334 jsAst.Expression convertRtiToRuntimeType = backend.emitter |
335 .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType); | 335 .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType); |
336 | 336 |
337 return new StubMethod( | 337 return new StubMethod( |
338 name, | 338 name, |
339 js('function () { return #(#) }', | 339 js('function () { return #(#) }', |
340 [convertRtiToRuntimeType, computeTypeVariable])); | 340 [convertRtiToRuntimeType, computeTypeVariable])); |
341 } | 341 } |
342 } | 342 } |
OLD | NEW |