summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-05-01 14:48:40 +0200
committerAraq <rumpf_a@web.de>2013-05-01 14:48:40 +0200
commit56045ad7ff06c8dc7e3b1c4ac9ae3cb083fae485 (patch)
treeea8099ab8eb1c5e7f8407f75eeb610213de9773d
parenteaeb26f0037b04f58b755770e3ba401cb0b877a2 (diff)
downloadNim-56045ad7ff06c8dc7e3b1c4ac9ae3cb083fae485.tar.gz
bugfixes mostly JS related
-rw-r--r--compiler/ccgtypes.nim11
-rw-r--r--compiler/jsgen.nim9
-rw-r--r--compiler/types.nim15
-rw-r--r--lib/pure/pegs.nim8
-rw-r--r--lib/pure/times.nim4
-rw-r--r--lib/system/jssys.nim5
-rw-r--r--tests/manyloc/argument_parser/ex_wget.nimrod.cfg1
-rw-r--r--tests/manyloc/nake/nakefile.nim (renamed from tests/manyloc/keineschweine/nakefile.nim)2
-rw-r--r--tests/manyloc/nake/nakefile.nimrod.cfg (renamed from tests/manyloc/keineschweine/nakefile.nimrod.cfg)0
-rw-r--r--todo.txt2
10 files changed, 37 insertions, 20 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index d37e79d6b..6f54f7e2f 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -137,17 +137,6 @@ proc mangleName(s: PSym): PRope =
       app(result, toRope(s.id))
     s.loc.r = result
 
-proc isCompileTimeOnly(t: PType): bool =
-  result = t.kind in {tyTypedesc, tyExpr}
-
-proc containsCompileTimeOnly(t: PType): bool =
-  if isCompileTimeOnly(t): return true
-  if t.sons != nil:
-    for i in 0 .. <t.sonsLen:
-      if t.sons[i] != nil and isCompileTimeOnly(t.sons[i]):
-        return true
-  return false
-
 proc typeName(typ: PType): PRope =
   result = if typ.sym != nil: typ.sym.name.s.mangle.toRope
            else: ~"TY"
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 692c8fd27..a76f8a883 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -611,10 +611,11 @@ proc genIf(p: PProc, n: PNode, r: var TCompRes) =
 
 proc generateHeader(p: PProc, typ: PType): PRope =
   result = nil
-  for i in countup(1, sonsLen(typ.n) - 1): 
+  for i in countup(1, sonsLen(typ.n) - 1):
     if result != nil: app(result, ", ")
     assert(typ.n.sons[i].kind == nkSym)
     var param = typ.n.sons[i].sym
+    if isCompileTimeOnly(param.typ): continue
     var name = mangleName(param)
     app(result, name)
     if mapType(param.typ) == etyBaseIndex: 
@@ -865,8 +866,10 @@ proc genArg(p: PProc, n: PNode, r: var TCompRes) =
 proc genArgs(p: PProc, n: PNode, r: var TCompRes) =
   app(r.res, "(")
   for i in countup(1, sonsLen(n) - 1): 
+    let it = n.sons[i]
+    if it.typ.isCompileTimeOnly: continue  
     if i > 1: app(r.res, ", ")
-    genArg(p, n.sons[i], r)
+    genArg(p, it, r)
   app(r.res, ")")
   r.kind = resExpr
 
@@ -1128,7 +1131,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
     # XXX: range checking?
     if not (optOverflowCheck in p.Options): binaryExpr(p, n, r, "", "$1 - $2")
     else: binaryExpr(p, n, r, "addInt", "addInt($1, $2)")
-  of mAppendStrCh: binaryExpr(p, n, r, "addChar", "$1 = addChar($1, $2)")
+  of mAppendStrCh: binaryExpr(p, n, r, "addChar", "addChar($1, $2)")
   of mAppendStrStr:
     if skipTypes(n.sons[1].typ, abstractVarRange).kind == tyCString:
         binaryExpr(p, n, r, "", "$1 += $2")
diff --git a/compiler/types.nim b/compiler/types.nim
index 5b1da74d4..6f47a7f2d 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -486,7 +486,9 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
   of tyPtr, tyRef, tyVar, tyMutable, tyConst: 
     result = typeToStr[t.kind] & typeToString(t.sons[0])
   of tyRange:
-    result = "range " & rangeToStr(t.n) & "(" & typeToString(t.sons[0]) & ")"
+    result = "range " & rangeToStr(t.n)
+    if prefer != preferExported:
+      result.add("(" & typeToString(t.sons[0]) & ")")
   of tyProc:
     result = if tfIterator in t.flags: "iterator (" else: "proc ("
     for i in countup(1, sonsLen(t) - 1): 
@@ -1281,3 +1283,14 @@ proc compatibleEffects*(formal, actual: PType): bool =
       result = compatibleEffectsAux(st, real.sons[tagEffects])
       if not result: return
   result = true
+
+proc isCompileTimeOnly*(t: PType): bool {.inline.} =
+  result = t.kind in {tyTypedesc, tyExpr}
+
+proc containsCompileTimeOnly*(t: PType): bool =
+  if isCompileTimeOnly(t): return true
+  if t.sons != nil:
+    for i in 0 .. <t.sonsLen:
+      if t.sons[i] != nil and isCompileTimeOnly(t.sons[i]):
+        return true
+  return false
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim
index 4e31ffc0c..61a1c08c7 100644
--- a/lib/pure/pegs.nim
+++ b/lib/pure/pegs.nim
@@ -867,8 +867,9 @@ template `=~`*(s: string, pattern: TPeg): bool =
   ##   else:
   ##     echo("syntax error")
   ##  
+  bind maxSubpatterns
   when not definedInScope(matches):
-    var matches {.inject.}: array[0..pegs.maxSubpatterns-1, string]
+    var matches {.inject.}: array[0..maxSubpatterns-1, string]
   match(s, pattern, matches)
 
 # ------------------------- more string handling ------------------------------
@@ -1740,8 +1741,9 @@ when isMainModule:
     assert matches[0] == "a"
   else:
     assert false
-    
-  if match("abcdefg", peg"c {d} ef {g}", matches, 2): 
+
+  var matches: array[0..maxSubpatterns-1, string]
+  if match("abcdefg", peg"c {d} ef {g}", matches, 2):
     assert matches[0] == "d"
     assert matches[1] == "g"
   else:
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 03a05aea1..b57b9e959 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -463,6 +463,8 @@ when not defined(JS):
     
 elif defined(JS):
   proc newDate(): TTime {.importc: "new Date".}
+  proc internGetTime(): TTime {.importc: "new Date", tags: [].}
+  
   proc newDate(value: float): TTime {.importc: "new Date".}
   proc newDate(value: string): TTime {.importc: "new Date".}
   proc getTime(): TTime =
@@ -494,7 +496,7 @@ elif defined(JS):
     result.yearday = 0
   
   proc TimeInfoToTime*(timeInfo: TTimeInfo): TTime =
-    result = getTime()
+    result = internGetTime()
     result.setSeconds(timeInfo.second)
     result.setMinutes(timeInfo.minute)
     result.setHours(timeInfo.hour)
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index 1c43bfdc7..850dd1e11 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -620,4 +620,9 @@ proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
     x = x.base
   return true
 
+proc addChar(x: string, c: char) {.compilerproc, noStackFrame.} =
+  asm """
+    `x`[`x`.length-1] = `c`; `x`.push(0);
+  """
+
 {.pop.}
diff --git a/tests/manyloc/argument_parser/ex_wget.nimrod.cfg b/tests/manyloc/argument_parser/ex_wget.nimrod.cfg
new file mode 100644
index 000000000..4ea571d31
--- /dev/null
+++ b/tests/manyloc/argument_parser/ex_wget.nimrod.cfg
@@ -0,0 +1 @@
+# This file exists only to mark 'ex_wget' as the project file
diff --git a/tests/manyloc/keineschweine/nakefile.nim b/tests/manyloc/nake/nakefile.nim
index f175321b9..700f9ab49 100644
--- a/tests/manyloc/keineschweine/nakefile.nim
+++ b/tests/manyloc/nake/nakefile.nim
@@ -76,7 +76,7 @@ task "testskel", "create skeleton test dir for testing":
 
 task "clean", "cleanup generated files":
   var dirs = @["nimcache", "server"/"nimcache"]
-  dirs.each(proc(x: var string) =
+  dirs.map(proc(x: var string) =
     if existsDir(x): removeDir(x))
 
 task "download", "download game assets":
diff --git a/tests/manyloc/keineschweine/nakefile.nimrod.cfg b/tests/manyloc/nake/nakefile.nimrod.cfg
index 6f3e86fe6..6f3e86fe6 100644
--- a/tests/manyloc/keineschweine/nakefile.nimrod.cfg
+++ b/tests/manyloc/nake/nakefile.nimrod.cfg
diff --git a/todo.txt b/todo.txt
index 768d39747..a5b4fc211 100644
--- a/todo.txt
+++ b/todo.txt
@@ -9,6 +9,8 @@ version 0.9.2
 - document NimMain and check whether it works for threading
 - make use of commonType relation in expressions
 - further expr/stmt unification:
+  - merge nkStmtListExpr and nkStmtList
+  - merge nkBlockExpr and nkBlockStmt
   - rewrite nkCaseExpr handling
   - try except as an expression