Implement isExported for symbols in macros (#11963)
* Implement isExported for macros * Reimplement isExported using VM callback mechanism * VM does not support exceptions, use stacktrace() instead.
This commit is contained in:
parent
7cb31455ee
commit
d5840e1e3d
3 changed files with 23 additions and 1 deletions
|
|
@ -146,5 +146,14 @@ proc registerAdditionalOps*(c: PCtx) =
|
|||
|
||||
registerCallback c, "stdlib.macros.symBodyHash", proc (a: VmArgs) {.nimcall.} =
|
||||
let n = getNode(a, 0)
|
||||
if n.kind != nkSym: raise newException(ValueError, "node is not a symbol")
|
||||
if n.kind != nkSym:
|
||||
stackTrace(c, PStackFrame(prc: c.prc.sym, comesFrom: 0, next: nil), c.exceptionInstr,
|
||||
"symBodyHash() requires a symbol. '" & $n & "' is of kind '" & $n.kind & "'", n.info)
|
||||
setResult(a, $symBodyDigest(c.graph, n.sym))
|
||||
|
||||
registerCallback c, "stdlib.macros.isExported", proc(a: VmArgs) {.nimcall.} =
|
||||
let n = getNode(a, 0)
|
||||
if n.kind != nkSym:
|
||||
stackTrace(c, PStackFrame(prc: c.prc.sym, comesFrom: 0, next: nil), c.exceptionInstr,
|
||||
"isExported() requires a symbol. '" & $n & "' is of kind '" & $n.kind & "'", n.info)
|
||||
setResult(a, sfExported in n.sym.flags)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue