summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorrumpf_a@web.de <>2009-12-19 18:15:49 +0100
committerrumpf_a@web.de <>2009-12-19 18:15:49 +0100
commit8ce705f6860169b6b0c6db94db38ba25f4f1965f (patch)
tree3927687f72c4bfcb3a149c3b9914b65085a61736
parent10ab814fbae0a54151028efd42ee9f806cc6bacd (diff)
downloadNim-8ce705f6860169b6b0c6db94db38ba25f4f1965f.tar.gz
got rid of platdef.c generation
-rwxr-xr-xkoch.nim10
-rw-r--r--[-rwxr-xr-x]rod/ast.nim21
-rw-r--r--[-rwxr-xr-x]rod/ccgexprs.nim0
-rw-r--r--[-rwxr-xr-x]rod/cgen.nim0
-rw-r--r--[-rwxr-xr-x]rod/condsyms.nim0
-rwxr-xr-xrod/docgen.nim6
-rw-r--r--[-rwxr-xr-x]rod/evals.nim0
-rwxr-xr-xrod/expand_importc.nim23
-rwxr-xr-xrod/expandimportc.nim58
-rwxr-xr-xrod/nhashes.nim11
-rwxr-xr-xrod/nimrod.cfg1
-rwxr-xr-xrod/nimrod.dot73
-rw-r--r--[-rwxr-xr-x]rod/nimrod.nim0
-rwxr-xr-xrod/nstrtabs.nim45
-rw-r--r--[-rwxr-xr-x]rod/options.nim0
-rw-r--r--[-rwxr-xr-x]rod/pbraces.nim0
-rwxr-xr-xrod/platform.nim11
-rw-r--r--[-rwxr-xr-x]rod/pnimsyn.nim0
-rw-r--r--[-rwxr-xr-x]rod/pragmas.nim0
-rw-r--r--[-rwxr-xr-x]rod/rodread.nim0
-rw-r--r--[-rwxr-xr-x]rod/rodwrite.nim0
-rwxr-xr-xrod/ropes.nim98
-rw-r--r--[-rwxr-xr-x]rod/sem.nim0
-rw-r--r--[-rwxr-xr-x]rod/semdata.nim0
-rw-r--r--[-rwxr-xr-x]rod/semfold.nim0
-rw-r--r--[-rwxr-xr-x]rod/transf.nim0
-rw-r--r--[-rwxr-xr-x]rod/trees.nim0
27 files changed, 184 insertions, 173 deletions
diff --git a/koch.nim b/koch.nim
index 02b0334b0..16efbb5ac 100755
--- a/koch.nim
+++ b/koch.nim
@@ -20,7 +20,7 @@ const
 Build time: $2, $3
 
 Usage:
-  koch.py [options] command [options for command]
+  koch [options] command [options for command]
 Options:
   --help, -h               shows this help and quits
 Possible Commands:
@@ -90,7 +90,7 @@ proc writePlatdefC =
     quit("Cannot write 'build/platdef.c'\n")
 
 const
-  bootOptions = "--compile:build/platdef.c"
+  bootOptions = "" # "--compile:build/platdef.c"
 
 proc findStartNimrod: string = 
   const buildScript = "build.sh"
@@ -118,16 +118,18 @@ proc findStartNimrod: string =
 
 proc bootIteration(args: string): bool = 
   var nimrod1 = "rod" / "nimrod1".exe
+  if not ExistsFile("rod" / "nimrod".exe):
+    quit("no binary has been created! Failed! Try with --forcebuild")
   moveFile nimrod1, "rod" / "nimrod".exe
   exec "rod" / "nimrod1 cc $# $# rod/nimrod.nim" % [bootOptions, args]
-  result = sameFileContent("rod" / "nimrod".exe, "rod" / "nimrod1".exe)
+  result = sameFileContent("rod" / "nimrod".exe, nimrod1)
   if result:
     moveFile "bin" / "nimrod".exe, "rod" / "nimrod".exe
     echo "executables are equal: SUCCESS!"
   removeFile nimrod1
 
 proc boot(args: string) =
-  writePlatdefC()
+  #writePlatdefC()
   echo "iteration: 1"
   exec findStartNimrod() & " cc $# $# rod" / "nimrod.nim" % [bootOptions, args]
   echo "iteration: 2"
