Begin work on reworked extern instruction
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user