Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move assertions out of system #19599

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/aliases.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import
ast, astalgo, types, trees, intsets

when defined(nimPreviewSlimSystem):
import std/assertions

type
TAnalysisResult* = enum
arNo, arMaybe, arYes
Expand Down
3 changes: 3 additions & 0 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import
lineinfos, hashes, options, ropes, idents, int128, tables
from strutils import toLowerAscii

when defined(nimPreviewSlimSystem):
import std/assertions

export int128

type
Expand Down
3 changes: 3 additions & 0 deletions compiler/astalgo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import
ast, hashes, intsets, strutils, options, lineinfos, ropes, idents, rodutils,
msgs

when defined(nimPreviewSlimSystem):
import std/assertions

proc hashNode*(p: RootRef): Hash
proc treeToYaml*(conf: ConfigRef; n: PNode, indent: int = 0, maxRecDepth: int = - 1): Rope
# Convert a tree into its YAML representation; this is used by the
Expand Down
3 changes: 3 additions & 0 deletions compiler/bitsets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# this unit handles Nim sets; it implements bit sets
# the code here should be reused in the Nim standard library

when defined(nimPreviewSlimSystem):
import std/assertions

type
ElemType = byte
TBitSet* = seq[ElemType] # we use byte here to avoid issues with
Expand Down
3 changes: 3 additions & 0 deletions compiler/btrees.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
## BTree implementation with few features, but good enough for the
## Nim compiler's needs.

when defined(nimPreviewSlimSystem):
import std/assertions

const
M = 512 # max children per B-tree node = M-1
# (must be even and greater than 2)
Expand Down
3 changes: 3 additions & 0 deletions compiler/ccgutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import
ast, types, hashes, strutils, msgs, wordrecg,
platform, trees, options, cgendata

when defined(nimPreviewSlimSystem):
import std/assertions

proc getPragmaStmt*(n: PNode, w: TSpecialWord): PNode =
case n.kind
of nkStmtList:
Expand Down
4 changes: 4 additions & 0 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import
lowerings, tables, sets, ndi, lineinfos, pathutils, transf,
injectdestructors, astmsgs


when defined(nimPreviewSlimSystem):
import std/assertions

when not defined(leanCompiler):
import spawn, semparallel

Expand Down
4 changes: 4 additions & 0 deletions compiler/cgmeth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import
intsets, options, ast, msgs, idents, renderer, types, magicsys,
sempass2, strutils, modulegraphs, lineinfos

when defined(nimPreviewSlimSystem):
import std/assertions


proc genConv(n: PNode, d: PType, downcast: bool; conf: ConfigRef): PNode =
var dest = skipTypes(d, abstractPtrs)
var source = skipTypes(n.typ, abstractPtrs)
Expand Down
3 changes: 3 additions & 0 deletions compiler/closureiters.nim
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ import
renderer, magicsys, lowerings, lambdalifting, modulegraphs, lineinfos,
tables, options

when defined(nimPreviewSlimSystem):
import std/assertions

type
Ctx = object
g: ModuleGraph
Expand Down
3 changes: 3 additions & 0 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import

from ast import setUseIc, eqTypeFlags, tfGcSafe, tfNoSideEffect

when defined(nimPreviewSlimSystem):
import std/assertions

# but some have deps to imported modules. Yay.
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
bootSwitch(usedFFI, hasFFI, "-d:nimHasLibFFI")
Expand Down
3 changes: 3 additions & 0 deletions compiler/concepts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import ast, astalgo, semdata, lookups, lineinfos, idents, msgs, renderer, types,

from magicsys import addSonSkipIntLit

when defined(nimPreviewSlimSystem):
import std/assertions

const
logBindings = false

Expand Down
3 changes: 3 additions & 0 deletions compiler/dfa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import ast, intsets, lineinfos, renderer
import std/private/asciitables

when defined(nimPreviewSlimSystem):
import std/assertions

type
InstrKind* = enum
goto, fork, def, use
Expand Down
4 changes: 4 additions & 0 deletions compiler/enumtostr.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

import ast, idents, lineinfos, modulegraphs, magicsys

