diff options
author | Araq <rumpf_a@web.de> | 2013-12-23 20:12:13 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-12-23 20:12:13 +0100 |
commit | 32ef1f8f323044c0d92f1beef396ce3223a96231 (patch) | |
tree | 3cc51a89964ec655b6edecad581881bb47a3954b /compiler | |
parent | 4447c1b7e323443a26189140410814195eee18a9 (diff) | |
download | Nim-32ef1f8f323044c0d92f1beef396ce3223a96231.tar.gz |
vm: FFI improvements
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/evalffi.nim | 3 | ||||
-rw-r--r-- | compiler/vmgen.nim | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim index f2337f7ce..3b8ce0505 100644 --- a/compiler/evalffi.nim +++ b/compiler/evalffi.nim @@ -41,6 +41,8 @@ proc getDll(cache: var TDllCache; dll: string; info: TLineInfo): pointer = const nkPtrLit = nkIntLit # hopefully we can get rid of this hack soon +var myerrno {.importc: "errno", header: "<errno.h>".}: cint ## error variable + proc importcSymbol*(sym: PSym): PNode = let name = ropeToStr(sym.loc.r) @@ -51,6 +53,7 @@ proc importcSymbol*(sym: PSym): PNode = of "stdin": result.intVal = cast[TAddress](system.stdin) of "stdout": result.intVal = cast[TAddress](system.stdout) of "stderr": result.intVal = cast[TAddress](system.stderr) + of "vmErrnoWrapper": result.intVal = cast[TAddress](myerrno) else: let lib = sym.annex if lib != nil and lib.path.kind notin {nkStrLit..nkTripleStrLit}: diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 486d24e6c..ab120f008 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -945,10 +945,7 @@ proc genTypeLit(c: PCtx; t: PType; dest: var TDest) = proc importcSym(c: PCtx; info: TLineInfo; s: PSym) = when hasFFI: if allowFFI in c.features: - if s.kind == skVar and lfNoDecl in s.loc.flags: - c.globals.add(copyNode(emptyNode)) - else: - c.globals.add(importcSymbol(s)) + c.globals.add(importcSymbol(s)) s.position = c.globals.len else: localError(info, errGenerated, "VM is not allowed to 'importc'") |