moderate system cleanup & refactor (#20355)
* system refactor, move out 600 lines * compilation, slice, backwardsindex, misc_num moved out of system * some procs/types moved into arithmetics, basic_types * system no longer depends on syncio * some procs moved around to fit with their surroundings * make exceptions an import, old ops to misc_num * move instantiationInfo back * move back nim version, fix windows echo * include compilation * better docs for imported modules, fix unsigned ops also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem * fix terminal * workaround IC test & weird csize bug, changelog * move NimMajor etc back to compilation, rebase for CI * try ic fix * form single `indices`, slim out TaintedString, try fix IC * fix CI, update changelog, addQuitProc * fix CI * try fix CI * actually fix CI finally hopefully * Update lib/system/compilation.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * update kochdocs * hopefully fix csize uses for slimsystem * fix tquit Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
This commit is contained in:
parent
b463c8aedf
commit
919a889ba8
37 changed files with 1167 additions and 1102 deletions
|
|
@ -45,109 +45,6 @@ proc dec*[T: Ordinal](x: var T, y = 1) {.magic: "Dec", noSideEffect.} =
|
|||
# --------------------------------------------------------------------------
|
||||
# built-in operators
|
||||
|
||||
when defined(nimNoZeroExtendMagic):
|
||||
proc ze*(x: int8): int {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int](uint(cast[uint8](x)))
|
||||
|
||||
proc ze*(x: int16): int {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int](uint(cast[uint16](x)))
|
||||
|
||||
proc ze64*(x: int8): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint8](x)))
|
||||
|
||||
proc ze64*(x: int16): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint16](x)))
|
||||
|
||||
proc ze64*(x: int32): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint32](x)))
|
||||
|
||||
proc ze64*(x: int): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned. Does nothing if the size of an `int` is the same as `int64`.
|
||||
## (This is the case on 64 bit processors.)
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint](x)))
|
||||
|
||||
proc toU8*(x: int): int8 {.deprecated.} =
|
||||
## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
|
||||
## from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int8](x)
|
||||
|
||||
proc toU16*(x: int): int16 {.deprecated.} =
|
||||
## treats `x` as unsigned and converts it to an `int16` by taking the last
|
||||
## 16 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int16](x)
|
||||
|
||||
proc toU32*(x: int64): int32 {.deprecated.} =
|
||||
## treats `x` as unsigned and converts it to an `int32` by taking the
|
||||
## last 32 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int32](x)
|
||||
|
||||
elif not defined(js):
|
||||
proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned. Does nothing if the size of an `int` is the same as `int64`.
|
||||
## (This is the case on 64 bit processors.)
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect, deprecated.}
|
||||
## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
|
||||
## from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect, deprecated.}
|
||||
## treats `x` as unsigned and converts it to an `int16` by taking the last
|
||||
## 16 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect, deprecated.}
|
||||
## treats `x` as unsigned and converts it to an `int32` by taking the
|
||||
## last 32 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
# integer calculations:
|
||||
proc `+`*(x: int): int {.magic: "UnaryPlusI", noSideEffect.}
|
||||
## Unary `+` operator for an integer. Has no effect.
|
||||
|
|
@ -399,6 +296,59 @@ proc `mod`*(x, y: uint16): uint16 {.magic: "ModU", noSideEffect.}
|
|||
proc `mod`*(x, y: uint32): uint32 {.magic: "ModU", noSideEffect.}
|
||||
proc `mod`*(x, y: uint64): uint64 {.magic: "ModU", noSideEffect.}
|
||||
|
||||
proc `+=`*[T: SomeInteger](x: var T, y: T) {.
|
||||
magic: "Inc", noSideEffect.}
|
||||
## Increments an integer.
|
||||
|
||||
proc `-=`*[T: SomeInteger](x: var T, y: T) {.
|
||||
magic: "Dec", noSideEffect.}
|
||||
## Decrements an integer.
|
||||
|
||||
proc `*=`*[T: SomeInteger](x: var T, y: T) {.
|
||||
inline, noSideEffect.} =
|
||||
## Binary `*=` operator for integers.
|
||||
x = x * y
|
||||
|
||||
# floating point operations:
|
||||
proc `+`*(x: float32): float32 {.magic: "UnaryPlusF64", noSideEffect.}
|
||||
proc `-`*(x: float32): float32 {.magic: "UnaryMinusF64", noSideEffect.}
|
||||
proc `+`*(x, y: float32): float32 {.magic: "AddF64", noSideEffect.}
|
||||
proc `-`*(x, y: float32): float32 {.magic: "SubF64", noSideEffect.}
|
||||
proc `*`*(x, y: float32): float32 {.magic: "MulF64", noSideEffect.}
|
||||
proc `/`*(x, y: float32): float32 {.magic: "DivF64", noSideEffect.}
|
||||
|
||||
proc `+`*(x: float): float {.magic: "UnaryPlusF64", noSideEffect.}
|
||||
proc `-`*(x: float): float {.magic: "UnaryMinusF64", noSideEffect.}
|
||||
proc `+`*(x, y: float): float {.magic: "AddF64", noSideEffect.}
|
||||
proc `-`*(x, y: float): float {.magic: "SubF64", noSideEffect.}
|
||||
proc `*`*(x, y: float): float {.magic: "MulF64", noSideEffect.}
|
||||
proc `/`*(x, y: float): float {.magic: "DivF64", noSideEffect.}
|
||||
|
||||
proc `+=`*[T: float|float32|float64] (x: var T, y: T) {.
|
||||
inline, noSideEffect.} =
|
||||
## Increments in place a floating point number.
|
||||
x = x + y
|
||||
|
||||
proc `-=`*[T: float|float32|float64] (x: var T, y: T) {.
|
||||
inline, noSideEffect.} =
|
||||
## Decrements in place a floating point number.
|
||||
x = x - y
|
||||
|
||||
proc `*=`*[T: float|float32|float64] (x: var T, y: T) {.
|
||||
inline, noSideEffect.} =
|
||||
## Multiplies in place a floating point number.
|
||||
x = x * y
|
||||
|
||||
proc `/=`*(x: var float64, y: float64) {.inline, noSideEffect.} =
|
||||
## Divides in place a floating point number.
|
||||
x = x / y
|
||||
|
||||
proc `/=`*[T: float|float32](x: var T, y: T) {.inline, noSideEffect.} =
|
||||
## Divides in place a floating point number.
|
||||
x = x / y
|
||||
|
||||
# the following have to be included in system, not imported for some reason:
|
||||
|
||||
proc `+%`*(x, y: int): int {.inline.} =
|
||||
## Treats `x` and `y` as unsigned and adds them.
|
||||
##
|
||||
|
|
@ -454,15 +404,106 @@ proc `%%`*(x, y: int16): int16 {.inline.} = cast[int16](cast[uint16](x) mod cast
|
|||
proc `%%`*(x, y: int32): int32 {.inline.} = cast[int32](cast[uint32](x) mod cast[uint32](y))
|
||||
proc `%%`*(x, y: int64): int64 {.inline.} = cast[int64](cast[uint64](x) mod cast[uint64](y))
|
||||
|
||||
proc `+=`*[T: SomeInteger](x: var T, y: T) {.
|
||||
magic: "Inc", noSideEffect.}
|
||||
## Increments an integer.
|
||||
when not defined(nimPreviewSlimSystem):
|
||||
when defined(nimNoZeroExtendMagic):
|
||||
proc ze*(x: int8): int {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int](uint(cast[uint8](x)))
|
||||
|
||||
proc `-=`*[T: SomeInteger](x: var T, y: T) {.
|
||||
magic: "Dec", noSideEffect.}
|
||||
## Decrements an integer.
|
||||
proc ze*(x: int16): int {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int](uint(cast[uint16](x)))
|
||||
|
||||
proc `*=`*[T: SomeInteger](x: var T, y: T) {.
|
||||
inline, noSideEffect.} =
|
||||
## Binary `*=` operator for integers.
|
||||
x = x * y
|
||||
proc ze64*(x: int8): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint8](x)))
|
||||
|
||||
proc ze64*(x: int16): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint16](x)))
|
||||
|
||||
proc ze64*(x: int32): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint32](x)))
|
||||
|
||||
proc ze64*(x: int): int64 {.deprecated.} =
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned. Does nothing if the size of an `int` is the same as `int64`.
|
||||
## (This is the case on 64 bit processors.)
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int64](uint64(cast[uint](x)))
|
||||
|
||||
proc toU8*(x: int): int8 {.deprecated.} =
|
||||
## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
|
||||
## from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int8](x)
|
||||
|
||||
proc toU16*(x: int): int16 {.deprecated.} =
|
||||
## treats `x` as unsigned and converts it to an `int16` by taking the last
|
||||
## 16 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int16](x)
|
||||
|
||||
proc toU32*(x: int64): int32 {.deprecated.} =
|
||||
## treats `x` as unsigned and converts it to an `int32` by taking the
|
||||
## last 32 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
cast[int32](x)
|
||||
|
||||
elif not defined(js):
|
||||
proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect, deprecated.}
|
||||
## zero extends a smaller integer type to `int64`. This treats `x` as
|
||||
## unsigned. Does nothing if the size of an `int` is the same as `int64`.
|
||||
## (This is the case on 64 bit processors.)
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect, deprecated.}
|
||||
## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
|
||||
## from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect, deprecated.}
|
||||
## treats `x` as unsigned and converts it to an `int16` by taking the last
|
||||
## 16 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
||||
proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect, deprecated.}
|
||||
## treats `x` as unsigned and converts it to an `int32` by taking the
|
||||
## last 32 bits from `x`.
|
||||
## **Deprecated since version 0.19.9**: Use unsigned integers instead.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue