compound assignment

This commit is contained in:
2026-06-22 21:20:15 +02:00
parent 663f4dc658
commit 6512ccd543
14 changed files with 995 additions and 99 deletions
+16
View File
@@ -102,6 +102,9 @@ Expr_Kind :: enum u8 {
Negate,
Not,
Add,
Sub,
Mul,
Div,
Pointer_Add,
Eq,
Ne,
@@ -151,6 +154,15 @@ Stmt_Kind :: enum u8 {
For,
}
Assignment_Op :: enum u8 {
Set,
Add,
Sub,
Mul,
Div,
Pointer_Add,
}
Stmt :: struct {
kind: Stmt_Kind,
span: source.Span,
@@ -160,6 +172,10 @@ Stmt :: struct {
expr: Expr_Id,
iterator_type: types.Type,
pointer_capture: bool,
// Assignments carry their operation explicitly. Arithmetic operations lower
// by computing the target address once, loading its current value, applying
// the operation to `expr`, and storing through the original address.
assignment_op: Assignment_Op,
// Boolean `If` statements use `expr` as the condition. Conditional unwraps
// use `unwraps` for the ordered optional expressions and capture locals, and
// `guard` for the optional boolean checked after every unwrap succeeds.