mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 12:27:41 +00:00
Add Array support to @Type
This commit is contained in:
parent
847a262efd
commit
9a358d2d33
@ -20942,6 +20942,13 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi
|
||||
return ptr_type;
|
||||
return get_slice_type(ira->codegen, ptr_type);
|
||||
}
|
||||
case ZigTypeIdArray:
|
||||
assert(payload->special == ConstValSpecialStatic);
|
||||
assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr));
|
||||
return get_array_type(ira->codegen,
|
||||
get_const_field_meta_type(ira, payload, "child", 1),
|
||||
bigint_as_u64(get_const_field_lit_int(ira, payload, "len", 0))
|
||||
);
|
||||
case ZigTypeIdComptimeFloat:
|
||||
return ira->codegen->builtin_types.entry_num_lit_float;
|
||||
case ZigTypeIdComptimeInt:
|
||||
@ -20950,7 +20957,6 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi
|
||||
return ira->codegen->builtin_types.entry_undef;
|
||||
case ZigTypeIdNull:
|
||||
return ira->codegen->builtin_types.entry_null;
|
||||
case ZigTypeIdArray:
|
||||
case ZigTypeIdOptional:
|
||||
case ZigTypeIdErrorUnion:
|
||||
case ZigTypeIdErrorSet:
|
||||
|
||||
@ -93,6 +93,12 @@ test "Type.Pointer" {
|
||||
});
|
||||
}
|
||||
|
||||
test "Type.Array" {
|
||||
testing.expect([123]u8 == @Type(TypeInfo { .Array = TypeInfo.Array { .len = 123, .child = u8 } }));
|
||||
testing.expect([2]u32 == @Type(TypeInfo { .Array = TypeInfo.Array { .len = 2, .child = u32 } }));
|
||||
testTypes([_]type {[1]u8, [30]usize, [7]bool});
|
||||
}
|
||||
|
||||
test "Type.ComptimeFloat" {
|
||||
testTypes([_]type {comptime_float});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user