unary <; countup two type parameters; --recursivePath should work now

This commit is contained in:
Araq
2011-01-29 14:18:43 +01:00
parent f46870fe1c
commit 36accda8aa
13 changed files with 69 additions and 54 deletions

View File

@@ -861,7 +861,7 @@ iterator walkDir*(dir: string): tuple[kind: TPathComponent, path: string] =
if y != "." and y != "..":
var s: TStat
y = dir / y
if stat(y, s) < 0'i32: break
if lstat(y, s) < 0'i32: break
var k = pcFile
if S_ISDIR(s.st_mode): k = pcDir
if S_ISLNK(s.st_mode): k = succ(k)
@@ -1245,3 +1245,4 @@ proc findExe*(exe: string): string =
result = ""
{.pop.}

View File

@@ -1,7 +1,7 @@
#
#
# Nimrod's Runtime Library
# (c) Copyright 2010 Andreas Rumpf
# (c) Copyright 2011 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
@@ -247,6 +247,14 @@ proc sizeof*[T](x: T): natural {.magic: "SizeOf", noSideEffect.}
## that one never needs to know ``x``'s size. As a special semantic rule,
## ``x`` may also be a type identifier (``sizeof(int)`` is valid).
proc `<`*[T](x: ordinal[T]): T {.magic: "UnaryLt", noSideEffect.}
## unary ``<`` that can be used for nice looking excluding ranges:
##
## .. code-block:: nimrod
## for i in 0 .. <10: echo i
##
## Semantically this is the same as ``pred``.
proc succ*[T](x: ordinal[T], y = 1): T {.magic: "Succ", noSideEffect.}
## returns the ``y``-th successor of the value ``x``. ``T`` has to be
## an ordinal type. If such a value does not exist, ``EOutOfRange`` is raised
@@ -1017,11 +1025,11 @@ iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
yield res
dec(res, step)
iterator countup*[T](a, b: T, step = 1): T {.inline.} =
iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} =
## Counts from ordinal value `a` up to `b` with the given
## step count. `T` may be any ordinal type, `step` may only
## step count. `S`, `T` may be any ordinal type, `step` may only
## be positive.
var res = a
var res: T = a
while res <= b:
yield res
inc(res, step)
@@ -1459,6 +1467,8 @@ when not defined(EcmaScript) and not defined(NimrodVM):
proc write*(f: TFile, r: float)
proc write*(f: TFile, i: int)
proc write*(f: TFile, i: biggestInt)
proc write*(f: TFile, r: biggestFloat)
proc write*(f: TFile, s: string)
proc write*(f: TFile, b: Bool)
proc write*(f: TFile, c: char)

View File

@@ -1,7 +1,7 @@
#
#
# Nimrod's Runtime Library
# (c) Copyright 2009 Andreas Rumpf
# (c) Copyright 2011 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
@@ -59,11 +59,19 @@ proc write(f: TFile, i: int) =
fprintf(f, "%lld", i)
else:
fprintf(f, "%ld", i)
proc write(f: TFile, i: biggestInt) =
when sizeof(biggestint) == 8:
fprintf(f, "%lld", i)
else:
fprintf(f, "%ld", i)
proc write(f: TFile, b: bool) =
if b: write(f, "true")
else: write(f, "false")
proc write(f: TFile, r: float) = fprintf(f, "%g", r)
proc write(f: TFile, r: biggestFloat) = fprintf(f, "%g", r)
proc write(f: TFile, c: Char) = putc(c, f)
proc write(f: TFile, a: openArray[string]) =
for x in items(a): write(f, x)