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

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

Issue 2906333002: Move buildMethodInvocation to BodyBuilder. (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/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
index b9f0dbe9e69c3cdf80cefcfa07e11972b83b6df6..d204b9fd870be049e2848be9a5c52898ebe28611 100644
--- a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart
@@ -5,18 +5,19 @@
library fasta.fasta_accessors;
import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
- show KernelArguments, KernelMethodInvocation;
+ show KernelArguments;
import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken;
import 'package:front_end/src/scanner/token.dart' show Token;
-import 'frontend_accessors.dart' show Accessor, buildIsNull, makeLet;
+import 'frontend_accessors.dart' show Accessor;
import 'package:front_end/src/fasta/type_inference/type_promotion.dart'
show TypePromoter;
-import 'package:kernel/ast.dart';
+import 'package:kernel/ast.dart'
+ hide InvalidExpression, InvalidInitializer, InvalidStatement;
import '../errors.dart' show internalError;
@@ -55,7 +56,7 @@ abstract class BuilderHelper {
Expression toValue(node);
- Member lookupSuperMember(Name name, {bool isSetter: false});
+ Member lookupSuperMember(Name name, {bool isSetter});
scopeLookup(Scope scope, String name, Token token,
{bool isQualified: false, PrefixBuilder prefix});
@@ -80,15 +81,18 @@ abstract class BuilderHelper {
Expression throwNoSuchMethodError(
String name, Arguments arguments, int offset,
- {bool isSuper: false, isGetter: false, isSetter: false});
+ {bool isSuper, bool isGetter, bool isSetter});
bool checkArguments(FunctionNode function, Arguments arguments,
List<TypeParameter> typeParameters);
StaticGet makeStaticGet(Member readTarget, Token token);
- dynamic addCompileTimeError(int charOffset, String message,
- {bool silent: false});
+ dynamic addCompileTimeError(int charOffset, String message, {bool silent});
+
+ Expression buildMethodInvocation(
+ Expression receiver, Name name, Arguments arguments, int offset,
+ {bool isConstantExpression, bool isNullAware});
}
abstract class FastaAccessor implements Accessor {
@@ -130,8 +134,8 @@ abstract class FastaAccessor implements Accessor {
/* Expression | FastaAccessor */ buildPropertyAccess(
IncompleteSend send, bool isNullAware) {
if (send is SendAccessor) {
- return buildMethodInvocation(buildSimpleRead(), send.name, send.arguments,
- offsetForToken(send.token),
+ return helper.buildMethodInvocation(buildSimpleRead(), send.name,
+ send.arguments, offsetForToken(send.token),
isNullAware: isNullAware);
} else {
return PropertyAccessor.make(helper, send.token, buildSimpleRead(),
@@ -285,8 +289,11 @@ class ThisAccessor extends FastaAccessor {
if (send is SendAccessor) {
// Notice that 'this' or 'super' can't be null. So we can ignore the
// value of [isNullAware].
- MethodInvocation result = buildMethodInvocation(new ThisExpression(),
- send.name, send.arguments, offsetForToken(token));
+ MethodInvocation result = helper.buildMethodInvocation(
+ new ThisExpression(),
+ send.name,
+ send.arguments,
+ offsetForToken(token));
return isSuper ? helper.toSuperMethodInvocation(result) : result;
} else {
if (isSuper) {
@@ -305,7 +312,7 @@ class ThisAccessor extends FastaAccessor {
if (isInitializer) {
return buildConstructorInitializer(offset, new Name(""), arguments);
} else {
- return buildMethodInvocation(
+ return helper.buildMethodInvocation(
new ThisExpression(), callName, arguments, offset);
}
}
@@ -445,7 +452,7 @@ class SendAccessor extends IncompleteSend {
Member target = builder.target;
if (target != null) {
if (target is Field) {
- result = buildMethodInvocation(
+ result = helper.buildMethodInvocation(
new StaticGet(target),
callName,
arguments,
@@ -461,7 +468,7 @@ class SendAccessor extends IncompleteSend {
}
}
} else {
- result = buildMethodInvocation(
+ result = helper.buildMethodInvocation(
helper.toValue(receiver), name, arguments, offsetForToken(token),
isNullAware: isNullAware);
}
@@ -591,8 +598,12 @@ class IndexAccessor extends kernel.IndexAccessor with FastaAccessor {
String get plainNameForWrite => "[]=";
Expression doInvocation(int offset, Arguments arguments) {
- return buildMethodInvocation(
- buildSimpleRead(), callName, arguments, offset);
+ return helper.buildMethodInvocation(
+ buildSimpleRead(),
+ callName,
+ arguments,
+ offset,
+ );
}
toString() => "IndexAccessor()";
@@ -625,7 +636,7 @@ class PropertyAccessor extends kernel.PropertyAccessor with FastaAccessor {
bool get isThisPropertyAccessor => receiver is ThisExpression;
Expression doInvocation(int offset, Arguments arguments) {
- return buildMethodInvocation(receiver, name, arguments, offset);
+ return helper.buildMethodInvocation(receiver, name, arguments, offset);
}
toString() => "PropertyAccessor()";
@@ -682,8 +693,8 @@ class StaticAccessor extends kernel.StaticAccessor with FastaAccessor {
Expression doInvocation(int offset, Arguments arguments) {
if (readTarget == null || isFieldOrGetter(readTarget)) {
- return buildMethodInvocation(buildSimpleRead(), callName, arguments,
- offset + (readTarget?.name?.name?.length ?? 0));
+ return helper.buildMethodInvocation(buildSimpleRead(), callName,
+ arguments, offset + (readTarget?.name?.name?.length ?? 0));
} else {
return helper.buildStaticInvocation(readTarget, arguments)
..fileOffset = offset;
@@ -703,7 +714,7 @@ class SuperPropertyAccessor extends kernel.SuperPropertyAccessor
Expression doInvocation(int offset, Arguments arguments) {
if (getter == null || isFieldOrGetter(getter)) {
- return buildMethodInvocation(
+ return helper.buildMethodInvocation(
buildSimpleRead(), callName, arguments, offset);
} else {
return new DirectMethodInvocation(new ThisExpression(), getter, arguments)
@@ -724,7 +735,7 @@ class ThisIndexAccessor extends kernel.ThisIndexAccessor with FastaAccessor {
String get plainNameForWrite => "[]=";
Expression doInvocation(int offset, Arguments arguments) {
- return buildMethodInvocation(
+ return helper.buildMethodInvocation(
buildSimpleRead(), callName, arguments, offset);
}
@@ -741,7 +752,7 @@ class SuperIndexAccessor extends kernel.SuperIndexAccessor with FastaAccessor {
String get plainNameForWrite => "[]=";
Expression doInvocation(int offset, Arguments arguments) {
- return buildMethodInvocation(
+ return helper.buildMethodInvocation(
buildSimpleRead(), callName, arguments, offset);
}
@@ -767,7 +778,8 @@ class ThisPropertyAccessor extends kernel.ThisPropertyAccessor
// `this.name.call(arguments)`.
interfaceTarget = null;
}
- return buildMethodInvocation(new ThisExpression(), name, arguments, offset);
+ return helper.buildMethodInvocation(
+ new ThisExpression(), name, arguments, offset);
}
toString() => "ThisPropertyAccessor()";
@@ -801,7 +813,7 @@ class VariableAccessor extends kernel.VariableAccessor with FastaAccessor {
Expression doInvocation(int offset, Arguments arguments) {
// Normally the offset is at the start of the token, but in this case,
// because we insert a '.call', we want it at the end instead.
- return buildMethodInvocation(buildSimpleRead(), callName, arguments,
+ return helper.buildMethodInvocation(buildSimpleRead(), callName, arguments,
offset + (variable.name?.length ?? 0));
}
@@ -816,7 +828,7 @@ class ReadOnlyAccessor extends kernel.ReadOnlyAccessor with FastaAccessor {
: super(helper, expression, token);
Expression doInvocation(int offset, Arguments arguments) {
- return buildMethodInvocation(
+ return helper.buildMethodInvocation(
buildSimpleRead(), callName, arguments, offset);
}
}
@@ -860,23 +872,3 @@ class UnresolvedAccessor extends FastaAccessor with ErrorAccessor {
bool isFieldOrGetter(Member member) {
return member is Field || (member is Procedure && member.isGetter);
}
-
-Expression buildMethodInvocation(
- Expression receiver, Name name, Arguments arguments, int offset,
- {bool isNullAware: false}) {
- if (isNullAware) {
- VariableDeclaration variable = new VariableDeclaration.forValue(receiver);
- return makeLet(
- variable,
- new ConditionalExpression(
- buildIsNull(new VariableGet(variable)),
- new NullLiteral(),
- new KernelMethodInvocation(
- new VariableGet(variable), name, arguments)
- ..fileOffset = offset,
- const DynamicType()));
- } else {
- return new KernelMethodInvocation(receiver, name, arguments)
- ..fileOffset = offset;
- }
-}
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698