feat: support callback signatures and many-pointer addition

This commit is contained in:
2026-10-26 11:32:29 +01:00
parent 676f3666b4
commit 7856f4f963
8 changed files with 417 additions and 50 deletions
+9 -1
View File
@@ -1065,7 +1065,7 @@ lower_expression proc(state @mut State, id ast.NodeId) ir.ValueId ! (mem.AllocEr
# ranges have no physical value; only lower_for decomposes an iterable.
if (!trap_type(state, id)) unreachable
}
.array_type, .pointer_type, .record_type, .enum_type, .union_type, .distinct_type: {
.array_type, .pointer_type, .function_type, .record_type, .enum_type, .union_type, .distinct_type: {
if (!trap_type(state, id)) {
trap(state, try diagnostics.add(state.diagnostics, .type_not_value, span), span)
}
@@ -1240,6 +1240,14 @@ lower_expression proc(state @mut State, id ast.NodeId) ir.ValueId ! (mem.AllocEr
if (state.terminated) return ir.no_value
right :: try lower_expression(state, expression.right)
if (state.terminated or trap_type(state, id)) return ir.no_value
if (expression.operator == .add and type == .pointer) {
pointer :: typecheck.pointer_type(state.checked, typecheck.type_of(state.checked, id).pointer_type)
return try emit(state, ir.Instruction{
op = .pointer_offset, type = .pointer, left = left, right = right,
pointee = lower_type(state, pointer.element),
array_type = try array_shape(state, pointer.element), span = span,
})
}
op ir.Op :: match expression.operator {
.add: .add
.subtract: .subtract