You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Add the `LPtr` IL providing a dedicated pointer type and an `Offset`
operation for pointer arithmetic. Higher-level ILs as well as `skully`
and `source2il` are changed to use the new `Ptr` type.
## Details
### Idea
The idea behind a dedicated pointer type is to:
1. allow for better static error detection, once type checking for ILs
is implemented
2. allow higher-level passes to defer decision making (i.e., regarding
how a pointer is implemented)
3. keep the type for code generators that need it
### Implementation
* add the `LPtr` providing the `Ptr` type and `Nil` and `Offset`
expression. It extends the `L0` IL and is the new basis for the
`L1` IL
* integrate the new IL and the new `ptrToInt` pass (`LPtr` -> `L0`)
into the main executable and the REPL
* update the higher-level ILs to consider `Ptr` and `Nil`
* change the stack allocation pass to emit `Offset` instead of integer
arithmetic
* change the aggregate-related passes, as well as the global-to-pointer
pass, to use `Ptr` instead of lowering to `UInt`
* update the expected output of the modified existing tests
* add tests for the new `ptrToInt` pass
The IL uses a symbolic name (rather than a numeric one) so that the
existing ILs don't have to be renamed.
Usage of `Offset` is disallowed past the `L2` IL for now, so that raw
pointer arithmetic is not exposed to higher-level ILs for now.
### Source2IL
* add an internal-only `tkPointer` type
* replace the `pointerType` constant with using `tkPointer` directly
* translate `tkPointer` and procedure pointers to the IL `Ptr` type
* update the hand-written `L30` code to not use pointer arithmetic
### Skully
* translate MIR pointer-like types to `Ptr`
* use `Nil` for representing nil pointers
* adjust the cast translation, which needs to handle pointers no longer
being arithmetic types
0 commit comments