these values can be defined at the top of the function

This commit is contained in:
CPunch 2023-05-28 00:08:28 -05:00 committed by cpunch
parent 4ed1c79b50
commit 3a872fb83f
1 changed files with 3 additions and 2 deletions

View File

@ -112,6 +112,9 @@ static bool readCObjString(UndumpState *udstate, CObjString **str)
static bool readCObjFunction(UndumpState *udstate, CObjFunction **func)
{
size_t constants;
CValue val;
*func = cosmoO_newFunction(udstate->state);
check(readCObjString(udstate, &(*func)->name));
@ -128,10 +131,8 @@ static bool readCObjFunction(UndumpState *udstate, CObjFunction **func)
readVector(udstate, (void **)&(*func)->chunk.lineInfo, sizeof(int), &(*func)->chunk.count));
/* read constants */
size_t constants;
check(readSize(udstate, &constants));
for (int i = 0; i < constants; i++) {
CValue val;
check(readCValue(udstate, &val));
addConstant(udstate->state, &(*func)->chunk, val);
}