| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart'; | 8 import '../common/names.dart'; |
| 9 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| 11 import '../constants/values.dart'; | 11 import '../constants/values.dart'; |
| 12 import '../common_elements.dart'; | 12 import '../common_elements.dart'; |
| 13 import '../elements/elements.dart'; | 13 import '../elements/elements.dart'; |
| 14 import '../elements/entities.dart'; | 14 import '../elements/entities.dart'; |
| 15 import '../elements/operators.dart'; | 15 import '../elements/operators.dart'; |
| 16 import '../elements/types.dart'; | 16 import '../elements/types.dart'; |
| 17 import '../js_backend/backend.dart' show JavaScriptBackend; | 17 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 18 import '../native/native.dart' as native; | 18 import '../native/native.dart' as native; |
| 19 import '../universe/call_structure.dart'; | 19 import '../universe/call_structure.dart'; |
| 20 import '../universe/selector.dart'; | 20 import '../universe/selector.dart'; |
| 21 import 'kernel_debug.dart'; | 21 import 'kernel_debug.dart'; |
| 22 | 22 |
| 23 /// Interface that translates between Kernel IR nodes and entities. | 23 /// Interface that translates between Kernel IR nodes and entities. |
| 24 abstract class KernelElementAdapter { | 24 abstract class IrToElementMap { |
| 25 /// Access to the commonly used elements and types. | 25 /// Access to the commonly used elements and types. |
| 26 CommonElements get commonElements; | 26 CommonElements get commonElements; |
| 27 | 27 |
| 28 /// [ElementEnvironment] for library, class and member lookup. | 28 /// [ElementEnvironment] for library, class and member lookup. |
| 29 ElementEnvironment get elementEnvironment; | 29 ElementEnvironment get elementEnvironment; |
| 30 | 30 |
| 31 /// Returns the [DartType] corresponding to [type]. | 31 /// Returns the [DartType] corresponding to [type]. |
| 32 DartType getDartType(ir.DartType type); | 32 DartType getDartType(ir.DartType type); |
| 33 | 33 |
| 34 /// Returns the list of [DartType]s corresponding to [types]. | 34 /// Returns the list of [DartType]s corresponding to [types]. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 /// Kinds of foreign functions. | 117 /// Kinds of foreign functions. |
| 118 enum ForeignKind { | 118 enum ForeignKind { |
| 119 JS, | 119 JS, |
| 120 JS_BUILTIN, | 120 JS_BUILTIN, |
| 121 JS_EMBEDDED_GLOBAL, | 121 JS_EMBEDDED_GLOBAL, |
| 122 JS_INTERCEPTOR_CONSTANT, | 122 JS_INTERCEPTOR_CONSTANT, |
| 123 NONE, | 123 NONE, |
| 124 } | 124 } |
| 125 | 125 |
| 126 abstract class KernelElementAdapterMixin implements KernelElementAdapter { | 126 abstract class IrToElementMapMixin implements IrToElementMap { |
| 127 DiagnosticReporter get reporter; | 127 DiagnosticReporter get reporter; |
| 128 FunctionType getFunctionType(ir.FunctionNode node); | 128 FunctionType getFunctionType(ir.FunctionNode node); |
| 129 native.BehaviorBuilder get nativeBehaviorBuilder; | 129 native.BehaviorBuilder get nativeBehaviorBuilder; |
| 130 ConstantValue computeConstantValue(ConstantExpression constant); | 130 ConstantValue computeConstantValue(ConstantExpression constant); |
| 131 | 131 |
| 132 @override | 132 @override |
| 133 Name getName(ir.Name name) { | 133 Name getName(ir.Name name) { |
| 134 return new Name( | 134 return new Name( |
| 135 name.name, name.isPrivate ? getLibrary(name.library) : null); | 135 name.name, name.isPrivate ? getLibrary(name.library) : null); |
| 136 } | 136 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 sb.write(value); | 459 sb.write(value); |
| 460 } | 460 } |
| 461 return sb.toString(); | 461 return sb.toString(); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 /// Visitor that converts a kernel constant expression into a | 465 /// Visitor that converts a kernel constant expression into a |
| 466 /// [ConstantExpression]. | 466 /// [ConstantExpression]. |
| 467 class Constantifier extends ir.ExpressionVisitor<ConstantExpression> { | 467 class Constantifier extends ir.ExpressionVisitor<ConstantExpression> { |
| 468 final bool requireConstant; | 468 final bool requireConstant; |
| 469 final KernelElementAdapterMixin elementAdapter; | 469 final IrToElementMapMixin elementAdapter; |
| 470 | 470 |
| 471 Constantifier(this.elementAdapter, {this.requireConstant: true}); | 471 Constantifier(this.elementAdapter, {this.requireConstant: true}); |
| 472 | 472 |
| 473 CommonElements get _commonElements => elementAdapter.commonElements; | 473 CommonElements get _commonElements => elementAdapter.commonElements; |
| 474 | 474 |
| 475 ConstantExpression visit(ir.Expression node) { | 475 ConstantExpression visit(ir.Expression node) { |
| 476 ConstantExpression constant = node.accept(this); | 476 ConstantExpression constant = node.accept(this); |
| 477 if (constant == null && requireConstant) { | 477 if (constant == null && requireConstant) { |
| 478 throw new UnsupportedError( | 478 throw new UnsupportedError( |
| 479 "No constant computed for $node (${node.runtimeType})"); | 479 "No constant computed for $node (${node.runtimeType})"); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 } | 779 } |
| 780 if (isRedirecting) { | 780 if (isRedirecting) { |
| 781 return new RedirectingGenerativeConstantConstructor( | 781 return new RedirectingGenerativeConstantConstructor( |
| 782 defaultValues, superConstructorInvocation); | 782 defaultValues, superConstructorInvocation); |
| 783 } else { | 783 } else { |
| 784 return new GenerativeConstantConstructor( | 784 return new GenerativeConstantConstructor( |
| 785 type, defaultValues, fieldMap, superConstructorInvocation); | 785 type, defaultValues, fieldMap, superConstructorInvocation); |
| 786 } | 786 } |
| 787 } | 787 } |
| 788 } | 788 } |
| OLD | NEW |