-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Turn wildcard locals into ExpressionStatements or EmptyStatements.
This CL converts VariableDeclarations to ExpressionStatements or EmptyStatements. If the declaration has an initializer, it will be converted to an ExpressionStatement, otherwise, an EmptyStatement. This will help the VM and potentially other backends, avoid allocating space for a variable declaration that will never be used. Bug: #55655 Change-Id: I845b7e5e61fbb0340623ec0dee7269491bc09513 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373640 Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
- Loading branch information
Showing
19 changed files
with
214 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
pkg/front_end/testcases/wildcard_variables/local_var_order.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
String foo(String s) { | ||
print(s); | ||
return s; | ||
} | ||
|
||
test() { | ||
String a = foo("a"), _ = foo("b"), c = foo("c"), _ = foo("d"); | ||
} |
14 changes: 14 additions & 0 deletions
14
pkg/front_end/testcases/wildcard_variables/local_var_order.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo(core::String s) → core::String { | ||
core::print(s); | ||
return s; | ||
} | ||
static method test() → dynamic { | ||
core::String a = self::foo("a"); | ||
self::foo("b"); | ||
core::String c = self::foo("c"); | ||
self::foo("d"); | ||
} |
14 changes: 14 additions & 0 deletions
14
pkg/front_end/testcases/wildcard_variables/local_var_order.dart.strong.modular.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo(core::String s) → core::String { | ||
core::print(s); | ||
return s; | ||
} | ||
static method test() → dynamic { | ||
core::String a = self::foo("a"); | ||
self::foo("b"); | ||
core::String c = self::foo("c"); | ||
self::foo("d"); | ||
} |
8 changes: 8 additions & 0 deletions
8
pkg/front_end/testcases/wildcard_variables/local_var_order.dart.strong.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo(core::String s) → core::String | ||
; | ||
static method test() → dynamic | ||
; |
14 changes: 14 additions & 0 deletions
14
pkg/front_end/testcases/wildcard_variables/local_var_order.dart.strong.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo(core::String s) → core::String { | ||
core::print(s); | ||
return s; | ||
} | ||
static method test() → dynamic { | ||
core::String a = self::foo("a"); | ||
self::foo("b"); | ||
core::String c = self::foo("c"); | ||
self::foo("d"); | ||
} |
3 changes: 3 additions & 0 deletions
3
pkg/front_end/testcases/wildcard_variables/local_var_order.dart.textual_outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
String foo(String s) {} | ||
|
||
test() {} |
3 changes: 3 additions & 0 deletions
3
...ont_end/testcases/wildcard_variables/local_var_order.dart.textual_outline_modelled.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
String foo(String s) {} | ||
|
||
test() {} |