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
|
||||
GroundArg* valueArg = &inst->args.at[inst->args.len - 1];
|
||||
GroundVariable* valueItem = NULL;
|
||||
HASH_FIND_STR(state->variables, valueArg->as.ref->string, valueItem);
|
||||
if (valueItem == NULL) {
|
||||
valueItem = malloc(sizeof(GroundVariable));
|
||||
if (valueItem == NULL) {
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
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->len++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user