newruntime: progress

This commit is contained in:
Araq 2019-04-02 00:46:38 +02:00
commit b77a2037f8
4 changed files with 18 additions and 12 deletions

View file

@ -145,8 +145,7 @@ proc setLen[T](s: var seq[T], newlen: Natural) =
if newlen < s.len:
shrink(s, newLen)
else:
var v: T # get the default value of 'v'
grow(s, newLen, v)
grow(s, newLen, default(T))
when false:
proc resize[T](s: var NimSeqV2[T]) =

View file

@ -1706,6 +1706,10 @@ proc `@`* [IDX, T](a: array[IDX, T]): seq[T] {.
## echo @a # => @[1, 3, 5]
## echo @b # => @['f', 'o', 'o']
when defined(nimHasDefault):
proc default*(T: typedesc): T {.magic: "Default", noSideEffect.}
## returns the default value of the type ``T``.
proc setLen*[T](s: var seq[T], newlen: Natural) {.
magic: "SetLengthSeq", noSideEffect.}
## Sets the length of seq `s` to `newlen`. ``T`` may be any sequence type.
@ -4400,10 +4404,6 @@ when defined(genode):
# and return to thread entrypoint.
when defined(nimHasDefault):
proc default*(T: typedesc): T {.magic: "Default", noSideEffect.}
## returns the default value of the type ``T``.
import system/widestrs
export widestrs