fix the clanker's code
This commit is contained in:
@@ -419,22 +419,38 @@ 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];
|
||||||
GroundVariable* valueItem = NULL;
|
if (valueArg->type == GroundArg_Value) {
|
||||||
HASH_FIND_STR(state->variables, valueArg->as.ref->string, valueItem);
|
GroundVariable* item = malloc(sizeof(GroundVariable));
|
||||||
if (valueItem == NULL) {
|
if (item == NULL) {
|
||||||
valueItem = malloc(sizeof(GroundVariable));
|
|
||||||
if (valueItem == NULL) {
|
|
||||||
Ground.Log.Error("malloc failed in Ground.New.Bytecode -> doOffsets");
|
Ground.Log.Error("malloc failed in Ground.New.Bytecode -> doOffsets");
|
||||||
Ground.Flags.error = true;
|
Ground.Flags.error = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
valueItem->value = Ground.New.Value.Int(0);
|
item->value = Ground.Copy.Value(&valueArg->as.value);
|
||||||
strncpy(valueItem->name, valueArg->as.ref->string, 2047);
|
if (Ground.Flags.error) return 0;
|
||||||
valueItem->_offset = size++;
|
item->_offset = size++;
|
||||||
HASH_ADD_STR(state->variables, name, valueItem);
|
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;
|
||||||
|
HASH_FIND_STR(state->variables, valueArg->as.ref->string, valueItem);
|
||||||
|
if (valueItem == NULL) {
|
||||||
|
valueItem = malloc(sizeof(GroundVariable));
|
||||||
|
if (valueItem == NULL) {
|
||||||
|
Ground.Log.Error("malloc failed in Ground.New.Bytecode -> doOffsets");
|
||||||
|
Ground.Flags.error = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
valueItem->value = Ground.New.Value.Int(0);
|
||||||
|
strncpy(valueItem->name, valueArg->as.ref->string, 2047);
|
||||||
|
valueItem->_offset = size++;
|
||||||
|
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