package iskra // NodeKind classifies code constructs as a bitfield. type NodeKind uint16 const ( KindUnknown NodeKind = 0 KindPkg NodeKind = 1 << 0 KindImport NodeKind = 1 << 1 KindConst NodeKind = 1 << 2 KindVar NodeKind = 1 << 3 KindType NodeKind = 1 << 4 KindFunc NodeKind = 1 << 5 KindMethod NodeKind = 1 << 6 KindField NodeKind = 1 << 7 KindStmt NodeKind = 1 << 8 KindExpr NodeKind = 1 << 9 KindControl NodeKind = 1 << 10 KindLiteral NodeKind = 1 << 11 ) func (k NodeKind) Has(tag NodeKind) bool { return k&tag != 0 } func (k NodeKind) IsKnown() bool { return k != KindUnknown } // MetaEntry is per-record semantic metadata, indexed by record index in Tree.RecMeta. // AdjCount/AdjOffset removed: cross-stage adjacency is key-implicit (same hash, // different stage prefix); cross-branch adjacency is in Record.Link[2]. // // Extra layout: // [0:4] TritPath (uint32) // [4] low nibble: Rotation // [5:8] signature hash (24-bit, fast rejection) // [8:12] ContentOffset into Tree.TokenPool // [12:16] ContentLen (token count) type MetaEntry struct { Count uint32 Kind NodeKind StageTag uint8 _pad [9]byte Extra [16]byte } func (m *MetaEntry) ContentOffset() uint32 { return uint32(m.Extra[8]) | uint32(m.Extra[9])<<8 | uint32(m.Extra[10])<<16 | uint32(m.Extra[11])<<24 } func (m *MetaEntry) ContentLen() uint32 { return uint32(m.Extra[12]) | uint32(m.Extra[13])<<8 | uint32(m.Extra[14])<<16 | uint32(m.Extra[15])<<24 } func (m *MetaEntry) SetContentRef(offset, length uint32) { m.Extra[8] = byte(offset) m.Extra[9] = byte(offset >> 8) m.Extra[10] = byte(offset >> 16) m.Extra[11] = byte(offset >> 24) m.Extra[12] = byte(length) m.Extra[13] = byte(length >> 8) m.Extra[14] = byte(length >> 16) m.Extra[15] = byte(length >> 24) } func (m *MetaEntry) SigHash() uint32 { return uint32(m.Extra[5]) | uint32(m.Extra[6])<<8 | uint32(m.Extra[7])<<16 } func (m *MetaEntry) SetSigHash(h uint32) { m.Extra[5] = byte(h) m.Extra[6] = byte(h >> 8) m.Extra[7] = byte(h >> 16) }