move assertions out of system (#19599)

This commit is contained in:
flywind 2022-03-24 03:34:53 +08:00 • committed by GitHub
commit 7f6e800caf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
110 changed files with 361 additions and 10 deletions

View file

@ -10,6 +10,10 @@
include "system/inclrtl"
import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
## This module contains the interface to the compiler's abstract syntax
## tree (`AST`:idx:). Macros operate on this tree.
##

View file

@ -44,6 +44,10 @@ runnableExamples:
import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
type
SortOrder* = enum
Descending, Ascending

View file

@ -16,6 +16,9 @@ import std/private/since
import strutils
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(windows):
import winlean
from os import absolutePath

View file

@ -10,6 +10,10 @@
# An `include` file which contains common code for
# hash sets and tables.
when defined(nimPreviewSlimSystem):
import std/assertions
const
growthFactor = 2

View file

@ -84,6 +84,10 @@ import std/private/since
import macros
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(nimHasEffectsOf):
{.experimental: "strictEffects".}
else:

View file

@ -67,6 +67,10 @@ runnableExamples:
import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
type
Hash* = int ## A hash value. Hash tables using these values should
## always have a size of a power of two so they can use the `and`

View file

@ -165,7 +165,7 @@ import options # xxx remove this dependency using same approach as https://githu
import std/private/since
when defined(nimPreviewSlimSystem):
import std/syncio
import std/[syncio, assertions]
export
tables.`$`

View file

@ -14,6 +14,9 @@
import
strutils, streams
when defined(nimPreviewSlimSystem):
import std/assertions
const
EndOfFile* = '\0' ## end of file marker
NewLines* = {'\c', '\L'}

View file

@ -60,6 +60,10 @@ import std/private/since
import bitops, fenv
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(c) or defined(cpp):
proc c_isnan(x: float): bool {.importc: "isnan", header: "<math.h>".}
# a generic like `x: SomeFloat` might work too if this is implemented via a C macro.

View file

@ -71,6 +71,10 @@ supports pattern matching on `Option`s, with the `Some(<pattern>)` and
import typetraits
when defined(nimPreviewSlimSystem):
import std/assertions
when (NimMajor, NimMinor) >= (1, 1):
type
SomePointer = ref | ptr | pointer | proc

View file

@ -35,7 +35,7 @@ import std/private/since
import strutils, pathnorm
when defined(nimPreviewSlimSystem):
import std/syncio
import std/[syncio, assertions]
const weirdTarget = defined(nimscript) or defined(js)

View file

@ -31,6 +31,10 @@ else:
when defined(linux) and defined(useClone):
import linux
when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]
type
ProcessOption* = enum ## Options that can be passed to `startProcess proc
## <#startProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_.

View file

@ -14,6 +14,9 @@
import strutils, lexbase, streams, unicode
import std/private/decode_helpers
when defined(nimPreviewSlimSystem):
import std/assertions
type
JsonEventKind* = enum ## enumeration of all events that may occur when parsing
jsonError, ## an error occurred during parsing

View file

@ -13,6 +13,10 @@
import deques, streams
when defined(nimPreviewSlimSystem):
import std/assertions
type
PipeOutStream*[T] = ref object of T
# When stream peek operation is called, it reads from base stream

View file

@ -316,6 +316,10 @@ single letter DSLs.
import macros, parseutils, unicode
import strutils except format
when defined(nimPreviewSlimSystem):
import std/assertions
proc mkDigit(v: int, typ: char): string {.inline.} =
assert(v < 26)
if v < 10:

View file

@ -53,6 +53,10 @@ import std/private/since
import
hashes, strutils
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(js) or defined(nimscript) or defined(Standalone):
{.pragma: rtlFunc.}
else:

View file

@ -82,6 +82,9 @@ include "system/inclrtl"
import std/private/since
from std/private/strimpl import cmpIgnoreStyleImpl, cmpIgnoreCaseImpl, startsWithImpl, endsWithImpl
when defined(nimPreviewSlimSystem):
import std/assertions
const
Whitespace* = {' ', '\t', '\v', '\r', '\l', '\f'}

View file

@ -67,7 +67,7 @@ when defined(windows):
import winlean
when defined(nimPreviewSlimSystem):
import std/syncio
import std/[syncio, assertions]
type
PTerminal = ref object

View file

@ -201,6 +201,10 @@ import strutils, math, options
import std/private/since
include "system/inclrtl"
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(js):
import jscore

View file

@ -15,6 +15,10 @@
import std/private/since
export system.`$` # for backward compatibility
when defined(nimPreviewSlimSystem):
import std/assertions
type HoleyEnum* = (not Ordinal) and enum ## Enum with holes.
type OrdinalEnum* = Ordinal and enum ## Enum without holes.

View file

@ -1,7 +1,13 @@
## This module provides various assertion utilities.
##
## **Note:** This module is reexported by `system` and thus does not need to be
## imported directly (with `system/assertions`).
#
#
# Nim's Runtime Library
# (c) Copyright 2022 Nim contributors
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## This module implements assertion handling.
when not declared(sysFatal):
include "system/fatal"

View file

@ -10,6 +10,10 @@
import macros
from typetraits import OrdinalEnum, HoleyEnum
when defined(nimPreviewSlimSystem):
import std/assertions
# xxx `genEnumCaseStmt` needs tests and runnableExamples
macro genEnumCaseStmt*(typ: typedesc, argSym: typed, default: typed,

View file

@ -34,6 +34,9 @@ import macros
from enumutils import symbolName
from typetraits import OrdinalEnum
when defined(nimPreviewSlimSystem):
import std/assertions
when not defined(nimFixedForwardGeneric):
# xxx remove pending csources_v1 update >= 1.2.0
proc to[T](node: JsonNode, t: typedesc[T]): T =

View file

@ -24,6 +24,9 @@
import std/private/since
import hashes
when defined(nimPreviewSlimSystem):
import std/assertions
type
BitScalar = uint

View file

@ -8,6 +8,10 @@ import os
when defined(windows):
from strutils import replace
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(nimHasEffectsOf):
{.experimental: "strictEffects".}
else:

View file

@ -29,6 +29,9 @@ runnableExamples("-r:off"):
import strutils
from endians import bigEndian32, bigEndian64
when defined(nimPreviewSlimSystem):
import std/syncio
const Sha1DigestSize = 20
type

View file

@ -1830,8 +1830,11 @@ when not defined(nimscript):
when defined(nimV2):
include system/arc
import system/assertions
export assertions
when not defined(nimPreviewSlimSystem):
{.deprecated: """assertions is about to move out of system; use `-d:nimPreviewSlimSystem` and
import `std/assertions`.""".}
import std/assertions
export assertions
import system/iterators
export iterators

View file

@ -24,6 +24,8 @@
import std/private/digitsutils
when defined(nimPreviewSlimSystem):
import std/assertions
const
dtoaMinBufferLength*: cint = 64

View file

@ -7,6 +7,9 @@
# distribution, for details about the copyright.
#
when defined(nimPreviewSlimSystem):
import std/assertions
proc c_memcpy(a, b: pointer, size: csize_t): pointer {.importc: "memcpy", header: "<string.h>", discardable.}
proc addCstringN(result: var string, buf: cstring; buflen: int) =

View file

@ -1,3 +1,6 @@
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(nimHasLentIterators) and not defined(nimNoLentIterators):
template lent2(T): untyped = lent T
else:

View file

@ -12,6 +12,9 @@
import std/private/digitsutils
when defined(nimPreviewSlimSystem):
import std/assertions
template sf_Assert(x: untyped): untyped =
assert(x)