hfguidshfiouhowfonweoinfvodnsbdifbisdb

This commit is contained in:
2026-07-13 16:47:41 +10:00
parent 7619b897e0
commit 05eddd9a0e
5 changed files with 215 additions and 17 deletions

View File

@@ -913,7 +913,24 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns
GroundBytecodeValue* type = HEAP_GET(heap, instruction->args.at[i]);
switch (type->type.type) {
case GroundType_Struct: {
// TODO nested structs
GroundBytecodeStruct* innerStruct = &type->as.Struct;
GroundBytecodeObject nestedObject = {
.size = innerStruct->size,
.capacity = innerStruct->size,
.values = malloc(sizeof(GroundBytecodeValue) * innerStruct->size)
};
if (nestedObject.values == NULL) {
Ground.Log.Error("malloc failed in Ground.Bytecode.Instruction.execute");
Ground.Flags.error = true;
return CONTINUE;
}
for (GroundSize k = 0; k < innerStruct->size; k++) {
nestedObject.values[k] = Ground.Copy.BytecodeValue(&innerStruct->values[k]);
}
gbs->values[offset] = (GroundBytecodeValue) {
.as.Object = nestedObject,
.type = {GroundType_Object}
};
break;
}
case GroundType_CoreType: {
@@ -1054,6 +1071,22 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns
return CONTINUE;
}
SETFIELD: {
// args: [parent_offset, field0_offset, ..., fieldF_offset, value_offset]
GroundBytecodeValue* current = HEAP_GET(heap, instruction->args.at[0]);
for (GroundSize i = 1; i < instruction->args.len - 1; i++) {
if (current->type.type != GroundType_Object) {
Ground.Log.Error("SETFIELD on non-object value in Ground.Bytecode.Instruction.execute");
Ground.Flags.error = true;
return CONTINUE;
}
current = &current->as.Object.values[instruction->args.at[i]];
}
GroundBytecodeValue* value = HEAP_GET(heap, instruction->args.at[instruction->args.len - 1]);
Ground.Free.BytecodeValue(current);
*current = Ground.Copy.BytecodeValue(value);
return CONTINUE;
}
USE: {