mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 06:54:16 +00:00
adds procedure test code and fix bugs
This commit is contained in:
@@ -261,7 +261,9 @@ proc fromNif(c: var DecodeContext; n: var Cursor): PNode =
|
||||
case kind:
|
||||
of nkEmpty:
|
||||
result = newNodeI(nkEmpty, c.fromNifLineInfo(n))
|
||||
inc n
|
||||
incExpect n, {Ident, DotToken}
|
||||
let flags = fromNifNodeFlags n
|
||||
result.flags = flags
|
||||
skipParRi n
|
||||
of nkIdent:
|
||||
incExpect n, Ident
|
||||
@@ -304,7 +306,7 @@ proc fromNif(c: var DecodeContext; n: var Cursor): PNode =
|
||||
else:
|
||||
c.withNode n, result, kind:
|
||||
while n.kind != ParRi:
|
||||
result.add c.fromNif n
|
||||
result.addAllowNil c.fromNif n
|
||||
else:
|
||||
assert false, "Not yet implemented " & $n.kind
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ proc toNif(c: var EncodeContext; n: PNode) =
|
||||
of nkEmpty:
|
||||
let info = c.toNif n.info
|
||||
c.dest.addParLe pool.tags.getOrIncl(toNifTag(nkEmpty)), info
|
||||
c.dest.writeNodeFlags(n.flags)
|
||||
c.dest.addParRi
|
||||
of nkIdent:
|
||||
let info = c.toNif n.info
|
||||
@@ -187,7 +188,7 @@ proc toNif(c: var EncodeContext; n: PNode) =
|
||||
c.withNode n:
|
||||
discard
|
||||
else:
|
||||
assert n.len > 0, $n.kind
|
||||
assert n.kind in {nkArgList, nkBracket} or n.len > 0, $n.kind
|
||||
c.withNode(n):
|
||||
for i in 0 ..< n.len:
|
||||
c.toNif n[i]
|
||||
|
||||
@@ -330,3 +330,4 @@ testNifEncDec(graph, "modtest1.nim")
|
||||
testNifEncDec(graph, "modtestliterals.nim")
|
||||
testNifEncDec(graph, "modtesttypesections.nim")
|
||||
testNifEncDec(graph, "modtestpragmas.nim")
|
||||
testNifEncDec(graph, "modtestprocs.nim")
|
||||
|
||||
9
tests/icnif/testcode/modtestprocs.nim
Normal file
9
tests/icnif/testcode/modtestprocs.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
proc foo() = discard
|
||||
proc bar(x: int): int = x
|
||||
proc baz(x, y: int): string = $(x + y)
|
||||
|
||||
proc baz(a: bool; b: string; c: int): float =
|
||||
if a and b == "" and c == 0:
|
||||
result = 0.0
|
||||
else:
|
||||
result = 1.0
|
||||
Reference in New Issue
Block a user