@@ -10124,6 +10124,29 @@ static int JS_SetGlobalVar(JSContext *ctx, JSAtom prop, JSValue val,
10124
10124
return JS_SetPropertyInternal(ctx, ctx->global_obj, prop, val, flags);
10125
10125
}
10126
10126
10127
+ /* return -1, FALSE or TRUE */
10128
+ static int JS_DeleteGlobalVar(JSContext *ctx, JSAtom prop)
10129
+ {
10130
+ JSObject *p;
10131
+ JSShapeProperty *prs;
10132
+ JSProperty *pr;
10133
+ int ret;
10134
+
10135
+ /* 9.1.1.4.7 DeleteBinding ( N ) */
10136
+ p = JS_VALUE_GET_OBJ(ctx->global_var_obj);
10137
+ prs = find_own_property(&pr, p, prop);
10138
+ if (prs)
10139
+ return FALSE; /* lexical variables cannot be deleted */
10140
+ ret = JS_HasProperty(ctx, ctx->global_obj, prop);
10141
+ if (ret < 0)
10142
+ return -1;
10143
+ if (ret) {
10144
+ return JS_DeleteProperty(ctx, ctx->global_obj, prop, 0);
10145
+ } else {
10146
+ return TRUE;
10147
+ }
10148
+ }
10149
+
10127
10150
/* return -1, false or true. return false if not configurable or
10128
10151
invalid object. return -1 in case of exception.
10129
10152
flags can be 0, JS_PROP_THROW or JS_PROP_THROW_STRICT */
@@ -18669,7 +18692,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
18669
18692
pc += 4;
18670
18693
18671
18694
sf->cur_pc = pc;
18672
- ret = JS_DeleteProperty (ctx, ctx->global_obj, atom, 0 );
18695
+ ret = JS_DeleteGlobalVar (ctx, atom);
18673
18696
if (unlikely(ret < 0))
18674
18697
goto exception;
18675
18698
*sp++ = js_bool(ret);
0 commit comments