From 0c839cf3f857dc801584ab3af8bd1032acc26e80 Mon Sep 17 00:00:00 2001 From: Dmitry Stefantsov Date: Thu, 3 May 2018 11:21:23 +0000 Subject: [PATCH] [fasta] Add 'as' expressions to the Forest API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id023f24c9e115e15ed81b93625e39230649b7822 Reviewed-on: https://dart-review.googlesource.com/53600 Reviewed-by: Peter von der Ahé Commit-Queue: Dmitry Stefantsov --- pkg/front_end/lib/src/fasta/kernel/body_builder.dart | 3 +-- pkg/front_end/lib/src/fasta/kernel/fangorn.dart | 7 +++++++ pkg/front_end/lib/src/fasta/kernel/forest.dart | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index 01706664d84..c477cfd022c 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -2008,8 +2008,7 @@ class BodyBuilder extends ScopeListener push(deprecated_buildCompileTimeError( "Not a constant expression.", operator.charOffset)); } else { - push(new ShadowAsExpression(expression, type) - ..fileOffset = offsetForToken(operator)); + push(forest.asExpression(expression, type, operator)); } } diff --git a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart index 566ee452756..8a34d1d9254 100644 --- a/pkg/front_end/lib/src/fasta/kernel/fangorn.dart +++ b/pkg/front_end/lib/src/fasta/kernel/fangorn.dart @@ -28,6 +28,7 @@ import '../scanner.dart' show Token; import 'kernel_shadow_ast.dart' show ShadowArguments, + ShadowAsExpression, ShadowBoolLiteral, ShadowCheckLibraryIsLoaded, ShadowDoubleLiteral, @@ -154,6 +155,12 @@ class Fangorn extends Forest { return new ShadowCheckLibraryIsLoaded(dependency); } + @override + Expression asExpression(Expression expression, covariant type, Token token) { + return new ShadowAsExpression(expression, type) + ..fileOffset = offsetForToken(token); + } + @override bool isErroneousNode(TreeNode node) { if (node is ExpressionStatement) { diff --git a/pkg/front_end/lib/src/fasta/kernel/forest.dart b/pkg/front_end/lib/src/fasta/kernel/forest.dart index c9a526ccb70..8b7327fce42 100644 --- a/pkg/front_end/lib/src/fasta/kernel/forest.dart +++ b/pkg/front_end/lib/src/fasta/kernel/forest.dart @@ -54,6 +54,9 @@ abstract class Forest { Expression checkLibraryIsLoaded(covariant dependency); + Expression asExpression( + Expression expression, covariant type, Location location); + bool isErroneousNode(covariant node); // TODO(ahe): Remove this method when all users are moved here.