explain how AstGen will diverge from zig codebase

This commit is contained in:
Techarix 2023-02-14 22:53:05 +01:00 committed by Techatrix
parent 4215edbc33
commit 018569888f
2 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,11 @@
//! Ingests an AST and produces ZIR code. //! Ingests an AST and produces ZIR code.
//!
//! TODO
//! In contrast to the upstream zig codebase, generating Zir
//! will not fail after encountering compile errors but will
//! instead try to ignore or patch these errors.
//! If this is not possible, an `unknown` instructions will be emitted.
const AstGen = @This(); const AstGen = @This();
const std = @import("std"); const std = @import("std");

View File

@ -2065,10 +2065,6 @@ pub const Inst = struct {
/// The tag type is specified so that it is safe to bitcast between `[]u32` /// The tag type is specified so that it is safe to bitcast between `[]u32`
/// and `[]Ref`. /// and `[]Ref`.
pub const Ref = enum(u32) { pub const Ref = enum(u32) {
/// This Ref does not correspond to any ZIR instruction or constant
/// value and may instead be used as a sentinel to indicate null.
none,
u1_type, u1_type,
u8_type, u8_type,
i8_type, i8_type,
@ -2130,6 +2126,7 @@ pub const Inst = struct {
const_slice_u8_type, const_slice_u8_type,
anyerror_void_error_union_type, anyerror_void_error_union_type,
generic_poison_type, generic_poison_type,
unknown_type,
/// `undefined` (untyped) /// `undefined` (untyped)
undef, undef,
@ -2160,9 +2157,13 @@ pub const Inst = struct {
/// Used for generic parameters where the type and value /// Used for generic parameters where the type and value
/// is not known until generic function instantiation. /// is not known until generic function instantiation.
generic_poison, generic_poison,
unknown,
ref_start_index, ref_start_index,
/// This Ref does not correspond to any ZIR instruction or constant
/// value and may instead be used as a sentinel to indicate null.
none = std.math.maxInt(u32),
_, _,
}; };
@ -3839,7 +3840,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
}; };
} }
const ref_start_index: u32 = @enumToInt(Inst.Ref.ref_start_index); pub const ref_start_index: u32 = @enumToInt(Inst.Ref.ref_start_index);
pub fn indexToRef(inst: Inst.Index) Inst.Ref { pub fn indexToRef(inst: Inst.Index) Inst.Ref {
return @intToEnum(Inst.Ref, ref_start_index + inst); return @intToEnum(Inst.Ref, ref_start_index + inst);