summary refs log tree commit diff stats
path: root/compiler/evals.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-12-19 08:44:20 +0100
committerAraq <rumpf_a@web.de>2012-12-19 08:44:20 +0100
commitc73d9fdd4c5d216b75ae4dc7659ea6c19c13ad15 (patch)
tree51f44d636986f33b40aaeb88247485a036d54642 /compiler/evals.nim
parent3e514cd5dc1f95561be4fa39bf4881fb40be9529 (diff)
downloadNim-c73d9fdd4c5d216b75ae4dc7659ea6c19c13ad15.tar.gz
small examples work with the FFI
Diffstat (limited to 'compiler/evals.nim')
-rwxr-xr-xcompiler/evals.nim17
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/evals.nim b/compiler/evals.nim
index 535d9aebd..ab6218be0 100755
--- a/compiler/evals.nim
+++ b/compiler/evals.nim
@@ -339,16 +339,15 @@ proc evalGlobalVar(c: PEvalContext, s: PSym, flags: TEvalFlags): PNode =
       if not aliasNeeded(result, flags): 
         result = copyTree(result)
     else:
+      when hasFFI:
+        if sfImportc in s.flags:
+          result = importcSymbol(s)
+          IdNodeTablePut(c.globals, s, result)
+          return result
+      
       result = s.ast
       if result == nil or result.kind == nkEmpty:
-        when hasFFI:
-          # for 'stdin' etc. we need to support 'importc' for variables:
-          if sfImportc in s.flags:
-            result = importcSymbol(s)
-          else:
-            result = getNullValue(s.typ, s.info)
-        else:
-          result = getNullValue(s.typ, s.info)
+        result = getNullValue(s.typ, s.info)
       else:
         result = evalAux(c, result, {})
         if isSpecial(result): return
@@ -392,7 +391,7 @@ proc evalCall(c: PEvalContext, n: PNode): PNode =
       var newCall = newNodeI(nkCall, n.info, n.len)
       newCall.sons[0] = evalGlobalVar(c, prc.sym, {})
       for i in 1 .. <n.len:
-        newCall.sons[i] = d.params[i-1]
+        newCall.sons[i] = d.params[i]
       return callForeignFunction(newCall)
   
   pushStackFrame(c, d)
an class="n">y, z var en: E en = a