add "child" field to pointer type
This commit is contained in:
parent
b35dad88b4
commit
c2357830b4
14
src/ir.cpp
14
src/ir.cpp
|
@ -11416,6 +11416,20 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
|
|||
buf_ptr(&child_type->name), buf_ptr(field_name)));
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
} else if (child_type->id == TypeTableEntryIdPointer) {
|
||||
if (buf_eql_str(field_name, "child")) {
|
||||
bool ptr_is_const = true;
|
||||
bool ptr_is_volatile = false;
|
||||
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
|
||||
create_const_type(ira->codegen, child_type->data.pointer.child_type),
|
||||
ira->codegen->builtin_types.entry_type,
|
||||
ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile);
|
||||
} else {
|
||||
ir_add_error(ira, &field_ptr_instruction->base,
|
||||
buf_sprintf("type '%s' has no member called '%s'",
|
||||
buf_ptr(&child_type->name), buf_ptr(field_name)));
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
} else {
|
||||
ir_add_error(ira, &field_ptr_instruction->base,
|
||||
buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name)));
|
||||
|
|
|
@ -534,3 +534,7 @@ const vram = @intToPtr(&volatile u8, 0x20000000)[0..0x8000];
|
|||
export fn writeToVRam() {
|
||||
vram[0] = 'X';
|
||||
}
|
||||
|
||||
test "pointer child field" {
|
||||
assert((&u32).child == u32);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user