diff --git a/rod/ast.nim b/rod/ast.nim
index 89fadf375..24ee4da5b 100755..100644
--- a/rod/ast.nim
+++ b/rod/ast.nim
@@ -845,14 +845,11 @@ proc sonsLen(n: PType): int =
   else: result = len(n.sons)
   
 proc newSons(father: PType, length: int) = 
-  var i, L: int
-  if isNil(father.sons): father.sons = @ []
-  L = len(father.sons)
-  setlen(father.sons, L + length)
+  if isNil(father.sons): father.sons = @[]
+  setlen(father.sons, len(father.sons) + length)
 
 proc addSon(father, son: PType) = 
-  var L: int
-  if isNil(father.sons): father.sons = @ []
+  if isNil(father.sons): father.sons = @[]
   add(father.sons, son)
   assert((father.kind != tyGenericInvokation) or (son.kind != tyGenericInst))
 
@@ -861,20 +858,16 @@ proc sonsLen(n: PNode): int =
   else: result = len(n.sons)
   
 proc newSons(father: PNode, length: int) = 
-  var i, L: int
-  if isNil(father.sons): father.sons = @ []
-  L = len(father.sons)
-  setlen(father.sons, L + length)
+  if isNil(father.sons): father.sons = @[]
+  setlen(father.sons, len(father.sons) + length)
 
 proc addSon(father, son: PNode) = 
-  var L: int
-  if isNil(father.sons): father.sons = @ []
+  if isNil(father.sons): father.sons = @[]
   add(father.sons, son)
 
 proc delSon(father: PNode, idx: int) = 
-  var length: int
   if isNil(father.sons): return 
-  length = sonsLen(father)
+  var length = sonsLen(father)
   for i in countup(idx, length - 2): father.sons[i] = father.sons[i + 1]
   setlen(father.sons, length - 1)
 
diff --git a/rod/ccgexprs.nim b/rod/ccgexprs.nim
index 905e3b115..905e3b115 100755..100644
--- a/rod/ccgexprs.nim
+++ b/rod/ccgexprs.nim
diff --git a/rod/cgen.nim b/rod/cgen.nim
index 1aaa56c81..1aaa56c81 100755..100644
--- a/rod/cgen.nim
+++ b/rod/cgen.nim
diff --git a/rod/condsyms.nim b/rod/condsyms.nim
index 0325a2b77..0325a2b77 100755..100644
--- a/rod/condsyms.nim
+++ b/rod/condsyms.nim
diff --git a/rod/docgen.nim b/rod/docgen.nim
index 66580149b..711848e5f 100755
--- a/rod/docgen.nim
+++ b/rod/docgen.nim
@@ -410,8 +410,7 @@ proc renderHeadline(d: PDoc, n: PRstNode): PRope =
         toRope(chr(n.level - 1 + ord('A')) & "")])
   
 proc renderOverline(d: PDoc, n: PRstNode): PRope = 
-  var t: PRope
-  t = nil
+  var t: PRope = nil
   for i in countup(0, rsonsLen(n) - 1): app(t, renderRstToOut(d, n.sons[i]))
   result = nil
   if d.meta[metaTitle] == nil: 
@@ -543,10 +542,9 @@ proc renderTocEntry(d: PDoc, e: TTocEntry): PRope =
                  "\\item\\label{$1_toc} $2\\ref{$1}$n", [e.refname, e.header])
 
 proc renderTocEntries(d: PDoc, j: var int, lvl: int): PRope = 
-  var a: int
   result = nil
   while (j <= high(d.tocPart)): 
-    a = abs(d.tocPart[j].n.level)
+    var a = abs(d.tocPart[j].n.level)
     if (a == lvl): 
       app(result, renderTocEntry(d, d.tocPart[j]))
       inc(j)
