| Index: pkg/compiler/lib/src/elements/entities.dart
|
| diff --git a/pkg/compiler/lib/src/elements/entities.dart b/pkg/compiler/lib/src/elements/entities.dart
|
| index eedc0f65841a37aa6dcbd78733b3c3603a58d257..c6b4bbbf188c02c38047f9486aee0da00b6cc446 100644
|
| --- a/pkg/compiler/lib/src/elements/entities.dart
|
| +++ b/pkg/compiler/lib/src/elements/entities.dart
|
| @@ -4,6 +4,9 @@
|
|
|
| library entities;
|
|
|
| +import 'package:front_end/src/fasta/parser/async_modifier.dart'
|
| + show AsyncModifier;
|
| +
|
| import '../common.dart';
|
| import '../universe/call_structure.dart' show CallStructure;
|
|
|
| @@ -123,6 +126,61 @@ abstract class FunctionEntity extends MemberEntity {
|
|
|
| /// The structure of the function parameters.
|
| ParameterStructure get parameterStructure;
|
| +
|
| + /// The synchronous/asynchronous marker on this function.
|
| + AsyncMarker get asyncMarker;
|
| +}
|
| +
|
| +/// Enum for the synchronous/asynchronous function body modifiers.
|
| +class AsyncMarker {
|
| + /// The default function body marker.
|
| + static const AsyncMarker SYNC = const AsyncMarker._(AsyncModifier.Sync);
|
| +
|
| + /// The `sync*` function body marker.
|
| + static const AsyncMarker SYNC_STAR =
|
| + const AsyncMarker._(AsyncModifier.SyncStar, isYielding: true);
|
| +
|
| + /// The `async` function body marker.
|
| + static const AsyncMarker ASYNC =
|
| + const AsyncMarker._(AsyncModifier.Async, isAsync: true);
|
| +
|
| + /// The `async*` function body marker.
|
| + static const AsyncMarker ASYNC_STAR = const AsyncMarker._(
|
| + AsyncModifier.AsyncStar,
|
| + isAsync: true,
|
| + isYielding: true);
|
| +
|
| + /// Is `true` if this marker defines the function body to have an
|
| + /// asynchronous result, that is, either a [Future] or a [Stream].
|
| + final bool isAsync;
|
| +
|
| + /// Is `true` if this marker defines the function body to have a plural
|
| + /// result, that is, either an [Iterable] or a [Stream].
|
| + final bool isYielding;
|
| +
|
| + final AsyncModifier asyncParserState;
|
| +
|
| + const AsyncMarker._(this.asyncParserState,
|
| + {this.isAsync: false, this.isYielding: false});
|
| +
|
| + String toString() {
|
| + return '${isAsync ? 'async' : 'sync'}${isYielding ? '*' : ''}';
|
| + }
|
| +
|
| + /// Canonical list of marker values.
|
| + ///
|
| + /// Added to make [AsyncMarker] enum-like.
|
| + static const List<AsyncMarker> values = const <AsyncMarker>[
|
| + SYNC,
|
| + SYNC_STAR,
|
| + ASYNC,
|
| + ASYNC_STAR
|
| + ];
|
| +
|
| + /// Index to this marker within [values].
|
| + ///
|
| + /// Added to make [AsyncMarker] enum-like.
|
| + int get index => values.indexOf(this);
|
| }
|
|
|
| /// Stripped down super interface for constructor like entities.
|
|
|