summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cgen.nim2
-rw-r--r--compiler/evals.nim19
-rw-r--r--compiler/extccomp.nim8
-rw-r--r--compiler/nimrod.ini12
-rw-r--r--compiler/options.nim14
-rw-r--r--compiler/parser.nim2
-rw-r--r--compiler/rodread.nim2
-rw-r--r--compiler/rodwrite.nim3
-rw-r--r--compiler/vm.nim2
9 files changed, 44 insertions, 20 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index f33de9df0..c82c3887c 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -1210,7 +1210,7 @@ proc writeHeader(m: BModule) =
   writeRope(result, m.filename)
 
 proc getCFile(m: BModule): string =
-  result = changeFileExt(completeCFilePath(m.cfilename), cExt)
+  result = changeFileExt(completeCFilePath(m.cfilename.withPackageName), cExt)
 
 proc myOpenCached(module: PSym, rd: PRodReader): PPassContext =
   assert optSymbolFiles in gGlobalOptions
diff --git a/compiler/evals.nim b/compiler/evals.nim
index f8336fce7..7e2c8a41d 100644
--- a/compiler/evals.nim
+++ b/compiler/evals.nim
@@ -162,10 +162,11 @@ var
   gNestedEvals: int  # count the recursive calls to ``evalAux`` to prevent
                      # endless recursion
 
-proc evalWhile(c: PEvalContext, n: PNode): PNode = 
-  while true: 
+proc evalWhile(c: PEvalContext, n: PNode): PNode =
+  while true:
     evalX(n.sons[0], {})
-    if getOrdValue(result) == 0: break
+    if getOrdValue(result) == 0:
+      result = emptyNode; break
     result = evalAux(c, n.sons[1], {})
     case result.kind
     of nkBreakStmt: 
@@ -304,7 +305,7 @@ proc allocSlot(c: PStackFrame; sym: PSym): int =
   setLen(c.slots, max(result+1, c.slots.len))
 
 proc setSlot(c: PStackFrame, sym: PSym, val: PNode) =
-  assert sym.owner == c.prc
+  assert sym.owner == c.prc or sfFromGeneric in sym.flags
   let idx = allocSlot(c, sym)
   c.slots[idx] = val
 
@@ -377,7 +378,7 @@ proc evalVariable(c: PStackFrame, sym: PSym, flags: TEvalFlags): PNode =
   #result = emptyNode
 
 proc evalGlobalVar(c: PEvalContext, s: PSym, flags: TEvalFlags): PNode =
-  if sfCompileTime in s.flags or c.mode == emRepl:
+  if sfCompileTime in s.flags or c.mode == emRepl or s.kind == skForVar:
     result = IdNodeTableGet(c.globals, s)
     if result != nil: 
       if not aliasNeeded(result, flags): 
