| OLD | NEW |
| 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 library dart2js.js_emitter.full_emitter.interceptor_emitter; | 5 library dart2js.js_emitter.full_emitter.interceptor_emitter; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
| 8 import '../../elements/entities.dart'; | 8 import '../../elements/entities.dart'; |
| 9 import '../../js/js.dart' as jsAst; | 9 import '../../js/js.dart' as jsAst; |
| 10 import '../../js/js.dart' show js; | 10 import '../../js/js.dart' show js; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 42 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
| 43 | 43 |
| 44 parts.add(js.comment('getInterceptor methods')); | 44 parts.add(js.comment('getInterceptor methods')); |
| 45 | 45 |
| 46 Iterable<jsAst.Name> names = | 46 Iterable<jsAst.Name> names = |
| 47 backend.oneShotInterceptorData.specializedGetInterceptorNames; | 47 backend.oneShotInterceptorData.specializedGetInterceptorNames; |
| 48 for (jsAst.Name name in names) { | 48 for (jsAst.Name name in names) { |
| 49 Set<ClassEntity> classes = | 49 Set<ClassEntity> classes = |
| 50 backend.oneShotInterceptorData.getSpecializedGetInterceptorsFor(name); | 50 backend.oneShotInterceptorData.getSpecializedGetInterceptorsFor(name); |
| 51 parts.add(js.statement('#.# = #', [ | 51 parts.add(js.statement('#.# = #', [ |
| 52 namer.globalObjectForLibrary(backend.helpers.interceptorsLibrary), | 52 namer |
| 53 .globalObjectForLibrary(backend.commonElements.interceptorsLibrary), |
| 53 name, | 54 name, |
| 54 buildGetInterceptorMethod(name, classes) | 55 buildGetInterceptorMethod(name, classes) |
| 55 ])); | 56 ])); |
| 56 } | 57 } |
| 57 | 58 |
| 58 return new jsAst.Block(parts); | 59 return new jsAst.Block(parts); |
| 59 } | 60 } |
| 60 | 61 |
| 61 jsAst.Statement buildOneShotInterceptors() { | 62 jsAst.Statement buildOneShotInterceptors() { |
| 62 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 63 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
| 63 Iterable<jsAst.Name> names = | 64 Iterable<jsAst.Name> names = |
| 64 backend.oneShotInterceptorData.oneShotInterceptorNames; | 65 backend.oneShotInterceptorData.oneShotInterceptorNames; |
| 65 | 66 |
| 66 InterceptorStubGenerator stubGenerator = | 67 InterceptorStubGenerator stubGenerator = |
| 67 new InterceptorStubGenerator(compiler, namer, backend, closedWorld); | 68 new InterceptorStubGenerator(compiler, namer, backend, closedWorld); |
| 68 String globalObject = | 69 String globalObject = namer |
| 69 namer.globalObjectForLibrary(backend.helpers.interceptorsLibrary); | 70 .globalObjectForLibrary(backend.commonElements.interceptorsLibrary); |
| 70 for (jsAst.Name name in names) { | 71 for (jsAst.Name name in names) { |
| 71 jsAst.Expression function = | 72 jsAst.Expression function = |
| 72 stubGenerator.generateOneShotInterceptor(name); | 73 stubGenerator.generateOneShotInterceptor(name); |
| 73 parts.add(js.statement('${globalObject}.# = #', [name, function])); | 74 parts.add(js.statement('${globalObject}.# = #', [name, function])); |
| 74 } | 75 } |
| 75 | 76 |
| 76 return new jsAst.Block(parts); | 77 return new jsAst.Block(parts); |
| 77 } | 78 } |
| 78 | 79 |
| 79 /** | 80 /** |
| (...skipping 25 matching lines...) Expand all Loading... |
| 105 */ | 106 */ |
| 106 jsAst.Statement buildTypeToInterceptorMap(Program program) { | 107 jsAst.Statement buildTypeToInterceptorMap(Program program) { |
| 107 jsAst.Expression array = program.typeToInterceptorMap; | 108 jsAst.Expression array = program.typeToInterceptorMap; |
| 108 if (array == null) return js.comment("Empty type-to-interceptor map."); | 109 if (array == null) return js.comment("Empty type-to-interceptor map."); |
| 109 | 110 |
| 110 jsAst.Expression typeToInterceptorMap = emitter | 111 jsAst.Expression typeToInterceptorMap = emitter |
| 111 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); | 112 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); |
| 112 return js.statement('# = #', [typeToInterceptorMap, array]); | 113 return js.statement('# = #', [typeToInterceptorMap, array]); |
| 113 } | 114 } |
| 114 } | 115 } |
| OLD | NEW |