C codegen: preparations for different seq and string implementations
This commit is contained in:
parent
b25044286b
commit
d837362216
8 changed files with 116 additions and 43 deletions
|
|
@ -15,11 +15,11 @@ type
|
|||
len, cap: int
|
||||
data: ptr UncheckedArray[T]
|
||||
|
||||
const nimSeqVersion {.core.} = 2
|
||||
|
||||
template frees(s) = dealloc(s.data, s.cap * sizeof(T))
|
||||
|
||||
# XXX make code memory safe for overflows in '*'
|
||||
proc nimSeqLiteral[T](x: openArray[T]): seq[T] {.core.} =
|
||||
seq[T](len: x.len, cap: x.len, data: x)
|
||||
|
||||
when defined(nimHasTrace):
|
||||
proc `=trace`[T](s: seq[T]; a: Allocator) =
|
||||
|
|
@ -120,7 +120,7 @@ proc `$`*[T](x: seq[T]): string =
|
|||
result = "@["
|
||||
var firstElement = true
|
||||
for i in 0..<x.len:
|
||||
let
|
||||
let
|
||||
value = x.data[i]
|
||||
if firstElement:
|
||||
firstElement = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue