[kernel][Contexts] Add VariableDeclaration

This adds a VariableDeclaration node which is used in ForStatement instead of VariableStatement.

This is a step towards removing the initializer from Variable. Long term, VariableDeclaration will own the initializer expression for variables and function parameters will have a defaultValue property instead of using the initializer property for the default value.

TEST=existing

Change-Id: I4a663eeb6006a0f9f098fb2b3e3b502d2ae583b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505681
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Johnni Winther
2026-05-27 00:41:34 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 7e348949c1
commit 6b693e00bc
60 changed files with 1400 additions and 1359 deletions
@@ -4888,13 +4888,13 @@ class BytecodeGenerator extends RecursiveVisitor {
}
@override
void visitLegacyVariableStatement(LegacyVariableStatement node) {
void visitVariableDeclaration(VariableDeclaration node) {
_handleVariableInitialization(node.variable);
}
@override
void visitVariableInitialization(VariableInitialization node) {
_handleVariableInitialization(node.variable);
void visitVariableStatement(VariableStatement node) {
visitVariableDeclaration(node.declaration);
}
void _handleVariableInitialization(Variable node) {