| author | |
| committer | |
| log | ca6db2d008cf3e0e3700e84400bd3d6e259e3c0f |
| tree | a5975ad5f4f6c655577152d087e3f31eb5d060ad |
| parent | 1696e943acd67119104f303467c0e26eecb94544 |
| signature | Commit is signed but in an unrecognized format. |
3 files changed, 33 insertions(+), 3 deletions(-)
lib/std/builtin.zig+7-1| ... | ... | @@ -157,7 +157,7 @@ pub const TypeInfo = union(enum) { |
| 157 | 157 | Fn: Fn, |
| 158 | 158 | BoundFn: Fn, |
| 159 | 159 | Opaque: void, |
| 160 | Frame: void, | |
| 160 | Frame: Frame, | |
| 161 | 161 | AnyFrame: AnyFrame, |
| 162 | 162 | Vector: Vector, |
| 163 | 163 | EnumLiteral: void, |
| ... | ... | @@ -315,6 +315,12 @@ pub const TypeInfo = union(enum) { |
| 315 | 315 | args: []FnArg, |
| 316 | 316 | }; |
| 317 | 317 | |
| 318 | /// This data structure is used by the Zig language code generation and | |
| 319 | /// therefore must be kept in sync with the compiler implementation. | |
| 320 | pub const Frame = struct { | |
| 321 | function: var, | |
| 322 | }; | |
| 323 | ||
| 318 | 324 | /// This data structure is used by the Zig language code generation and |
| 319 | 325 | /// therefore must be kept in sync with the compiler implementation. |
| 320 | 326 | pub const AnyFrame = struct { |
src/ir.cpp+10-2| ... | ... | @@ -25446,10 +25446,18 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI |
| 25446 | 25446 | ZigType *child_type = get_const_field_meta_type_optional(ira, source_instr->source_node, payload, "child", 0); |
| 25447 | 25447 | return get_any_frame_type(ira->codegen, child_type); |
| 25448 | 25448 | } |
| 25449 | case ZigTypeIdEnumLiteral: | |
| 25450 | return ira->codegen->builtin_types.entry_enum_literal; | |
| 25451 | case ZigTypeIdFnFrame: { | |
| 25452 | assert(payload->special == ConstValSpecialStatic); | |
| 25453 | assert(payload->type == ir_type_info_get_type(ira, "Frame", nullptr)); | |
| 25454 | ZigValue *function = get_const_field(ira, source_instr->source_node, payload, "function", 0); | |
| 25455 | assert(function->type->id == ZigTypeIdFn); | |
| 25456 | ZigFn *fn = function->data.x_ptr.data.fn.fn_entry; | |
| 25457 | return get_fn_frame_type(ira->codegen, fn); | |
| 25458 | } | |
| 25449 | 25459 | case ZigTypeIdErrorSet: |
| 25450 | 25460 | case ZigTypeIdEnum: |
| 25451 | case ZigTypeIdFnFrame: | |
| 25452 | case ZigTypeIdEnumLiteral: | |
| 25453 | 25461 | ir_add_error(ira, source_instr, buf_sprintf( |
| 25454 | 25462 | "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId))); |
| 25455 | 25463 | return ira->codegen->invalid_inst_gen->value->type; |
test/stage1/behavior/type.zig+16| ... | ... | @@ -213,3 +213,19 @@ test "Type.AnyFrame" { |
| 213 | 213 | anyframe->anyframe->u8, |
| 214 | 214 | }); |
| 215 | 215 | } |
| 216 | ||
| 217 | test "Type.EnumLiteral" { | |
| 218 | testTypes(&[_]type{ | |
| 219 | @TypeOf(.Dummy), | |
| 220 | }); | |
| 221 | } | |
| 222 | ||
| 223 | fn add(a: i32, b: i32) i32 { | |
| 224 | return a + b; | |
| 225 | } | |
| 226 | ||
| 227 | test "Type.Frame" { | |
| 228 | testTypes(&[_]type{ | |
| 229 | @Frame(add), | |
| 230 | }); | |
| 231 | } |