Skip to content

Commit

Permalink
revert public function names
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Apr 28, 2020
1 parent 85ee99b commit c4151bb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
30 changes: 15 additions & 15 deletions compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,11 @@ proc genFieldCheck(p: BProc, e: PNode, obj: Rope, field: PSym) =
let strLit = genStringLiteral(p.module, newStrNode(nkStrLit, msg))
if op.magic == mNot:
linefmt(p, cpsStmts,
"if ($1){ #raiseFieldDefect($2); $3}$n",
"if ($1){ #raiseFieldError($2); $3}$n",
[rdLoc(test), strLit, raiseInstr(p)])
else:
linefmt(p, cpsStmts,
"if (!($1)){ #raiseFieldDefect($2); $3}$n",
"if (!($1)){ #raiseFieldError($2); $3}$n",
[rdLoc(test), strLit, raiseInstr(p)])

proc genCheckedRecordField(p: BProc, e: PNode, d: var TLoc) =
Expand Down Expand Up @@ -869,10 +869,10 @@ proc genArrayElem(p: BProc, n, x, y: PNode, d: var TLoc) =
# semantic pass has already checked for const index expressions
if firstOrd(p.config, ty) == 0:
if (firstOrd(p.config, b.t) < firstOrd(p.config, ty)) or (lastOrd(p.config, b.t) > lastOrd(p.config, ty)):
linefmt(p, cpsStmts, "if ((NU)($1) > (NU)($2)){ #raiseIndexDefect2($1, $2); $3}$n",
linefmt(p, cpsStmts, "if ((NU)($1) > (NU)($2)){ #raiseIndexError2($1, $2); $3}$n",
[rdCharLoc(b), intLiteral(lastOrd(p.config, ty)), raiseInstr(p)])
else:
linefmt(p, cpsStmts, "if ($1 < $2 || $1 > $3){ #raiseIndexDefect3($1, $2, $3); $4}$n",
linefmt(p, cpsStmts, "if ($1 < $2 || $1 > $3){ #raiseIndexError3($1, $2, $3); $4}$n",
[rdCharLoc(b), first, intLiteral(lastOrd(p.config, ty)), raiseInstr(p)])
else:
let idx = getOrdValue(y)
Expand All @@ -896,18 +896,18 @@ proc genBoundsCheck(p: BProc; arr, a, b: TLoc) =
of tyOpenArray, tyVarargs:
linefmt(p, cpsStmts,
"if ($2-$1 != -1 && " &
"((NU)($1) >= (NU)($3Len_0) || (NU)($2) >= (NU)($3Len_0))){ #raiseIndexDefect(); $4}$n",
"((NU)($1) >= (NU)($3Len_0) || (NU)($2) >= (NU)($3Len_0))){ #raiseIndexError(); $4}$n",
[rdLoc(a), rdLoc(b), rdLoc(arr), raiseInstr(p)])
of tyArray:
let first = intLiteral(firstOrd(p.config, ty))
linefmt(p, cpsStmts,
"if ($2-$1 != -1 && " &
"($2-$1 < -1 || $1 < $3 || $1 > $4 || $2 < $3 || $2 > $4)){ #raiseIndexDefect(); $5}$n",
"($2-$1 < -1 || $1 < $3 || $1 > $4 || $2 < $3 || $2 > $4)){ #raiseIndexError(); $5}$n",
[rdCharLoc(a), rdCharLoc(b), first, intLiteral(lastOrd(p.config, ty)), raiseInstr(p)])
of tySequence, tyString:
linefmt(p, cpsStmts,
"if ($2-$1 != -1 && " &
"((NU)($1) >= (NU)$3 || (NU)($2) >= (NU)$3)){ #raiseIndexDefect(); $4}$n",
"((NU)($1) >= (NU)$3 || (NU)($2) >= (NU)$3)){ #raiseIndexError(); $4}$n",
[rdLoc(a), rdLoc(b), lenExpr(p, arr), raiseInstr(p)])
else: discard

Expand All @@ -916,7 +916,7 @@ proc genOpenArrayElem(p: BProc, n, x, y: PNode, d: var TLoc) =
initLocExpr(p, x, a)
initLocExpr(p, y, b) # emit range check:
if optBoundsCheck in p.options:
linefmt(p, cpsStmts, "if ((NU)($1) >= (NU)($2Len_0)){ #raiseIndexDefect2($1,$2Len_0-1); $3}$n",
linefmt(p, cpsStmts, "if ((NU)($1) >= (NU)($2Len_0)){ #raiseIndexError2($1,$2Len_0-1); $3}$n",
[rdLoc(b), rdLoc(a), raiseInstr(p)]) # BUGFIX: ``>=`` and not ``>``!
inheritLocation(d, a)
putIntoDest(p, d, n,
Expand All @@ -932,11 +932,11 @@ proc genSeqElem(p: BProc, n, x, y: PNode, d: var TLoc) =
if optBoundsCheck in p.options:
if ty.kind == tyString and (not defined(nimNoZeroTerminator) or optLaxStrings in p.options):
linefmt(p, cpsStmts,
"if ((NU)($1) > (NU)$2){ #raiseIndexDefect2($1,$2); $3}$n",
"if ((NU)($1) > (NU)$2){ #raiseIndexError2($1,$2); $3}$n",
[rdLoc(b), lenExpr(p, a), raiseInstr(p)])
else:
linefmt(p, cpsStmts,
"if ((NU)($1) >= (NU)$2){ #raiseIndexDefect2($1,$2-1); $3}$n",
"if ((NU)($1) >= (NU)$2){ #raiseIndexError2($1,$2-1); $3}$n",
[rdLoc(b), lenExpr(p, a), raiseInstr(p)])
if d.k == locNone: d.storage = OnHeap
if skipTypes(a.t, abstractVar).kind in {tyRef, tyPtr}:
Expand Down Expand Up @@ -1983,9 +1983,9 @@ proc genRangeChck(p: BProc, n: PNode, d: var TLoc) =
else:
let raiser =
case skipTypes(n.typ, abstractVarRange).kind
of tyUInt..tyUInt64, tyChar: "raiseRangeDefectU"
of tyFloat..tyFloat128: "raiseRangeDefectF"
else: "raiseRangeDefectI"
of tyUInt..tyUInt64, tyChar: "raiseRangeErrorU"
of tyFloat..tyFloat128: "raiseRangeErrorF"
else: "raiseRangeErrorI"
discard cgsym(p.module, raiser)
# This seems to be bug-compatible with Nim version 1 but what we
# should really do here is to check if uint64Value < high(int)
Expand Down Expand Up @@ -2462,10 +2462,10 @@ proc upConv(p: BProc, n: PNode, d: var TLoc) =
else:
genTypeInfo(p.module, dest, n.info)
if nilCheck != nil:
linefmt(p, cpsStmts, "if ($1 && !#isObj($2, $3)){ #raiseObjectConversionDefect(); $4}$n",
linefmt(p, cpsStmts, "if ($1 && !#isObj($2, $3)){ #raiseObjectConversionError(); $4}$n",
[nilCheck, r, checkFor, raiseInstr(p)])
else:
linefmt(p, cpsStmts, "if (!#isObj($1, $2)){ #raiseObjectConversionDefect(); $3}$n",
linefmt(p, cpsStmts, "if (!#isObj($1, $2)){ #raiseObjectConversionError(); $3}$n",
[r, checkFor, raiseInstr(p)])
if n[0].typ.kind != tyObject:
putIntoDest(p, d, n,
Expand Down
4 changes: 2 additions & 2 deletions compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,10 @@ proc genCheckedFieldOp(p: PProc, n: PNode, addrTyp: PType, r: var TCompRes) =
let tmp = p.getTemp()
lineF(p, "var $1 = $2;$n", tmp, obj.res)

useMagic(p, "raiseFieldDefect")
useMagic(p, "raiseFieldError")
useMagic(p, "makeNimstrLit")
let msg = genFieldDefect(field, disc)
lineF(p, "if ($1[$2.$3]$4undefined) { raiseFieldDefect(makeNimstrLit($5)); }$n",
lineF(p, "if ($1[$2.$3]$4undefined) { raiseFieldError(makeNimstrLit($5)); }$n",
setx.res, tmp, disc.loc.r, if negCheck: ~"!==" else: ~"===",
makeJSString(msg))

Expand Down
24 changes: 12 additions & 12 deletions lib/system/chcks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,54 @@
# Implementation of some runtime checks.
include system/indexerrors

proc raiseRangeDefect(val: BiggestInt) {.compilerproc, noinline.} =
proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} =
when hostOS == "standalone":
sysFatal(RangeDefect, "value out of range")
else:
sysFatal(RangeDefect, "value out of range: ", $val)

proc raiseIndexDefect3(i, a, b: int) {.compilerproc, noinline.} =
proc raiseIndexError3(i, a, b: int) {.compilerproc, noinline.} =
sysFatal(IndexDefect, formatErrorIndexBound(i, a, b))

proc raiseIndexDefect2(i, n: int) {.compilerproc, noinline.} =
proc raiseIndexError2(i, n: int) {.compilerproc, noinline.} =
sysFatal(IndexDefect, formatErrorIndexBound(i, n))

proc raiseIndexDefect() {.compilerproc, noinline.} =
proc raiseIndexError() {.compilerproc, noinline.} =
sysFatal(IndexDefect, "index out of bounds")

proc raiseFieldDefect(f: string) {.compilerproc, noinline.} =
proc raiseFieldError(f: string) {.compilerproc, noinline.} =
sysFatal(FieldDefect, f)

proc raiseRangeDefectI(i, a, b: BiggestInt) {.compilerproc, noinline.} =
proc raiseRangeErrorI(i, a, b: BiggestInt) {.compilerproc, noinline.} =
sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)

proc raiseRangeDefectF(i, a, b: float) {.compilerproc, noinline.} =
proc raiseRangeErrorF(i, a, b: float) {.compilerproc, noinline.} =
sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)

proc raiseRangeDefectU(i, a, b: uint64) {.compilerproc, noinline.} =
proc raiseRangeErrorU(i, a, b: uint64) {.compilerproc, noinline.} =
# todo: better error reporting
sysFatal(RangeDefect, "value out of range")

proc raiseObjectConversionDefect() {.compilerproc, noinline.} =
proc raiseObjectConversionError() {.compilerproc, noinline.} =
sysFatal(ObjectConversionDefect, "invalid object conversion")

proc chckIndx(i, a, b: int): int =
if i >= a and i <= b:
return i
else:
raiseIndexDefect3(i, a, b)
raiseIndexError3(i, a, b)

proc chckRange(i, a, b: int): int =
if i >= a and i <= b:
return i
else:
raiseRangeDefect(i)
raiseRangeError(i)

proc chckRange64(i, a, b: int64): int64 {.compilerproc.} =
if i >= a and i <= b:
return i
else:
raiseRangeDefect(i)
raiseRangeError(i)

proc chckRangeU(i, a, b: uint64): uint64 {.compilerproc.} =
if i >= a and i <= b:
Expand Down
10 changes: 5 additions & 5 deletions lib/system/jssys.nim
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ proc raiseOverflow {.exportc: "raiseOverflow", noreturn, compilerproc.} =
proc raiseDivByZero {.exportc: "raiseDivByZero", noreturn, compilerproc.} =
raise newException(DivByZeroDefect, "division by zero")

proc raiseRangeDefect() {.compilerproc, noreturn.} =
proc raiseRangeError() {.compilerproc, noreturn.} =
raise newException(RangeDefect, "value out of range")

proc raiseIndexDefect(i, a, b: int) {.compilerproc, noreturn.} =
proc raiseIndexError(i, a, b: int) {.compilerproc, noreturn.} =
raise newException(IndexDefect, formatErrorIndexBound(int(i), int(a), int(b)))

proc raiseFieldDefect(f: string) {.compilerproc, noreturn.} =
proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
raise newException(FieldDefect, f)

proc setConstr() {.varargs, asmNoStackFrame, compilerproc.} =
Expand Down Expand Up @@ -651,11 +651,11 @@ proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {.

proc chckIndx(i, a, b: int): int {.compilerproc.} =
if i >= a and i <= b: return i
else: raiseIndexDefect(i, a, b)
else: raiseIndexError(i, a, b)

proc chckRange(i, a, b: int): int {.compilerproc.} =
if i >= a and i <= b: return i
else: raiseRangeDefect()
else: raiseRangeError()

proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
# checks if obj is of type subclass:
Expand Down

0 comments on commit c4151bb

Please sign in to comment.