Merge branch 'devel' of github.com:Araq/Nimrod into devel
This commit is contained in:
commit
f59d76a59e
5 changed files with 25 additions and 9 deletions
|
|
@ -1578,15 +1578,15 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
of mGetTypeInfo: genGetTypeInfo(p, e, d)
|
of mGetTypeInfo: genGetTypeInfo(p, e, d)
|
||||||
of mSwap: genSwap(p, e, d)
|
of mSwap: genSwap(p, e, d)
|
||||||
of mUnaryLt:
|
of mUnaryLt:
|
||||||
if not (optOverflowCheck in p.options): unaryExpr(p, e, d, "$1 - 1")
|
if not (optOverflowCheck in p.options): unaryExpr(p, e, d, "($1 - 1)")
|
||||||
else: unaryExpr(p, e, d, "#subInt($1, 1)")
|
else: unaryExpr(p, e, d, "#subInt($1, 1)")
|
||||||
of mPred:
|
of mPred:
|
||||||
# XXX: range checking?
|
# XXX: range checking?
|
||||||
if not (optOverflowCheck in p.options): binaryExpr(p, e, d, "$1 - $2")
|
if not (optOverflowCheck in p.options): binaryExpr(p, e, d, "($1 - $2)")
|
||||||
else: binaryExpr(p, e, d, "#subInt($1, $2)")
|
else: binaryExpr(p, e, d, "#subInt($1, $2)")
|
||||||
of mSucc:
|
of mSucc:
|
||||||
# XXX: range checking?
|
# XXX: range checking?
|
||||||
if not (optOverflowCheck in p.options): binaryExpr(p, e, d, "$1 + $2")
|
if not (optOverflowCheck in p.options): binaryExpr(p, e, d, "($1 + $2)")
|
||||||
else: binaryExpr(p, e, d, "#addInt($1, $2)")
|
else: binaryExpr(p, e, d, "#addInt($1, $2)")
|
||||||
of mInc:
|
of mInc:
|
||||||
if not (optOverflowCheck in p.options):
|
if not (optOverflowCheck in p.options):
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,8 @@ template equalsImpl() =
|
||||||
# different insertion orders mean different 'data' seqs, so we have
|
# different insertion orders mean different 'data' seqs, so we have
|
||||||
# to use the slow route here:
|
# to use the slow route here:
|
||||||
for key, val in s:
|
for key, val in s:
|
||||||
if not hasKey(t, key): return false
|
# prefix notation leads to automatic dereference in case of PTable
|
||||||
|
if not t.hasKey(key): return false
|
||||||
if t[key] != val: return false
|
if t[key] != val: return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
@ -332,7 +333,9 @@ proc `$`*[A, B](t: PTable[A, B]): string =
|
||||||
dollarImpl()
|
dollarImpl()
|
||||||
|
|
||||||
proc `==`*[A, B](s, t: PTable[A, B]): bool =
|
proc `==`*[A, B](s, t: PTable[A, B]): bool =
|
||||||
equalsImpl()
|
if isNil(s): result = isNil(t)
|
||||||
|
elif isNil(t): result = false
|
||||||
|
else: result = equalsImpl()
|
||||||
|
|
||||||
proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): PTable[C, B] =
|
proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): PTable[C, B] =
|
||||||
## Index the collection with the proc provided.
|
## Index the collection with the proc provided.
|
||||||
|
|
|
||||||
|
|
@ -621,9 +621,13 @@ proc `%`*(elements: openArray[PJsonNode]): PJsonNode =
|
||||||
|
|
||||||
proc `==`* (a,b: PJsonNode): bool =
|
proc `==`* (a,b: PJsonNode): bool =
|
||||||
## Check two nodes for equality
|
## Check two nodes for equality
|
||||||
if a.kind != b.kind: false
|
if a.isNil:
|
||||||
|
if b.isNil: return true
|
||||||
|
return false
|
||||||
|
elif b.isNil or a.kind != b.kind:
|
||||||
|
return false
|
||||||
else:
|
else:
|
||||||
case a.kind
|
return case a.kind
|
||||||
of JString:
|
of JString:
|
||||||
a.str == b.str
|
a.str == b.str
|
||||||
of JInt:
|
of JInt:
|
||||||
|
|
|
||||||
|
|
@ -763,7 +763,7 @@ elif not defined(useNimRtl):
|
||||||
discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
|
discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
|
||||||
exitnow(1)
|
exitnow(1)
|
||||||
|
|
||||||
when defined(macosx):
|
when defined(macosx) or defined(freebsd):
|
||||||
var environ {.importc.}: cstringArray
|
var environ {.importc.}: cstringArray
|
||||||
|
|
||||||
proc startProcessAfterFork(data: ptr TStartProcessData) =
|
proc startProcessAfterFork(data: ptr TStartProcessData) =
|
||||||
|
|
@ -793,7 +793,7 @@ elif not defined(useNimRtl):
|
||||||
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
|
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
|
||||||
|
|
||||||
if data.optionPoUsePath:
|
if data.optionPoUsePath:
|
||||||
when defined(macosx):
|
when defined(macosx) or defined(freebsd):
|
||||||
# MacOSX doesn't have execvpe, so we need workaround.
|
# MacOSX doesn't have execvpe, so we need workaround.
|
||||||
# On MacOSX we can arrive here only from fork, so this is safe:
|
# On MacOSX we can arrive here only from fork, so this is safe:
|
||||||
environ = data.sysEnv
|
environ = data.sysEnv
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,15 @@ block countTableTest1:
|
||||||
block SyntaxTest:
|
block SyntaxTest:
|
||||||
var x = newTable[int, string]({:})
|
var x = newTable[int, string]({:})
|
||||||
|
|
||||||
|
block nilTest:
|
||||||
|
var i, j: PTable[int, int] = nil
|
||||||
|
assert i == j
|
||||||
|
j = newTable[int, int]()
|
||||||
|
assert i != j
|
||||||
|
assert j != i
|
||||||
|
i = newTable[int, int]()
|
||||||
|
assert i == j
|
||||||
|
|
||||||
proc orderedTableSortTest() =
|
proc orderedTableSortTest() =
|
||||||
var t = newOrderedTable[string, int](2)
|
var t = newOrderedTable[string, int](2)
|
||||||
for key, val in items(data): t[key] = val
|
for key, val in items(data): t[key] = val
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue