macros: distinct literals (#235)

This commit is contained in:
Jacek Sieka 2024-09-27 17:36:35 +02:00 committed by GitHub
parent 9501d3d60c
commit b7b5969557
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import import
std/[macros, tables, hashes] std/[hashes, macros, tables, typetraits]
export export
macros macros
@ -395,6 +395,11 @@ proc newLitFixed*(arg: tuple): NimNode {.compileTime.} =
for a,b in arg.fieldPairs: for a,b in arg.fieldPairs:
result.add nnkExprColonExpr.newTree(newIdentNode(a), newLitFixed(b)) result.add nnkExprColonExpr.newTree(newIdentNode(a), newLitFixed(b))
proc newLitFixed*(arg: distinct): NimNode {.compileTime.} =
result = newLitFixed distinctBase(arg)
var typ = getTypeInst(typeof(arg))[1]
result = newCall(typ,result)
iterator typedParams*(n: NimNode, skip = 0): (NimNode, NimNode) = iterator typedParams*(n: NimNode, skip = 0): (NimNode, NimNode) =
let params = n[3] let params = n[3]
for i in (1 + skip) ..< params.len: for i in (1 + skip) ..< params.len: