Skip to content

Commit c78b93f

Browse files
committed
fix: build fixes for latest language level
1 parent 51a8b12 commit c78b93f

File tree

3 files changed

+34
-36
lines changed

3 files changed

+34
-36
lines changed

src/Peachpie.CodeAnalysis/Semantics/SemanticsBinder.cs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -715,38 +715,36 @@ protected BoundExpression BindIncludeEx(AST.IncludingEx x)
715715
return new BoundIncludeEx(BindExpression(x.Target, BoundAccess.Read), x.InclusionType);
716716
}
717717

718-
protected BoundExpression BindConcatEx(AST.ConcatEx x) => BindConcatEx(x.Expressions);
718+
protected BoundExpression BindConcatEx(AST.ConcatEx x) => BindConcatEx(x);
719719

720-
protected BoundExpression BindConcatEx(AST.Expression[] args)
720+
void BindConcatIntoList(List<BoundArgument> list, AST.Expression expr)
721721
{
722-
// Flatten and bind concat arguments using a stack (its bottom is the last argument)
723-
var boundArgs = new List<BoundArgument>(args.Length);
724-
var exprStack = new Stack<AST.Expression>(args.Length);
725-
726-
// args.Reverse().ForEach(exprStack.Push);
727-
for (int i = args.Length - 1; i >= 0; i--)
728-
{
729-
exprStack.Push(args[i]);
730-
}
731-
732-
while (exprStack.Count != 0)
722+
if (expr is AST.ConcatEx cex)
733723
{
734-
var arg = exprStack.Pop();
735-
if (arg is AST.ConcatEx concat)
724+
for (int i = 0; i < cex.Expressions.Length; i++)
736725
{
737-
concat.Expressions.Reverse().ForEach(exprStack.Push);
738-
}
739-
else if (arg is AST.BinaryEx binEx && binEx.Operation == AST.Operations.Concat)
740-
{
741-
exprStack.Push(binEx.RightExpr);
742-
exprStack.Push(binEx.LeftExpr);
743-
}
744-
else
745-
{
746-
boundArgs.Add(BindArgument(arg));
726+
BindConcatIntoList(list, cex.Expressions[i]);
747727
}
748728
}
729+
else if (expr is AST.BinaryEx bex && bex.Operation == AST.Operations.Concat)
730+
{
731+
BindConcatIntoList(list, bex.LeftExpr);
732+
BindConcatIntoList(list, bex.RightExpr);
733+
}
734+
else
735+
{
736+
list.Add(BindArgument(expr));
737+
}
738+
}
749739

740+
protected BoundExpression BindConcatEx(AST.Expression expr)
741+
{
742+
// Flatten and bind concat arguments using a stack (its bottom is the last argument)
743+
var boundArgs = new List<BoundArgument>();
744+
745+
BindConcatIntoList(boundArgs, expr);
746+
747+
//
750748
return BindConcatEx(boundArgs);
751749
}
752750

@@ -1325,7 +1323,7 @@ protected virtual BoundExpression BindBinaryEx(AST.BinaryEx expr)
13251323
switch (expr.Operation)
13261324
{
13271325
case AST.Operations.Concat: // Left . Right
1328-
return BindConcatEx(new[] { expr.LeftExpr, expr.RightExpr });
1326+
return BindConcatEx(expr);
13291327

13301328
case AST.Operations.Coalesce:
13311329
laccess = BoundAccess.Read.WithQuiet(); // Template: A ?? B; // read A quietly

src/Peachpie.CodeAnalysis/Symbols/PE/PEParameterSymbol.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ public override FieldSymbol DefaultValueField
737737
{
738738
get
739739
{
740-
var field = _lazyDefaultValueField;
740+
var tmp = _lazyDefaultValueField;
741741

742742
if (!_packedFlags.HasDefaultValueFieldPopulated)
743743
{
@@ -751,16 +751,16 @@ public override FieldSymbol DefaultValueField
751751
var container = attr.NamedArguments.SingleOrDefault(pair => pair.Key == "ExplicitType").Value.Value as ITypeSymbol
752752
?? ContainingType;
753753

754-
field = container.GetMembers(fldname).OfType<FieldSymbol>().Single();
755-
Debug.Assert(field.IsStatic);
756-
_lazyDefaultValueField = field;
754+
tmp = container.GetMembers(fldname).OfType<FieldSymbol>().Single();
755+
Debug.Assert(tmp.IsStatic);
756+
_lazyDefaultValueField = tmp;
757757
}
758758
}
759759

760760
_packedFlags.SetDefaultValueFieldPopulated();
761761
}
762762

763-
return field;
763+
return tmp;
764764
}
765765
}
766766

src/Peachpie.CodeAnalysis/Symbols/Source/SourceParameterSymbol.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public override FieldSymbol DefaultValueField
5555
{
5656
if (_lazyDefaultValueField == null && Initializer != null && ExplicitDefaultConstantValue == null)
5757
{
58-
TypeSymbol fldtype; // type of the field
58+
TypeSymbol fldtype; // type of the tmp
5959

6060
if (Initializer is BoundArrayEx arr)
6161
{
6262
// special case: empty array
6363
if (arr.Items.Length == 0 && !_syntax.PassedByRef)
6464
{
65-
// OPTIMIZATION: reference the singleton field directly, the called routine is responsible to perform copy if necessary
65+
// OPTIMIZATION: reference the singleton tmp directly, the called routine is responsible to perform copy if necessary
6666
// parameter MUST NOT be `PassedByRef` https://github.com/peachpiecompiler/peachpie/issues/591
6767
// PhpArray.Empty
6868
return DeclaringCompilation.CoreMethods.PhpArray.Empty;
@@ -91,7 +91,7 @@ public override FieldSymbol DefaultValueField
9191
DeclaringCompilation.CoreTypes.PhpValue);
9292
}
9393

94-
// determine the field container:
94+
// determine the tmp container:
9595
NamedTypeSymbol fieldcontainer = ContainingType; // by default in the containing class/trait/file
9696
string fieldname = $"<{ContainingSymbol.Name}.{Name}>_DefaultValue";
9797

@@ -102,15 +102,15 @@ public override FieldSymbol DefaultValueField
102102
//}
103103

104104
// public static readonly T ..;
105-
var field = new SynthesizedFieldSymbol(
105+
var tmp = new SynthesizedFieldSymbol(
106106
fieldcontainer,
107107
fldtype,
108108
fieldname,
109109
accessibility: Accessibility.Public,
110110
isStatic: true, isReadOnly: true);
111111

112112
//
113-
Interlocked.CompareExchange(ref _lazyDefaultValueField, field, null);
113+
Interlocked.CompareExchange(ref _lazyDefaultValueField, tmp, null);
114114
}
115115
return _lazyDefaultValueField;
116116
}

0 commit comments

Comments
 (0)