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
feat: implement static globals, type casts, pointer arithmetic, and enhanced diagnostics (#298)
This commit introduces several core language features, including global
static variables, explicit type casting, and pointer arithmetic. It also
significantly upgrades the compiler's resilience by introducing a
panic-guarded diagnostic system and cross-platform ABI support.
Changes:
- **Language Features**:
- **Static Globals**: Added the `static` keyword for global variables
that persist throughout the program.
- **Type Casting**: Implemented the `as` operator (e.g., `expr as type`)
for explicit type conversions, supported in both the parser and
LLVM backend.
- **Pointer Arithmetic**: Added support for `ptr + int`, `ptr - int`,
and `ptr - ptr` (pointer difference) using LLVM `gep` and `sub`
instructions.
- **Match Statement**: Finalized the `match` expression syntax and
verification, ensuring no duplicate patterns in arms.
- **Compiler Infrastructure**:
- **Panic-Guarded Diagnostics**: Introduced a robust runner that
captures backend panics and uses "source-span inference" to map
low-level LLVM errors back to the original Wave source code.
- **Cross-ABI Support**: Overhauled `abi_c.rs` to support target-specific
calling conventions for both **Linux x86_64 (SysV)** and
**macOS arm64 (Darwin)**, handling aggregate splitting and SRet rules.
- **Structured Errors**: Refactored the parser to return `ParseError`
objects containing detailed diagnostics (expected/found tokens,
help messages, and context).
- **Standard Library Updates**:
- Updated the Linux syscall layer (`fs`, `memory`, `socket`, `process`)
with explicit `as i64` casts to comply with stricter type-checking
rules for register arguments.
- Improved memory allocation safety with `null` checks and syscall
error handling.
- **Documentation**:
- Expanded `README.md` with build instructions, target support status,
and a comprehensive CLI usage guide.
These updates bridge the gap between low-level system access and
high-level safety, making Wave more suitable for systems programming
on multiple architectures.
Signed-off-by: LunaStev <luna@lunastev.org>
0 commit comments