hfguidshfiouhowfonweoinfvodnsbdifbisdb
This commit is contained in:
@@ -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 = ¤t->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: {
|
||||
|
||||
Reference in New Issue
Block a user