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 part of dart2js.js_emitter.full_emitter; | 5 part of dart2js.js_emitter.full_emitter; |
6 | 6 |
7 class InterceptorEmitter extends CodeEmitterHelper { | 7 class InterceptorEmitter extends CodeEmitterHelper { |
8 final Set<jsAst.Name> interceptorInvocationNames = | 8 final Set<jsAst.Name> interceptorInvocationNames = |
9 new Set<jsAst.Name>(); | 9 new Set<jsAst.Name>(); |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 parts.add(js.comment('getInterceptor methods')); | 34 parts.add(js.comment('getInterceptor methods')); |
35 | 35 |
36 Map<jsAst.Name, Set<ClassElement>> specializedGetInterceptors = | 36 Map<jsAst.Name, Set<ClassElement>> specializedGetInterceptors = |
37 backend.specializedGetInterceptors; | 37 backend.specializedGetInterceptors; |
38 List<jsAst.Name> names = specializedGetInterceptors.keys.toList() | 38 List<jsAst.Name> names = specializedGetInterceptors.keys.toList() |
39 ..sort(); | 39 ..sort(); |
40 for (jsAst.Name name in names) { | 40 for (jsAst.Name name in names) { |
41 Set<ClassElement> classes = specializedGetInterceptors[name]; | 41 Set<ClassElement> classes = specializedGetInterceptors[name]; |
42 parts.add( | 42 parts.add( |
43 js.statement('#.# = #', | 43 js.statement('#.# = #', |
44 [namer.globalObjectFor(backend.interceptorsLibrary), | 44 [namer.globalObjectFor(backend.helpers.interceptorsLibrary), |
45 name, | 45 name, |
46 buildGetInterceptorMethod(name, classes)])); | 46 buildGetInterceptorMethod(name, classes)])); |
47 } | 47 } |
48 | 48 |
49 return new jsAst.Block(parts); | 49 return new jsAst.Block(parts); |
50 } | 50 } |
51 | 51 |
52 jsAst.Statement buildOneShotInterceptors() { | 52 jsAst.Statement buildOneShotInterceptors() { |
53 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 53 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
54 Iterable<jsAst.Name> names = backend.oneShotInterceptors.keys.toList() | 54 Iterable<jsAst.Name> names = backend.oneShotInterceptors.keys.toList() |
55 ..sort(); | 55 ..sort(); |
56 | 56 |
57 InterceptorStubGenerator stubGenerator = | 57 InterceptorStubGenerator stubGenerator = |
58 new InterceptorStubGenerator(compiler, namer, backend); | 58 new InterceptorStubGenerator(compiler, namer, backend); |
59 String globalObject = namer.globalObjectFor(backend.interceptorsLibrary); | 59 String globalObject = |
| 60 namer.globalObjectFor(backend.helpers.interceptorsLibrary); |
60 for (jsAst.Name name in names) { | 61 for (jsAst.Name name in names) { |
61 jsAst.Expression function = | 62 jsAst.Expression function = |
62 stubGenerator.generateOneShotInterceptor(name); | 63 stubGenerator.generateOneShotInterceptor(name); |
63 parts.add(js.statement('${globalObject}.# = #', [name, function])); | 64 parts.add(js.statement('${globalObject}.# = #', [name, function])); |
64 } | 65 } |
65 | 66 |
66 return new jsAst.Block(parts); | 67 return new jsAst.Block(parts); |
67 } | 68 } |
68 | 69 |
69 /** | 70 /** |
(...skipping 24 matching lines...) Expand all Loading... |
94 */ | 95 */ |
95 jsAst.Statement buildTypeToInterceptorMap(Program program) { | 96 jsAst.Statement buildTypeToInterceptorMap(Program program) { |
96 jsAst.Expression array = program.typeToInterceptorMap; | 97 jsAst.Expression array = program.typeToInterceptorMap; |
97 if (array == null) return js.comment("Empty type-to-interceptor map."); | 98 if (array == null) return js.comment("Empty type-to-interceptor map."); |
98 | 99 |
99 jsAst.Expression typeToInterceptorMap = emitter | 100 jsAst.Expression typeToInterceptorMap = emitter |
100 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); | 101 .generateEmbeddedGlobalAccess(embeddedNames.TYPE_TO_INTERCEPTOR_MAP); |
101 return js.statement('# = #', [typeToInterceptorMap, array]); | 102 return js.statement('# = #', [typeToInterceptorMap, array]); |
102 } | 103 } |
103 } | 104 } |
OLD | NEW |