Browse Source

- Altered the InitializerPeepholeTransforms' ArrayInitializer forward-scan to only look at the next instruction: in practice, CSC does not seem to generate code that needs anything more, and there are some questions as to the validity of the looping itself (i.e. what if there is a branch between them?

- Added another test to the InitializerTests, to validate that it handles deeper multi-dimensional arrays (I went 3x3x3 for simplicity)
pull/252/head
Alex Lyman 15 years ago committed by Daniel Grunwald
parent
commit
e484d35fe2
  1. 2
      ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs
  2. 82
      ICSharpCode.Decompiler/Tests/InitializerTests.cs

2
ICSharpCode.Decompiler/ILAst/InitializerPeepholeTransforms.cs

@ -120,7 +120,6 @@ namespace ICSharpCode.Decompiler.ILAst @@ -120,7 +120,6 @@ namespace ICSharpCode.Decompiler.ILAst
bool ForwardScanInitializeArrayRuntimeHelper(List<ILNode> body, int pos, ILVariable array, TypeReference arrayType, int arrayLength, out ILExpression[] values, out int foundPos)
{
for (; pos < body.Count; pos++) {
ILVariable v2;
MethodReference methodRef;
ILExpression methodArg1;
@ -140,7 +139,6 @@ namespace ICSharpCode.Decompiler.ILAst @@ -140,7 +139,6 @@ namespace ICSharpCode.Decompiler.ILAst
return true;
}
}
}
values = null;
foundPos = -1;
return false;

82
ICSharpCode.Decompiler/Tests/InitializerTests.cs

@ -709,4 +709,86 @@ public class InitializerTests @@ -709,4 +709,86 @@ public class InitializerTests
}
};
}
public void ArrayOfArrayOfArrayInit()
{
int[][,,] array = new int[][,,]
{
new int[, , ]
{
{
{
1,
2,
3
},
{
4,
5,
6
},
{
7,
8,
9
}
},
{
{
11,
12,
13
},
{
14,
15,
16
},
{
17,
18,
19
}
}
},
new int[, , ]
{
{
{
21,
22,
23
},
{
24,
25,
26
},
{
27,
28,
29
}
},
{
{
31,
32,
33
},
{
34,
35,
36
},
{
37,
38,
39
}
}
}
};
}
}

Loading…
Cancel
Save