@@ -549,7 +550,9 @@ proc evalSym(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
   of skProc, skConverter, skMacro, skType:
     result = n
     #result = s.getBody
-  of skVar, skLet, skForVar, skTemp, skResult:
+  of skForVar:
+    result = evalGlobalVar(c, s, flags)
+  of skVar, skLet, skTemp, skResult:
     if sfGlobal notin s.flags:
       result = evalVariable(c.tos, s, flags)
     else:
@@ -1396,7 +1399,7 @@ proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
   of nkChckRangeF, nkChckRange64, nkChckRange: result = evalRangeChck(c, n)
   of nkStringToCString: result = evalConvStrToCStr(c, n)
   of nkCStringToString: result = evalConvCStrToStr(c, n)
-  of nkStmtListExpr, nkStmtList, nkModule: 
+  of nkStmtListExpr, nkStmtList: 
     for i in countup(0, sonsLen(n) - 1): 
       result = evalAux(c, n.sons[i], flags)
       case result.kind
@@ -1455,7 +1458,7 @@ proc evalConstExprAux*(p: PEvalContext, module, prc: PSym, e: PNode): PNode =
 
 proc setupMacroParam(x: PNode): PNode =
   result = x
-  if result.kind == nkHiddenStdConv: result = result.sons[1]
+  if result.kind in {nkHiddenSubConv, nkHiddenStdConv}: result = result.sons[1]
 
 proc evalMacroCall(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode =
   # XXX GlobalError() is ugly here, but I don't know a better solution for now
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 488ed18fb..89524bc53 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -298,13 +298,13 @@ const
     gpp()]
 
 const
-  hExt* = "h"
+  hExt* = ".h"
 
 var
   cCompiler* = ccGcc # the used compiler
 
-  cExt* = "c" # extension of generated C/C++ files
-              # (can be changed to .cpp later)
+  cExt* = ".c" # extension of generated C/C++ files
+               # (can be changed to .cpp later)
   
   cIncludes*: seq[string] = @[]   # directories to search for included files
   cLibs*: seq[string] = @[]       # directories to search for lib files
@@ -518,7 +518,7 @@ proc footprint(filename: string): TCrc32 =
       getCompileCFileCmd(filename, true)
 
 proc externalFileChanged(filename: string): bool = 
-  var crcFile = toGeneratedFile(filename, "crc")
+  var crcFile = toGeneratedFile(filename.withPackageName, "crc")
   var currentCrc = int(footprint(filename))
   var f: TFile
   if open(f, crcFile, fmRead): 
diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini
index 22623993c..0dc44a7c9 100644
--- a/compiler/nimrod.ini
+++ b/compiler/nimrod.ini
@@ -1,8 +1,16 @@
 [Project]
 Name: "Nimrod"
 Version: "$version"
-OS: "windows;linux;macosx;solaris;freebsd;netbsd;openbsd"
-CPU: "i386;amd64;powerpc64;arm"  # ;sparc
+Platforms: """
+  windows: i386;amd64
+  linux: i386;amd64;powerpc64;arm;sparc;mips
+  macosx: i386;amd64;powerpc64
+  solaris: i386;amd64;sparc
+  freebsd: i386;amd64
+  netbsd: i386;amd64
+  openbsd: i386;amd64
+  haiku: i386;amd64
+"""
 
 Authors: "Andreas Rumpf"
 Description: """This is the Nimrod Compiler. Nimrod is a new statically typed,
diff --git a/compiler/options.nim b/compiler/options.nim
index 3c91d4439..e50535b8e 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -208,7 +208,19 @@ proc removeTrailingDirSep*(path: string): string =
 proc getGeneratedPath: string =
   result = if nimcacheDir.len > 0: nimcacheDir else: gProjectPath.shortenDir /
                                                          genSubDir
-  
+
+proc withPackageName*(path: string): string =
+  var x = path
+  while true:
+    x = parentDir(x)
+    if x.len == 0: break
+    case x.normalize
+    of "lib", "src", "source", "package", "pckg", "library": discard
+    else:
+      let (path, file, ext) = path.splitFile
+      return (path / (x & '_' & file)) & ext
+  result = path
+
 proc toGeneratedFile*(path, ext: string): string = 
   ## converts "/home/a/mymodule.nim", "rod" to "/home/a/nimcache/mymodule.rod"
   var (head, tail) = splitPath(path)
diff --git a/compiler/parser.nim b/compiler/parser.nim
index a2fe34849..6e2d0867b 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -1440,7 +1440,7 @@ proc parseSection(p: var TParser, kind: TNodeKind,
       skipComment(p, result)
       while sameInd(p):
         case p.tok.tokType
-        of tkSymbol, tkAccent: 
+        of tkSymbol, tkAccent, tkParLe: 
           var a = defparser(p)
           skipComment(p, a)
           addSon(result, a)
diff --git a/compiler/rodread.nim b/compiler/rodread.nim
index 562eaebab..a2ec2b4af 100644
--- a/compiler/rodread.nim
+++ b/compiler/rodread.nim
@@ -818,7 +818,7 @@ proc checkDep(fileIdx: int32): TReasonForRecompile =
   gMods[fileIdx].reason = rrNone  # we need to set it here to avoid cycles
   result = rrNone
   var r: PRodReader = nil
-  var rodfile = toGeneratedFile(filename, RodExt)
+  var rodfile = toGeneratedFile(filename.withPackageName, RodExt)
   r = newRodReader(rodfile, crc, fileIdx)
   if r == nil: 
     result = (if ExistsFile(rodfile): rrRodInvalid else: rrRodDoesNotExist)
diff --git a/compiler/rodwrite.nim b/compiler/rodwrite.nim
index 496fa49cf..34e890fd9 100644
--- a/compiler/rodwrite.nim
+++ b/compiler/rodwrite.nim
@@ -421,7 +421,8 @@ proc addStmt(w: PRodWriter, n: PNode) =
 proc writeRod(w: PRodWriter) = 
   processStacks(w, true)
   var f: TFile
-  if not open(f, completeGeneratedFilePath(changeFileExt(w.filename, "rod")),
+  if not open(f, completeGeneratedFilePath(changeFileExt(
+                      w.filename.withPackageName, RodExt)),
               fmWrite):
     #echo "couldn't write rod file for: ", w.filename
     return
diff --git a/compiler/vm.nim b/compiler/vm.nim
index e13d91e77..d5a816e53 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -890,7 +890,7 @@ proc evalStaticExpr*(module: PSym, e: PNode, prc: PSym): PNode =
 
 proc setupMacroParam(x: PNode): PNode =
   result = x
-  if result.kind == nkHiddenStdConv: result = result.sons[1]
+  if result.kind in {nkHiddenSubConv, nkHiddenStdConv}: result = result.sons[1]
 
 proc evalMacroCall(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode =
   # XXX GlobalError() is ugly here, but I don't know a better solution for now