when defined(nimPreviewSlimSystem):
import std/assertions


proc genEnumToStrProc*(t: PType; info: TLineInfo; g: ModuleGraph; idgen: IdGenerator): PSym =
result = newSym(skProc, getIdent(g.cache, "$"), nextSymId idgen, t.owner, info)

Expand Down
3 changes: 3 additions & 0 deletions compiler/errorhandling.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

import ast, renderer, options, strutils, types

when defined(nimPreviewSlimSystem):
import std/assertions

type
ErrorKind* = enum ## expand as you need.
RawTypeMismatchError
Expand Down
3 changes: 3 additions & 0 deletions compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import ropes, platform, condsyms, options, msgs, lineinfos, pathutils

import std/[os, strutils, osproc, sha1, streams, sequtils, times, strtabs, json, jsonutils, sugar]

when defined(nimPreviewSlimSystem):
import std/syncio

type
TInfoCCProp* = enum # properties of the C compiler:
hasSwitchRange, # CC allows ranges in switch statements (GNU C)
Expand Down
3 changes: 3 additions & 0 deletions compiler/gorgeimpl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import msgs, std / sha1, os, osproc, streams, options,
lineinfos, pathutils

when defined(nimPreviewSlimSystem):
import std/syncio

proc readOutput(p: Process): (string, int) =
result[0] = ""
var output = p.outputStream
Expand Down
3 changes: 3 additions & 0 deletions compiler/guards.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import ast, astalgo, msgs, magicsys, nimsets, trees, types, renderer, idents,
saturate, modulegraphs, options, lineinfos, int128

when defined(nimPreviewSlimSystem):
import std/assertions

const
someEq = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
mEqStr, mEqSet, mEqCString}
Expand Down
3 changes: 3 additions & 0 deletions compiler/hlo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

# This include implements the high level optimization pass.

when defined(nimPreviewSlimSystem):
import std/assertions

proc hlo(c: PContext, n: PNode): PNode

proc evalPattern(c: PContext, n, orig: PNode): PNode =
Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/bitabs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import hashes, rodfiles

when defined(nimPreviewSlimSystem):
import std/assertions

type
LitId* = distinct uint32

Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/cbackend.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import std/packedsets, algorithm, tables

when defined(nimPreviewSlimSystem):
import std/assertions

import ".."/[ast, options, lineinfos, modulegraphs, cgendata, cgen,
pathutils, extccomp, msgs]

Expand Down
4 changes: 4 additions & 0 deletions compiler/ic/dce.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
## Dead code elimination (=DCE) for IC.

import std/[intsets, tables]

when defined(nimPreviewSlimSystem):
import std/assertions

import ".." / [ast, options, lineinfos, types]

import packed_ast, ic, bitabs
Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/ic.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import ".." / [ast, idents, lineinfos, msgs, ropes, options,
#import ".." / [renderer, astalgo]
from os import removeFile, isAbsolute

when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]

type
PackedConfig* = object
backend: TBackend
Expand Down
4 changes: 4 additions & 0 deletions compiler/ic/integrity.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
## The set must cover a complete Nim project.

import sets

when defined(nimPreviewSlimSystem):
import std/assertions

import ".." / [ast, modulegraphs]
import packed_ast, bitabs, ic

Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/navigator.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import sets
from os import nil
from std/private/miscdollars import toLocation

when defined(nimPreviewSlimSystem):
import std/assertions

import ".." / [ast, modulegraphs, msgs, options]
import packed_ast, bitabs, ic

Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/packed_ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import hashes, tables, strtabs
import bitabs
import ".." / [ast, options]

when defined(nimPreviewSlimSystem):
import std/assertions

type
SymId* = distinct int32
ModuleId* = distinct int32
Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/replayer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import ".." / [ast, modulegraphs, trees, extccomp, btrees,

import tables

when defined(nimPreviewSlimSystem):
import std/assertions

import packed_ast, ic, bitabs

proc replayStateChanges*(module: PSym; g: ModuleGraph) =
Expand Down
3 changes: 3 additions & 0 deletions compiler/ic/rodfiles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

from typetraits import supportsCopyMem

when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]

