fix the clanker's code
This commit is contained in:
@@ -419,6 +419,22 @@ static inline GroundSize doOffsets(GroundProgram* gp, GroundState* state, Ground
|
|||||||
|
|
||||||
// Resolve the value variable
|
// Resolve the value variable
|
||||||
GroundArg* valueArg = &inst->args.at[inst->args.len - 1];
|
GroundArg* valueArg = &inst->args.at[inst->args.len - 1];
|
||||||
|
if (valueArg->type == GroundArg_Value) {
|
||||||
|
GroundVariable* item = malloc(sizeof(GroundVariable));
|
||||||
|
if (item == NULL) {
|
||||||
|
Ground.Log.Error("malloc failed in Ground.New.Bytecode -> doOffsets");
|
||||||
|
Ground.Flags.error = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
item->value = Ground.Copy.Value(&valueArg->as.value);
|
||||||
|
if (Ground.Flags.error) return 0;
|
||||||
|
item->_offset = size++;
|
||||||
|
snprintf(item->name, sizeof(item->name) - 1, "_._.ground_internal_constant_%zu", item->_offset);
|
||||||
|
HASH_ADD_STR(state->variables, name, item);
|
||||||
|
valueArg->_offset = item->_offset;
|
||||||
|
newInst.args.at[gbiSize - 1] = item->_offset;
|
||||||
|
} else {
|
||||||
|
valueArg->_offset = item->_offset;
|
||||||
GroundVariable* valueItem = NULL;
|
GroundVariable* valueItem = NULL;
|
||||||
HASH_FIND_STR(state->variables, valueArg->as.ref->string, valueItem);
|
HASH_FIND_STR(state->variables, valueArg->as.ref->string, valueItem);
|
||||||
if (valueItem == NULL) {
|
if (valueItem == NULL) {
|
||||||
@@ -434,7 +450,7 @@ static inline GroundSize doOffsets(GroundProgram* gp, GroundState* state, Ground
|
|||||||
HASH_ADD_STR(state->variables, name, valueItem);
|
HASH_ADD_STR(state->variables, name, valueItem);
|
||||||
}
|
}
|
||||||
newInst.args.at[gbiSize - 1] = valueItem->_offset;
|
newInst.args.at[gbiSize - 1] = valueItem->_offset;
|
||||||
|
}
|
||||||
gbp->at[i] = newInst;
|
gbp->at[i] = newInst;
|
||||||
gbp->len++;
|
gbp->len++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user