[fasta] Add 'as' expressions to the Forest API

Change-Id: Id023f24c9e115e15ed81b93625e39230649b7822
Reviewed-on: https://dart-review.googlesource.com/53600
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
This commit is contained in:
Dmitry Stefantsov 2018-05-03 11:21:23 +00:00 committed by commit-bot@chromium.org
parent 16f6ce2fee
commit 0c839cf3f8
3 changed files with 11 additions and 2 deletions

View file

@ -2008,8 +2008,7 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
push(deprecated_buildCompileTimeError(
"Not a constant expression.", operator.charOffset));
} else {
push(new ShadowAsExpression(expression, type)
..fileOffset = offsetForToken(operator));
push(forest.asExpression(expression, type, operator));
}
}

View file

@ -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<Expression, Statement, Token, Arguments> {
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) {

View file

@ -54,6 +54,9 @@ abstract class Forest<Expression, Statement, Location, Arguments> {
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.