diff --git a/rod/evals.nim b/rod/evals.nim
index 4c7b1df9d..4c7b1df9d 100755..100644
--- a/rod/evals.nim
+++ b/rod/evals.nim
diff --git a/rod/expand_importc.nim b/rod/expand_importc.nim
deleted file mode 100755
index da233df0b..000000000
--- a/rod/expand_importc.nim
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-#
-#           The Nimrod Compiler
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Simple tool to expand ``importc`` pragmas. Used for the clean up process of
-## the diverse wrappers.
-
-import 
-  os, ropes, idents, ast, pnimsyn, rnimsyn
-  
-  times, commands, scanner, condsyms, options, msgs, nversion, nimconf, ropes, 
-  extccomp, strutils, os, platform, main, parseopt
-
-if paramcount() == 0:
-  echo ""
-
-
-
diff --git a/rod/expandimportc.nim b/rod/expandimportc.nim
new file mode 100755
index 000000000..82a0578ac
--- /dev/null
+++ b/rod/expandimportc.nim
@@ -0,0 +1,58 @@
+#
+#
+#           The Nimrod Compiler
+#        (c) Copyright 2009 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Simple tool to expand ``importc`` pragmas. Used for the clean up process of
+## the diverse wrappers.
+
+import 
+  os, ropes, idents, ast, pnimsyn, rnimsyn, msgs, wordrecg, syntaxes
+
+proc modifyPragmas(n: PNode, name: string) =
+  for i in countup(0, sonsLen(n) - 1): 
+    var it = n.sons[i]
+    if it.kind == nkIdent and whichKeyword(it.ident) == wImportc:
+      var x = newNode(nkExprColonExpr)
+      addSon(x, it)
+      addSon(x, newStrNode(nkStrLit, name))
+      n.sons[i] = x
+
+proc getName(n: PNode): string = 
+  case n.kind
+  of nkPostfix: result = getName(n.sons[1])
+  of nkPragmaExpr: result = getName(n.sons[0])
+  of nkSym: result = n.sym.name.s
+  of nkIdent: result = n.ident.s
+  of nkAccQuoted: result = getName(n.sons[0])
+  else: internalError(n.info, "getName()")
+
+proc processRoutine(n: PNode) =
+  var name = getName(n.sons[namePos])
+  modifyPragmas(n.sons[pragmasPos], name)
+  
+proc processTree(n: PNode) =
+  if n == nil: return
+  case n.kind
+  of nkEmpty..nkNilLit: nil
+  of nkProcDef, nkConverterDef: processRoutine(n)
+  else:
+    for i in 0..sonsLen(n)-1: processTree(n.sons[i])
+
+proc main(infile, outfile: string) =
+  var module = ParseFile(infile)
+  processTree(module)
+  renderModule(module, outfile)
+
+if paramcount() >= 1:
+  var infile = addFileExt(paramStr(1), "nim")
+  var outfile = changeFileExt(infile, "new.nim")
+  if paramCount() >= 2:
+    outfile = addFileExt(paramStr(2), "new.nim")
+  main(infile, outfile)
+else:
+  echo "usage: expand_importc filename[.nim] outfilename[.nim]"
diff --git a/rod/nhashes.nim b/rod/nhashes.nim
index 2c78dd44d..b9dd3670a 100755
--- a/rod/nhashes.nim
+++ b/rod/nhashes.nim
@@ -32,17 +32,6 @@ proc concHash*(h: THash, val: int): THash
 proc finishHash*(h: THash): THash
 # implementation
 
-proc nextPowerOfTwo(x: int): int = 
-  result = x -% 1 # complicated, to make it a nop if sizeof(int) == 4,
-                  # because shifting more than 31 bits is undefined in C
-  result = result or (result shr ((sizeof(int) - 4) * 8))
-  result = result or (result shr 16)
-  result = result or (result shr 8)
-  result = result or (result shr 4)
-  result = result or (result shr 2)
-  result = result or (result shr 1)
-  Inc(result)
-
 proc concHash(h: THash, val: int): THash = 
   result = h +% val
   result = result +% result shl 10
diff --git a/rod/nimrod.cfg b/rod/nimrod.cfg
index 0c286472b..51b675525 100755
--- a/rod/nimrod.cfg
+++ b/rod/nimrod.cfg
@@ -9,4 +9,3 @@
 @elif vcc:
   # cgen.speed = ""
 @end
-
diff --git a/rod/nimrod.dot b/rod/nimrod.dot
index 920944897..36429844f 100755
--- a/rod/nimrod.dot
+++ b/rod/nimrod.dot
@@ -15,7 +15,6 @@ options -> nstrtabs;
 msgs -> options;
 msgs -> strutils;
 msgs -> os;
-nversion -> strutils;
 crc -> strutils;
 platform -> strutils;
 ropes -> msgs;
@@ -52,6 +51,7 @@ hashes -> strutils;
 strtabs -> os;
 strtabs -> hashes;
 strtabs -> strutils;
+osproc -> strutils;
 osproc -> os;
 osproc -> strtabs;
 osproc -> streams;
