OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * The [ConstantHandler] keeps track of compile-time constants, | 8 * The [ConstantHandler] keeps track of compile-time constants, |
9 * initializations of global and static fields, and default values of | 9 * initializations of global and static fields, and default values of |
10 * optional parameters. | 10 * optional parameters. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 String get name => 'ConstantHandler'; | 43 String get name => 'ConstantHandler'; |
44 | 44 |
45 void registerCompileTimeConstant(Constant constant) { | 45 void registerCompileTimeConstant(Constant constant) { |
46 registerInstantiatedClass(constant.computeType(compiler).element); | 46 registerInstantiatedClass(constant.computeType(compiler).element); |
47 if (constant.isFunction()) { | 47 if (constant.isFunction()) { |
48 FunctionConstant function = constant; | 48 FunctionConstant function = constant; |
49 registerGetOfStaticFunction(function.element); | 49 registerGetOfStaticFunction(function.element); |
50 } else if (constant.isInterceptor()) { | 50 } else if (constant.isInterceptor()) { |
51 // An interceptor constant references the class's prototype chain. | 51 // An interceptor constant references the class's prototype chain. |
52 registerInstantiatedClass(constant.dispatchedType.element); | 52 InterceptorConstant interceptor = constant; |
| 53 registerInstantiatedClass(interceptor.dispatchedType.element); |
53 } | 54 } |
54 compiledConstants.add(constant); | 55 compiledConstants.add(constant); |
55 } | 56 } |
56 | 57 |
57 void registerInstantiatedClass(ClassElement element) { | 58 void registerInstantiatedClass(ClassElement element) { |
58 if (isMetadata) return; | 59 if (isMetadata) return; |
59 compiler.enqueuer.codegen.registerInstantiatedClass(element); | 60 compiler.enqueuer.codegen.registerInstantiatedClass(element); |
60 } | 61 } |
61 | 62 |
62 void registerStaticUse(Element element) { | 63 void registerStaticUse(Element element) { |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 // Use the default value. | 886 // Use the default value. |
886 fieldValue = handler.compileConstant(field); | 887 fieldValue = handler.compileConstant(field); |
887 } | 888 } |
888 jsNewArguments.add(fieldValue); | 889 jsNewArguments.add(fieldValue); |
889 }, | 890 }, |
890 includeBackendMembers: true, | 891 includeBackendMembers: true, |
891 includeSuperMembers: true); | 892 includeSuperMembers: true); |
892 return jsNewArguments; | 893 return jsNewArguments; |
893 } | 894 } |
894 } | 895 } |
OLD | NEW |