fix mcode compilation
This commit is contained in:
@@ -25359,11 +25359,19 @@ static JSValue js_cell_push (JSContext *ctx, JSValue this_val, int argc, JSValue
|
||||
|
||||
if (!JS_IsArray (argv[0])) return JS_NULL;
|
||||
|
||||
JSGCRef arr_ref;
|
||||
JS_PushGCRef (ctx, &arr_ref);
|
||||
arr_ref.val = argv[0];
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (js_intrinsic_array_push (ctx, &argv[0], argv[i]) < 0)
|
||||
if (js_intrinsic_array_push (ctx, &arr_ref.val, argv[i]) < 0) {
|
||||
JS_PopGCRef (ctx, &arr_ref);
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
}
|
||||
|
||||
argv[0] = arr_ref.val;
|
||||
JS_PopGCRef (ctx, &arr_ref);
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
@@ -33759,6 +33767,14 @@ static cJSON *mach_gen_function (MachGenState *parent, cJSON *func_node) {
|
||||
s.nr_close_slots = 0;
|
||||
s.nr_local_slots = 0;
|
||||
|
||||
/* Use nr_slots from AST to pre-allocate var capacity */
|
||||
cJSON *ns = cJSON_GetObjectItem (func_node, "nr_slots");
|
||||
int ast_nr_slots = ns ? (int)cJSON_GetNumberValue (ns) : 0;
|
||||
if (ast_nr_slots > 0) {
|
||||
s.var_capacity = ast_nr_slots;
|
||||
s.vars = sys_malloc (s.var_capacity * sizeof(MachVarInfo));
|
||||
}
|
||||
|
||||
int param_slot = 1;
|
||||
cJSON *param;
|
||||
cJSON_ArrayForEach (param, params) {
|
||||
@@ -33775,14 +33791,6 @@ static cJSON *mach_gen_function (MachGenState *parent, cJSON *func_node) {
|
||||
|
||||
cJSON_AddNumberToObject (result, "nr_args", s.nr_args);
|
||||
|
||||
/* Use nr_slots from AST to pre-allocate var capacity */
|
||||
cJSON *ns = cJSON_GetObjectItem (func_node, "nr_slots");
|
||||
int ast_nr_slots = ns ? (int)cJSON_GetNumberValue (ns) : 0;
|
||||
if (ast_nr_slots > 0) {
|
||||
s.var_capacity = ast_nr_slots;
|
||||
s.vars = sys_malloc (s.var_capacity * sizeof(MachVarInfo));
|
||||
}
|
||||
|
||||
/* Scan scope record for variable declarations */
|
||||
mach_gen_scan_scope (&s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user