@@ -108,6 +108,13 @@ pnimsyn -> idents;
 pnimsyn -> strutils;
 pnimsyn -> ast;
 pnimsyn -> msgs;
+pbraces -> llstream;
+pbraces -> scanner;
+pbraces -> idents;
+pbraces -> strutils;
+pbraces -> ast;
+pbraces -> msgs;
+pbraces -> pnimsyn;
 rnimsyn -> scanner;
 rnimsyn -> options;
 rnimsyn -> idents;
@@ -115,6 +122,40 @@ rnimsyn -> strutils;
 rnimsyn -> ast;
 rnimsyn -> msgs;
 rnimsyn -> lists;
+filters -> llstream;
+filters -> os;
+filters -> wordrecg;
+filters -> idents;
+filters -> strutils;
+filters -> ast;
+filters -> astalgo;
+filters -> msgs;
+filters -> options;
+filters -> rnimsyn;
+ptmplsyn -> llstream;
+ptmplsyn -> os;
+ptmplsyn -> wordrecg;
+ptmplsyn -> idents;
+ptmplsyn -> strutils;
+ptmplsyn -> ast;
+ptmplsyn -> astalgo;
+ptmplsyn -> msgs;
+ptmplsyn -> options;
+ptmplsyn -> rnimsyn;
+ptmplsyn -> filters;
+syntaxes -> strutils;
+syntaxes -> llstream;
+syntaxes -> ast;
+syntaxes -> astalgo;
+syntaxes -> idents;
+syntaxes -> scanner;
+syntaxes -> options;
+syntaxes -> msgs;
+syntaxes -> pnimsyn;
+syntaxes -> pbraces;
+syntaxes -> ptmplsyn;
+syntaxes -> filters;
+syntaxes -> rnimsyn;
 paslex -> nhashes;
 paslex -> options;
 paslex -> msgs;
@@ -194,7 +235,7 @@ passes -> math;
 passes -> magicsys;
 passes -> nversion;
 passes -> nimsets;
-passes -> pnimsyn;
+passes -> syntaxes;
 passes -> times;
 passes -> rodread;
 treetab -> nhashes;
@@ -302,6 +343,7 @@ procfind -> astalgo;
 procfind -> msgs;
 procfind -> semdata;
 procfind -> types;
+procfind -> trees;
 pragmas -> os;
 pragmas -> platform;
 pragmas -> condsyms;
@@ -319,7 +361,9 @@ pragmas -> lists;
 pragmas -> extccomp;
 pragmas -> math;
 pragmas -> magicsys;
+pragmas -> trees;
 sem -> strutils;
+sem -> nhashes;
 sem -> lists;
 sem -> options;
 sem -> scanner;
@@ -378,7 +422,7 @@ docgen -> ropes;
 docgen -> idents;
 docgen -> wordrecg;
 docgen -> math;
-docgen -> pnimsyn;
+docgen -> syntaxes;
 docgen -> rnimsyn;
 docgen -> scanner;
 docgen -> rst;
@@ -392,6 +436,14 @@ ccgutils -> nhashes;
 ccgutils -> strutils;
 ccgutils -> types;
 ccgutils -> msgs;
+cgmeth -> options;
+cgmeth -> ast;
+cgmeth -> astalgo;
+cgmeth -> msgs;
+cgmeth -> idents;
+cgmeth -> rnimsyn;
+cgmeth -> types;
+cgmeth -> magicsys;
 cgen -> ast;
 cgen -> astalgo;
 cgen -> strutils;
@@ -419,6 +471,7 @@ cgen -> rodread;
 cgen -> wordrecg;
 cgen -> rnimsyn;
 cgen -> treetab;
+cgen -> cgmeth;
 ecmasgen -> ast;
 ecmasgen -> astalgo;
 ecmasgen -> strutils;
@@ -445,15 +498,6 @@ ecmasgen -> ccgutils;
 ecmasgen -> wordrecg;
 ecmasgen -> rnimsyn;
 ecmasgen -> rodread;
-ptmplsyn -> llstream;
-ptmplsyn -> os;
-ptmplsyn -> wordrecg;
-ptmplsyn -> strutils;
-ptmplsyn -> ast;
-ptmplsyn -> astalgo;
-ptmplsyn -> msgs;
-ptmplsyn -> options;
-ptmplsyn -> pnimsyn;
 interact -> llstream;
 interact -> strutils;
 interact -> ropes;
