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.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] =
|
||||
result = cast[NdTable[U, V]](alloc(sizeof(Table[U, V])))
|
||||
result[].cap = 0
|
||||
|
|
|
@ -43,7 +43,7 @@ proc run*(chunk: Chunk): InterpretResult =
|
|||
ip: ptr uint8 = chunk.code[0].unsafeAddr
|
||||
stack: Stack[NdValue] = newStack[NdValue](256)
|
||||
hadError: bool
|
||||
globals: Table[NdValue, NdValue]
|
||||
globals: Table[NdValue, NdValue] = newTable[NdValue, NdValue](64)
|
||||
frames: Stack[Frame] = newStack[Frame](4)
|
||||
openUpvalues: Upvalue[NdValue] = nil
|
||||
|
||||
|
@ -131,7 +131,7 @@ proc run*(chunk: Chunk): InterpretResult =
|
|||
upval.location = upval.closed.addr
|
||||
openUpvalues = upval.next
|
||||
|
||||
# initialize globals
|
||||
|
||||
constructStdlib()
|
||||
for i in 0 .. natives.high():
|
||||
let native = i.uint32.fromNative()
|
||||
|
|
Loading…
Reference in New Issue