| 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 class InterceptorStubGenerator { | 7 class InterceptorStubGenerator { |
| 8 final Compiler compiler; | 8 final Compiler compiler; |
| 9 final Namer namer; | 9 final Namer namer; |
| 10 final JavaScriptBackend backend; | 10 final JavaScriptBackend backend; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 jsAst.ArrayInitializer generateTypeToInterceptorMap() { | 354 jsAst.ArrayInitializer generateTypeToInterceptorMap() { |
| 355 // TODO(sra): Perhaps inject a constant instead? | 355 // TODO(sra): Perhaps inject a constant instead? |
| 356 CustomElementsAnalysis analysis = backend.customElementsAnalysis; | 356 CustomElementsAnalysis analysis = backend.customElementsAnalysis; |
| 357 if (!analysis.needsTable) return null; | 357 if (!analysis.needsTable) return null; |
| 358 | 358 |
| 359 List<jsAst.Expression> elements = <jsAst.Expression>[]; | 359 List<jsAst.Expression> elements = <jsAst.Expression>[]; |
| 360 JavaScriptConstantCompiler handler = backend.constants; | 360 JavaScriptConstantCompiler handler = backend.constants; |
| 361 List<ConstantValue> constants = | 361 List<ConstantValue> constants = |
| 362 handler.getConstantsForEmission(emitter.compareConstants); | 362 handler.getConstantsForEmission(emitter.compareConstants); |
| 363 for (ConstantValue constant in constants) { | 363 for (ConstantValue constant in constants) { |
| 364 if (constant is TypeConstantValue) { | 364 if (constant is TypeConstantValue && |
| 365 TypeConstantValue typeConstant = constant; | 365 constant.representedType is ResolutionInterfaceType) { |
| 366 Element element = typeConstant.representedType.element; | 366 ResolutionInterfaceType type = constant.representedType; |
| 367 Element element = type.element; |
| 367 if (element is ClassElement) { | 368 if (element is ClassElement) { |
| 368 ClassElement classElement = element; | 369 ClassElement classElement = element; |
| 369 if (!analysis.needsClass(classElement)) continue; | 370 if (!analysis.needsClass(classElement)) continue; |
| 370 | 371 |
| 371 elements.add(emitter.constantReference(constant)); | 372 elements.add(emitter.constantReference(constant)); |
| 372 elements.add(backend.emitter.interceptorClassAccess(classElement)); | 373 elements.add(backend.emitter.interceptorClassAccess(classElement)); |
| 373 | 374 |
| 374 // Create JavaScript Object map for by-name lookup of generative | 375 // Create JavaScript Object map for by-name lookup of generative |
| 375 // constructors. For example, the class A has three generative | 376 // constructors. For example, the class A has three generative |
| 376 // constructors | 377 // constructors |
| (...skipping 17 matching lines...) Expand all Loading... |
| 394 | 395 |
| 395 var map = new jsAst.ObjectInitializer(properties); | 396 var map = new jsAst.ObjectInitializer(properties); |
| 396 elements.add(map); | 397 elements.add(map); |
| 397 } | 398 } |
| 398 } | 399 } |
| 399 } | 400 } |
| 400 | 401 |
| 401 return new jsAst.ArrayInitializer(elements); | 402 return new jsAst.ArrayInitializer(elements); |
| 402 } | 403 } |
| 403 } | 404 } |
| OLD | NEW |