Skip to content

Commit

Permalink
Merge branch 'devel' into pr_iterator_array_lent
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Nov 6, 2023
2 parents 2fccb91 + 58c4431 commit 4a3208b
Show file tree
Hide file tree
Showing 282 changed files with 4,875 additions and 1,422 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/bisects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ jobs:
nim-version: 'devel'

- uses: juancarlospaco/nimrun-action@nim
if: |
runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) ||
runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') ||
runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) ||
runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/ci_bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
with:
fetch-depth: 2

- name: 'Install node.js 16.x'
uses: actions/setup-node@v3
- name: 'Install node.js 20.x'
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- name: 'Install dependencies (Linux amd64)'
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
with:
fetch-depth: 2

- name: 'Install node.js 16.x'
uses: actions/setup-node@v3
- name: 'Install node.js 20.x'
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- name: 'Install dependencies (Linux amd64)'
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
with:
fetch-depth: 2

- name: 'Install node.js 16.x'
uses: actions/setup-node@v3
- name: 'Install node.js 20.x'
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- name: 'Install dependencies (Linux amd64)'
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ jobs:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install node.js 16.x'
versionSpec: '20.x'
displayName: 'Install node.js 20.x'
condition: and(succeeded(), eq(variables['skipci'], 'false'))

- bash: |
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

## Changes affecting backward compatibility

- `-d:nimStrictDelete` becomes the default. An index error is produced when the index passed to `system.delete` was out of bounds. Use `-d:nimAuditDelete` to mimic the old behavior for backwards compatibility.
- The default user-agent in `std/httpclient` has been changed to `Nim-httpclient/<version>` instead of `Nim httpclient/<version>` which was incorrect according to the HTTP spec.

## Standard library additions and changes

[//]: # "Changes:"

- Changed `std/osfiles.copyFile` to allow to specify `bufferSize` instead of a hardcoded one.
- Changed `std/osfiles.copyFile` to use `POSIX_FADV_SEQUENTIAL` hints for kernel-level aggressive sequential read-aheads.
- `std/htmlparser` has been moved to a nimble package, use `nimble` or `atlas` to install it.

[//]: # "Additions:"

Expand All @@ -29,6 +32,9 @@ slots when enlarging a sequence.
## Language changes

- `noInit` can be used in types and fields to disable member initializers in the C++ backend.
- C++ custom constructors initializers see https://nim-lang.org/docs/manual_experimental.htm#constructor-initializer
- `member` can be used to attach a procedure to a C++ type.
- C++ `constructor` now reuses `result` instead creating `this`.

## Compiler changes

Expand Down
4 changes: 3 additions & 1 deletion compiler/aliases.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
## Simple alias analysis for the HLO and the code generators.

import
ast, astalgo, types, trees, intsets
ast, astalgo, types, trees

import std/intsets

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down
9 changes: 6 additions & 3 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
# abstract syntax tree + symbol table

import
lineinfos, hashes, options, ropes, idents, int128, tables, wordrecg
from strutils import toLowerAscii
lineinfos, options, ropes, idents, int128, wordrecg

import std/[tables, hashes]
from std/strutils import toLowerAscii

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down Expand Up @@ -901,6 +903,7 @@ type
info*: TLineInfo
when defined(nimsuggest):
endInfo*: TLineInfo
hasUserSpecifiedType*: bool # used for determining whether to display inlay type hints
owner*: PSym
flags*: TSymFlags
ast*: PNode # syntax tree of proc, iterator, etc.:
Expand All @@ -924,7 +927,7 @@ type
# for variables a slot index for the evaluator
offset*: int32 # offset of record field
disamb*: int32 # disambiguation number; the basic idea is that
# `<procname>__<module>_<disamb>`
# `<procname>__<module>_<disamb>` is unique
loc*: TLoc
annex*: PLib # additional fields (seldom used, so we use a
# reference to another object to save space)
Expand Down
7 changes: 4 additions & 3 deletions compiler/astalgo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# the data structures here are used in various places of the compiler.

import
ast, hashes, intsets, options, lineinfos, ropes, idents, rodutils,
ast, options, lineinfos, ropes, idents, rodutils,
msgs

import strutils except addf
import std/[hashes, intsets]
import std/strutils except addf

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down Expand Up @@ -408,7 +409,7 @@ proc symToYaml(conf: ConfigRef; n: PSym, indent: int = 0, maxRecDepth: int = - 1
var marker = initIntSet()
result = symToYamlAux(conf, n, marker, indent, maxRecDepth)

import tables
import std/tables

const backrefStyle = "\e[90m"
const enumStyle = "\e[34m"
Expand Down
14 changes: 7 additions & 7 deletions compiler/ccgcalls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ proc openArrayLoc(p: BProc, formalType: PType, n: PNode; result: var Rope) =
let (x, y) = genOpenArraySlice(p, q, formalType, n.typ[0])
result.add x & ", " & y
else:
var a: TLoc = initLocExpr(p, if n.kind == nkHiddenStdConv: n[1] else: n)
var a = initLocExpr(p, if n.kind == nkHiddenStdConv: n[1] else: n)
case skipTypes(a.t, abstractVar+{tyStatic}).kind
of tyOpenArray, tyVarargs:
if reifiedOpenArray(n):
Expand Down Expand Up @@ -277,7 +277,7 @@ proc literalsNeedsTmp(p: BProc, a: TLoc): TLoc =
genAssignment(p, result, a, {})

proc genArgStringToCString(p: BProc, n: PNode; result: var Rope; needsTmp: bool) {.inline.} =
var a: TLoc = initLocExpr(p, n[0])
var a = initLocExpr(p, n[0])
appcg(p.module, result, "#nimToCStringConv($1)", [withTmpIfNeeded(p, a, needsTmp).rdLoc])

proc genArg(p: BProc, n: PNode, param: PSym; call: PNode; result: var Rope; needsTmp = false) =
Expand All @@ -287,7 +287,7 @@ proc genArg(p: BProc, n: PNode, param: PSym; call: PNode; result: var Rope; need
elif skipTypes(param.typ, abstractVar).kind in {tyOpenArray, tyVarargs}:
var n = if n.kind != nkHiddenAddr: n else: n[0]
openArrayLoc(p, param.typ, n, result)
elif ccgIntroducedPtr(p.config, param, call[0].typ[0]) and
elif ccgIntroducedPtr(p.config, param, call[0].typ[0]) and
(optByRef notin param.options or not p.module.compileToCpp):
a = initLocExpr(p, n)
if n.kind in {nkCharLit..nkNilLit}:
Expand Down Expand Up @@ -417,7 +417,7 @@ proc addActualSuffixForHCR(res: var Rope, module: PSym, sym: PSym) =

proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) =
# this is a hotspot in the compiler
var op: TLoc = initLocExpr(p, ri[0])
var op = initLocExpr(p, ri[0])
# getUniqueType() is too expensive here:
var typ = skipTypes(ri[0].typ, abstractInstOwned)
assert(typ.kind == tyProc)
Expand All @@ -439,7 +439,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
const PatProc = "$1.ClE_0? $1.ClP_0($3$1.ClE_0):(($4)($1.ClP_0))($2)"
const PatIter = "$1.ClP_0($3$1.ClE_0)" # we know the env exists

var op: TLoc = initLocExpr(p, ri[0])
var op = initLocExpr(p, ri[0])

# getUniqueType() is too expensive here:
var typ = skipTypes(ri[0].typ, abstractInstOwned)
Expand Down Expand Up @@ -672,7 +672,7 @@ proc genPatternCall(p: BProc; ri: PNode; pat: string; typ: PType; result: var Ro
result.add(substr(pat, start, i - 1))

proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
var op: TLoc = initLocExpr(p, ri[0])
var op = initLocExpr(p, ri[0])
# getUniqueType() is too expensive here:
var typ = skipTypes(ri[0].typ, abstractInst)
assert(typ.kind == tyProc)
Expand Down Expand Up @@ -716,7 +716,7 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =

proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
# generates a crappy ObjC call
var op: TLoc = initLocExpr(p, ri[0])
var op = initLocExpr(p, ri[0])
var pl = "["
# getUniqueType() is too expensive here:
var typ = skipTypes(ri[0].typ, abstractInst)
Expand Down
6 changes: 6 additions & 0 deletions compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,12 @@ proc lookupFieldAgain(p: BProc, ty: PType; field: PSym; r: var Rope;

proc genRecordField(p: BProc, e: PNode, d: var TLoc) =
var a: TLoc = default(TLoc)
if p.module.compileToCpp and e.kind == nkDotExpr and e[1].kind == nkSym and e[1].typ.kind == tyPtr:
# special case for C++: we need to pull the type of the field as member and friends require the complete type.
let typ = e[1].typ[0]
if typ.itemId in p.module.g.graph.memberProcsPerType:
discard getTypeDesc(p.module, typ)

genRecordFieldAux(p, e, d, a)
var r = rdLoc(a)
var f = e[1].sym
Expand Down
2 changes: 1 addition & 1 deletion compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# ------------------------- Name Mangling --------------------------------

import sighashes, modulegraphs, strscans
import sighashes, modulegraphs, std/strscans
import ../dist/checksums/src/checksums/md5

type
Expand Down
4 changes: 3 additions & 1 deletion compiler/ccgutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# This module declares some helpers for the C code generator.

import
ast, types, hashes, strutils, msgs, wordrecg,
ast, types, msgs, wordrecg,
platform, trees, options, cgendata

import std/[hashes, strutils]

when defined(nimPreviewSlimSystem):
import std/assertions

Expand Down
12 changes: 6 additions & 6 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
## This module implements the C code generator.

import
ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, intsets,
ast, astalgo, trees, platform, magicsys, extccomp, options,
nversion, nimsets, msgs, bitsets, idents, types,
ccgutils, os, ropes, math, wordrecg, treetab, cgmeth,
ccgutils, ropes, wordrecg, treetab, cgmeth,
rodutils, renderer, cgendata, aliases,
lowerings, tables, sets, ndi, lineinfos, pathutils, transf,
lowerings, ndi, lineinfos, pathutils, transf,
injectdestructors, astmsgs, modulepaths, backendpragmas

from expanddefaults import caseObjDefaultBranch
Expand All @@ -27,10 +27,10 @@ when defined(nimPreviewSlimSystem):
when not defined(leanCompiler):
import spawn, semparallel

import strutils except `%`, addf # collides with ropes.`%`
import std/strutils except `%`, addf # collides with ropes.`%`

from ic / ic import ModuleBackendFlag
import dynlib
import std/[dynlib, math, tables, sets, os, intsets, hashes]

when not declared(dynlib.libCandidates):
proc libCandidates(s: string, dest: var seq[string]) =
Expand Down Expand Up @@ -121,7 +121,7 @@ proc getModuleDllPath(m: BModule, module: int): Rope =
proc getModuleDllPath(m: BModule, s: PSym): Rope =
result = getModuleDllPath(m.g.modules[s.itemId.module])

import macros
import std/macros

proc cgFormatValue(result: var string; value: string) =
result.add value
Expand Down
6 changes: 4 additions & 2 deletions compiler/cgendata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
## This module contains the data structures for the C code generation phase.

import
ast, ropes, options, intsets,
tables, ndi, lineinfos, pathutils, modulegraphs, sets
ast, ropes, options,
ndi, lineinfos, pathutils, modulegraphs

import std/[intsets, tables, sets]

type
TLabel* = Rope # for the C generator a label is just a rope
Expand Down
5 changes: 4 additions & 1 deletion compiler/cgmeth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
## This module implements code generation for methods.

import
intsets, options, ast, msgs, idents, renderer, types, magicsys,
options, ast, msgs, idents, renderer, types, magicsys,
sempass2, modulegraphs, lineinfos


import std/intsets

when defined(nimPreviewSlimSystem):
import std/assertions

Expand Down
4 changes: 3 additions & 1 deletion compiler/closureiters.nim
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
import
ast, msgs, idents,
renderer, magicsys, lowerings, lambdalifting, modulegraphs, lineinfos,
tables, options
options

import std/tables

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down
4 changes: 3 additions & 1 deletion compiler/cmdlinehelper.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

import
options, idents, nimconf, extccomp, commands, msgs,
lineinfos, modulegraphs, condsyms, os, pathutils, parseopt
lineinfos, modulegraphs, condsyms, pathutils

import std/[os, parseopt]

proc prependCurDir*(f: AbsoluteFile): AbsoluteFile =
when defined(unix):
Expand Down
8 changes: 6 additions & 2 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ bootSwitch(usedNoGC, defined(nogc), "--gc:none")
import std/[setutils, os, strutils, parseutils, parseopt, sequtils, strtabs]
import
msgs, options, nversion, condsyms, extccomp, platform,
wordrecg, nimblecmd, lineinfos, pathutils, pathnorm
wordrecg, nimblecmd, lineinfos, pathutils

import std/pathnorm

from ast import setUseIc, eqTypeFlags, tfGcSafe, tfNoSideEffect

Expand Down Expand Up @@ -460,6 +462,7 @@ proc handleCmdInput*(conf: ConfigRef) =
proc parseCommand*(command: string): Command =
case command.normalize
of "c", "cc", "compile", "compiletoc": cmdCompileToC
of "nir": cmdCompileToNir
of "cpp", "compiletocpp": cmdCompileToCpp
of "objc", "compiletooc": cmdCompileToOC
of "js", "compiletojs": cmdCompileToJS
Expand Down Expand Up @@ -496,6 +499,7 @@ proc setCmd*(conf: ConfigRef, cmd: Command) =
of cmdCompileToCpp: conf.backend = backendCpp
of cmdCompileToOC: conf.backend = backendObjc
of cmdCompileToJS: conf.backend = backendJs
of cmdCompileToNir: conf.backend = backendNir
else: discard

proc setCommandEarly*(conf: ConfigRef, command: string) =
Expand Down Expand Up @@ -794,7 +798,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
if conf.backend == backendJs or conf.cmd == cmdNimscript: discard
else: processOnOffSwitchG(conf, {optThreads}, arg, pass, info)
#if optThreads in conf.globalOptions: conf.setNote(warnGcUnsafe)
of "tlsemulation":
of "tlsemulation":
processOnOffSwitchG(conf, {optTlsEmulation}, arg, pass, info)
if optTlsEmulation in conf.globalOptions:
conf.legacyFeatures.incl emitGenerics
Expand Down
4 changes: 3 additions & 1 deletion compiler/concepts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
## for details. Note this is a first implementation and only the "Concept matching"
## section has been implemented.

import ast, astalgo, semdata, lookups, lineinfos, idents, msgs, renderer, types, intsets
import ast, astalgo, semdata, lookups, lineinfos, idents, msgs, renderer, types

import std/intsets

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down
3 changes: 2 additions & 1 deletion compiler/condsyms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# This module handles the conditional symbols.

import
strtabs
std/strtabs

from options import Feature
from lineinfos import hintMin, hintMax, warnMin, warnMax
Expand Down Expand Up @@ -162,3 +162,4 @@ proc initDefines*(symbols: StringTableRef) =
defineSymbol("nimHasNolineTooLong")

defineSymbol("nimHasCastExtendedVm")
defineSymbol("nimHasWarnStdPrefix")
Loading

0 comments on commit 4a3208b

Please sign in to comment.