Expanded bytecode inspector, added functions to Toy_copyValue

This commit is contained in:
2026-04-17 11:55:46 +10:00
parent 81c95ff69d
commit 5b101d763e
12 changed files with 175 additions and 77 deletions

View File

@@ -20,6 +20,23 @@ Toy_Function* Toy_createFunctionFromCallback(Toy_Bucket** bucketHandle, Toy_nati
return fn;
}
Toy_Function* Toy_copyFunction(Toy_Bucket** bucketHandle, Toy_Function* original) {
Toy_Function* fn = (Toy_Function*)Toy_partitionBucket(bucketHandle, sizeof(Toy_Function));
if (original->type == TOY_FUNCTION_CUSTOM) {
fn->type = original->type;
fn->bytecode.code = original->bytecode.code;
fn->bytecode.parentScope = original->bytecode.parentScope;
Toy_private_incrementScopeRefCount(fn->bytecode.parentScope);
}
else if (fn->type == TOY_FUNCTION_NATIVE) {
fn->type = original->type;
fn->native.callback = original->native.callback;
}
return fn;
}
TOY_API void Toy_freeFunction(Toy_Function* fn) {
if (fn->type == TOY_FUNCTION_CUSTOM) {
Toy_private_decrementScopeRefCount(fn->bytecode.parentScope);