summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2015-10-13 15:25:40 -0700
committerAman Gupta <aman@tmm1.net>2015-10-13 15:25:40 -0700
commite2dbf222e60e00eb3f321151f4f206ed9c606a6c (patch)
treec513c0051fcb789add33cd3daaaab42344ee1da4 /compiler
parentc3415a27d77f302be4f41d5f9bbcdf7c0dd3e80a (diff)
parent7f4f37eaa20ea8aa5cf8c34e497aaa8245c590b3 (diff)
downloadNim-e2dbf222e60e00eb3f321151f4f206ed9c606a6c.tar.gz
Merge remote-tracking branch 'origin/devel' into appveyor
Diffstat (limited to 'compiler')
-rw-r--r--compiler/docgen.nim2
-rw-r--r--compiler/importer.nim4
-rw-r--r--compiler/main.nim2
-rw-r--r--compiler/nimblecmd.nim2
-rw-r--r--compiler/options.nim6
-rw-r--r--compiler/rodread.nim6
-rw-r--r--compiler/suggest.nim6
-rw-r--r--compiler/transf.nim4
-rw-r--r--compiler/vmhooks.nim8
-rw-r--r--compiler/vmmarshal.nim2
10 files changed, 29 insertions, 13 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 4b52b1c92..8ae32492a 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -75,7 +75,7 @@ proc newDocumentor*(filename: string, config: StringTableRef): PDoc =
   ga('send', 'pageview');
 
 </script>
-    """ % [config["doc.googleAnalytics"]]
+    """ % [config.getOrDefault"doc.googleAnalytics"]
   else:
     result.analytics = ""
 
diff --git a/compiler/importer.nim b/compiler/importer.nim
index d619725db..c121059fd 100644
--- a/compiler/importer.nim
+++ b/compiler/importer.nim
@@ -121,7 +121,7 @@ proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) =
       if s.kind != skEnumField:
         if s.kind notin ExportableSymKinds:
           internalError(s.info, "importAllSymbols: " & $s.kind)
-        if exceptSet.empty or s.name.id notin exceptSet:
+        if exceptSet.isNil or s.name.id notin exceptSet:
           rawImportSymbol(c, s)
     s = nextIter(i, fromMod.tab)
 
@@ -138,7 +138,7 @@ proc importForwarded(c: PContext, n: PNode, exceptSet: IntSet) =
       let s = a.sym
       if s.kind == skModule:
         importAllSymbolsExcept(c, s, exceptSet)
-      elif exceptSet.empty or s.name.id notin exceptSet:
+      elif exceptSet.isNil or s.name.id notin exceptSet:
         rawImportSymbol(c, s)
   of nkExportExceptStmt:
     localError(n.info, errGenerated, "'export except' not implemented")
diff --git a/compiler/main.nim b/compiler/main.nim
index 3bb6fc343..2ee07a443 100644
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -15,7 +15,7 @@ import
   wordrecg, sem, semdata, idents, passes, docgen, extccomp,
   cgen, jsgen, json, nversion,
   platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
-  tables, docgen2, service, parser, modules, ccgutils, sigmatch, ropes, lists
+  docgen2, service, parser, modules, ccgutils, sigmatch, ropes, lists
 
 from magicsys import systemModule, resetSysTypes
 
diff --git a/compiler/nimblecmd.nim b/compiler/nimblecmd.nim
index 9b647e67d..c6c2ab058 100644
--- a/compiler/nimblecmd.nim
+++ b/compiler/nimblecmd.nim
@@ -48,7 +48,7 @@ proc addPackage(packages: StringTableRef, p: string) =
   let name = p.substr(0, x-1)
   if x < p.len:
     let version = p.substr(x+1)
-    if packages[name] <. version:
+    if packages.getOrDefault(name) <. version:
       packages[name] = version
   else:
     packages[name] = latest
diff --git a/compiler/options.nim b/compiler/options.nim
index adb340fea..98224a11d 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -86,7 +86,7 @@ type                          # please make sure we have under 32 options
     gcNone, gcBoehm, gcGo, gcMarkAndSweep, gcRefc, gcV2, gcGenerational
 
   IdeCmd* = enum
-    ideNone, ideSug, ideCon, ideDef, ideUse
+    ideNone, ideSug, ideCon, ideDef, ideUse, ideDus
 
 var
   gIdeCmd*: IdeCmd
@@ -173,7 +173,7 @@ proc existsConfigVar*(key: string): bool =
   result = hasKey(gConfigVars, key)
 
 proc getConfigVar*(key: string): string =
-  result = gConfigVars[key]
+  result = gConfigVars.getOrDefault key
 
 proc setConfigVar*(key, val: string) =
   gConfigVars[key] = val
@@ -421,6 +421,7 @@ proc parseIdeCmd*(s: string): IdeCmd =
   of "con": ideCon
   of "def": ideDef
   of "use": ideUse
