mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-15 16:13:45 +00:00
Merge branch 'devel' into pr_legacy_asm
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
- [``joyent_http_parser``](https://github.com/nim-lang/joyent_http_parser)
|
||||
|
||||
- Proc [toCountTable](https://nim-lang.org/docs/tables.html#toCountTable,openArray[A])
|
||||
now produces a `CountTable` with values correspoding to the number of occurrences
|
||||
now produces a `CountTable` with values corresponding to the number of occurrences
|
||||
of the key in the input. It used to produce a table with all values set to `1`.
|
||||
|
||||
Counting occurrences in a sequence used to be:
|
||||
@@ -339,7 +339,7 @@ for i in a..b:
|
||||
|
||||
- Fixed "ReraiseError when using try/except within finally block"
|
||||
([#5871](https://github.com/nim-lang/Nim/issues/5871))
|
||||
- Fixed "Range type inference leads to counter-intuitive behvaiour"
|
||||
- Fixed "Range type inference leads to counter-intuitive behaviour"
|
||||
([#5854](https://github.com/nim-lang/Nim/issues/5854))
|
||||
- Fixed "JSON % operator can fail in extern procs with dynamic types"
|
||||
([#6385](https://github.com/nim-lang/Nim/issues/6385))
|
||||
@@ -403,7 +403,7 @@ for i in a..b:
|
||||
([#6589](https://github.com/nim-lang/Nim/issues/6589))
|
||||
- Fixed "Generated c code calls function twice"
|
||||
([#6292](https://github.com/nim-lang/Nim/issues/6292))
|
||||
- Fixed "Range type inference leads to counter-intuitive behvaiour"
|
||||
- Fixed "Range type inference leads to counter-intuitive behaviour"
|
||||
([#5854](https://github.com/nim-lang/Nim/issues/5854))
|
||||
- Fixed "New backward indexing is too limited"
|
||||
([#6631](https://github.com/nim-lang/Nim/issues/6631))
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Fixed "Assertion error when running `nim check` on compiler/nim.nim" [#12281](https://github.com/nim-lang/Nim/issues/12281)
|
||||
* Fixed "Compiler crash with empty array and generic instantiation with int as parameter" [#12264](https://github.com/nim-lang/Nim/issues/12264)
|
||||
* Fixed "Regression in JS backend codegen "Error: request to generate code for .compileTime proc"" [#12240](https://github.com/nim-lang/Nim/issues/12240)
|
||||
* Fix how `relativePath` handle case sensitiviy
|
||||
* Fix how `relativePath` handles case sensitivity
|
||||
* Fixed "SIGSEGV in compiler when using generic types and seqs" [#12336](https://github.com/nim-lang/Nim/issues/12336)
|
||||
* Fixed "[1.0.0] weird interaction between `import os` and casting integer to char on macosx trigger bad codegen" [#12291](https://github.com/nim-lang/Nim/issues/12291)
|
||||
* VM: no special casing for big endian machines
|
||||
@@ -43,7 +43,7 @@
|
||||
* threadpool: fix link in docs (#12258)
|
||||
* Fix spellings (#12277)
|
||||
* fix #12278, don't expose internal PCRE documentation
|
||||
* Fixed "Documentation of quitprocs is wrong" [#12279(https://github.com/nim-lang/Nim/issues/12279)
|
||||
* Fixed "Documentation of quitprocs is wrong" [#12279](https://github.com/nim-lang/Nim/issues/12279)
|
||||
* Fix typo in docs
|
||||
* Fix reference to parseSpec proc in readme
|
||||
* [doc/tut1] removed discard discussion in comments
|
||||
|
||||
@@ -166,7 +166,7 @@ proc containsVariable(n: PNode): bool =
|
||||
proc checkIsolate*(n: PNode): bool =
|
||||
if types.containsTyRef(n.typ):
|
||||
# XXX Maybe require that 'n.typ' is acyclic. This is not much
|
||||
# worse than the already exisiting inheritance and closure restrictions.
|
||||
# worse than the already existing inheritance and closure restrictions.
|
||||
case n.kind
|
||||
of nkCharLit..nkNilLit:
|
||||
result = true
|
||||
|
||||
@@ -25,7 +25,7 @@ const
|
||||
useEffectSystem* = true
|
||||
useWriteTracking* = false
|
||||
hasFFI* = defined(nimHasLibFFI)
|
||||
copyrightYear* = "2024"
|
||||
copyrightYear* = "2025"
|
||||
|
||||
nimEnableCovariance* = defined(nimEnableCovariance)
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym, t: PType): PSym =
|
||||
#[
|
||||
|
||||
We cannot naively check for symbol recursions, because otherwise
|
||||
object types A, B whould share their fields!
|
||||
object types A, B would share their fields!
|
||||
|
||||
import tables
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=====================================================
|
||||
Nim -- a Compiler for Nim. https://nim-lang.org/
|
||||
|
||||
Copyright (C) 2006-2024 Andreas Rumpf. All rights reserved.
|
||||
Copyright (C) 2006-2025 Andreas Rumpf. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -358,7 +358,7 @@ Memory management
|
||||
|
||||
In the previous sections, the `NimMain()` function reared its head. Since
|
||||
JavaScript already provides automatic memory management, you can freely pass
|
||||
objects between the two languages without problems. In C and derivate languages
|
||||
objects between the two languages without problems. In C and derivative languages
|
||||
you need to be careful about what you do and how you share memory. The
|
||||
previous examples only dealt with simple scalar values, but passing a Nim
|
||||
string to C, or reading back a C string in Nim already requires you to be
|
||||
|
||||
@@ -6264,7 +6264,7 @@ The default for symbols of entity `type`, `var`, `let` and `const`
|
||||
is `gensym`. For `proc`, `iterator`, `converter`, `template`,
|
||||
`macro`, the default is `inject`, but if a `gensym` symbol with the same name
|
||||
is defined in the same syntax-level scope, it will be `gensym` by default.
|
||||
This can be overriden by marking the routine as `inject`.
|
||||
This can be overridden by marking the routine as `inject`.
|
||||
|
||||
If the name of the entity is passed as a template parameter, it is an `inject`'ed symbol:
|
||||
|
||||
|
||||
@@ -1327,7 +1327,7 @@ proc `name=`*(someProc: NimNode; val: NimNode) =
|
||||
else: someProc[0] = val
|
||||
|
||||
proc params*(someProc: NimNode): NimNode =
|
||||
if someProc.kind == nnkProcTy:
|
||||
if someProc.kind in {nnkProcTy, nnkIteratorTy}:
|
||||
someProc[0]
|
||||
else:
|
||||
someProc.expectRoutine
|
||||
@@ -1335,7 +1335,7 @@ proc params*(someProc: NimNode): NimNode =
|
||||
|
||||
proc `params=`* (someProc: NimNode; params: NimNode) =
|
||||
expectKind(params, nnkFormalParams)
|
||||
if someProc.kind == nnkProcTy:
|
||||
if someProc.kind in {nnkProcTy, nnkIteratorTy}:
|
||||
someProc[0] = params
|
||||
else:
|
||||
someProc.expectRoutine
|
||||
@@ -1344,7 +1344,7 @@ proc `params=`* (someProc: NimNode; params: NimNode) =
|
||||
proc pragma*(someProc: NimNode): NimNode =
|
||||
## Get the pragma of a proc type.
|
||||
## These will be expanded.
|
||||
if someProc.kind == nnkProcTy:
|
||||
if someProc.kind in {nnkProcTy, nnkIteratorTy}:
|
||||
result = someProc[1]
|
||||
else:
|
||||
someProc.expectRoutine
|
||||
@@ -1352,7 +1352,7 @@ proc pragma*(someProc: NimNode): NimNode =
|
||||
proc `pragma=`*(someProc: NimNode; val: NimNode) =
|
||||
## Set the pragma of a proc type.
|
||||
expectKind(val, {nnkEmpty, nnkPragma})
|
||||
if someProc.kind == nnkProcTy:
|
||||
if someProc.kind in {nnkProcTy, nnkIteratorTy}:
|
||||
someProc[1] = val
|
||||
else:
|
||||
someProc.expectRoutine
|
||||
|
||||
@@ -30,6 +30,7 @@ import std/oserrors
|
||||
when defined(nimPreviewSlimSystem):
|
||||
import std/[syncio, assertions]
|
||||
|
||||
from system/ansi_c import c_memchr
|
||||
|
||||
proc newEIO(msg: string): ref IOError =
|
||||
result = (ref IOError)(msg: msg)
|
||||
@@ -448,14 +449,12 @@ iterator memSlices*(mfile: MemFile, delim = '\l', eat = '\r'): MemSlice {.inline
|
||||
## echo count
|
||||
## ```
|
||||
|
||||
proc c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
|
||||
importc: "memchr", header: "<string.h>".}
|
||||
proc `-!`(p, q: pointer): int {.inline.} = return cast[int](p) -% cast[int](q)
|
||||
var ending: pointer
|
||||
var ms = MemSlice(data: mfile.mem, size: 0)
|
||||
var remaining = mfile.size
|
||||
while remaining > 0:
|
||||
ending = c_memchr(ms.data, delim, csize_t(remaining))
|
||||
ending = c_memchr(ms.data, cint(delim), csize_t(remaining))
|
||||
if ending == nil: # unterminated final slice
|
||||
ms.size = remaining # Weird case..check eat?
|
||||
yield ms
|
||||
|
||||
@@ -1950,8 +1950,8 @@ func find*(a: SkipTable, s, sub: string, start: Natural = 0, last = -1): int {.
|
||||
inc skip, a[s[skip + subLast]]
|
||||
|
||||
when not (defined(js) or defined(nimdoc) or defined(nimscript)):
|
||||
func c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
|
||||
importc: "memchr", header: "<string.h>".}
|
||||
from system/ansi_c import c_memchr
|
||||
|
||||
const hasCStringBuiltin = true
|
||||
else:
|
||||
const hasCStringBuiltin = false
|
||||
@@ -1982,7 +1982,7 @@ func find*(s: string, sub: char, start: Natural = 0, last = -1): int {.rtl,
|
||||
when hasCStringBuiltin:
|
||||
let length = last-start+1
|
||||
if length > 0:
|
||||
let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](length))
|
||||
let found = c_memchr(s[start].unsafeAddr, cint(sub), cast[csize_t](length))
|
||||
if not found.isNil:
|
||||
return cast[int](found) -% cast[int](s.cstring)
|
||||
else:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
when defined(nimPreviewSlimSystem):
|
||||
import std/assertions
|
||||
|
||||
proc c_memcpy(a, b: pointer, size: csize_t): pointer {.importc: "memcpy", header: "<string.h>", discardable.}
|
||||
from system/ansi_c import c_memcpy
|
||||
|
||||
proc addCstringN(result: var string, buf: cstring; buflen: int) =
|
||||
# no nimvm support needed, so it doesn't need to be fast here either
|
||||
|
||||
@@ -75,11 +75,7 @@ template endsWithImpl*[T: string | cstring](s, suffix: T) =
|
||||
func cmpNimIdentifier*[T: string | cstring](a, b: T): int =
|
||||
cmpIgnoreStyleImpl(a, b, true)
|
||||
|
||||
func c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
|
||||
importc: "memchr", header: "<string.h>".}
|
||||
func c_strstr(haystack, needle: cstring): cstring {.
|
||||
importc: "strstr", header: "<string.h>".}
|
||||
|
||||
from system/ansi_c import c_memchr, c_strstr
|
||||
|
||||
func find*(s: cstring, sub: char, start: Natural = 0, last = 0): int =
|
||||
## Searches for `sub` in `s` inside the range `start..last` (both ends included).
|
||||
@@ -91,7 +87,7 @@ func find*(s: cstring, sub: char, start: Natural = 0, last = 0): int =
|
||||
let last = if last == 0: s.high else: last
|
||||
let L = last-start+1
|
||||
if L > 0:
|
||||
let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](L))
|
||||
let found = c_memchr(s[start].unsafeAddr, cint(sub), cast[csize_t](L))
|
||||
if not found.isNil:
|
||||
return cast[int](found) -% cast[int](s)
|
||||
return -1
|
||||
|
||||
@@ -15,6 +15,8 @@ import std/formatfloat
|
||||
when defined(windows):
|
||||
import std/widestrs
|
||||
|
||||
from system/ansi_c import c_memchr
|
||||
|
||||
# ----------------- IO Part ------------------------------------------------
|
||||
type
|
||||
CFile {.importc: "FILE", header: "<stdio.h>",
|
||||
@@ -401,9 +403,6 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect],
|
||||
## `false` is returned `line` contains no new data.
|
||||
result = false
|
||||
|
||||
proc c_memchr(s: pointer, c: cint, n: csize_t): pointer {.
|
||||
importc: "memchr", header: "<string.h>".}
|
||||
|
||||
when defined(windows):
|
||||
proc readConsole(hConsoleInput: FileHandle, lpBuffer: pointer,
|
||||
nNumberOfCharsToRead: int32,
|
||||
@@ -491,7 +490,7 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect],
|
||||
checkErr(f)
|
||||
break
|
||||
|
||||
let m = c_memchr(addr line[pos], '\L'.ord, cast[csize_t](sp))
|
||||
let m = c_memchr(addr line[pos], cint('\L'), cast[csize_t](sp))
|
||||
if m != nil:
|
||||
# \l found: Could be our own or the one by fgets, in any case, we're done
|
||||
var last = cast[int](m) - cast[int](addr line[0])
|
||||
|
||||
@@ -190,7 +190,7 @@ macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkC
|
||||
# passing by static parameters
|
||||
# so we pass them directly instead of passing by scratchObj
|
||||
callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
|
||||
of nnkSym, nnkPtrTy, nnkProcTy, nnkTupleConstr:
|
||||
of nnkSym, nnkPtrTy, nnkProcTy, nnkTupleTy, nnkTupleConstr:
|
||||
addAllNode(param, e[i])
|
||||
of nnkCharLit..nnkNilLit:
|
||||
callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
|
||||
|
||||
@@ -107,15 +107,9 @@ proc writeVu64*(z: var openArray[byte], x: uint64): int =
|
||||
varintWrite32(toOpenArray(z, 5, 8), y)
|
||||
return 9
|
||||
|
||||
proc sar(a, b: int64): int64 {.noinit.} =
|
||||
{.emit: [result, " = ", a, " >> ", b, ";"].}
|
||||
|
||||
proc sal(a, b: int64): int64 {.noinit.} =
|
||||
{.emit: [result, " = ", a, " << ", b, ";"].}
|
||||
|
||||
proc encodeZigzag*(x: int64): uint64 {.inline.} =
|
||||
uint64(sal(x, 1)) xor uint64(sar(x, 63))
|
||||
let xu = uint64(x)
|
||||
(xu shl 1) xor (xu shr 63)
|
||||
|
||||
proc decodeZigzag*(x: uint64): int64 {.inline.} =
|
||||
let casted = cast[int64](x)
|
||||
result = (`shr`(casted, 1)) xor (-(casted and 1))
|
||||
cast[int64]((x shr 1) xor (x shl 63))
|
||||
|
||||
@@ -27,6 +27,8 @@ proc c_strcmp*(a, b: cstring): cint {.
|
||||
importc: "strcmp", header: "<string.h>", noSideEffect.}
|
||||
proc c_strlen*(a: cstring): csize_t {.
|
||||
importc: "strlen", header: "<string.h>", noSideEffect.}
|
||||
proc c_strstr*(haystack, needle: cstring): cstring {.
|
||||
importc: "strstr", header: "<string.h>", noSideEffect.}
|
||||
proc c_abort*() {.
|
||||
importc: "abort", header: "<stdlib.h>", noSideEffect, noreturn.}
|
||||
|
||||
@@ -76,19 +78,14 @@ elif defined(haiku):
|
||||
SIGTERM* = cint(15)
|
||||
SIGPIPE* = cint(7)
|
||||
SIG_DFL* = CSighandlerT(nil)
|
||||
else:
|
||||
when defined(nimscript):
|
||||
{.error: "SIGABRT not ported to your platform".}
|
||||
else:
|
||||
var
|
||||
SIGINT* {.importc: "SIGINT", nodecl.}: cint
|
||||
SIGSEGV* {.importc: "SIGSEGV", nodecl.}: cint
|
||||
SIGABRT* {.importc: "SIGABRT", nodecl.}: cint
|
||||
SIGFPE* {.importc: "SIGFPE", nodecl.}: cint
|
||||
SIGILL* {.importc: "SIGILL", nodecl.}: cint
|
||||
SIG_DFL* {.importc: "SIG_DFL", nodecl.}: CSighandlerT
|
||||
when defined(macosx) or defined(linux):
|
||||
var SIGPIPE* {.importc: "SIGPIPE", nodecl.}: cint
|
||||
elif not defined(nimscript):
|
||||
var
|
||||
SIGINT* {.importc: "SIGINT", nodecl.}: cint
|
||||
SIGSEGV* {.importc: "SIGSEGV", nodecl.}: cint
|
||||
SIGABRT* {.importc: "SIGABRT", nodecl.}: cint
|
||||
SIGFPE* {.importc: "SIGFPE", nodecl.}: cint
|
||||
SIGILL* {.importc: "SIGILL", nodecl.}: cint
|
||||
SIG_DFL* {.importc: "SIG_DFL", nodecl.}: CSighandlerT
|
||||
|
||||
when defined(macosx):
|
||||
const SIGBUS* = cint(10)
|
||||
|
||||
@@ -202,7 +202,7 @@ Nim. You are explicitly permitted to develop commercial applications using Nim.
|
||||
|
||||
Please read the [copying.txt](copying.txt) file for more details.
|
||||
|
||||
Copyright © 2006-2024 Andreas Rumpf, all rights reserved.
|
||||
Copyright © 2006-2025 Andreas Rumpf, all rights reserved.
|
||||
|
||||
[nim-site]: https://nim-lang.org
|
||||
[nim-forum]: https://forum.nim-lang.org
|
||||
|
||||
Reference in New Issue
Block a user