@@ -481,6 +525,7 @@ transf -> ast;
 transf -> astalgo;
 transf -> trees;
 transf -> treetab;
+transf -> evals;
 transf -> msgs;
 transf -> os;
 transf -> idents;
@@ -489,12 +534,13 @@ transf -> types;
 transf -> passes;
 transf -> semfold;
 transf -> magicsys;
+transf -> cgmeth;
 main -> llstream;
 main -> strutils;
 main -> ast;
 main -> astalgo;
 main -> scanner;
-main -> pnimsyn;
+main -> syntaxes;
 main -> rnimsyn;
 main -> options;
 main -> msgs;
@@ -517,7 +563,6 @@ main -> extccomp;
 main -> cgen;
 main -> ecmasgen;
 main -> platform;
-main -> ptmplsyn;
 main -> interact;
 main -> nimconf;
 main -> importer;
diff --git a/rod/nimrod.nim b/rod/nimrod.nim
index b5ed532c9..b5ed532c9 100755..100644
--- a/rod/nimrod.nim
+++ b/rod/nimrod.nim
diff --git a/rod/nstrtabs.nim b/rod/nstrtabs.nim
index 6046db3cf..811e461cc 100755
--- a/rod/nstrtabs.nim
+++ b/rod/nstrtabs.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
+#        (c) Copyright 2009 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -52,12 +52,11 @@ const
 
 proc newStringTable(keyValuePairs: openarray[string], 
                     mode: TStringTableMode = modeCaseSensitive): PStringTable = 
-  var i: int
   new(result)
   result.mode = mode
   result.counter = 0
   newSeq(result.data, startSize)
-  i = 0
+  var i = 0
   while i < high(keyValuePairs): 
     put(result, keyValuePairs[i], keyValuePairs[i + 1])
     inc(i, 2)
@@ -81,17 +80,14 @@ proc mustRehash(length, counter: int): bool =
 proc length(t: PStringTable): int = 
   result = t.counter
 
-const 
-  EmptySeq = []
-
 proc nextTry(h, maxHash: THash): THash = 
-  result = ((5 * h) + 1) and maxHash # For any initial h in range(maxHash), repeating that maxHash times
-                                     # generates each int in range(maxHash) exactly once (see any text on
-                                     # random-number generation for proof).
+  result = ((5 * h) + 1) and maxHash
+  # For any initial h in range(maxHash), repeating that maxHash times
+  # generates each int in range(maxHash) exactly once (see any text on
+  # random-number generation for proof).
   
 proc RawGet(t: PStringTable, key: string): int = 
-  var h: THash
-  h = myhash(t, key) and high(t.data) # start with real hash value
+  var h = myhash(t, key) and high(t.data) # start with real hash value
   while not isNil(t.data[h].key): 
     if mycmp(t, t.data[h].key, key): 
       return h
@@ -99,8 +95,7 @@ proc RawGet(t: PStringTable, key: string): int =
   result = - 1
 
 proc get(t: PStringTable, key: string): string = 
-  var index: int
-  index = RawGet(t, key)
+  var index = RawGet(t, key)
   if index >= 0: result = t.data[index].val
   else: result = ""
   
@@ -108,8 +103,7 @@ proc hasKey(t: PStringTable, key: string): bool =
   result = rawGet(t, key) >= 0
 
 proc RawInsert(t: PStringTable, data: var TKeyValuePairSeq, key, val: string) = 
-  var h: THash
-  h = myhash(t, key) and high(data)
+  var h = myhash(t, key) and high(data)
   while not isNil(data[h].key): 
     h = nextTry(h, high(data))
   data[h].key = key
@@ -123,8 +117,7 @@ proc Enlarge(t: PStringTable) =
   swap(t.data, n)
 
 proc Put(t: PStringTable, key, val: string) = 
-  var index: int
-  index = RawGet(t, key)
+  var index = RawGet(t, key)
   if index >= 0: 
     t.data[index].val = val
   else: 
@@ -139,22 +132,18 @@ proc RaiseFormatException(s: string) =
   raise e
 
 proc getValue(t: PStringTable, flags: TFormatFlags, key: string): string = 
-  if hasKey(t, key): 
-    return get(t, key)
+  if hasKey(t, key): return get(t, key)
   if useEnvironment in flags: result = os.getEnv(key)
   else: result = ""
