Merge branch 'master' of github.com:Araq/Nimrod

This commit is contained in:
Araq
2012-04-15 10:02:35 +02:00
20 changed files with 440 additions and 264 deletions

View File

@@ -29,19 +29,14 @@ template colorOp(op: expr) {.immediate.} =
extract(a, ar, ag, ab)
extract(b, br, bg, bb)
result = rawRGB(op(ar, br), op(ag, bg), op(ab, bb))
template satPlus(a, b: expr): expr =
# saturated plus:
block:
var result = a +% b
if result > 255: result = 255
result
template satMinus(a, b: expr): expr =
block:
var result = a -% b
if result < 0: result = 0
result
proc satPlus(a, b: int): int {.inline.} =
result = a +% b
if result > 255: result = 255
proc satMinus(a, b: int): int {.inline.} =
result = a -% b
if result < 0: result = 0
proc `+`*(a, b: TColor): TColor =
## adds two colors: This uses saturated artithmetic, so that each color

View File

@@ -1738,7 +1738,6 @@ when isMainModule:
else:
assert false
var matches: array[0..5, string]
if match("abcdefg", peg"c {d} ef {g}", matches, 2):
assert matches[0] == "d"
assert matches[1] == "g"

View File

@@ -1593,12 +1593,12 @@ proc echo*[Ty](x: openarray[Ty]) {.magic: "Echo", noSideEffect.}
template newException*(exceptn: typeDesc, message: string): expr =
## creates an exception object of type ``exceptn`` and sets its ``msg`` field
## to `message`. Returns the new exception object.
block: # open a new scope
var
e: ref exceptn
new(e)
e.msg = message
e
# block: # open a new scope
var
e: ref exceptn
new(e)
e.msg = message
e
when not defined(EcmaScript) and not defined(NimrodVM):
{.push stack_trace: off.}