Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: pkg/compiler/lib/src/elements/entities.dart

Issue 2897273002: Add FunctionEntity.asyncMarker and refactor SourceInformationStrategy to avoid ResolvedAst (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/io/multi_information.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/io/multi_information.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698