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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 7 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
8 final Set<HInstruction> boundsChecked; | 8 final Set<HInstruction> boundsChecked; |
9 | 9 |
10 JavaScriptItemCompilationContext() | 10 JavaScriptItemCompilationContext() |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 Element getInterceptorMethod; | 69 Element getInterceptorMethod; |
70 Element interceptedNames; | 70 Element interceptedNames; |
71 | 71 |
72 HType stringType; | 72 HType stringType; |
73 HType indexablePrimitiveType; | 73 HType indexablePrimitiveType; |
74 HType readableArrayType; | 74 HType readableArrayType; |
75 HType mutableArrayType; | 75 HType mutableArrayType; |
76 HType fixedArrayType; | 76 HType fixedArrayType; |
77 HType extendableArrayType; | 77 HType extendableArrayType; |
78 | |
79 | 78 |
80 // TODO(9577): Make it so that these are not needed when there are no native | 79 // TODO(9577): Make it so that these are not needed when there are no native |
81 // classes. | 80 // classes. |
82 Element dispatchPropertyName; | 81 Element dispatchPropertyName; |
83 Element getNativeInterceptorMethod; | 82 Element getNativeInterceptorMethod; |
84 Element defineNativeMethodsFinishMethod; | 83 Element defineNativeMethodsFinishMethod; |
85 Element getDispatchPropertyMethod; | 84 Element getDispatchPropertyMethod; |
86 Element setDispatchPropertyMethod; | 85 Element setDispatchPropertyMethod; |
87 Element initializeDispatchPropertyMethod; | 86 Element initializeDispatchPropertyMethod; |
88 bool needToInitializeDispatchProperty = false; | 87 bool needToInitializeDispatchProperty = false; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 * Set of classes whose `operator ==` methods handle `null` themselves. | 148 * Set of classes whose `operator ==` methods handle `null` themselves. |
150 */ | 149 */ |
151 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); | 150 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); |
152 | 151 |
153 List<CompilerTask> get tasks { | 152 List<CompilerTask> get tasks { |
154 return <CompilerTask>[builder, optimizer, generator, emitter]; | 153 return <CompilerTask>[builder, optimizer, generator, emitter]; |
155 } | 154 } |
156 | 155 |
157 final RuntimeTypes rti; | 156 final RuntimeTypes rti; |
158 | 157 |
| 158 /// Holds the method "disableTreeShaking" in js_mirrors when |
| 159 /// dart:mirrors has been loaded. |
| 160 FunctionElement disableTreeShakingMarker; |
| 161 |
| 162 /// Holds the method "preserveNames" in js_mirrors when |
| 163 /// dart:mirrors has been loaded. |
| 164 FunctionElement preserveNamesMarker; |
| 165 |
159 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval) | 166 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval) |
160 : namer = determineNamer(compiler), | 167 : namer = determineNamer(compiler), |
161 usedInterceptors = new Set<Selector>(), | 168 usedInterceptors = new Set<Selector>(), |
162 oneShotInterceptors = new Map<String, Selector>(), | 169 oneShotInterceptors = new Map<String, Selector>(), |
163 interceptedElements = new Map<SourceString, Set<Element>>(), | 170 interceptedElements = new Map<SourceString, Set<Element>>(), |
164 rti = new RuntimeTypes(compiler), | 171 rti = new RuntimeTypes(compiler), |
165 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), | 172 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), |
166 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { | 173 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { |
167 emitter = disableEval | 174 emitter = disableEval |
168 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) | 175 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 ClassElement get stringImplementation => jsStringClass; | 1114 ClassElement get stringImplementation => jsStringClass; |
1108 ClassElement get listImplementation => jsArrayClass; | 1115 ClassElement get listImplementation => jsArrayClass; |
1109 ClassElement get constListImplementation => jsArrayClass; | 1116 ClassElement get constListImplementation => jsArrayClass; |
1110 ClassElement get fixedListImplementation => jsFixedArrayClass; | 1117 ClassElement get fixedListImplementation => jsFixedArrayClass; |
1111 ClassElement get growableListImplementation => jsExtendableArrayClass; | 1118 ClassElement get growableListImplementation => jsExtendableArrayClass; |
1112 ClassElement get mapImplementation => mapLiteralClass; | 1119 ClassElement get mapImplementation => mapLiteralClass; |
1113 ClassElement get constMapImplementation => constMapLiteralClass; | 1120 ClassElement get constMapImplementation => constMapLiteralClass; |
1114 ClassElement get typeImplementation => typeLiteralClass; | 1121 ClassElement get typeImplementation => typeLiteralClass; |
1115 ClassElement get boolImplementation => jsBoolClass; | 1122 ClassElement get boolImplementation => jsBoolClass; |
1116 ClassElement get nullImplementation => jsNullClass; | 1123 ClassElement get nullImplementation => jsNullClass; |
| 1124 |
| 1125 void enableMirrors() { |
| 1126 LibraryElement library = compiler.libraries['dart:_js_mirrors']; |
| 1127 disableTreeShakingMarker = |
| 1128 library.find(const SourceString('disableTreeShaking')); |
| 1129 preserveNamesMarker = |
| 1130 library.find(const SourceString('preserveNames')); |
| 1131 } |
| 1132 |
| 1133 void registerStaticUse(Element element, Enqueuer enqueuer) { |
| 1134 if (element == disableTreeShakingMarker) { |
| 1135 enqueuer.enqueueEverything(); |
| 1136 } else if (element == preserveNamesMarker) { |
| 1137 } |
| 1138 } |
1117 } | 1139 } |
OLD | NEW |