22// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33// See the LICENSE file in the project root for more information.
44
5+ #nullable enable
6+
57using System . Collections . Generic ;
6- using System . Collections . ObjectModel ;
8+ using System . Linq ;
79using System . Runtime . CompilerServices ;
810
9- using Microsoft . Scripting ;
10- using Microsoft . Scripting . Runtime ;
11-
1211using IronPython . Runtime . Binding ;
13- using IronPython . Runtime . Operations ;
1412
15- using MSAst = System . Linq . Expressions ;
13+ using Microsoft . Scripting ;
14+ using Microsoft . Scripting . Runtime ;
1615
1716using AstUtils = Microsoft . Scripting . Ast . Utils ;
17+ using MSAst = System . Linq . Expressions ;
1818
1919namespace IronPython . Compiler . Ast {
20- using Ast = MSAst . Expression ;
21-
2220 public abstract class SequenceExpression : Expression {
2321 private readonly Expression [ ] _items ;
2422
@@ -28,6 +26,8 @@ protected SequenceExpression(Expression[] items) {
2826
2927 public IList < Expression > Items => _items ;
3028
29+ protected bool HasStarredExpression => Items . OfType < StarredExpression > ( ) . Any ( ) ;
30+
3131 internal override MSAst . Expression TransformSet ( SourceSpan span , MSAst . Expression right , PythonOperationKind op ) {
3232 // if we just have a simple named multi-assignment (e.g. a, b = 1,2)
3333 // then go ahead and step over the entire statement at once. If we have a
@@ -58,7 +58,7 @@ internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expressio
5858 }
5959
6060 // 1. Evaluate the expression and assign the value to the temp.
61- MSAst . ParameterExpression right_temp = Ast . Variable ( typeof ( object ) , "unpacking" ) ;
61+ MSAst . ParameterExpression right_temp = Expression . Variable ( typeof ( object ) , "unpacking" ) ;
6262
6363 // 2. Add the assignment "right_temp = right" into the suite/block
6464 MSAst . Expression assignStmt1 = MakeAssignment ( right_temp , right ) ;
@@ -92,7 +92,7 @@ internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expressio
9292 ) , typeof ( object [ ] ) ) ;
9393
9494 // 4. Create temporary variable for the array
95- MSAst . ParameterExpression array_temp = Ast . Variable ( typeof ( object [ ] ) , "array" ) ;
95+ MSAst . ParameterExpression array_temp = Expression . Variable ( typeof ( object [ ] ) , "array" ) ;
9696
9797 // 5. Assign the value of the method call (mce) into the array temp
9898 // And add the assignment "array_temp = Ops.GetEnumeratorValues(...)" into the block
@@ -112,7 +112,7 @@ internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expressio
112112 }
113113
114114 // 6. array_temp[i]
115- MSAst . Expression element = Ast . ArrayAccess (
115+ MSAst . Expression element = Expression . ArrayAccess (
116116 array_temp , // array expression
117117 AstUtils . Constant ( i ) // index
118118 ) ;
@@ -129,13 +129,13 @@ internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expressio
129129 }
130130 // 9. add the sets as their own block so they can be marked as a single span, if necessary.
131131 sets . Add ( AstUtils . Empty ( ) ) ;
132- MSAst . Expression itemSet = GlobalParent . AddDebugInfo ( Ast . Block ( sets . ToReadOnlyCollection ( ) ) , leftSpan ) ;
132+ MSAst . Expression itemSet = GlobalParent . AddDebugInfo ( Expression . Block ( sets . ToReadOnlyCollection ( ) ) , leftSpan ) ;
133133
134134 // 10. Return the suite statement (block)
135- return GlobalParent . AddDebugInfo ( Ast . Block ( new [ ] { array_temp , right_temp } , assignStmt1 , assignStmt2 , itemSet , AstUtils . Empty ( ) ) , totalSpan ) ;
135+ return GlobalParent . AddDebugInfo ( Expression . Block ( new [ ] { array_temp , right_temp } , assignStmt1 , assignStmt2 , itemSet , AstUtils . Empty ( ) ) , totalSpan ) ;
136136 }
137137
138- internal override string CheckAssign ( ) {
138+ internal override string ? CheckAssign ( ) {
139139 var starCount = 0 ;
140140 foreach ( var item in Items ) {
141141 if ( item . CheckAssign ( ) is { } checkAssign ) {
@@ -157,7 +157,7 @@ internal override string CheckAssign() {
157157 return null ;
158158 }
159159
160- internal override string CheckDelete ( ) => null ;
160+ internal override string ? CheckDelete ( ) => null ;
161161
162162 internal override string CheckAugmentedAssign ( )
163163 => CheckAssign ( ) ?? "illegal expression for augmented assignment" ;
@@ -170,7 +170,7 @@ internal override MSAst.Expression TransformDelete() {
170170 statements [ i ] = _items [ i ] . TransformDelete ( ) ;
171171 }
172172 statements [ _items . Length ] = AstUtils . Empty ( ) ;
173- return GlobalParent . AddDebugInfo ( Ast . Block ( statements ) , Span ) ;
173+ return GlobalParent . AddDebugInfo ( Expression . Block ( statements ) , Span ) ;
174174 }
175175
176176 internal override bool CanThrow {
0 commit comments