Skip to content

Commit

Permalink
Version 2.19.0-215.0.dev
Browse files Browse the repository at this point in the history
Merge e8b67cc into dev
  • Loading branch information
Dart CI committed Sep 19, 2022
2 parents 1b6e5e8 + e8b67cc commit c18e6d4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 70 deletions.
130 changes: 61 additions & 69 deletions pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1522,16 +1522,16 @@ class AstBuilder extends StackListener {
}

@override
void endFieldInitializer(Token assignment, Token token) {
assert(optional('=', assignment));
void endFieldInitializer(Token equals, Token token) {
assert(optional('=', equals));
debugEvent("FieldInitializer");

var initializer = pop() as ExpressionImpl;
var name = pop() as SimpleIdentifierImpl;
push(
_makeVariableDeclaration(
name: name,
equals: assignment,
VariableDeclarationImpl(
name2: name.token,
equals: equals,
initializer: initializer,
),
);
Expand All @@ -1540,12 +1540,21 @@ class AstBuilder extends StackListener {
@override
void endForControlFlow(Token token) {
debugEvent("endForControlFlow");
var entry = pop() as Object;
var body = pop() as CollectionElementImpl;
var forLoopParts = pop() as ForPartsImpl;
var leftParen = pop() as Token;
var leftParenthesis = pop() as Token;
var forToken = pop() as Token;

pushForControlFlowInfo(null, forToken, leftParen, forLoopParts, entry);
push(
ForElementImpl(
awaitKeyword: null,
forKeyword: forToken,
leftParenthesis: leftParenthesis,
forLoopParts: forLoopParts,
rightParenthesis: leftParenthesis.endGroup!,
body: body,
),
);
}

@override
Expand Down Expand Up @@ -1579,14 +1588,22 @@ class AstBuilder extends StackListener {
void endForInControlFlow(Token token) {
debugEvent("endForInControlFlow");

var entry = pop() as Object;
var body = pop() as CollectionElementImpl;
var forLoopParts = pop() as ForEachPartsImpl;
var leftParenthesis = pop() as Token;
var forToken = pop() as Token;
var awaitToken = pop(NullValue.AwaitToken) as Token?;

pushForControlFlowInfo(
awaitToken, forToken, leftParenthesis, forLoopParts, entry);
push(
ForElementImpl(
awaitKeyword: awaitToken,
forKeyword: forToken,
leftParenthesis: leftParenthesis,
forLoopParts: forLoopParts,
rightParenthesis: leftParenthesis.endGroup!,
body: body,
),
);
}

@override
Expand Down Expand Up @@ -1892,7 +1909,18 @@ class AstBuilder extends StackListener {
var thenElement = pop() as CollectionElementImpl;
var condition = pop() as _ParenthesizedCondition;
var ifToken = pop() as Token;
pushIfControlFlowInfo(ifToken, condition, thenElement, null, null);
push(
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
condition: condition.expression,
caseClause: null,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
elseKeyword: null,
elseElement: null,
),
);
}

@override
Expand All @@ -1902,8 +1930,18 @@ class AstBuilder extends StackListener {
var thenElement = pop() as CollectionElementImpl;
var condition = pop() as _ParenthesizedCondition;
var ifToken = pop() as Token;
pushIfControlFlowInfo(
ifToken, condition, thenElement, elseToken, elseElement);
push(
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
condition: condition.expression,
caseClause: null,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
elseKeyword: elseToken,
elseElement: elseElement,
),
);
}

@override
Expand Down Expand Up @@ -2003,8 +2041,8 @@ class AstBuilder extends StackListener {
if (node is VariableDeclaration) {
variable = node;
} else if (node is SimpleIdentifierImpl) {
variable = _makeVariableDeclaration(
name: node,
variable = VariableDeclarationImpl(
name2: node.token,
equals: null,
initializer: null,
);
Expand Down Expand Up @@ -2956,17 +2994,17 @@ class AstBuilder extends StackListener {
}

@override
void endVariableInitializer(Token assignmentOperator) {
assert(optionalOrNull('=', assignmentOperator));
void endVariableInitializer(Token equals) {
assert(optionalOrNull('=', equals));
debugEvent("VariableInitializer");

var initializer = pop() as ExpressionImpl;
var identifier = pop() as SimpleIdentifierImpl;
// TODO(ahe): Don't push initializers, instead install them.
push(
_makeVariableDeclaration(
name: identifier,
equals: assignmentOperator,
VariableDeclarationImpl(
name2: identifier.token,
equals: equals,
initializer: initializer,
),
);
Expand Down Expand Up @@ -4131,8 +4169,8 @@ class AstBuilder extends StackListener {

var name = pop() as SimpleIdentifierImpl;
push(
_makeVariableDeclaration(
name: name,
VariableDeclarationImpl(
name2: name.token,
equals: null,
initializer: null,
),
Expand Down Expand Up @@ -4653,40 +4691,6 @@ class AstBuilder extends StackListener {
return types.whereType<NamedType>().toList();
}

void pushForControlFlowInfo(Token? awaitToken, Token forToken,
Token leftParenthesis, ForLoopPartsImpl forLoopParts, Object entry) {
push(
ForElementImpl(
awaitKeyword: awaitToken,
forKeyword: forToken,
leftParenthesis: leftParenthesis,
forLoopParts: forLoopParts,
rightParenthesis: leftParenthesis.endGroup!,
body: entry as CollectionElementImpl,
),
);
}

void pushIfControlFlowInfo(
Token ifToken,
_ParenthesizedCondition condition,
CollectionElementImpl thenElement,
Token? elseToken,
CollectionElementImpl? elseElement) {
push(
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
condition: condition.expression,
caseClause: null,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
elseKeyword: elseToken,
elseElement: elseElement,
),
);
}

void reportErrorIfNullableType(Token? questionMark) {
if (questionMark != null) {
assert(optional('?', questionMark));
Expand Down Expand Up @@ -4757,18 +4761,6 @@ class AstBuilder extends StackListener {
typeArguments: typeArguments));
}

VariableDeclaration _makeVariableDeclaration({
required SimpleIdentifierImpl name,
required Token? equals,
required ExpressionImpl? initializer,
}) {
return VariableDeclarationImpl(
name2: name.token,
equals: equals,
initializer: initializer,
);
}

void _reportFeatureNotEnabled({
required ExperimentalFeature feature,
required Token startToken,
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 2
MINOR 19
PATCH 0
PRERELEASE 214
PRERELEASE 215
PRERELEASE_PATCH 0

0 comments on commit c18e6d4

Please sign in to comment.