-  if (result == ""): 
+  if result.len == 0: 
     if useKey in flags: result = '$' & key
     elif not (useEmpty in flags): raiseFormatException(key)
   
 proc `%`(f: string, t: PStringTable, flags: TFormatFlags = {}): string = 
   const 
     PatternChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF'}
-  var 
-    i, j: int
-    key: string
   result = ""
-  i = 0
+  var i = 0
   while i <= len(f) + 0 - 1: 
     if f[i] == '$': 
       case f[i + 1]
@@ -162,15 +151,15 @@ proc `%`(f: string, t: PStringTable, flags: TFormatFlags = {}): string =
         add(result, '$')
         inc(i, 2)
       of '{': 
-        j = i + 1
+        var j = i + 1
         while (j <= len(f) + 0 - 1) and (f[j] != '}'): inc(j)
-        key = copy(f, i + 2 + 0 - 1, j - 1 + 0 - 1)
+        var key = copy(f, i + 2 + 0 - 1, j - 1 + 0 - 1)
         add(result, getValue(t, flags, key))
         i = j + 1
       of 'a'..'z', 'A'..'Z', '\x80'..'\xFF', '_': 
-        j = i + 1
+        var j = i + 1
         while (j <= len(f) + 0 - 1) and (f[j] in PatternChars): inc(j)
-        key = copy(f, i + 1 + 0 - 1, j - 1 + 0 - 1)
+        var key = copy(f, i + 1 + 0 - 1, j - 1 + 0 - 1)
         add(result, getValue(t, flags, key))
         i = j
       else: 
diff --git a/rod/options.nim b/rod/options.nim
index 15bca38b6..15bca38b6 100755..100644
--- a/rod/options.nim
+++ b/rod/options.nim
diff --git a/rod/pbraces.nim b/rod/pbraces.nim
index 4a5f85b85..4a5f85b85 100755..100644
--- a/rod/pbraces.nim
+++ b/rod/pbraces.nim
diff --git a/rod/platform.nim b/rod/platform.nim
index 6e747014d..c3a8a2837 100755
--- a/rod/platform.nim
+++ b/rod/platform.nim
@@ -203,10 +203,13 @@ proc NameToCPU(name: string): TSystemCPU =
       return i
   result = cpuNone
 
-proc nimCPU(): cstring{.importc, noconv.}
-proc nimOS(): cstring{.importc, noconv.}
+#proc nimCPU(): cstring{.importc, noconv.}
+#proc nimOS(): cstring{.importc, noconv.}
+
+#hostCPU = nameToCPU($nimCPU())
+#hostOS = nameToOS($nimOS())
+hostCPU = nameToCPU(system.hostCPU)
+hostOS = nameToOS(system.hostOS)
 
-hostCPU = nameToCPU($(nimCPU()))
-hostOS = nameToOS($(nimOS()))
 setTarget(hostOS, hostCPU) # assume no cross-compiling
 
diff --git a/rod/pnimsyn.nim b/rod/pnimsyn.nim
index 21980ccc4..21980ccc4 100755..100644
--- a/rod/pnimsyn.nim
+++ b/rod/pnimsyn.nim
diff --git a/rod/pragmas.nim b/rod/pragmas.nim
index 72a6bd4e4..72a6bd4e4 100755..100644
--- a/rod/pragmas.nim
+++ b/rod/pragmas.nim
diff --git a/rod/rodread.nim b/rod/rodread.nim
index ee295d122..ee295d122 100755..100644
--- a/rod/rodread.nim
+++ b/rod/rodread.nim
diff --git a/rod/rodwrite.nim b/rod/rodwrite.nim
index 370ebc314..370ebc314 100755..100644
--- a/rod/rodwrite.nim
+++ b/rod/rodwrite.nim
diff --git a/rod/ropes.nim b/rod/ropes.nim
index f9b1841ee..2069c8075 100755
--- a/rod/ropes.nim
+++ b/rod/ropes.nim
@@ -123,19 +123,17 @@ proc getCacheStats(): string =
     result = ""
   
 proc splay(s: string, tree: PRope, cmpres: var int): PRope = 
-  var 
-    le, r, y, t: PRope
-    c: int
-  t = tree
+  var c: int
+  var t = tree
   N.left = nil
   N.right = nil               # reset to nil
