diff --git a/changelog.md b/changelog.md index cfbd51de9e930..77450f906903d 100644 --- a/changelog.md +++ b/changelog.md @@ -6,8 +6,8 @@ - `addr` is now available for all addressable locations, `unsafeAddr` is now deprecated and an alias for `addr`. -- `io` and `assertions` are about to move out of the `system` module. - You may instead import `std/syncio` and `std/assertions`. +- `io`, `assertions` and `dollars` are about to move out of the `system` module. + You may instead import `std/syncio`, `std/assertions` and `std/dollars`. The `-d:nimPreviewSlimSystem` option makes these imports required. - The `gc:v2` option is removed. diff --git a/compiler/ast.nim b/compiler/ast.nim index 27e4fab63374b..05d126d28891b 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -14,7 +14,7 @@ import from strutils import toLowerAscii when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] export int128 diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 22f4257fc512b..755e2b2ef10ff 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -16,7 +16,7 @@ import msgs when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when not defined(nimHasCursor): {.pragma: cursor.} diff --git a/compiler/btrees.nim b/compiler/btrees.nim index c79442249df94..242823ca057db 100644 --- a/compiler/btrees.nim +++ b/compiler/btrees.nim @@ -11,7 +11,7 @@ ## Nim compiler's needs. when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] const M = 512 # max children per B-tree node = M-1 diff --git a/compiler/cgen.nim b/compiler/cgen.nim index c0b94ebbb0f14..52fdd17ec4569 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -18,7 +18,7 @@ import injectdestructors, astmsgs, modulepaths when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when not defined(leanCompiler): import spawn, semparallel diff --git a/compiler/closureiters.nim b/compiler/closureiters.nim index 613fbe582c567..172600f52c042 100644 --- a/compiler/closureiters.nim +++ b/compiler/closureiters.nim @@ -137,7 +137,7 @@ import tables, options when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type Ctx = object diff --git a/compiler/commands.nim b/compiler/commands.nim index a71dae9d96da0..bab41215355f2 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -32,7 +32,7 @@ import from ast import setUseIc, eqTypeFlags, tfGcSafe, tfNoSideEffect when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] # but some have deps to imported modules. Yay. bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc") diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 5a7e78d5f8b22..d14bc9cb5ef2c 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -15,6 +15,9 @@ import from options import Feature from lineinfos import hintMin, hintMax, warnMin, warnMax +when defined(nimPreviewSlimSystem): + import std/dollars + proc defineSymbol*(symbols: StringTableRef; symbol: string, value: string = "true") = symbols[symbol] = value diff --git a/compiler/depends.nim b/compiler/depends.nim index 7e5dabbd3332f..aa55823e8c459 100644 --- a/compiler/depends.nim +++ b/compiler/depends.nim @@ -17,7 +17,7 @@ import std/[os, strutils, parseutils] import std/private/globs when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 5b048ff6e99f0..7d6138a4f3bcb 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -33,7 +33,7 @@ import ast, intsets, lineinfos, renderer import std/private/asciitables when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type InstrKind* = enum diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 8c95692df7336..ff1d8ccfea03d 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -24,7 +24,7 @@ from std/private/globs import nativeToUnixPath from nodejs import findNodeJs when defined(nimPreviewSlimSystem): - import std/[assertions, syncio] + import std/[assertions, syncio, dollars] const diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim index d1d88a1fa18d4..555e479f37c65 100644 --- a/compiler/evalffi.nim +++ b/compiler/evalffi.nim @@ -13,6 +13,9 @@ import ast, types, options, tables, dynlib, msgs, lineinfos from os import getAppFilename import pkg/libffi +when defined(nimPreviewSlimSystem): + import std/dollars + when defined(windows): const libcDll = "msvcrt.dll" elif defined(linux): diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim index 8a6bf92870980..e5249c12e4c87 100644 --- a/compiler/evaltempl.nim +++ b/compiler/evaltempl.nim @@ -12,6 +12,9 @@ import strutils, options, ast, astalgo, msgs, renderer, lineinfos, idents +when defined(nimPreviewSlimSystem): + import std/dollars + type TemplCtx = object owner, genSymOwner: PSym diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 6d306d0e6eeaf..dd48d4de17d0b 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -17,7 +17,7 @@ import ropes, platform, condsyms, options, msgs, lineinfos, pathutils, modulepat import std/[os, strutils, osproc, sha1, streams, sequtils, times, strtabs, json, jsonutils, sugar, parseutils] when defined(nimPreviewSlimSystem): - import std/syncio + import std/[syncio, dollars] type TInfoCCProp* = enum # properties of the C compiler: diff --git a/compiler/ic/bitabs.nim b/compiler/ic/bitabs.nim index 8adab83880246..23fcdccaf2d98 100644 --- a/compiler/ic/bitabs.nim +++ b/compiler/ic/bitabs.nim @@ -4,7 +4,7 @@ import hashes, rodfiles when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type LitId* = distinct uint32 diff --git a/compiler/ic/ic.nim b/compiler/ic/ic.nim index 38b6987f99f33..61c7eb86c09bc 100644 --- a/compiler/ic/ic.nim +++ b/compiler/ic/ic.nim @@ -15,7 +15,7 @@ import ".." / [ast, idents, lineinfos, msgs, ropes, options, from os import removeFile, isAbsolute when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] type PackedConfig* = object diff --git a/compiler/ic/integrity.nim b/compiler/ic/integrity.nim index d341fd6536389..24677d91b5b0c 100644 --- a/compiler/ic/integrity.nim +++ b/compiler/ic/integrity.nim @@ -13,7 +13,7 @@ import sets when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] import ".." / [ast, modulegraphs] import packed_ast, bitabs, ic diff --git a/compiler/idents.nim b/compiler/idents.nim index f36ce09f3c48a..8c2efe594a394 100644 --- a/compiler/idents.nim +++ b/compiler/idents.nim @@ -15,7 +15,7 @@ import hashes, wordrecg when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type PIdent* = ref TIdent diff --git a/compiler/importer.nim b/compiler/importer.nim index c4e37c2692619..92e8ef765f871 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -16,7 +16,7 @@ import from strutils import `%` when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc readExceptSet*(c: PContext, n: PNode): IntSet = assert n.kind in {nkImportExceptStmt, nkExportExceptStmt} diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 867d30d96be64..7eee88df109da 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -20,7 +20,7 @@ import varpartitions when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] from trees import exprStructuralEquivalent, getRoot diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 60d10f58de5df..a23ef4e19ae76 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -38,7 +38,7 @@ import import json, sets, math, tables, intsets, strutils when defined(nimPreviewSlimSystem): - import std/[assertions, syncio] + import std/[assertions, syncio, dollars] type diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 96edba8c88329..f1a253b75ae59 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -15,7 +15,7 @@ import transf, liftdestructors, typeallowed when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] discard """ The basic approach is that captured vars need to be put on the heap and diff --git a/compiler/lexer.nim b/compiler/lexer.nim index e795d52c08024..3671ff2e075d8 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -20,7 +20,7 @@ import wordrecg, lineinfos, pathutils, parseutils when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] const MaxLineLength* = 80 # lines longer than this lead to a warning diff --git a/compiler/linter.nim b/compiler/linter.nim index 2c0ad4d6f43f8..fa2495b6ba11c 100644 --- a/compiler/linter.nim +++ b/compiler/linter.nim @@ -12,6 +12,9 @@ import std/strutils from std/sugar import dup +when defined(nimPreviewSlimSystem): + import std/dollars + import options, ast, msgs, idents, lineinfos, wordrecg, astmsgs, semdata, packages export packages diff --git a/compiler/lookups.nim b/compiler/lookups.nim index d61e15915ad3d..334a7796b8fdb 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -11,7 +11,7 @@ import std/[algorithm, strutils] when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] import intsets, ast, astalgo, idents, semdata, types, msgs, options, diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index fc66fc9fa20d6..9b9bcb8eb98d1 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -16,7 +16,7 @@ import ast, astalgo, types, idents, magicsys, msgs, options, modulegraphs, lineinfos when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc newDeref*(n: PNode): PNode {.inline.} = result = newNodeIT(nkHiddenDeref, n.info, n.typ[0]) diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim index ab234a2a8c438..b6d3c4312c591 100644 --- a/compiler/magicsys.nim +++ b/compiler/magicsys.nim @@ -13,6 +13,9 @@ import ast, astalgo, msgs, platform, idents, modulegraphs, lineinfos +when defined(nimPreviewSlimSystem): + import std/dollars + export createMagic proc nilOrSysInt*(g: ModuleGraph): PType = g.sysTypes[tyInt] diff --git a/compiler/main.nim b/compiler/main.nim index 0354bec9c7261..6bb551d9ff98e 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -24,7 +24,7 @@ import when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] import ic / [cbackend, integrity, navigator] from ic / ic import rodViewer diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index 8294d863e1d5d..e864e69976fe3 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -16,7 +16,7 @@ import ast, astalgo, options, lineinfos,idents, btrees, ropes, msgs, pathutils, import ic / [packed_ast, ic] when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type SigHash* = distinct MD5Digest diff --git a/compiler/modulepaths.nim b/compiler/modulepaths.nim index e80ea3fa66329..79efcc7b01611 100644 --- a/compiler/modulepaths.nim +++ b/compiler/modulepaths.nim @@ -10,6 +10,9 @@ import ast, renderer, strutils, msgs, options, idents, os, lineinfos, pathutils +when defined(nimPreviewSlimSystem): + import std/dollars + proc getModuleName*(conf: ConfigRef; n: PNode): string = # This returns a short relative module name without the nim extension # e.g. like "system", "importer" or "somepath/module" diff --git a/compiler/msgs.nim b/compiler/msgs.nim index ed65e03429646..9236fc4c954bf 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -13,7 +13,7 @@ import options, ropes, lineinfos, pathutils, strutils2 when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] type InstantiationInfo* = typeof(instantiationInfo()) diff --git a/compiler/ndi.nim b/compiler/ndi.nim index a9d9cfe791c6c..a4e9cd32013d2 100644 --- a/compiler/ndi.nim +++ b/compiler/ndi.nim @@ -13,7 +13,7 @@ import ast, msgs, ropes, options, pathutils when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] type NdiFile* = object diff --git a/compiler/nilcheck.nim b/compiler/nilcheck.nim index 49ceb8942b059..068cf366cc081 100644 --- a/compiler/nilcheck.nim +++ b/compiler/nilcheck.nim @@ -11,7 +11,7 @@ import ast, renderer, intsets, tables, msgs, options, lineinfos, strformat, iden import sequtils, strutils, sets when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] # IMPORTANT: notes not up to date, i'll update this comment again # diff --git a/compiler/nim.nim b/compiler/nim.nim index 48472507da17a..991e0fc452ae9 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -10,7 +10,7 @@ import std/[os, strutils, parseopt] when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when defined(windows) and not defined(nimKochBootstrap): # remove workaround pending bootstrap >= 1.5.1 diff --git a/compiler/nimblecmd.nim b/compiler/nimblecmd.nim index b6b08ccd455c0..dd1524a7936af 100644 --- a/compiler/nimblecmd.nim +++ b/compiler/nimblecmd.nim @@ -13,7 +13,7 @@ import parseutils, strutils, os, options, msgs, sequtils, lineinfos, pathutils, std/sha1, tables when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] proc addPath*(conf: ConfigRef; path: AbsoluteDir, info: TLineInfo) = if not conf.searchPaths.contains(path): diff --git a/compiler/nimpaths.nim b/compiler/nimpaths.nim index c6e1882892241..59897f3a6b56a 100644 --- a/compiler/nimpaths.nim +++ b/compiler/nimpaths.nim @@ -20,7 +20,7 @@ Unstable API import os, strutils when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] const diff --git a/compiler/nodejs.nim b/compiler/nodejs.nim index 283643e8d2edd..66f4c0e6db744 100644 --- a/compiler/nodejs.nim +++ b/compiler/nodejs.nim @@ -1,5 +1,9 @@ import os +when defined(nimPreviewSlimSystem): + import std/dollars + + proc findNodeJs*(): string {.inline.} = ## Find NodeJS executable and return it as a string. result = findExe("nodejs") diff --git a/compiler/parampatterns.nim b/compiler/parampatterns.nim index cceb236ae0951..0eeccb22bc73c 100644 --- a/compiler/parampatterns.nim +++ b/compiler/parampatterns.nim @@ -13,6 +13,9 @@ import strutils, ast, types, msgs, idents, renderer, wordrecg, trees, options +when defined(nimPreviewSlimSystem): + import std/dollars + # we precompile the pattern here for efficiency into some internal # stack based VM :-) Why? Because it's fun; I did no benchmarks to see if that # actually improves performance. diff --git a/compiler/parser.nim b/compiler/parser.nim index 52466d9fa0f04..7bc1a94913acf 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -37,7 +37,7 @@ when defined(nimpretty): import layouter when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type Parser* = object # A Parser object represents a file that diff --git a/compiler/passaux.nim b/compiler/passaux.nim index 68b7832489bb0..f1be8c9e27b24 100644 --- a/compiler/passaux.nim +++ b/compiler/passaux.nim @@ -14,6 +14,9 @@ import from modulegraphs import ModuleGraph, PPassContext +when defined(nimPreviewSlimSystem): + import std/dollars + type VerboseRef = ref object of PPassContext config: ConfigRef diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 8c7d75024eea2..fa49cdb401b90 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -15,7 +15,7 @@ import types, lookups, lineinfos, pathutils, linter when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] from ic / ic import addCompilerProc diff --git a/compiler/renderer.nim b/compiler/renderer.nim index f847aa0944eb6..4eb1572415ee4 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -18,7 +18,7 @@ import lexer, options, idents, strutils, ast, msgs, lineinfos when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] type TRenderFlag* = enum diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 677a3ce096ba4..72375db98b5dd 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -61,7 +61,7 @@ import from pathutils import AbsoluteFile when defined(nimPreviewSlimSystem): - import std/[assertions, syncio] + import std/[assertions, syncio, dollars] type diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 4f956785e0fdd..ca9060c2405d0 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -12,6 +12,9 @@ from algorithm import sort +when defined(nimPreviewSlimSystem): + import std/dollars + proc sameMethodDispatcher(a, b: PSym): bool = result = false if a.kind == skMethod and b.kind == skMethod: diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 72c8abaa98b1f..c2a0474b3c8a0 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -18,7 +18,7 @@ import from system/memory import nimCStrLen when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc errorType*(g: ModuleGraph): PType = ## creates a type representing an error state diff --git a/compiler/semmacrosanity.nim b/compiler/semmacrosanity.nim index aebee89981daa..40adf20712240 100644 --- a/compiler/semmacrosanity.nim +++ b/compiler/semmacrosanity.nim @@ -12,6 +12,9 @@ import ast, msgs, types, options +when defined(nimPreviewSlimSystem): + import std/dollars + proc ithField(n: PNode, field: var int): PSym = result = nil case n.kind diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 1e3e4135080ba..dafbf6de8e919 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -13,7 +13,7 @@ import modulegraphs, varpartitions, typeallowed, nilcheck, errorhandling, tables when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when defined(useDfa): import dfa diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index 1835d9d0f7051..c4a4873c01755 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -14,7 +14,7 @@ from hashes import Hash import types when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc `&=`(c: var MD5Context, s: string) = md5Update(c, s, s.len) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index f195c4e455858..a1effd0b4690d 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -16,7 +16,7 @@ import linter, lineinfos, lowerings, modulegraphs, concepts when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type MismatchKind* = enum diff --git a/compiler/sourcemap.nim b/compiler/sourcemap.nim index b87de75f35eca..5b3d5165cd79e 100644 --- a/compiler/sourcemap.nim +++ b/compiler/sourcemap.nim @@ -1,5 +1,8 @@ import os, strformat, strutils, tables, sets, ropes, json, algorithm +when defined(nimPreviewSlimSystem): + import std/dollars + type SourceNode* = ref object line*: int diff --git a/compiler/spawn.nim b/compiler/spawn.nim index 581f722d5390f..156e3da1d6d70 100644 --- a/compiler/spawn.nim +++ b/compiler/spawn.nim @@ -13,6 +13,9 @@ import ast, types, idents, magicsys, msgs, options, modulegraphs, lowerings, liftdestructors, renderer from trees import getMagic, getRoot +when defined(nimPreviewSlimSystem): + import std/dollars + proc callProc(a: PNode): PNode = result = newNodeI(nkCall, a.info) result.add a diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim index c00fe8b6771b8..3d8fae5104acf 100644 --- a/compiler/syntaxes.nim +++ b/compiler/syntaxes.nim @@ -14,7 +14,7 @@ import filters, filter_tmpl, renderer, lineinfos, pathutils when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] export Parser, parseAll, parseTopLevelStmt, checkFirstLineIndentation, closeParser diff --git a/compiler/types.nim b/compiler/types.nim index 6855776412e37..1d902963a1191 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -14,7 +14,7 @@ import lineinfos, int128, modulegraphs, astmsgs when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type TPreferedDesc* = enum diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim index a93104b06c4ef..a876ec2d46a6b 100644 --- a/compiler/varpartitions.nim +++ b/compiler/varpartitions.nim @@ -33,7 +33,7 @@ from trees import getMagic, isNoSideEffectPragma, stupidStmtListExpr from isolation_check import canAlias when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type AbstractTime = distinct int diff --git a/compiler/vm.nim b/compiler/vm.nim index 28df27ef389d8..a9c0a14cb17a2 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -18,6 +18,9 @@ import gorgeimpl, lineinfos, btrees, macrocacheimpl, modulegraphs, sighashes, int128, vmprofiler +when defined(nimPreviewSlimSystem): + import std/dollars + import ast except getstr from semfold import leValueConv, ordinalValToString from evaltempl import evalTemplate diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index aa2bdbe4ccad0..aad2b522ec467 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -30,7 +30,7 @@ import tables when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] import strutils, ast, types, msgs, renderer, vmdef, diff --git a/compiler/vmmarshal.nim b/compiler/vmmarshal.nim index 83c441283ee1b..c9f8fc30ca837 100644 --- a/compiler/vmmarshal.nim +++ b/compiler/vmmarshal.nim @@ -13,7 +13,7 @@ import streams, json, intsets, tables, ast, astalgo, idents, types, msgs, options, lineinfos when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc ptrToInt(x: PNode): int {.inline.} = result = cast[int](x) # don't skip alignment diff --git a/compiler/vmprofiler.nim b/compiler/vmprofiler.nim index f586c8ffe3b5a..846485c6d77e2 100644 --- a/compiler/vmprofiler.nim +++ b/compiler/vmprofiler.nim @@ -3,6 +3,9 @@ import options, vmdef, times, lineinfos, strutils, tables, msgs +when defined(nimPreviewSlimSystem): + import std/dollars + proc enter*(prof: var Profiler, c: PCtx, tos: PStackFrame) {.inline.} = if optProfileVM in c.config.globalOptions: prof.tEnter = cpuTime() diff --git a/lib/core/macros.nim b/lib/core/macros.nim index ad87a0f64e2fb..d01b9f3b21343 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -11,7 +11,7 @@ include "system/inclrtl" import std/private/since when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] ## This module contains the interface to the compiler's abstract syntax diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index 91076bbeedeca..a5435e03ce7a7 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -239,7 +239,7 @@ import from highlite import SourceLanguage, getSourceLanguage when defined(nimPreviewSlimSystem): - import std/[assertions, syncio] + import std/[assertions, syncio, dollars] type diff --git a/lib/packages/docutils/rstast.nim b/lib/packages/docutils/rstast.nim index eac3a5e15e7b5..b204c5c8f6efb 100644 --- a/lib/packages/docutils/rstast.nim +++ b/lib/packages/docutils/rstast.nim @@ -12,7 +12,7 @@ import strutils, json when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 6232cb0be570e..929ad926925c9 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -44,7 +44,7 @@ import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils, when defined(nimPreviewSlimSystem): - import std/[assertions, syncio] + import std/[assertions, syncio, dollars] import ../../std/private/since diff --git a/lib/pure/base64.nim b/lib/pure/base64.nim index 9b7af88ef1180..d08031293c1d6 100644 --- a/lib/pure/base64.nim +++ b/lib/pure/base64.nim @@ -59,6 +59,10 @@ runnableExamples: ## * `md5 module`_ for the MD5 checksum algorithm ## * `sha1 module`_ for the SHA-1 checksum algorithm + +when defined(nimPreviewSlimSystem): + import std/dollars + template cbBase(a, b): untyped = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim index 48fd91b8f33c7..18f390d3d6514 100644 --- a/lib/pure/dynlib.nim +++ b/lib/pure/dynlib.nim @@ -42,7 +42,8 @@ runnableExamples: unloadLib(lib) - +when defined(nimPreviewSlimSystem): + import std/dollars import std/strutils type diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 928bc0fbfb8db..cab9910173904 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -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, assertions] + import std/[syncio, assertions, dollars] export tables.`$` diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 15324f8824b64..3771ebba005ad 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -61,7 +61,7 @@ import std/private/since import bitops, fenv when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when defined(c) or defined(cpp): diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 79f9950a768fc..8fad1e3e809f2 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -35,7 +35,7 @@ import std/private/since import strutils, pathnorm when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] const weirdTarget = defined(nimscript) or defined(js) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 666ccdda8fe9e..4e878a231d932 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -32,7 +32,7 @@ when defined(linux) and defined(useClone): import linux when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] type diff --git a/lib/pure/parsejson.nim b/lib/pure/parsejson.nim index c92eac26e923f..fb613cb8559a1 100644 --- a/lib/pure/parsejson.nim +++ b/lib/pure/parsejson.nim @@ -15,7 +15,7 @@ import strutils, lexbase, streams, unicode import std/private/decode_helpers when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type JsonEventKind* = enum ## enumeration of all events that may occur when parsing diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim index 247d0a296bf8f..a84214ab1c541 100644 --- a/lib/pure/strformat.nim +++ b/lib/pure/strformat.nim @@ -317,7 +317,7 @@ import macros, parseutils, unicode import strutils except format when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc mkDigit(v: int, typ: char): string {.inline.} = diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 7db6f28af1c02..8a74bbdb98abe 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -287,7 +287,7 @@ import macros, parseutils import std/private/since when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] proc conditionsToIfChain(n, idx, res: NimNode; start: int): NimNode = diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 3b315e564aa51..2290f134a2b57 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -84,7 +84,7 @@ from std/private/strimpl import cmpIgnoreStyleImpl, cmpIgnoreCaseImpl, startsWithImpl, endsWithImpl when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] const diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index d7beef8d9a901..5385e14ffb184 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -13,6 +13,9 @@ import std/private/since import macros +when defined(nimPreviewSlimSystem): + import std/dollars + proc checkPragma(ex, prag: var NimNode) = since (1, 3): if ex.kind == nnkPragmaExpr: diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 571c9b13c5613..5233a1ec2f57f 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -67,7 +67,7 @@ when defined(windows): import winlean when defined(nimPreviewSlimSystem): - import std/[syncio, assertions] + import std/[syncio, assertions, dollars] type PTerminal = ref object diff --git a/lib/pure/times.nim b/lib/pure/times.nim index b70c5cedc5f57..e67b29bd55b08 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -202,7 +202,7 @@ import std/private/since include "system/inclrtl" when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when defined(js): diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim index c20f9e64519ce..44077a132c019 100644 --- a/lib/pure/typetraits.nim +++ b/lib/pure/typetraits.nim @@ -16,7 +16,7 @@ import std/private/since export system.`$` # for backward compatibility when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] type HoleyEnum* = (not Ordinal) and enum ## Enum with holes. diff --git a/lib/system/dollars.nim b/lib/std/dollars.nim similarity index 95% rename from lib/system/dollars.nim rename to lib/std/dollars.nim index 46085d2aa688d..15a21947af009 100644 --- a/lib/system/dollars.nim +++ b/lib/std/dollars.nim @@ -1,4 +1,14 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2022 Nim contributors +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + ## `$` is Nim's general way of spelling `toString`:idx:. + runnableExamples: assert $0.1 == "0.1" assert $(-2*3) == "-6" @@ -174,4 +184,4 @@ proc `$`*[T](x: openArray[T]): string = ## ## .. code-block:: Nim ## $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]" - collectionToString(x, "[", ", ", "]") + collectionToString(x, "[", ", ", "]") \ No newline at end of file diff --git a/lib/std/enumutils.nim b/lib/std/enumutils.nim index 9d4ff1bcfac8d..bdc65175ff171 100644 --- a/lib/std/enumutils.nim +++ b/lib/std/enumutils.nim @@ -11,7 +11,7 @@ import macros from typetraits import OrdinalEnum, HoleyEnum when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] # xxx `genEnumCaseStmt` needs tests and runnableExamples diff --git a/lib/std/jsonutils.nim b/lib/std/jsonutils.nim index 722ea49b5ad11..2f108dca46eef 100644 --- a/lib/std/jsonutils.nim +++ b/lib/std/jsonutils.nim @@ -35,7 +35,7 @@ from enumutils import symbolName from typetraits import OrdinalEnum when defined(nimPreviewSlimSystem): - import std/assertions + import std/[assertions, dollars] when not defined(nimFixedForwardGeneric): # xxx remove pending csources_v1 update >= 1.2.0 diff --git a/lib/std/syncio.nim b/lib/std/syncio.nim index eab96254a8973..7056edb8fc81e 100644 --- a/lib/std/syncio.nim +++ b/lib/std/syncio.nim @@ -12,6 +12,8 @@ include system/inclrtl import std/private/since import system/formatfloat +when defined(nimPreviewSlimSystem): + import std/dollars # ----------------- IO Part ------------------------------------------------ type diff --git a/lib/system.nim b/lib/system.nim index 6d737d552130e..726a28e38c75b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2145,8 +2145,13 @@ const ## is the patch number of Nim's version. ## Odd for devel, even for releases. -import system/dollars -export dollars +when not defined(nimPreviewSlimSystem): + {.deprecated: """dollars is about to move out of system; use `-d:nimPreviewSlimSystem` and + import `std/dollars`.""".} + import std/dollars + export dollars +else: + import std/dollars when defined(nimAuditDelete): {.pragma: auditDelete, deprecated: "review this call for out of bounds behavior".} diff --git a/lib/system/formatfloat.nim b/lib/system/formatfloat.nim index aada3e1bf0619..cd1084e52351a 100644 --- a/lib/system/formatfloat.nim +++ b/lib/system/formatfloat.nim @@ -77,7 +77,7 @@ proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat): result = 3 proc writeFloatToBuffer*(buf: var array[65, char]; value: BiggestFloat | float32): int {.inline.} = - when defined(nimPreviewFloatRoundtrip): + when defined(nimPreviewFloatRoundtrip) or defined(nimPreviewSlimSystem): writeFloatToBufferRoundtrip(buf, value) else: writeFloatToBufferSprintf(buf, value) @@ -98,22 +98,23 @@ proc addFloatSprintf*(result: var string; x: float) = let n = writeFloatToBufferSprintf(buffer, x) result.addCstringN(cstring(buffer[0].addr), n) -proc nimFloatToString(a: float): cstring = - ## ensures the result doesn't print like an integer, i.e. return 2.0, not 2 - # print `-0.0` properly - asm """ - function nimOnlyDigitsOrMinus(n) { - return n.toString().match(/^-?\d+$/); - } - if (Number.isSafeInteger(`a`)) - `result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0" - else { - `result` = `a`+"" - if(nimOnlyDigitsOrMinus(`result`)){ - `result` = `a`+".0" +when defined(js): + proc nimFloatToString(a: float): cstring = + ## ensures the result doesn't print like an integer, i.e. return 2.0, not 2 + # print `-0.0` properly + asm """ + function nimOnlyDigitsOrMinus(n) { + return n.toString().match(/^-?\d+$/); } - } - """ + if (Number.isSafeInteger(`a`)) + `result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0" + else { + `result` = `a`+"" + if(nimOnlyDigitsOrMinus(`result`)){ + `result` = `a`+".0" + } + } + """ proc addFloat*(result: var string; x: float | float32) {.inline.} = ## Converts float to its string representation and appends it to `result`. @@ -124,7 +125,7 @@ proc addFloat*(result: var string; x: float | float32) {.inline.} = s.addFloat(45.67) assert s == "foo:45.67" template impl = - when defined(nimPreviewFloatRoundtrip): + when defined(nimPreviewFloatRoundtrip) or defined(nimPreviewSlimSystem): addFloatRoundtrip(result, x) else: addFloatSprintf(result, x) diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 6ab5f3c3f744c..b2edeaa17cfa8 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -1,5 +1,9 @@ include system/inclrtl +when defined(nimPreviewSlimSystem): + import std/dollars + + proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".} ## imported from typetraits