Begin work on reworked extern instruction

This commit is contained in:
2026-07-04 17:53:14 +10:00
parent 3204613c6f
commit 7c29048397
4 changed files with 100 additions and 3 deletions

View File

@@ -822,6 +822,34 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns
return CONTINUE;
}
EXTERN: {
// extern "libfile.so" "symbolName" !fnName -returnType -argType...
void* handle = Ground.FFI.openSharedObject(HEAP_GET(heap, instruction->args.at[0])->as.String.cstr);
if (Ground.Flags.error) {
return CONTINUE;
}
void* function = Ground.FFI.getFunction(handle, HEAP_GET(heap, instruction->args.at[0])->as.String.cstr);
if (Ground.Flags.error) {
return CONTINUE;
}
GroundSize argsSize = instruction->args.len - 4; // subtract 4 for libfile, symbol name, fn name, return type
GroundBytecodeFunction bf = {
.isNativeFunction = true,
.closure = NULL,
.program.native = handle,
.args = {
.at = malloc(sizeof(GroundFunctionArg) * argsSize),
.capacity = argsSize,
.count = argsSize
},
};
if (bf.args.at == NULL) {
Ground.Log.Error("malloc failed in Ground.Bytecode.Instruction.execute");
Ground.Flags.error = true;
return CONTINUE;
}
for (size_t i = 0; i < argsSize; i++) {
}
return CONTINUE;
}
CREATELABEL: {