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

Allow for static values as array sizes. #28

Merged

Conversation

m-kurtenacker
Copy link
Contributor

This applies to both array types [T * n], as well as RepeatArrayExpr [E; n]. In both cases, n must be defined as static n = ..., or artic might fail.

There are three parts to this:

  • Extend the ast and parser to accept ast::Path as a size, in place of a literal.
  • Extend the binder to bind those paths to the static declaration.
  • During type checking, replace the ast::Path with the static size taken from the declaration.
    This last step will replace the size member of the RepeatArrayExpr and the SizedArrayType, so the emitter does not require any substantial changes.

The way type inference is implemented should allow modules to be used when defining the size of an array, but addressing struct members will fail with an assert during type inference right now.

This applies to both array types `[T * n]`, as well as RepeatArrayExpr
`[E; n]`. In both cases, n must be defined as `static n = ...`, or the
emitter might fail.
@m-kurtenacker m-kurtenacker marked this pull request as draft November 5, 2024 14:53
@m-kurtenacker m-kurtenacker marked this pull request as ready for review November 11, 2024 14:47
@m-kurtenacker m-kurtenacker merged commit 45a32b3 into AnyDSL:development Nov 11, 2024
0 of 6 checks passed
@m-kurtenacker m-kurtenacker deleted the feature/static-array-sizes branch November 11, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant