| 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 Map<jsAst.Name, Set<ClassEntity>> specializedGetInterceptors = | 46 Map<jsAst.Name, Set<ClassEntity>> specializedGetInterceptors = |
| 47 backend.specializedGetInterceptors; | 47 backend.specializedGetInterceptors; |
| 48 List<jsAst.Name> names = specializedGetInterceptors.keys.toList()..sort(); | 48 List<jsAst.Name> names = specializedGetInterceptors.keys.toList()..sort(); |
| 49 for (jsAst.Name name in names) { | 49 for (jsAst.Name name in names) { |
| 50 Set<ClassEntity> classes = specializedGetInterceptors[name]; | 50 Set<ClassEntity> classes = specializedGetInterceptors[name]; |
| 51 parts.add(js.statement('#.# = #', [ | 51 parts.add(js.statement('#.# = #', [ |
| 52 namer.globalObjectFor(backend.helpers.interceptorsLibrary), | 52 namer.globalObjectForLibrary(backend.helpers.interceptorsLibrary), |
| 53 name, | 53 name, |
| 54 buildGetInterceptorMethod(name, classes) | 54 buildGetInterceptorMethod(name, classes) |
| 55 ])); | 55 ])); |
| 56 } | 56 } |
| 57 | 57 |
| 58 return new jsAst.Block(parts); | 58 return new jsAst.Block(parts); |
| 59 } | 59 } |
| 60 | 60 |
| 61 jsAst.Statement buildOneShotInterceptors() { | 61 jsAst.Statement buildOneShotInterceptors() { |
| 62 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 62 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
| 63 Iterable<jsAst.Name> names = backend.oneShotInterceptors.keys.toList() | 63 Iterable<jsAst.Name> names = backend.oneShotInterceptors.keys.toList() |
| 64 ..sort(); | 64 ..sort(); |
| 65 | 65 |
| 66 InterceptorStubGenerator stubGenerator = | 66 InterceptorStubGenerator stubGenerator = |
| 67 new InterceptorStubGenerator(compiler, namer, backend, closedWorld); | 67 new InterceptorStubGenerator(compiler, namer, backend, closedWorld); |
| 68 String globalObject = | 68 String globalObject = |
| 69 namer.globalObjectFor(backend.helpers.interceptorsLibrary); | 69 namer.globalObjectForLibrary(backend.helpers.interceptorsLibrary); |
| 70 for (jsAst.Name name in names) { | 70 for (jsAst.Name name in names) { |
| 71 jsAst.Expression function = | 71 jsAst.Expression function = |
| 72 stubGenerator.generateOneShotInterceptor(name); | 72 stubGenerator.generateOneShotInterceptor(name); |
| 73 parts.add(js.statement('${globalObject}.# = #', [name, function])); | 73 parts.add(js.statement('${globalObject}.# = #', [name, function])); |
| 74 } | 74 } |
| 75 | 75 |
| 76 return new jsAst.Block(parts); | 76 return new jsAst.Block(parts); |
| 77 } | 77 } |
| 78 | 78 |
| 79 /** | 79 /** |
| (...skipping 25 matching lines...) Expand all Loading... |
| 105 */ | 105 */ |
| 106 jsAst.Statement buildTypeToInterceptorMap(Program program) { | 106 jsAst.Statement buildTypeToInterceptorMap(Program program) { |
| 107 jsAst.Expression array = program.typeToInterceptorMap; | 107 jsAst.Expression array = program.typeToInterceptorMap; |
| 108 if (array == null) return js.comment("Empty type-to-interceptor map."); | 108 if (array == null) return js.comment("Empty type-to-interceptor map."); |
| 109 | 109 |
| 110 jsAst.Expression typeToInterceptorMap = emitter | 110 jsAst.Expression typeToInterceptorMap = emitter |
| 111 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); | 111 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); |
| 112 return js.statement('# = #', [typeToInterceptorMap, array]); | 112 return js.statement('# = #', [typeToInterceptorMap, array]); |
| 113 } | 113 } |
| 114 } | 114 } |
| OLD | NEW |