diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index c4a3dfd779..d0112f9d7f 100755 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -368,6 +368,22 @@ proc IfSwitchSplitPoint(p: BProc, n: PNode): int = if branch.kind == nkOfBranch and branchHasTooBigRange(branch): result = i +proc genCaseRange(p: BProc, branch: PNode) = + var length = branch.len + for j in 0 .. length-2: + if branch[j].kind == nkRange: + if hasSwitchRange in CC[ccompiler].props: + appf(p.s[cpsStmts], "case $1 ... $2:$n", [ + genLiteral(p, branch[j][0]), + genLiteral(p, branch[j][1])]) + else: + var v = copyNode(branch[j][0]) + while v.intVal <= branch[j][1].intVal: + appf(p.s[cpsStmts], "case $1:$n", [genLiteral(p, v)]) + Inc(v.intVal) + else: + appf(p.s[cpsStmts], "case $1:$n", [genLiteral(p, branch[j])]) + proc genOrdinalCase(p: BProc, n: PNode) = # analyse 'case' statement: var splitPoint = IfSwitchSplitPoint(p, n) @@ -387,21 +403,8 @@ proc genOrdinalCase(p: BProc, n: PNode) = for i in splitPoint+1 .. < n.len: var branch = n[i] if branch.kind == nkOfBranch: - var length = branch.len - for j in 0 .. length-2: - if branch[j].kind == nkRange: - if hasSwitchRange in CC[ccompiler].props: - appf(p.s[cpsStmts], "case $1 ... $2:$n", [ - genLiteral(p, branch[j][0]), - genLiteral(p, branch[j][1])]) - else: - var v = copyNode(branch[j][0]) - while v.intVal <= branch[j][1].intVal: - appf(p.s[cpsStmts], "case $1:$n", [genLiteral(p, v)]) - Inc(v.intVal) - else: - appf(p.s[cpsStmts], "case $1:$n", [genLiteral(p, branch[j])]) - genStmts(p, branch[length-1]) + genCaseRange(p, branch) + genStmts(p, branch.lastSon) else: # else part of case statement: appf(p.s[cpsStmts], "default:$n") diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 7368b3c080..78800165a3 100755 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -236,9 +236,7 @@ type proc fsClose(s: PStream) = close(PFileStream(s).f) proc fsFlush(s: PStream) = flushFile(PFileStream(s).f) -{.push warning[Deprecated]: off.} proc fsAtEnd(s: PStream): bool = return EndOfFile(PFileStream(s).f) -{.pop.} proc fsSetPosition(s: PStream, pos: int) = setFilePos(PFileStream(s).f, pos) proc fsGetPosition(s: PStream): int = return int(getFilePos(PFileStream(s).f)) diff --git a/todo.txt b/todo.txt index 7342161313..4a43c3b044 100755 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,7 @@ version 0.9.0 ============= +- bootstrapping fails with --symbolFiles:on again! - ``=`` should be overloadable; requires specialization for ``=`` - fix remaining generics bugs - fix remaining closure bugs: