| 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 library dart2js.common.codegen; | 5 library dart2js.common.codegen; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/values.dart' show ConstantValue; | |
| 9 import '../elements/resolution_types.dart' | 8 import '../elements/resolution_types.dart' |
| 10 show ResolutionDartType, ResolutionInterfaceType; | 9 show ResolutionDartType, ResolutionInterfaceType; |
| 11 import '../elements/elements.dart' | 10 import '../elements/elements.dart' |
| 12 show | 11 show |
| 13 ClassElement, | 12 ClassElement, |
| 14 Element, | 13 Element, |
| 15 FunctionElement, | 14 FunctionElement, |
| 16 LocalFunctionElement, | 15 LocalFunctionElement, |
| 17 MemberElement, | 16 MemberElement, |
| 18 ResolvedAst; | 17 ResolvedAst; |
| 18 import '../elements/entities.dart'; |
| 19 import '../js_backend/backend.dart' show JavaScriptBackend; | 19 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 20 import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse; | 20 import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse; |
| 21 import '../universe/world_impact.dart' | 21 import '../universe/world_impact.dart' |
| 22 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor; | 22 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor; |
| 23 import '../util/util.dart' show Pair, Setlet; | 23 import '../util/util.dart' show Pair, Setlet; |
| 24 import 'work.dart' show WorkItem; | 24 import 'work.dart' show WorkItem; |
| 25 | 25 |
| 26 class CodegenImpact extends WorldImpact { | 26 class CodegenImpact extends WorldImpact { |
| 27 const CodegenImpact(); | 27 const CodegenImpact(); |
| 28 | 28 |
| 29 Iterable<Pair<ResolutionDartType, ResolutionDartType>> | 29 Iterable<Pair<ResolutionDartType, ResolutionDartType>> |
| 30 get typeVariableBoundsSubtypeChecks { | 30 get typeVariableBoundsSubtypeChecks { |
| 31 return const <Pair<ResolutionDartType, ResolutionDartType>>[]; | 31 return const <Pair<ResolutionDartType, ResolutionDartType>>[]; |
| 32 } | 32 } |
| 33 | 33 |
| 34 Iterable<String> get constSymbols => const <String>[]; | 34 Iterable<String> get constSymbols => const <String>[]; |
| 35 | 35 |
| 36 Iterable<Set<ClassElement>> get specializedGetInterceptors { | 36 Iterable<Set<ClassEntity>> get specializedGetInterceptors { |
| 37 return const <Set<ClassElement>>[]; | 37 return const <Set<ClassEntity>>[]; |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool get usesInterceptor => false; | 40 bool get usesInterceptor => false; |
| 41 | 41 |
| 42 Iterable<Element> get asyncMarkers => const <FunctionElement>[]; | 42 Iterable<Element> get asyncMarkers => const <FunctionElement>[]; |
| 43 } | 43 } |
| 44 | 44 |
| 45 class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact { | 45 class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact { |
| 46 Setlet<Pair<ResolutionDartType, ResolutionDartType>> | 46 Setlet<Pair<ResolutionDartType, ResolutionDartType>> |
| 47 _typeVariableBoundsSubtypeChecks; | 47 _typeVariableBoundsSubtypeChecks; |
| 48 Setlet<String> _constSymbols; | 48 Setlet<String> _constSymbols; |
| 49 List<Set<ClassElement>> _specializedGetInterceptors; | 49 List<Set<ClassEntity>> _specializedGetInterceptors; |
| 50 bool _usesInterceptor = false; | 50 bool _usesInterceptor = false; |
| 51 Setlet<FunctionElement> _asyncMarkers; | 51 Setlet<FunctionElement> _asyncMarkers; |
| 52 | 52 |
| 53 _CodegenImpact(); | 53 _CodegenImpact(); |
| 54 | 54 |
| 55 void apply(WorldImpactVisitor visitor) { | 55 void apply(WorldImpactVisitor visitor) { |
| 56 staticUses.forEach(visitor.visitStaticUse); | 56 staticUses.forEach(visitor.visitStaticUse); |
| 57 dynamicUses.forEach(visitor.visitDynamicUse); | 57 dynamicUses.forEach(visitor.visitDynamicUse); |
| 58 typeUses.forEach(visitor.visitTypeUse); | 58 typeUses.forEach(visitor.visitTypeUse); |
| 59 } | 59 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 79 if (_constSymbols == null) { | 79 if (_constSymbols == null) { |
| 80 _constSymbols = new Setlet<String>(); | 80 _constSymbols = new Setlet<String>(); |
| 81 } | 81 } |
| 82 _constSymbols.add(name); | 82 _constSymbols.add(name); |
| 83 } | 83 } |
| 84 | 84 |
| 85 Iterable<String> get constSymbols { | 85 Iterable<String> get constSymbols { |
| 86 return _constSymbols != null ? _constSymbols : const <String>[]; | 86 return _constSymbols != null ? _constSymbols : const <String>[]; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void registerSpecializedGetInterceptor(Set<ClassElement> classes) { | 89 void registerSpecializedGetInterceptor(Set<ClassEntity> classes) { |
| 90 if (_specializedGetInterceptors == null) { | 90 if (_specializedGetInterceptors == null) { |
| 91 _specializedGetInterceptors = <Set<ClassElement>>[]; | 91 _specializedGetInterceptors = <Set<ClassEntity>>[]; |
| 92 } | 92 } |
| 93 _specializedGetInterceptors.add(classes); | 93 _specializedGetInterceptors.add(classes); |
| 94 } | 94 } |
| 95 | 95 |
| 96 Iterable<Set<ClassElement>> get specializedGetInterceptors { | 96 Iterable<Set<ClassEntity>> get specializedGetInterceptors { |
| 97 return _specializedGetInterceptors != null | 97 return _specializedGetInterceptors != null |
| 98 ? _specializedGetInterceptors | 98 ? _specializedGetInterceptors |
| 99 : const <Set<ClassElement>>[]; | 99 : const <Set<ClassEntity>>[]; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void registerUseInterceptor() { | 102 void registerUseInterceptor() { |
| 103 _usesInterceptor = true; | 103 _usesInterceptor = true; |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool get usesInterceptor => _usesInterceptor; | 106 bool get usesInterceptor => _usesInterceptor; |
| 107 | 107 |
| 108 void registerAsyncMarker(FunctionElement element) { | 108 void registerAsyncMarker(FunctionElement element) { |
| 109 if (_asyncMarkers == null) { | 109 if (_asyncMarkers == null) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 void registerInstantiatedClosure(LocalFunctionElement element) { | 160 void registerInstantiatedClosure(LocalFunctionElement element) { |
| 161 worldImpact.registerStaticUse(new StaticUse.closure(element)); | 161 worldImpact.registerStaticUse(new StaticUse.closure(element)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void registerConstSymbol(String name) { | 164 void registerConstSymbol(String name) { |
| 165 worldImpact.registerConstSymbol(name); | 165 worldImpact.registerConstSymbol(name); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void registerSpecializedGetInterceptor(Set<ClassElement> classes) { | 168 void registerSpecializedGetInterceptor(Set<ClassEntity> classes) { |
| 169 worldImpact.registerSpecializedGetInterceptor(classes); | 169 worldImpact.registerSpecializedGetInterceptor(classes); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void registerUseInterceptor() { | 172 void registerUseInterceptor() { |
| 173 worldImpact.registerUseInterceptor(); | 173 worldImpact.registerUseInterceptor(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void registerInstantiation(ResolutionInterfaceType type) { | 176 void registerInstantiation(ResolutionInterfaceType type) { |
| 177 registerTypeUse(new TypeUse.instantiation(type)); | 177 registerTypeUse(new TypeUse.instantiation(type)); |
| 178 } | 178 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 204 | 204 |
| 205 MemberElement get element => resolvedAst.element; | 205 MemberElement get element => resolvedAst.element; |
| 206 | 206 |
| 207 WorldImpact run() { | 207 WorldImpact run() { |
| 208 registry = new CodegenRegistry(element); | 208 registry = new CodegenRegistry(element); |
| 209 return backend.codegen(this); | 209 return backend.codegen(this); |
| 210 } | 210 } |
| 211 | 211 |
| 212 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; | 212 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; |
| 213 } | 213 } |
| OLD | NEW |