-  le = N
-  r = N
+  var le = N
+  var r = N
   while true: 
     c = cmp(s, t.data)
     if c < 0: 
       if (t.left != nil) and (s < t.left.data): 
-        y = t.left
+        var y = t.left
         t.left = y.right
         y.right = t
         t = y
@@ -145,7 +143,7 @@ proc splay(s: string, tree: PRope, cmpres: var int): PRope =
       t = t.left
     elif c > 0: 
       if (t.right != nil) and (s > t.right.data): 
-        y = t.right
+        var y = t.right
         t.right = y.left
         y.left = t
         t = y
@@ -165,14 +163,12 @@ proc splay(s: string, tree: PRope, cmpres: var int): PRope =
 proc insertInCache(s: string, tree: PRope): PRope = 
   # Insert i into the tree t, unless it's already there.
   # Return a pointer to the resulting tree.
-  var 
-    t: PRope
-    cmp: int
-  t = tree
+  var t = tree
   if t == nil: 
     result = newRope(s)
     if countCacheMisses: inc(misses)
     return 
+  var cmp: int
   t = splay(s, t, cmp)
   if cmp == 0: 
     # We get here if it's already in the Tree
@@ -216,14 +212,13 @@ proc toRope(s: string): PRope =
   assert(RopeInvariant(result))
 
 proc RopeSeqInsert(rs: var TRopeSeq, r: PRope, at: Natural) = 
-  var length: int
-  length = len(rs)
+  var length = len(rs)
   if at > length: 
     setlen(rs, at + 1)
   else: 
     setlen(rs, length + 1)    # move old rope elements:
   for i in countdown(length, at + 1): 
-    rs[i] = rs[i - 1]         # this is correct, I used pen and paper to validate it
+    rs[i] = rs[i - 1] # this is correct, I used pen and paper to validate it
   rs[at] = r
 
 proc con(a, b: PRope): PRope = 
@@ -241,12 +236,11 @@ proc con(a, b: PRope): PRope =
   assert(RopeInvariant(result))
 
 proc con(a: PRope, b: string): PRope = 
-  var r: PRope
   assert(RopeInvariant(a))
   if b == "": 
     result = a
   else: 
-    r = toRope(b)
+    var r = toRope(b)
     if a == nil: 
       result = r
     else: 
@@ -257,12 +251,11 @@ proc con(a: PRope, b: string): PRope =
   assert(RopeInvariant(result))
 
 proc con(a: string, b: PRope): PRope = 
-  var r: PRope
   assert(RopeInvariant(b))
   if a == "": 
     result = b
   else: 
-    r = toRope(a)
+    var r = toRope(a)
     if b == nil: 
       result = r
     else: 
@@ -295,21 +288,6 @@ proc prepend(a: var PRope, b: PRope) =
   a = con(b, a)
   assert(RopeInvariant(a))
 
-proc InitStack(stack: var TRopeSeq) = 
-  stack = @ []
-
-proc push(stack: var TRopeSeq, r: PRope) = 
-  var length: int
-  length = len(stack)
-  setlen(stack, length + 1)
-  stack[length] = r
-
-proc pop(stack: var TRopeSeq): PRope = 
-  var length: int
-  length = len(stack)
-  result = stack[length - 1]
-  setlen(stack, length - 1)
-
 proc WriteRopeRec(f: var tfile, c: PRope) = 
   assert(RopeInvariant(c))
   if c == nil: return 
@@ -320,16 +298,11 @@ proc WriteRopeRec(f: var tfile, c: PRope) =
     writeRopeRec(f, c.right)
 
 proc newWriteRopeRec(f: var tfile, c: PRope) = 
-  var 
-    stack: TRopeSeq
-    it: PRope
-  assert(RopeInvariant(c))
-  initStack(stack)
-  push(stack, c)
+  var stack: TRopeSeq = @[c]
   while len(stack) > 0: 
-    it = pop(stack)
+    var it = pop(stack)
     while it.data == nil: 
-      push(stack, it.right)
+      add(stack, it.right)
       it = it.left
       assert(it != nil)
     assert(it.data != nil)
@@ -355,15 +328,11 @@ proc recRopeToStr(result: var string, resultLen: var int, p: PRope) =
     assert(resultLen <= len(result))
 
 proc newRecRopeToStr(result: var string, resultLen: var int, r: PRope) = 