## Overview
## ========
## `RodFile` represents a Rod File (versioned binary format), and the
Expand Down
3 changes: 3 additions & 0 deletions compiler/idents.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import
hashes, wordrecg

when defined(nimPreviewSlimSystem):
import std/assertions

type
PIdent* = ref TIdent
TIdent*{.acyclic.} = object
Expand Down
3 changes: 3 additions & 0 deletions compiler/importer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import
modulegraphs, wordrecg, tables
from strutils import `%`

when defined(nimPreviewSlimSystem):
import std/assertions

proc readExceptSet*(c: PContext, n: PNode): IntSet =
assert n.kind in {nkImportExceptStmt, nkExportExceptStmt}
result = initIntSet()
Expand Down
3 changes: 3 additions & 0 deletions compiler/injectdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import
lineinfos, parampatterns, sighashes, liftdestructors, optimizer,
varpartitions

when defined(nimPreviewSlimSystem):
import std/assertions

from trees import exprStructuralEquivalent, getRoot

type
Expand Down
3 changes: 3 additions & 0 deletions compiler/int128.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from math import trunc

when defined(nimPreviewSlimSystem):
import std/assertions

type
Int128* = object
udata: array[4, uint32]
Expand Down
3 changes: 3 additions & 0 deletions compiler/isolation_check.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import
ast, types, renderer, intsets

when defined(nimPreviewSlimSystem):
import std/assertions

proc canAlias(arg, ret: PType; marker: var IntSet): bool

proc canAliasN(arg: PType; n: PNode; marker: var IntSet): bool =
Expand Down
3 changes: 3 additions & 0 deletions compiler/lambdalifting.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import
idents, renderer, types, magicsys, lowerings, tables, modulegraphs, lineinfos,
transf, liftdestructors, typeallowed

when defined(nimPreviewSlimSystem):
import std/assertions

discard """
The basic approach is that captured vars need to be put on the heap and
that the calling chain needs to be explicitly modelled. Things to consider:
Expand Down
3 changes: 3 additions & 0 deletions compiler/lexer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import
hashes, options, msgs, strutils, platform, idents, nimlexbase, llstream,
wordrecg, lineinfos, pathutils, parseutils

when defined(nimPreviewSlimSystem):
import std/assertions

const
MaxLineLength* = 80 # lines longer than this lead to a warning
numChars*: set[char] = {'0'..'9', 'a'..'z', 'A'..'Z'}
Expand Down
3 changes: 3 additions & 0 deletions compiler/liftdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import modulegraphs, lineinfos, idents, ast, renderer, semdata,

from trees import isCaseObj

when defined(nimPreviewSlimSystem):
import std/assertions

type
TLiftCtx = object
g: ModuleGraph
Expand Down
3 changes: 3 additions & 0 deletions compiler/llstream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import
pathutils

when defined(nimPreviewSlimSystem):
import std/syncio

# support `useGnuReadline`, `useLinenoise` for backwards compatibility
const hasRstdin = (defined(nimUseLinenoise) or defined(useLinenoise) or defined(useGnuReadline)) and
not defined(windows)
Expand Down
4 changes: 4 additions & 0 deletions compiler/lookups.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

# This module implements lookup helpers.
import std/[algorithm, strutils]

when defined(nimPreviewSlimSystem):
import std/assertions

import
intsets, ast, astalgo, idents, semdata, types, msgs, options,
renderer, nimfix/prettybase, lineinfos, modulegraphs, astmsgs
Expand Down
3 changes: 3 additions & 0 deletions compiler/lowerings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const
import ast, astalgo, types, idents, magicsys, msgs, options, modulegraphs,
lineinfos

when defined(nimPreviewSlimSystem):
import std/assertions

proc newDeref*(n: PNode): PNode {.inline.} =
result = newNodeIT(nkHiddenDeref, n.info, n.typ[0])
result.add n
Expand Down
4 changes: 4 additions & 0 deletions compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import
modules,
modulegraphs, lineinfos, pathutils, vmprofiler


when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]

import ic / [cbackend, integrity, navigator]
from ic / ic import rodViewer

Expand Down
Loading