jscode
This commit is contained in:
@@ -536,13 +536,10 @@ JSValue js_new_register_function(JSContext *ctx, JSCodeRegister *code, JSValue e
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Create a native (QBE-compiled) function */
|
||||
JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle,
|
||||
uint16_t nr_slots, int arity, JSValue outer_frame) {
|
||||
JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int arity, JSValue outer_frame) {
|
||||
JSGCRef frame_ref;
|
||||
JSGCRef fn_ref;
|
||||
JSFunction *fn;
|
||||
JSValue code_obj;
|
||||
JS_PushGCRef(ctx, &frame_ref);
|
||||
frame_ref.val = outer_frame;
|
||||
JS_AddGCRef(ctx, &fn_ref);
|
||||
@@ -560,12 +557,6 @@ JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle,
|
||||
fn->kind = JS_FUNC_KIND_NATIVE;
|
||||
fn->length = arity;
|
||||
fn->name = JS_NULL;
|
||||
code_obj = js_new_native_code(ctx, fn_ptr, dl_handle, nr_slots, arity);
|
||||
if (JS_IsException(code_obj)) {
|
||||
JS_DeleteGCRef(ctx, &fn_ref);
|
||||
JS_PopGCRef(ctx, &frame_ref);
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
fn = JS_VALUE_GET_FUNCTION(fn_ref.val);
|
||||
fn->u.cell.code = code_obj;
|
||||
fn->u.cell.env_record = JS_NULL;
|
||||
@@ -577,6 +568,15 @@ JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle,
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Create a native (QBE-compiled) function */
|
||||
JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle,
|
||||
uint16_t nr_slots, int arity, JSValue outer_frame) {
|
||||
JSValue code_obj = js_new_native_code(ctx, fn_ptr, dl_handle, nr_slots, arity);
|
||||
if (JS_IsException(code_obj))
|
||||
return JS_EXCEPTION;
|
||||
return js_new_native_function_with_code(ctx, code_obj, arity, outer_frame);
|
||||
}
|
||||
|
||||
/* Binary operations helper */
|
||||
static JSValue reg_vm_binop(JSContext *ctx, int op, JSValue a, JSValue b) {
|
||||
/* Fast path for integers */
|
||||
|
||||
Reference in New Issue
Block a user