e30cd0322c
This separates VariableDeclaration from Statement. VariableDeclaration no longer implements Statement and variable declared in a block or in a for-statement are now wrapped by a VariableStatement. Currently there are two VariableStatement implementations; LegacyVariableStatement for variables in the current model, called LegacyVariable, and VariableInitialization for variables used in the new, still experimental, encoding that supports scope computation. This CL is a step towards realigning the AST nodes to the new model in which each kind of variable has its own distinct subclass. (LocalVariable, PositionalParameter, NamedParameter, SyntheticVariable, etc.) Note that it is not the intent to use VariableStatement in ForStatement going forward but that will be handled in a follow-up. TEST=existing. Change-Id: I5b309cd62c9b138f95b74fb054686edffa49a393 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502681 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
27 lines
549 B
Plaintext
27 lines
549 B
Plaintext
library;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method test(positional-parameter list) → dynamic/* scope=[
|
|
#ctx1: not-captured VariableContext([
|
|
positional-parameter list;
|
|
]),
|
|
] */ /* scope=[
|
|
#ctx2: not-captured VariableContext([
|
|
local-variable s;
|
|
]),
|
|
] */ {
|
|
s := "";
|
|
for /* scope=[
|
|
#ctx3: not-captured VariableContext([
|
|
synthetic-variable #t1;
|
|
]),
|
|
] */ (synthetic-variable #t1 in list) {
|
|
s = #t1;
|
|
if(s.{core::String::isNotEmpty}{core::bool}) {
|
|
return s;
|
|
}
|
|
}
|
|
return s;
|
|
}
|