-
-
Save zacharycarter/e43526242ae2b5e28ec4d53e07817a9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc handleSetSeq(oId: NimNode, pnId: NimNode, sId: NimNode, name: string, dtype: NimNode): NimNode = | |
let | |
seqKind = dtype.nodeToVal().strVal | |
fieldName = ident(name) | |
eceId = ident"e" | |
bnId = ident"b" | |
result = quote do: | |
var `eceId` = nkExprColonExpr.newTree( | |
newSymNode(`sId`), | |
) | |
var `bnId` = nkBracket.newTree() | |
for val in `oid`.`fieldName`: | |
case `seqKind` | |
of "floatVal": | |
`bnId`.add nkFloatLit.newFloatNode(parseFloat(val)) | |
`eceId`.add `bnId` | |
of "intVal": | |
`bnId`.add nkIntLit.newIntNode(parseInt(val)) | |
`eceId`.add `bnId` | |
of "strVal": | |
`bnId`.add nkStrLit.newStrNode(val) | |
`eceId`.add `bnId` | |
else: | |
discard | |
`pnId`.add `eceId` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment