| 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.backend_api; | 5 library dart2js.backend_api; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/codegen.dart' show |
| 11 CodegenImpact; |
| 12 import '../common/resolution.dart' show |
| 13 ResolutionImpact; |
| 10 import '../compiler.dart' show | 14 import '../compiler.dart' show |
| 11 Compiler; | 15 Compiler; |
| 12 import '../compile_time_constants.dart' show | 16 import '../compile_time_constants.dart' show |
| 13 BackendConstantEnvironment, | 17 BackendConstantEnvironment, |
| 14 ConstantCompilerTask; | 18 ConstantCompilerTask; |
| 15 import '../constants/expressions.dart' show | 19 import '../constants/expressions.dart' show |
| 16 ConstantExpression; | 20 ConstantExpression; |
| 17 import '../constants/constant_system.dart' show | 21 import '../constants/constant_system.dart' show |
| 18 ConstantSystem; | 22 ConstantSystem; |
| 19 import '../constants/values.dart' show | 23 import '../constants/values.dart' show |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 Send; | 57 Send; |
| 54 import '../universe/call_structure.dart' show | 58 import '../universe/call_structure.dart' show |
| 55 CallStructure; | 59 CallStructure; |
| 56 import '../universe/world_impact.dart' show | 60 import '../universe/world_impact.dart' show |
| 57 WorldImpact; | 61 WorldImpact; |
| 58 | 62 |
| 59 import 'codegen.dart' show | 63 import 'codegen.dart' show |
| 60 CodegenWorkItem; | 64 CodegenWorkItem; |
| 61 import 'registry.dart' show | 65 import 'registry.dart' show |
| 62 Registry; | 66 Registry; |
| 63 import 'resolution.dart' show | |
| 64 ResolutionCallbacks; | |
| 65 import 'tasks.dart' show | 67 import 'tasks.dart' show |
| 66 CompilerTask; | 68 CompilerTask; |
| 67 import 'work.dart' show | 69 import 'work.dart' show |
| 68 ItemCompilationContext; | 70 ItemCompilationContext; |
| 69 | 71 |
| 70 | 72 |
| 71 abstract class Backend { | 73 abstract class Backend { |
| 72 final Compiler compiler; | 74 final Compiler compiler; |
| 73 | 75 |
| 74 Backend(this.compiler); | 76 Backend(this.compiler); |
| 75 | 77 |
| 76 /// Returns true if the backend supports reflection. | 78 /// Returns true if the backend supports reflection. |
| 77 bool get supportsReflection; | 79 bool get supportsReflection; |
| 78 | 80 |
| 79 /// The [ConstantSystem] used to interpret compile-time constants for this | 81 /// The [ConstantSystem] used to interpret compile-time constants for this |
| 80 /// backend. | 82 /// backend. |
| 81 ConstantSystem get constantSystem; | 83 ConstantSystem get constantSystem; |
| 82 | 84 |
| 83 /// The constant environment for the backend interpretation of compile-time | 85 /// The constant environment for the backend interpretation of compile-time |
| 84 /// constants. | 86 /// constants. |
| 85 BackendConstantEnvironment get constants; | 87 BackendConstantEnvironment get constants; |
| 86 | 88 |
| 87 /// The compiler task responsible for the compilation of constants for both | 89 /// The compiler task responsible for the compilation of constants for both |
| 88 /// the frontend and the backend. | 90 /// the frontend and the backend. |
| 89 ConstantCompilerTask get constantCompilerTask; | 91 ConstantCompilerTask get constantCompilerTask; |
| 90 | 92 |
| 91 /// Backend callback methods for the resolution phase. | 93 /// Backend transformation methods for the world impacts. |
| 92 ResolutionCallbacks get resolutionCallbacks; | 94 ImpactTransformer get impactTransformer; |
| 93 | 95 |
| 94 /// The strategy used for collecting and emitting source information. | 96 /// The strategy used for collecting and emitting source information. |
| 95 SourceInformationStrategy get sourceInformationStrategy { | 97 SourceInformationStrategy get sourceInformationStrategy { |
| 96 return const SourceInformationStrategy(); | 98 return const SourceInformationStrategy(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 // TODO(johnniwinther): Move this to the JavaScriptBackend. | 101 // TODO(johnniwinther): Move this to the JavaScriptBackend. |
| 100 String get patchVersion => null; | 102 String get patchVersion => null; |
| 101 | 103 |
| 102 /// Set of classes that need to be considered for reflection although not | 104 /// Set of classes that need to be considered for reflection although not |
| 103 /// otherwise visible during resolution. | 105 /// otherwise visible during resolution. |
| 104 Iterable<ClassElement> classesRequiredForReflection = const []; | 106 Iterable<ClassElement> classesRequiredForReflection = const []; |
| 105 | 107 |
| 106 // Given a [FunctionElement], return a buffer with the code generated for it | 108 // Given a [FunctionElement], return a buffer with the code generated for it |
| 107 // or null if no code was generated. | 109 // or null if no code was generated. |
| 108 CodeBuffer codeOf(Element element) => null; | 110 CodeBuffer codeOf(Element element) => null; |
| 109 | 111 |
| 110 void initializeHelperClasses() {} | 112 void initializeHelperClasses() {} |
| 111 | 113 |
| 112 void enqueueHelpers(ResolutionEnqueuer world, Registry registry); | 114 void enqueueHelpers(ResolutionEnqueuer world, Registry registry); |
| 115 |
| 113 WorldImpact codegen(CodegenWorkItem work); | 116 WorldImpact codegen(CodegenWorkItem work); |
| 114 | 117 |
| 115 // The backend determines the native resolution enqueuer, with a no-op | 118 // The backend determines the native resolution enqueuer, with a no-op |
| 116 // default, so tools like dart2dart can ignore the native classes. | 119 // default, so tools like dart2dart can ignore the native classes. |
| 117 native.NativeEnqueuer nativeResolutionEnqueuer(world) { | 120 native.NativeEnqueuer nativeResolutionEnqueuer(world) { |
| 118 return new native.NativeEnqueuer(); | 121 return new native.NativeEnqueuer(); |
| 119 } | 122 } |
| 120 native.NativeEnqueuer nativeCodegenEnqueuer(world) { | 123 native.NativeEnqueuer nativeCodegenEnqueuer(world) { |
| 121 return new native.NativeEnqueuer(); | 124 return new native.NativeEnqueuer(); |
| 122 } | 125 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 /// Returns the constant expression of [node], or `null` if [node] is not | 420 /// Returns the constant expression of [node], or `null` if [node] is not |
| 418 /// a constant expression. | 421 /// a constant expression. |
| 419 ConstantExpression getConstant(Node node); | 422 ConstantExpression getConstant(Node node); |
| 420 | 423 |
| 421 /// Registers [type] as instantiated. | 424 /// Registers [type] as instantiated. |
| 422 void registerInstantiatedType(InterfaceType type); | 425 void registerInstantiatedType(InterfaceType type); |
| 423 | 426 |
| 424 /// Resolves [typeName] to a type in the context of [node]. | 427 /// Resolves [typeName] to a type in the context of [node]. |
| 425 DartType resolveTypeFromString(Node node, String typeName); | 428 DartType resolveTypeFromString(Node node, String typeName); |
| 426 } | 429 } |
| 430 |
| 431 /// Backend transformation methods for the world impacts. |
| 432 class ImpactTransformer { |
| 433 /// Transform the [ResolutionImpact] into a [WorldImpact] adding the |
| 434 /// backend dependencies for features used in [worldImpact]. |
| 435 WorldImpact transformResolutionImpact(ResolutionImpact worldImpact) { |
| 436 return worldImpact; |
| 437 } |
| 438 |
| 439 /// Transform the [CodegenImpact] into a [WorldImpact] adding the |
| 440 /// backend dependencies for features used in [worldImpact]. |
| 441 WorldImpact transformCodegenImpact(CodegenImpact worldImpact) { |
| 442 return worldImpact; |
| 443 } |
| 444 } |
| OLD | NEW |