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
parent 89d443d767
commit c945c56482

View File

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