Lombiq / Hastlayer-SDK

Turning .NET software into FPGA hardware for faster execution and lower power usage.
https://hastlayer.com
BSD 3-Clause "New" or "Revised" License
301 stars 33 forks source link

Add support for returning an array field (or its clone) from methods (HAST-258) #63

Open sarahelsaig opened 2 years ago

sarahelsaig commented 2 years ago

As mentioned here:

[...] if you return an array from a method instead of a property it won't work even if the two are functionally equivalent. For example Quire.Segments is an array returning property which is not suggested for performance reasons. But if I replace it with a ulong[] GetSegments() => _segments; method, I will get the The length of the array holder System.Void Lombiq.Arithmetics.Quire::.ctor(System.UInt64[],System.UInt16).Lombiq.Arithmetics.Quire.GetSegments (@this)[82..87) couldn't be statically determined. error. Checking if a method returns a trivial reference could resolve that problem.

We need:

Jira issue

Piedone commented 2 years ago

Following up here. Yep, we'd need to support those three scenarios indeed. IReadOnlyList<T> should be fairly straightforward since we don't actually need to do anything with it on the hardware, it can be an array (since write access to it is prevented in the .NET level already).