summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-01-05 00:11:29 -0800
committerAndreas Rumpf <rumpf_a@web.de>2020-01-05 09:11:29 +0100
commit13c08f3ab4db3cc7b162af383a74c4fc09f0c378 (patch)
tree017f361f1c260fbcacf0e9840f11ae5cc86192ce /compiler/pragmas.nim
parenta1beeb313fee19b4c9720ca68fde534e2ef587fe (diff)
downloadNim-13c08f3ab4db3cc7b162af383a74c4fc09f0c378.tar.gz
VM: support importc var, ptr/pointer types, cast int <=> ptr/pointer (#12877)
* VM: allow certain hardcoded special var variables at CT
* VM: allow all importc var, cast[int](ptr)
* fix tests tests/vm/tstaticprintseq.nim, tests/cpp/t8241.nim
* VM: == works for ptr/pointer nodes
* bugfix: ==, cast now also works for pointer, not just ptr
* VM supports cast PtrLikeKinds <=> PtrLikeKinds / int
* improve cname handling
* fixup + bug fix
* VM: support cast from ref to int
* address comment: opcLdGlobalDeref => opcLdGlobalDerefFFI
* defensive check against typ == nil
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r--compiler/pragmas.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index 726402bb4..1802493f4 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -129,6 +129,8 @@ proc setExternName(c: PContext; s: PSym, extname: string, info: TLineInfo) =
       s.loc.r = rope(extname % s.name.s)
     except ValueError:
       localError(c.config, info, "invalid extern name: '" & extname & "'. (Forgot to escape '$'?)")
+  when hasFFI:
+    s.cname = $s.loc.r
   if c.config.cmd == cmdPretty and '$' notin extname:
     # note that '{.importc.}' is transformed into '{.importc: "$1".}'
     s.loc.flags.incl(lfFullExternalName)