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:
metagn 2022-09-28 22:28:45 +03:00 • committed by GitHub
commit 919a889ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 1167 additions and 1102 deletions

View file

@ -74,37 +74,37 @@ block tn8vsint16:
import strutils
block tcolors:
type TColor = distinct int32
type TColor = distinct uint32
proc rgb(r, g, b: range[0..255]): TColor =
result = TColor(r or g shl 8 or b shl 16)
proc `$`(c: TColor): string =
result = "#" & toHex(int32(c), 6)
result = "#" & toHex(uint32(c), 6)
echo rgb(34, 55, 255)
when false:
block:
type
TColor = distinct int32
TColorComponent = distinct int8
TColor = distinct uint32
TColorComponent = distinct uint8
proc red(a: TColor): TColorComponent =
result = TColorComponent(int32(a) and 0xff'i32)
result = TColorComponent(uint32(a) and 0xff'u32)
proc green(a: TColor): TColorComponent =
result = TColorComponent(int32(a) shr 8'i32 and 0xff'i32)
result = TColorComponent(uint32(a) shr 8'u32 and 0xff'u32)
proc blue(a: TColor): TColorComponent =
result = TColorComponent(int32(a) shr 16'i32 and 0xff'i32)
result = TColorComponent(uint32(a) shr 16'u32 and 0xff'u32)
proc rgb(r, g, b: range[0..255]): TColor =
result = TColor(r or g shl 8 or b shl 8)
proc `+!` (a, b: TColorComponent): TColorComponent =
## saturated arithmetic:
result = TColorComponent(min(ze(int8(a)) + ze(int8(b)), 255))
result = TColorComponent(min(int(uint8(a)) + int(uint8(b)), 255))
proc `+` (a, b: TColor): TColor =
## saturated arithmetic for colors makes sense, I think:
return rgb(red(a) +! red(b), green(a) +! green(b), blue(a) +! blue(b))
return rgb(int(red(a) +! red(b)), int(green(a) +! green(b)), int(blue(a) +! blue(b)))
rgb(34, 55, 255)
discard rgb(34, 55, 255)
block:
type