Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generics (HAST-252) #22

Open
Piedone opened this issue Dec 10, 2017 · 2 comments
Open

Support generics (HAST-252) #22

Piedone opened this issue Dec 10, 2017 · 2 comments

Comments

@Piedone
Copy link
Member

Piedone commented Dec 10, 2017

Support for generic types, i.e. Generic<T>.

Unlike C++ templates generics in .NET directly exist in IL. How we could handle this is to substitute the type parameters (also a bit like with C++ templates) and basically create a version of the generic class for each type it's used with.

This can happen similarly to how array types are created in VHDL, e.g. we'd create a class named Generic_int and Generic_long from two usages of Generic<T>.

Possibly the best way to implement this would be via an AST processor in the Transformer.

Ideally, there would be a way to get rid of generics in IL and somehow substitute them statically (by the compiler or with some IL tool) but there seems to be no way to do this.

Jira issue

@antonfirsov
Copy link

antonfirsov commented Feb 14, 2018

Having arrays of struct-s + a generic SimpleMemory<T> (of structs) would be very handy for image processsing applications. I guess you need to follow some alignment rules on the hardware, so there might be contstraints, but couldn't it be viewed as sugar around byte[] for well-aligned data?

@Piedone
Copy link
Member Author

Piedone commented Feb 14, 2018

That's a good idea with SimpleMemory, and indeed it would be a nice addition. Since this is implementation-wise a different issue from user-defined generic types, let's follow it up here: #25.

BTW you can already define arrays of any supported type, including custom structs (but not store them directly in SimpleMemory).

@github-actions github-actions bot changed the title Support generics Support generics (HAST-252) Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants