mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-26 00:21:42 +00:00
progress
This commit is contained in:
@@ -3677,7 +3677,10 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
|
||||
of nkProcDef, nkFuncDef, nkMethodDef, nkConverterDef:
|
||||
if n[genericParamsPos].kind == nkEmpty:
|
||||
var prc = n[namePos].sym
|
||||
if delayedCodegen(p.module):
|
||||
if optCompress in p.config.globalOptions:
|
||||
if prc.magic in generatedMagics:
|
||||
genProc(p.module, prc)
|
||||
elif delayedCodegen(p.module):
|
||||
if p.module.alive.contains(prc.itemId.item) and
|
||||
prc.magic in generatedMagics:
|
||||
genProc(p.module, prc)
|
||||
|
||||
@@ -608,7 +608,7 @@ proc genProcParams(m: BModule; t: PType, rettype: var Rope, params: var Builder,
|
||||
else:
|
||||
descKind = dkRefParam
|
||||
if isCompileTimeOnly(param.typ): continue
|
||||
ensureMutable param
|
||||
#ensureMutable param
|
||||
fillParamName(m, param)
|
||||
fillLoc(param.locImpl, locParam, t.n[i],
|
||||
param.paramStorageLoc)
|
||||
|
||||
@@ -119,7 +119,7 @@ type
|
||||
mapping*: Rope # the generated mapping file (if requested)
|
||||
modules*: seq[BModule] # list of all compiled modules
|
||||
modulesClosed*: seq[BModule] # list of the same compiled modules, but in the order they were closed
|
||||
forwardedProcs*: seq[PSym] # proc:s that did not yet have a body
|
||||
forwardedProcs*: seq[PSym] # procs that did not yet have a body
|
||||
generatedHeader*: BModule
|
||||
typeInfoMarker*: TypeCacheWithOwner
|
||||
typeInfoMarkerV2*: TypeCacheWithOwner
|
||||
|
||||
@@ -29,6 +29,8 @@ const
|
||||
# doAssert res == digits100
|
||||
# ```
|
||||
|
||||
{.push checks: off, stackTrace: off.}
|
||||
|
||||
proc utoa2Digits*(buf: var openArray[char]; pos: int; digits: uint32) {.inline.} =
|
||||
buf[pos] = digits100[2 * digits]
|
||||
buf[pos+1] = digits100[2 * digits + 1]
|
||||
@@ -114,3 +116,5 @@ proc addInt*(result: var string; x: int64) {.enforceNoRaises.} =
|
||||
|
||||
proc addInt*(result: var string; x: int) {.inline, enforceNoRaises.} =
|
||||
addInt(result, int64(x))
|
||||
|
||||
{.pop.}
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
# Implementation of some runtime checks.
|
||||
include system/indexerrors
|
||||
when defined(nimPreviewSlimSystem):
|
||||
import std/formatfloat
|
||||
|
||||
proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} =
|
||||
when hostOS == "standalone":
|
||||
@@ -53,12 +51,6 @@ proc raiseRangeErrorI(i, a, b: BiggestInt) {.compilerproc, noinline.} =
|
||||
else:
|
||||
sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)
|
||||
|
||||
proc raiseRangeErrorF(i, a, b: float) {.compilerproc, noinline.} =
|
||||
when defined(standalone):
|
||||
sysFatal(RangeDefect, "value out of range")
|
||||
else:
|
||||
sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)
|
||||
|
||||
proc raiseRangeErrorU(i, a, b: uint64) {.compilerproc, noinline.} =
|
||||
# todo: better error reporting
|
||||
sysFatal(RangeDefect, "value out of range")
|
||||
@@ -97,16 +89,6 @@ proc chckRangeU(i, a, b: uint64): uint64 {.compilerproc.} =
|
||||
result = 0
|
||||
sysFatal(RangeDefect, "value out of range")
|
||||
|
||||
proc chckRangeF(x, a, b: float): float =
|
||||
if x >= a and x <= b:
|
||||
return x
|
||||
else:
|
||||
result = 0.0
|
||||
when hostOS == "standalone":
|
||||
sysFatal(RangeDefect, "value out of range")
|
||||
else:
|
||||
sysFatal(RangeDefect, "value out of range: ", $x)
|
||||
|
||||
proc chckNil(p: pointer) =
|
||||
if p == nil:
|
||||
sysFatal(NilAccessDefect, "attempt to write to a nil address")
|
||||
@@ -164,3 +146,32 @@ when not defined(nimV2):
|
||||
when defined(nimV2):
|
||||
proc raiseObjectCaseTransition() {.compilerproc.} =
|
||||
sysFatal(FieldDefect, "assignment to discriminant changes object branch")
|
||||
|
||||
when defined(nimPreviewSlimSystem):
|
||||
import std/formatfloat
|
||||
|
||||
when not defined(nimPreviewSlimSystem):
|
||||
import std/formatfloat
|
||||
export addFloat
|
||||
|
||||
func `$`*(x: float | float32): string =
|
||||
## Outplace version of `addFloat`.
|
||||
result = ""
|
||||
result.addFloat(x)
|
||||
|
||||
|
||||
proc raiseRangeErrorF(i, a, b: float) {.compilerproc, noinline.} =
|
||||
when defined(standalone):
|
||||
sysFatal(RangeDefect, "value out of range")
|
||||
else:
|
||||
sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)
|
||||
|
||||
proc chckRangeF(x, a, b: float): float =
|
||||
if x >= a and x <= b:
|
||||
return x
|
||||
else:
|
||||
result = 0.0
|
||||
when hostOS == "standalone":
|
||||
sysFatal(RangeDefect, "value out of range")
|
||||
else:
|
||||
sysFatal(RangeDefect, "value out of range: ", $x)
|
||||
|
||||
@@ -5,15 +5,6 @@ runnableExamples:
|
||||
|
||||
import std/private/[digitsutils, miscdollars]
|
||||
|
||||
when not defined(nimPreviewSlimSystem):
|
||||
import std/formatfloat
|
||||
export addFloat
|
||||
|
||||
func `$`*(x: float | float32): string =
|
||||
## Outplace version of `addFloat`.
|
||||
result = ""
|
||||
result.addFloat(x)
|
||||
|
||||
template addIntAlias(T: typedesc) =
|
||||
proc `$`*(x: T): string {.raises: [].} =
|
||||
## Outplace version of `addInt`.
|
||||
|
||||
@@ -5,7 +5,7 @@ const useLibC = not defined(nimNoLibc)
|
||||
when useLibC:
|
||||
import ansi_c
|
||||
|
||||
proc nimCopyMem*(dest, source: pointer, size: Natural) {.nonReloadable, compilerproc, inline.} =
|
||||
proc nimCopyMem*(dest, source: pointer, size: Natural) {.nonReloadable, compilerproc, inline, enforceNoRaises.} =
|
||||
when useLibC:
|
||||
c_memcpy(dest, source, cast[csize_t](size))
|
||||
else:
|
||||
@@ -16,7 +16,7 @@ proc nimCopyMem*(dest, source: pointer, size: Natural) {.nonReloadable, compiler
|
||||
d[i] = s[i]
|
||||
inc i
|
||||
|
||||
proc nimSetMem*(a: pointer, v: cint, size: Natural) {.nonReloadable, inline.} =
|
||||
proc nimSetMem*(a: pointer, v: cint, size: Natural) {.nonReloadable, inline, enforceNoRaises.} =
|
||||
when useLibC:
|
||||
c_memset(a, v, cast[csize_t](size))
|
||||
else:
|
||||
@@ -27,10 +27,10 @@ proc nimSetMem*(a: pointer, v: cint, size: Natural) {.nonReloadable, inline.} =
|
||||
a[i] = v
|
||||
inc i
|
||||
|
||||
proc nimZeroMem*(p: pointer, size: Natural) {.compilerproc, nonReloadable, inline.} =
|
||||
proc nimZeroMem*(p: pointer, size: Natural) {.compilerproc, nonReloadable, inline, enforceNoRaises.} =
|
||||
nimSetMem(p, 0, size)
|
||||
|
||||
proc nimCmpMem*(a, b: pointer, size: Natural): cint {.compilerproc, nonReloadable, inline.} =
|
||||
proc nimCmpMem*(a, b: pointer, size: Natural): cint {.compilerproc, nonReloadable, inline, enforceNoRaises.} =
|
||||
when useLibC:
|
||||
c_memcmp(a, b, cast[csize_t](size))
|
||||
else:
|
||||
@@ -42,7 +42,7 @@ proc nimCmpMem*(a, b: pointer, size: Natural): cint {.compilerproc, nonReloadabl
|
||||
if d != 0: return d
|
||||
inc i
|
||||
|
||||
proc nimCStrLen*(a: cstring): int {.compilerproc, nonReloadable, inline.} =
|
||||
proc nimCStrLen*(a: cstring): int {.compilerproc, nonReloadable, inline, enforceNoRaises.} =
|
||||
if a.isNil: return 0
|
||||
when useLibC:
|
||||
cast[int](c_strlen(a))
|
||||
|
||||
Reference in New Issue
Block a user