diff --git a/compiler/nir/nirtypes.nim b/compiler/nir/nirtypes.nim index d6c876d394..5c0d3c537a 100644 --- a/compiler/nir/nirtypes.nim +++ b/compiler/nir/nirtypes.nim @@ -15,6 +15,7 @@ import .. / ic / bitabs type NirTypeKind* = enum VoidTy, IntTy, UIntTy, FloatTy, BoolTy, CharTy, NameVal, IntVal, + AnnotationVal, VarargsTy, # the `...` in a C prototype; also the last "atom" APtrTy, # pointer to aliasable memory UPtrTy, # pointer to unique/unaliasable memory @@ -216,6 +217,9 @@ proc addArrayLen*(g: var TypeGraph; len: uint64) = proc addName*(g: var TypeGraph; name: string) = g.nodes.add TypeNode(x: toX(NameVal, g.names.getOrIncl(name))) +proc addAnnotation*(g: var TypeGraph; name: string) = + g.nodes.add TypeNode(x: toX(NameVal, g.names.getOrIncl(name))) + proc addField*(g: var TypeGraph; name: string; typ: TypeId) = let f = g.openType FieldDecl g.addType typ @@ -240,7 +244,7 @@ proc toString*(dest: var string; g: TypeGraph; i: TypeId) = of CharTy: dest.add "c" dest.addInt g[i].operand - of NameVal: + of NameVal, AnnotationVal: dest.add g.names[LitId g[i].operand] of IntVal: dest.add $g.numbers[LitId g[i].operand] diff --git a/compiler/nir/types2ir.nim b/compiler/nir/types2ir.nim index b6486f3702..b1742e9e59 100644 --- a/compiler/nir/types2ir.nim +++ b/compiler/nir/types2ir.nim @@ -29,7 +29,7 @@ template cached(c: var Context; t: PType; body: untyped) = proc typeToIr*(c: var Context; t: PType): TypeId -proc collectFieldTypes(c: var Context; n: PNode; dest: var seq[TypeId]) = +proc collectFieldTypes(c: var Context; n: PNode; dest: var Table[ItemId, TypeId]) = case n.kind of nkRecList: for i in 0..