Skip to content

Commit b597207

Browse files
chloestefantsovaCommit Bot
authored and
Commit Bot
committed
[cfe] Add WildcardBinder and ListBinder internal AST nodes
Part of #49749 Change-Id: Ic47effd09ebb38568a9c7847e658d22f03b2d873 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258806 Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 14da46c commit b597207

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

pkg/front_end/lib/src/fasta/kernel/internal_ast.dart

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4966,7 +4966,8 @@ class InternalRecordLiteral extends InternalExpression {
49664966

49674967
@override
49684968
void transformChildren(Transformer v) {
4969-
unsupported("${transformChildren}.accept on ${v.runtimeType}", -1, null);
4969+
unsupported(
4970+
"${runtimeType}.transformChildren on ${v.runtimeType}", -1, null);
49704971
}
49714972

49724973
@override
@@ -5006,3 +5007,115 @@ class InternalRecordLiteral extends InternalExpression {
50065007
printer.write(')');
50075008
}
50085009
}
5010+
5011+
abstract class Binder extends TreeNode {}
5012+
5013+
class ListBinder extends Binder {
5014+
final DartType typeBinderArgument;
5015+
final List<Binder> binders;
5016+
5017+
ListBinder(this.typeBinderArgument, this.binders);
5018+
5019+
@override
5020+
R accept<R>(TreeVisitor<R> visitor) {
5021+
if (visitor is Printer || visitor is Precedence || visitor is Transformer) {
5022+
// Allow visitors needed for toString and replaceWith.
5023+
return visitor.defaultTreeNode(this);
5024+
}
5025+
return unsupported(
5026+
"${runtimeType}.accept on ${visitor.runtimeType}", -1, null);
5027+
}
5028+
5029+
@override
5030+
R accept1<R, A>(TreeVisitor1<R, A> visitor, A arg) {
5031+
return unsupported(
5032+
"${runtimeType}.accept1 on ${visitor.runtimeType}", -1, null);
5033+
}
5034+
5035+
@override
5036+
void toTextInternal(AstPrinter printer) {
5037+
printer.write('[');
5038+
String comma = '';
5039+
for (Binder binder in binders) {
5040+
printer.write(comma);
5041+
binder.toTextInternal(printer);
5042+
comma = ', ';
5043+
}
5044+
printer.write(']');
5045+
}
5046+
5047+
@override
5048+
void transformChildren(Transformer v) {
5049+
unsupported(
5050+
"${runtimeType}.transformChildren on ${v.runtimeType}", -1, null);
5051+
}
5052+
5053+
@override
5054+
void transformOrRemoveChildren(RemovingTransformer v) {
5055+
unsupported("${runtimeType}.transformOrRemoveChildren on ${v.runtimeType}",
5056+
-1, null);
5057+
}
5058+
5059+
@override
5060+
void visitChildren(Visitor v) {
5061+
unsupported("${runtimeType}.visitChildren on ${v.runtimeType}", -1, null);
5062+
}
5063+
5064+
@override
5065+
String toString() {
5066+
return "ListBinder(${toStringInternal()})";
5067+
}
5068+
}
5069+
5070+
class WildcardBinder extends Binder {
5071+
final DartType? type;
5072+
5073+
WildcardBinder(this.type);
5074+
5075+
@override
5076+
R accept<R>(TreeVisitor<R> visitor) {
5077+
if (visitor is Printer || visitor is Precedence || visitor is Transformer) {
5078+
// Allow visitors needed for toString and replaceWith.
5079+
return visitor.defaultTreeNode(this);
5080+
}
5081+
return unsupported(
5082+
"${runtimeType}.accept on ${visitor.runtimeType}", -1, null);
5083+
}
5084+
5085+
@override
5086+
R accept1<R, A>(TreeVisitor1<R, A> visitor, A arg) {
5087+
return unsupported(
5088+
"${runtimeType}.accept1 on ${visitor.runtimeType}", -1, null);
5089+
}
5090+
5091+
@override
5092+
void toTextInternal(AstPrinter printer) {
5093+
if (type != null) {
5094+
type!.toTextInternal(printer);
5095+
printer.write(" ");
5096+
}
5097+
printer.write("_");
5098+
}
5099+
5100+
@override
5101+
void transformChildren(Transformer v) {
5102+
unsupported(
5103+
"${runtimeType}.transformChildren on ${v.runtimeType}", -1, null);
5104+
}
5105+
5106+
@override
5107+
void transformOrRemoveChildren(RemovingTransformer v) {
5108+
unsupported("${runtimeType}.transformOrRemoveChildren on ${v.runtimeType}",
5109+
-1, null);
5110+
}
5111+
5112+
@override
5113+
void visitChildren(Visitor v) {
5114+
unsupported("${runtimeType}.visitChildren on ${v.runtimeType}", -1, null);
5115+
}
5116+
5117+
@override
5118+
String toString() {
5119+
return "WildcardBinder(${toStringInternal()})";
5120+
}
5121+
}

0 commit comments

Comments
 (0)