Support for foreach (HAST-245)
Piedone opened this issue · comments
Zoltán Lehóczky commented
If DecompilerSettings.ForEachStatement
is set to false
then foreach statements are not recreated. So e.g. in ParallelAlgorithn
instead of:
for (int i = 0; i < MaxDegreeOfParallelism; i++)
{
output += tasks[i].Result;
}
We could write:
foreach (var task in tasks)
{
output += task.Result;
}
This is then decompiled into something like this (after const substitution):
int i = 0;
while (i< 280) {
Task<int> task;
task = array[i];
output = output + task.Result;
i = i + 1;
}
The Task<int>
variable declaration and the .Result
access need special support, otherwise, this is already supported.