From 32ef1f8f323044c0d92f1beef396ce3223a96231 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 23 Dec 2013 20:12:13 +0100 Subject: vm: FFI improvements --- compiler/evalffi.nim | 3 +++ compiler/vmgen.nim | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler') 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: "".}: 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'") -- cgit 1.4.1-2-gfad0