[dart2bytecode] Use more of new variable getters in dart2bytecode

More of the Kernel AST node getters with return types reflecting the
new variable model are used in this CL, pushing further the migration
of dart2bytecode to the new variable model.

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/485481

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I39e1ae53673b46a7fcc425fda24d43fb27e2f855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485740
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
Chloe Stefantsova
2026-03-05 05:23:21 -08:00
committed by Commit Queue
parent 6c543e5c05
commit 548b5e27b9
2 changed files with 9 additions and 9 deletions
@@ -3739,7 +3739,7 @@ class BytecodeGenerator extends RecursiveVisitor {
@override
void visitVariableSet(VariableSet node) {
final v = node.variable;
final v = node.expressionVariable;
_genPushContextIfCaptured(v);
_generateNode(node.value);
@@ -3781,7 +3781,7 @@ class BytecodeGenerator extends RecursiveVisitor {
asm.emitJump(done);
asm.bind(error);
asm.emitPushConstant(cp.addName(v.name!));
asm.emitPushConstant(cp.addName(v.cosmeticName!));
_genDirectCall(
throwLocalAlreadyInitialized, objectTable.getArgDescHandle(1), 1);
asm.emitDrop1();
@@ -4282,14 +4282,14 @@ class BytecodeGenerator extends RecursiveVisitor {
_enterScope(catchClause);
final exceptionVar = catchClause.exception;
final exceptionVar = catchClause.exceptionCatchVariable;
if (exceptionVar != null) {
_genPushContextIfCaptured(exceptionVar);
asm.emitPush(exception);
_genStoreVar(exceptionVar);
}
final stackTraceVar = catchClause.stackTrace;
final stackTraceVar = catchClause.stackTraceCatchVariable;
if (stackTraceVar != null) {
tryBlock.needsStackTrace = true;
_genPushContextIfCaptured(stackTraceVar);
+5 -5
View File
@@ -544,7 +544,7 @@ class _ScopeBuilder extends RecursiveVisitor {
@override
void visitVariableSet(VariableSet node) {
_useVariable(node.variable);
_useVariable(node.expressionVariable);
node.visitChildren(this);
}
@@ -625,7 +625,7 @@ class _ScopeBuilder extends RecursiveVisitor {
node.iterable.accept(this);
++_loopDepth;
_enterScope(node);
node.variable.accept(this);
node.expressionVariable.accept(this);
node.body.accept(this);
_leaveScope();
--_loopDepth;
@@ -1087,7 +1087,7 @@ class _Allocator extends RecursiveVisitor {
node.iterable.accept(this);
_enterScope(node);
node.variable.accept(this);
node.expressionVariable.accept(this);
node.body.accept(this);
_leaveScope();
@@ -1196,8 +1196,8 @@ class _Allocator extends RecursiveVisitor {
@override
void visitVariableSet(VariableSet node) {
final bool needsTemp =
node.parent is! ExpressionStatement && locals.isCaptured(node.variable);
final bool needsTemp = node.parent is! ExpressionStatement &&
locals.isCaptured(node.expressionVariable);
_visit(node, temps: needsTemp ? 1 : 0);
}