Skip to content

Simplify close_lexical_var #726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -14612,15 +14612,14 @@ static void close_var_refs(JSRuntime *rt, JSStackFrame *sf)
}
}

static void close_lexical_var(JSContext *ctx, JSStackFrame *sf, int idx, int is_arg)
static void close_lexical_var(JSContext *ctx, JSStackFrame *sf, int var_idx)
{
struct list_head *el, *el1;
JSVarRef *var_ref;
int var_idx = idx;

list_for_each_safe(el, el1, &sf->var_ref_list) {
var_ref = list_entry(el, JSVarRef, header.link);
if (var_idx == var_ref->var_idx && var_ref->is_arg == is_arg) {
if (var_idx == var_ref->var_idx && !var_ref->is_arg) {
var_ref->value = js_dup(sf->var_buf[var_idx]);
var_ref->pvalue = &var_ref->value;
list_del(&var_ref->header.link);
Expand Down Expand Up @@ -15873,7 +15872,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
int idx;
idx = get_u16(pc);
pc += 2;
close_lexical_var(ctx, sf, idx, FALSE);
close_lexical_var(ctx, sf, idx);
}
BREAK;

Expand Down
Loading