-  var 
-    stack: TRopeSeq
-    it: PRope
-  initStack(stack)
-  push(stack, r)
+  var stack: TRopeSeq = @[r]
   while len(stack) > 0: 
-    it = pop(stack)
+    var it = pop(stack)
     while it.data == nil: 
-      push(stack, it.right)
+      add(stack, it.right)
       it = it.left
     assert(it.data != nil)
     CopyMem(addr(result[resultLen + 0]), addr(it.data[0]), it.length)
@@ -371,13 +340,11 @@ proc newRecRopeToStr(result: var string, resultLen: var int, r: PRope) =
     assert(resultLen <= len(result))
 
 proc ropeToStr(p: PRope): string = 
-  var resultLen: int
-  assert(RopeInvariant(p))
   if p == nil: 
     result = ""
   else: 
     result = newString(p.length)
-    resultLen = 0
+    var resultLen = 0
     newRecRopeToStr(result, resultLen, p)
 
 proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope = 
@@ -426,11 +393,10 @@ const
   bufSize = 1024              # 1 KB is reasonable
 
 proc auxRopeEqualsFile(r: PRope, bin: var tfile, buf: Pointer): bool = 
-  var readBytes: int
   if (r.data != nil): 
     if r.length > bufSize: 
       internalError("ropes: token too long")
-    readBytes = readBuffer(bin, buf, r.length)
+    var readBytes = readBuffer(bin, buf, r.length)
     result = (readBytes == r.length) and
         equalMem(buf, addr(r.data[0]), r.length) # BUGFIX
   else: 
@@ -438,13 +404,11 @@ proc auxRopeEqualsFile(r: PRope, bin: var tfile, buf: Pointer): bool =
     if result: result = auxRopeEqualsFile(r.right, bin, buf)
   
 proc RopeEqualsFile(r: PRope, f: string): bool = 
-  var 
-    bin: tfile
-    buf: Pointer
+  var bin: tfile
   result = open(bin, f)
   if not result: 
     return                    # not equal if file does not exist
-  buf = alloc(BufSize)
+  var buf = alloc(BufSize)
   result = auxRopeEqualsFile(r, bin, buf)
   if result: 
     result = readBuffer(bin, buf, bufSize) == 0 # really at the end of file?
@@ -461,21 +425,16 @@ proc crcFromRopeAux(r: PRope, startVal: TCrc32): TCrc32 =
     result = crcFromRopeAux(r.right, result)
 
 proc newCrcFromRopeAux(r: PRope, startVal: TCrc32): TCrc32 = 
-  var 
-    stack: TRopeSeq
-    it: PRope
-    L, i: int
-  initStack(stack)
-  push(stack, r)
+  var stack: TRopeSeq = @[r]
   result = startVal
   while len(stack) > 0: 
-    it = pop(stack)
+    var it = pop(stack)
     while it.data == nil: 
-      push(stack, it.right)
+      add(stack, it.right)
       it = it.left
     assert(it.data != nil)
-    i = 0
-    L = len(it.data) + 0
+    var i = 0
+    var L = len(it.data)
     while i < L: 
       result = updateCrc32(it.data[i], result)
       inc(i)
@@ -493,5 +452,4 @@ proc writeRopeIfNotEqual(r: PRope, filename: string): bool =
   else: 
     result = false
   
-new(N)
-# init dummy node for splay algorithm
\ No newline at end of file
+new(N) # init dummy node for splay algorithm
\ No newline at end of file
diff --git a/rod/sem.nim b/rod/sem.nim
index 2f9f90335..2f9f90335 100755..100644
--- a/rod/sem.nim
+++ b/rod/sem.nim
diff --git a/rod/semdata.nim b/rod/semdata.nim
index 5020f103d..5020f103d 100755..100644
--- a/rod/semdata.nim
+++ b/rod/semdata.nim
diff --git a/rod/semfold.nim b/rod/semfold.nim
index 455ddf2b8..455ddf2b8 100755..100644
--- a/rod/semfold.nim
+++ b/rod/semfold.nim
diff --git a/rod/transf.nim b/rod/transf.nim
index 6bb825e13..6bb825e13 100755..100644
--- a/rod/transf.nim
+++ b/rod/transf.nim
diff --git a/rod/trees.nim b/rod/trees.nim
index 69b77b8ab..69b77b8ab 100755..100644
--- a/rod/trees.nim
+++ b/rod/trees.nim