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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2861523003: Add KernelXyzExpression stubs and factory methods. (Closed)
Patch Set: Created 3 years, 8 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
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
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 bce8224077f569f37547c9fc951c795466bcfec5..95703f0ab458c9f900ecd4328e224c95ca5473ca 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -664,8 +664,9 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
var receiver = pop();
bool isSuper = false;
if (receiver is ThisAccessor && receiver.isSuper) {
+ ThisAccessor thisAccessorReceiver = receiver;
isSuper = true;
- receiver = new ThisExpression();
+ receiver = astFactory.thisExpression(thisAccessorReceiver.token);
}
push(buildBinaryOperator(toValue(receiver), token, argument, isSuper));
}
@@ -687,14 +688,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
if (isSuper) {
result = toSuperMethodInvocation(result);
}
- return negate ? new Not(result) : result;
+ return negate ? astFactory.not(null, result) : result;
}
}
void doLogicalExpression(Token token) {
Expression argument = popForValue();
Expression receiver = popForValue();
- push(new LogicalExpression(receiver, token.stringValue, argument));
+ push(astFactory.logicalExpression(receiver, token.stringValue, argument));
}
/// Handle `a ?? b`.
@@ -729,9 +730,10 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
if (!target.isAccessor) {
if (areArgumentsCompatible(target.function, node.arguments)) {
// TODO(ahe): Use [DirectMethodInvocation] when possible.
- Expression result = new DirectMethodInvocation(
+ Expression result = astFactory.directMethodInvocation(
new ThisExpression(), target, node.arguments);
- result = new SuperMethodInvocation(node.name, node.arguments, null);
+ result = astFactory.superMethodInvocation(
+ null, node.name, node.arguments, null);
return result;
} else {
isNoSuchMethod = true;
@@ -744,8 +746,9 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
isSuper: true);
}
// TODO(ahe): Use [DirectPropertyGet] when possible.
- Expression receiver = new DirectPropertyGet(new ThisExpression(), target);
- receiver = new SuperPropertyGet(node.name, target);
+ Expression receiver =
+ astFactory.directPropertyGet(new ThisExpression(), target);
+ receiver = astFactory.superPropertyGet(node.name, target);
return buildMethodInvocation(
receiver, callName, node.arguments, node.fileOffset);
}
@@ -1177,8 +1180,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
Expression value = popForValue();
var accessor = pop();
if (accessor is TypeDeclarationBuilder) {
- push(wrapInvalid(new TypeLiteral(
- accessor.buildTypesWithBuiltArguments(library, null))));
+ push(wrapInvalid(astFactory
+ .typeLiteral(accessor.buildTypesWithBuiltArguments(library, null))));
} else if (accessor is! FastaAccessor) {
push(buildCompileTimeError("Can't assign to this.", token.charOffset));
} else {
@@ -1259,10 +1262,9 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
@override
- void endAwaitExpression(Token beginToken, Token endToken) {
+ void endAwaitExpression(Token keyword, Token endToken) {
debugEvent("AwaitExpression");
- push(
- new AwaitExpression(popForValue())..fileOffset = beginToken.charOffset);
+ push(astFactory.awaitExpression(keyword, popForValue()));
}
@override
@@ -1330,9 +1332,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
valueType = typeArguments[1];
}
}
- push(new MapLiteral(entries,
- keyType: keyType, valueType: valueType, isConst: constKeyword != null)
- ..fileOffset = constKeyword?.charOffset ?? beginToken.charOffset);
+ push(astFactory.mapLiteral(beginToken, constKeyword, entries,
+ keyType: keyType, valueType: valueType));
}
@override
@@ -1366,7 +1367,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
value += ".${symbolPartToString(parts[i])}";
}
}
- push(new SymbolLiteral(value));
+ push(astFactory.symbolLiteral(hashToken, value));
}
DartType kernelTypeFromString(
@@ -1478,7 +1479,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
debugEvent("AsOperator");
DartType type = pop();
Expression expression = popForValue();
- push(new AsExpression(expression, type)..fileOffset = operator.charOffset);
+ push(astFactory.asExpression(expression, operator, type));
}
@override
@@ -1514,7 +1515,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
push(buildCompileTimeError(
"Not a constant expression.", throwToken.charOffset));
} else {
- push(new Throw(expression)..fileOffset = throwToken.charOffset);
+ push(astFactory.throwExpression(throwToken, expression));
}
}
@@ -1733,7 +1734,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
debugEvent("UnaryPrefixExpression");
var receiver = pop();
if (optional("!", token)) {
- push(new Not(toValue(receiver)));
+ push(astFactory.not(token, toValue(receiver)));
} else {
String operator = token.stringValue;
if (optional("-", token)) {
@@ -1741,7 +1742,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
if (receiver is ThisAccessor && receiver.isSuper) {
push(toSuperMethodInvocation(buildMethodInvocation(
- new ThisExpression()..fileOffset = offsetForToken(receiver.token),
+ astFactory.thisExpression(receiver.token),
new Name(operator),
new Arguments.empty(),
token.charOffset)));
@@ -1849,12 +1850,11 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
return throwNoSuchMethodError(target.name.name, arguments, charOffset);
}
if (target is Constructor) {
- return new ConstructorInvocation(target, arguments)
- ..isConst = isConst
+ return astFactory.constructorInvocation(target, arguments,
+ isConst: isConst)
..fileOffset = charOffset;
} else {
- return new StaticInvocation(target, arguments)
- ..isConst = isConst
+ return astFactory.staticInvocation(target, arguments, isConst: isConst)
..fileOffset = charOffset;
}
}
@@ -2242,15 +2242,15 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
@override
- void endRethrowStatement(Token throwToken, Token endToken) {
+ void endRethrowStatement(Token rethrowToken, Token endToken) {
debugEvent("RethrowStatement");
if (inCatchBlock) {
- push(astFactory.expressionStatement(
- new Rethrow()..fileOffset = throwToken.charOffset));
+ push(astFactory
+ .expressionStatement(astFactory.rethrowExpression(rethrowToken)));
} else {
push(buildCompileTimeErrorStatement(
"'rethrow' can only be used in catch clauses.",
- throwToken.charOffset));
+ rethrowToken.charOffset));
}
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/builder/ast_factory.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698