init the globals table with a larger init cap
This commit is contained in:
parent
197d61b112
commit
856d1345e4
|
@ -25,6 +25,11 @@ proc newTable*[U, V]: Table[U, V] =
|
||||||
result.cap = 0
|
result.cap = 0
|
||||||
result.count = 0
|
result.count = 0
|
||||||
|
|
||||||
|
proc newTable*[U, V](initcap: int): Table[U, V] =
|
||||||
|
result.cap = initcap
|
||||||
|
result.count = 0
|
||||||
|
result.entries = cast[ptr UncheckedArray[Entry[U, V]]](alloc0(sizeof(Entry[U, V]) * initcap))
|
||||||
|
|
||||||
proc newNdTable*[U, V]: NdTable[U, V] =
|
proc newNdTable*[U, V]: NdTable[U, V] =
|
||||||
result = cast[NdTable[U, V]](alloc(sizeof(Table[U, V])))
|
result = cast[NdTable[U, V]](alloc(sizeof(Table[U, V])))
|
||||||
result[].cap = 0
|
result[].cap = 0
|
||||||
|
|
|
@ -43,7 +43,7 @@ proc run*(chunk: Chunk): InterpretResult =
|
||||||
ip: ptr uint8 = chunk.code[0].unsafeAddr
|
ip: ptr uint8 = chunk.code[0].unsafeAddr
|
||||||
stack: Stack[NdValue] = newStack[NdValue](256)
|
stack: Stack[NdValue] = newStack[NdValue](256)
|
||||||
hadError: bool
|
hadError: bool
|
||||||
globals: Table[NdValue, NdValue]
|
globals: Table[NdValue, NdValue] = newTable[NdValue, NdValue](64)
|
||||||
frames: Stack[Frame] = newStack[Frame](4)
|
frames: Stack[Frame] = newStack[Frame](4)
|
||||||
openUpvalues: Upvalue[NdValue] = nil
|
openUpvalues: Upvalue[NdValue] = nil
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ proc run*(chunk: Chunk): InterpretResult =
|
||||||
upval.location = upval.closed.addr
|
upval.location = upval.closed.addr
|
||||||
openUpvalues = upval.next
|
openUpvalues = upval.next
|
||||||
|
|
||||||
# initialize globals
|
|
||||||
constructStdlib()
|
constructStdlib()
|
||||||
for i in 0 .. natives.high():
|
for i in 0 .. natives.high():
|
||||||
let native = i.uint32.fromNative()
|
let native = i.uint32.fromNative()
|
||||||
|
|
Loading…
Reference in New Issue