summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/pegs.nim8
-rw-r--r--lib/pure/times.nim4
-rw-r--r--lib/system/jssys.nim5
3 files changed, 13 insertions, 4 deletions
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.}