+  of "dus": ideDus
   else: ideNone
 
 proc `$`*(c: IdeCmd): string =
@@ -429,4 +430,5 @@ proc `$`*(c: IdeCmd): string =
   of ideCon: "con"
   of ideDef: "def"
   of ideUse: "use"
+  of ideDus: "dus"
   of ideNone: "none"
diff --git a/compiler/rodread.nim b/compiler/rodread.nim
index e4530c2cc..2a85c8975 100644
--- a/compiler/rodread.nim
+++ b/compiler/rodread.nim
@@ -372,7 +372,7 @@ proc decodeSym(r: PRodReader, info: TLineInfo): PSym =
   else:
     internalError(info, "decodeSym: no ident")
   #echo "decoding: {", ident.s
-  result = r.syms[id]
+  result = r.syms.getOrDefault(id)
   if result == nil:
     new(result)
     result.id = id
@@ -491,7 +491,7 @@ proc processCompilerProcs(r: PRodReader, module: PSym) =
     inc(r.pos)
     var key = decodeVInt(r.s, r.pos)
     inc(r.pos)                # #10
-    var s = r.syms[key]
+    var s = r.syms.getOrDefault(key)
     if s == nil:
       s = newStub(r, w, key)
       s.owner = module
@@ -737,7 +737,7 @@ proc getReader(moduleId: int): PRodReader =
   return nil
 
 proc rrGetSym(r: PRodReader, id: int, info: TLineInfo): PSym =
-  result = r.syms[id]
+  result = r.syms.getOrDefault(id)
   if result == nil:
     # load the symbol:
     var d = iiTableGet(r.index.tab, id)
diff --git a/compiler/suggest.nim b/compiler/suggest.nim
index ed21aa4ea..18d723315 100644
--- a/compiler/suggest.nim
+++ b/compiler/suggest.nim
@@ -309,6 +309,10 @@ proc suggestSym*(info: TLineInfo; s: PSym) {.inline.} =
     findUsages(info, s)
   elif gIdeCmd == ideDef:
     findDefinition(info, s)
+  elif gIdeCmd == ideDus and s != nil:
+    if isTracked(info, s.name.s.len):
+      suggestResult(symToSuggest(s, isLocal=false, $ideDef))
+    findUsages(info, s)
 
 proc markUsed(info: TLineInfo; s: PSym) =
   incl(s.flags, sfUsed)
@@ -366,7 +370,7 @@ proc suggestExpr*(c: PContext, node: PNode) =
       suggestCall(c, a, n, outputs)
 
   dec(c.compilesContextId)
-  if outputs > 0 and gIdeCmd != ideUse: suggestQuit()
+  if outputs > 0 and gIdeCmd notin {ideUse, ideDus}: suggestQuit()
 
 proc suggestStmt*(c: PContext, n: PNode) =
   suggestExpr(c, n)
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 0ea9f7d80..92319ac19 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -825,11 +825,13 @@ proc flattenStmts(n: PNode) =
   var goOn = true
   while goOn:
     goOn = false
-    for i in 0..<n.len:
+    var i = 0
+    while i < n.len:
       let it = n[i]
       if it.kind in {nkStmtList, nkStmtListExpr}:
         n.sons[i..i] = it.sons[0..<it.len]
         goOn = true
+      inc i
 
 proc liftDeferAux(n: PNode) =
   if n.kind in {nkStmtList, nkStmtListExpr}:
diff --git a/compiler/vmhooks.nim b/compiler/vmhooks.nim
index 5dd27feda..576b0565f 100644
--- a/compiler/vmhooks.nim
+++ b/compiler/vmhooks.nim
@@ -30,6 +30,14 @@ proc setResult*(a: VmArgs; v: string) =
   s[a.ra].node = newNode(nkStrLit)
   s[a.ra].node.strVal = v
 
+proc setResult*(a: VmArgs; n: PNode) =
+  var s: seq[TFullReg]
+  move(s, cast[seq[TFullReg]](a.slots))
+  if s[a.ra].kind != rkNode:
+    myreset(s[a.ra])
+    s[a.ra].kind = rkNode
+  s[a.ra].node = n
+
 proc setResult*(a: VmArgs; v: seq[string]) =
   var s: seq[TFullReg]
   move(s, cast[seq[TFullReg]](a.slots))
diff --git a/compiler/vmmarshal.nim b/compiler/vmmarshal.nim
index 1670dd4c4..c08c5d249 100644
--- a/compiler/vmmarshal.nim
+++ b/compiler/vmmarshal.nim
@@ -239,7 +239,7 @@ proc loadAny(p: var JsonParser, t: PType,
       result = newNode(nkNilLit)
       next(p)
     of jsonInt:
-      result = tab[p.getInt]
+      result = tab.getOrDefault(p.getInt)
       if result.isNil:
         raiseParseErr(p, "cannot load object with address " & $p.getInt)
       next(p)