|
|
|
@ -383,14 +383,13 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -383,14 +383,13 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
|
|
|
|
|
protected internal override TranslatedExpression VisitLocAllocSpan(LocAllocSpan inst, TranslationContext context) |
|
|
|
|
{ |
|
|
|
|
return TranslateLocAllocSpan(inst, context.TypeHint, out var elementType) |
|
|
|
|
return TranslateLocAllocSpan(inst, context.TypeHint, out _) |
|
|
|
|
.WithILInstruction(inst).WithRR(new ResolveResult(inst.Type)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
StackAllocExpression TranslateLocAllocSpan(LocAllocSpan inst, IType typeHint, out IType elementType) |
|
|
|
|
{ |
|
|
|
|
elementType = inst.Type.TypeArguments[0]; |
|
|
|
|
PointerType pointerType = new PointerType(elementType); |
|
|
|
|
TranslatedExpression countExpression = Translate(inst.Argument) |
|
|
|
|
.ConvertTo(compilation.FindType(KnownTypeCode.Int32), this); |
|
|
|
|
return new StackAllocExpression { |
|
|
|
@ -696,8 +695,7 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -696,8 +695,7 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
return ErrorExpression("Nullable comparisons with three-valued-logic not supported in C#"); |
|
|
|
|
} |
|
|
|
|
if (inst.Kind.IsEqualityOrInequality()) { |
|
|
|
|
bool negateOutput; |
|
|
|
|
var result = TranslateCeq(inst, out negateOutput); |
|
|
|
|
var result = TranslateCeq(inst, out bool negateOutput); |
|
|
|
|
if (negateOutput) |
|
|
|
|
return LogicNot(result).WithILInstruction(inst); |
|
|
|
|
else |
|
|
|
@ -2573,31 +2571,29 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -2573,31 +2571,29 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
{ |
|
|
|
|
var stloc = block.Instructions.FirstOrDefault() as StLoc; |
|
|
|
|
var final = block.FinalInstruction as LdLoc; |
|
|
|
|
IType type; |
|
|
|
|
if (stloc == null || final == null || !stloc.Value.MatchNewArr(out type) || stloc.Variable != final.Variable || stloc.Variable.Kind != VariableKind.InitializerTarget) |
|
|
|
|
if (stloc == null || final == null || !stloc.Value.MatchNewArr(out IType type)) |
|
|
|
|
throw new ArgumentException("given Block is invalid!"); |
|
|
|
|
if (stloc.Variable != final.Variable || stloc.Variable.Kind != VariableKind.InitializerTarget) |
|
|
|
|
throw new ArgumentException("given Block is invalid!"); |
|
|
|
|
var newArr = (NewArr)stloc.Value; |
|
|
|
|
|
|
|
|
|
var translatedDimensions = newArr.Indices.Select(i => Translate(i)).ToArray(); |
|
|
|
|
var translatedDimensions = newArr.Indices.SelectArray(i => Translate(i)); |
|
|
|
|
|
|
|
|
|
if (!translatedDimensions.All(dim => dim.ResolveResult.IsCompileTimeConstant)) |
|
|
|
|
throw new ArgumentException("given Block is invalid!"); |
|
|
|
|
int dimensions = newArr.Indices.Count; |
|
|
|
|
int[] dimensionSizes = translatedDimensions.Select(dim => (int)dim.ResolveResult.ConstantValue).ToArray(); |
|
|
|
|
int[] dimensionSizes = translatedDimensions.SelectArray(dim => (int)dim.ResolveResult.ConstantValue); |
|
|
|
|
var container = new Stack<ArrayInitializer>(); |
|
|
|
|
var root = new ArrayInitializer(new ArrayInitializerExpression()); |
|
|
|
|
container.Push(root); |
|
|
|
|
var elementResolveResults = new List<ResolveResult>(); |
|
|
|
|
|
|
|
|
|
for (int i = 1; i < block.Instructions.Count; i++) { |
|
|
|
|
ILInstruction target, value, array; |
|
|
|
|
IType t; |
|
|
|
|
ILVariable v; |
|
|
|
|
if (!block.Instructions[i].MatchStObj(out target, out value, out t) || !type.Equals(t)) |
|
|
|
|
if (!block.Instructions[i].MatchStObj(out ILInstruction target, out ILInstruction value, out IType t) || !type.Equals(t)) |
|
|
|
|
throw new ArgumentException("given Block is invalid!"); |
|
|
|
|
if (!target.MatchLdElema(out t, out array) || !type.Equals(t)) |
|
|
|
|
if (!target.MatchLdElema(out t, out ILInstruction array) || !type.Equals(t)) |
|
|
|
|
throw new ArgumentException("given Block is invalid!"); |
|
|
|
|
if (!array.MatchLdLoc(out v) || v != final.Variable) |
|
|
|
|
if (!array.MatchLdLoc(out ILVariable v) || v != final.Variable) |
|
|
|
|
throw new ArgumentException("given Block is invalid!"); |
|
|
|
|
while (container.Count < dimensions) { |
|
|
|
|
var aie = new ArrayInitializerExpression(); |
|
|
|
|