Lombiq / Hastlayer-SDK

Turning .NET software into FPGA hardware for faster execution and lower power usage.

Home Page:https://hastlayer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for foreach (HAST-245)

Piedone opened this issue · comments

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.

Jira issue