X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fjaegertracing%2Fopentelemetry-cpp%2Fthird_party%2Fprometheus-cpp%2F3rdparty%2Fcivetweb%2Fsrc%2Fthird_party%2Fduktape-1.8.0%2Fsrc-separate%2Fduk_api_var.c;fp=ceph%2Fsrc%2Fjaegertracing%2Fopentelemetry-cpp%2Fthird_party%2Fprometheus-cpp%2F3rdparty%2Fcivetweb%2Fsrc%2Fthird_party%2Fduktape-1.8.0%2Fsrc-separate%2Fduk_api_var.c;h=6ac790ea8505b52e471c56f626cf5dfd2e127346;hb=1e59de90020f1d8d374046ef9cca56ccd4e806e2;hp=0000000000000000000000000000000000000000;hpb=bd41e436e25044e8e83156060a37c23cb661c364;p=ceph.git diff --git a/ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/src/third_party/duktape-1.8.0/src-separate/duk_api_var.c b/ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/src/third_party/duktape-1.8.0/src-separate/duk_api_var.c new file mode 100644 index 000000000..6ac790ea8 --- /dev/null +++ b/ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/src/third_party/duktape-1.8.0/src-separate/duk_api_var.c @@ -0,0 +1,86 @@ +/* + * Variable access + */ + +#include "duk_internal.h" + +DUK_EXTERNAL void duk_get_var(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_activation *act; + duk_hstring *h_varname; + duk_small_int_t throw_flag = 1; /* always throw ReferenceError for unresolvable */ + + DUK_ASSERT_CTX_VALID(ctx); + + h_varname = duk_require_hstring(ctx, -1); /* XXX: tostring? */ + DUK_ASSERT(h_varname != NULL); + + act = duk_hthread_get_current_activation(thr); + if (act) { + (void) duk_js_getvar_activation(thr, act, h_varname, throw_flag); /* -> [ ... varname val this ] */ + } else { + /* Outside any activation -> look up from global. */ + DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL_ENV] != NULL); + (void) duk_js_getvar_envrec(thr, thr->builtins[DUK_BIDX_GLOBAL_ENV], h_varname, throw_flag); + } + + /* [ ... varname val this ] (because throw_flag == 1, always resolved) */ + + duk_pop(ctx); + duk_remove(ctx, -2); + + /* [ ... val ] */ + + /* Return value would be pointless: because throw_flag==1, we always + * throw if the identifier doesn't resolve. + */ + return; +} + +DUK_EXTERNAL void duk_put_var(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_activation *act; + duk_hstring *h_varname; + duk_tval *tv_val; + duk_small_int_t throw_flag; + + DUK_ASSERT_CTX_VALID(ctx); + + h_varname = duk_require_hstring(ctx, -2); /* XXX: tostring? */ + DUK_ASSERT(h_varname != NULL); + + tv_val = duk_require_tval(ctx, -1); + + throw_flag = duk_is_strict_call(ctx); + + act = duk_hthread_get_current_activation(thr); + if (act) { + duk_js_putvar_activation(thr, act, h_varname, tv_val, throw_flag); /* -> [ ... varname val this ] */ + } else { + /* Outside any activation -> put to global. */ + DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL_ENV] != NULL); + duk_js_putvar_envrec(thr, thr->builtins[DUK_BIDX_GLOBAL_ENV], h_varname, tv_val, throw_flag); + } + + /* [ ... varname val ] */ + + duk_pop_2(ctx); + + /* [ ... ] */ + + return; +} + +DUK_EXTERNAL duk_bool_t duk_del_var(duk_context *ctx) { + DUK_ASSERT_CTX_VALID(ctx); + + DUK_ERROR_UNIMPLEMENTED_DEFMSG((duk_hthread *) ctx); + return 0; +} + +DUK_EXTERNAL duk_bool_t duk_has_var(duk_context *ctx) { + DUK_ASSERT_CTX_VALID(ctx); + + DUK_ERROR_UNIMPLEMENTED_DEFMSG((duk_hthread *) ctx); + return 0; +}