diff options
author | nc-x <neelesh.chandola@outlook.com> | 2019-08-18 15:21:28 +0530 |
---|---|---|
committer | Arne Döring <arne.doering@gmx.net> | 2019-08-18 11:51:28 +0200 |
commit | d5840e1e3d186a3b54859f3b1609b96975748372 (patch) | |
tree | a7dde3b2e34536c80521d5fb14e72c4635a54985 /compiler | |
parent | 7cb31455ee949ee006e2f314daa74866cf37a74e (diff) | |
download | Nim-d5840e1e3d186a3b54859f3b1609b96975748372.tar.gz |
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.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/vmops.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/vmops.nim b/compiler/vmops.nim index 5087dabfa..792feb0be 100644 --- a/compiler/vmops.nim +++ b/compiler/vmops.nim @@ -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) |