JavaScript-QuickJS-0.21/000755 000766 000024 00000000000 14563206245 015430 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/QuickJS.xs000644 000766 000024 00000106253 14562424540 017323 0ustar00felipestaff000000 000000 #include #include "easyxs/easyxs.h" #include "quickjs/quickjs.h" #include "quickjs/quickjs-libc.h" #define PERL_NS_ROOT "JavaScript::QuickJS" #define PERL_BOOLEAN_CLASS "Types::Serialiser::Boolean" #define PQJS_JSOBJECT_CLASS PERL_NS_ROOT "::JSObject" #define PQJS_FUNCTION_CLASS PERL_NS_ROOT "::Function" #define PQJS_REGEXP_CLASS PERL_NS_ROOT "::RegExp" #define PQJS_DATE_CLASS PERL_NS_ROOT "::Date" #define PQJS_PROMISE_CLASS PERL_NS_ROOT "::Promise" typedef struct { JSContext *ctx; pid_t pid; bool added_std; bool added_os; bool added_helpers; char* module_base_path; } perl_qjs_s; typedef struct { JSContext *ctx; JSValue jsobj; pid_t pid; } perl_qjs_jsobj_s; typedef struct { #ifdef MULTIPLICITY tTHX aTHX; #endif SV** svs; U32 svs_count; U32 refcount; bool ran_js_std_init_handlers; JSValue regexp_jsvalue; JSValue date_jsvalue; JSValue promise_jsvalue; } ctx_opaque_s; const char* __jstype_name_back[] = { [JS_TAG_BIG_DECIMAL - JS_TAG_FIRST] = "big decimal", [JS_TAG_BIG_INT - JS_TAG_FIRST] = "big integer", [JS_TAG_BIG_FLOAT - JS_TAG_FIRST] = "big float", [JS_TAG_SYMBOL - JS_TAG_FIRST] = "symbol", [JS_TAG_MODULE - JS_TAG_FIRST] = "module", [JS_TAG_OBJECT - JS_TAG_FIRST] = "object", [JS_TAG_FLOAT64 - JS_TAG_FIRST] = "float64", /* Small hack to ensure we can always read: */ [99] = NULL, }; const char* const DATE_GETTER_FROM_IX[] = { "toString", "toUTCString", "toGMTString", "toISOString", "toDateString", "toTimeString", "toLocaleString", "toLocaleDateString", "toLocaleTimeString", "getTimezoneOffset", "getTime", "getFullYear", "getUTCFullYear", "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds", "getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "getDay", "getUTCDay", "toJSON", }; const char* const DATE_SETTER_FROM_IX[] = { "setTime", "setMilliseconds", "setUTCMilliseconds", "setSeconds", "setUTCSeconds", "setMinutes", "setUTCMinutes", "setHours", "setUTCHours", "setDate", "setUTCDate", "setMonth", "setUTCMonth", "setFullYear", "setUTCFullYear", }; #if defined _WIN32 || defined __CYGWIN__ # define PATH_SEPARATOR '\\' #else # define PATH_SEPARATOR '/' #endif #define _jstype_name(typenum) __jstype_name_back[ typenum - JS_TAG_FIRST ] static SV* _JSValue_to_SV (pTHX_ JSContext* ctx, JSValue jsval, SV** err_svp); static inline SV* _JSValue_special_object_to_SV (pTHX_ JSContext* ctx, JSValue jsval, SV** err_svp, const char* class) { assert(!*err_svp); SV* sv = exs_new_structref(perl_qjs_jsobj_s, class); perl_qjs_jsobj_s* pqjs = exs_structref_ptr(sv); *pqjs = (perl_qjs_jsobj_s) { .ctx = ctx, .jsobj = JS_DupValue(ctx, jsval), .pid = getpid(), }; ctx_opaque_s* ctxdata = JS_GetContextOpaque(ctx); ctxdata->refcount++; return sv; } static inline SV* _JSValue_object_to_SV (pTHX_ JSContext* ctx, JSValue jsval, SV** err_svp) { assert(!*err_svp); JSPropertyEnum *tab_atom; uint32_t tab_atom_count; int propnameserr = JS_GetOwnPropertyNames(ctx, &tab_atom, &tab_atom_count, jsval, JS_GPN_STRING_MASK); PERL_UNUSED_VAR(propnameserr); assert(!propnameserr); HV* hv = newHV(); for(int i = 0; i < tab_atom_count; i++) { JSValue key = JS_AtomToString(ctx, tab_atom[i].atom); STRLEN strlen; const char* keystr = JS_ToCStringLen(ctx, &strlen, key); JSValue value = JS_GetProperty(ctx, jsval, tab_atom[i].atom); SV* val_sv = _JSValue_to_SV(aTHX_ ctx, value, err_svp); if (val_sv) { hv_store(hv, keystr, -strlen, val_sv, 0); } JS_FreeCString(ctx, keystr); JS_FreeValue(ctx, key); JS_FreeValue(ctx, value); JS_FreeAtom(ctx, tab_atom[i].atom); if (!val_sv) break; } js_free(ctx, tab_atom); if (*err_svp) { SvREFCNT_dec( (SV*) hv ); return NULL; } return newRV_noinc((SV*) hv); } static inline SV* _JSValue_array_to_SV (pTHX_ JSContext* ctx, JSValue jsval, SV** err_svp) { JSValue jslen = JS_GetPropertyStr(ctx, jsval, "length"); uint32_t len; JS_ToUint32(ctx, &len, jslen); JS_FreeValue(ctx, jslen); AV* av = newAV(); if (len) { av_fill( av, len - 1 ); for (uint32_t i=0; irefcount++; RETVAL = func_sv; } else if (JS_IsArray(ctx, jsval)) { RETVAL = _JSValue_array_to_SV(aTHX_ ctx, jsval, err_svp); } else { ctx_opaque_s* ctxdata = JS_GetContextOpaque(ctx); if (JS_IsInstanceOf(ctx, jsval, ctxdata->regexp_jsvalue)) { RETVAL = _JSValue_special_object_to_SV(aTHX_ ctx, jsval, err_svp, PQJS_REGEXP_CLASS); } else if (JS_IsInstanceOf(ctx, jsval, ctxdata->date_jsvalue)) { RETVAL = _JSValue_special_object_to_SV(aTHX_ ctx, jsval, err_svp, PQJS_DATE_CLASS); } else if (JS_IsInstanceOf(ctx, jsval, ctxdata->promise_jsvalue)) { RETVAL = _JSValue_special_object_to_SV(aTHX_ ctx, jsval, err_svp, PQJS_PROMISE_CLASS); } else { RETVAL = _JSValue_object_to_SV(aTHX_ ctx, jsval, err_svp); } } break; default: STMT_START { const char* typename = _jstype_name(tag); if (typename) { *err_svp = newSVpvf("Cannot convert JS %s (QuickJS tag %d) to Perl!", typename, tag); } else { *err_svp = newSVpvf("Cannot convert (unexpected) JS tag value %d to Perl!", tag); } return NULL; } STMT_END; } return RETVAL; } static inline void _ctx_add_sv(pTHX_ JSContext* ctx, SV* sv) { ctx_opaque_s* ctxdata = JS_GetContextOpaque(ctx); ctxdata->svs_count++; if (ctxdata->svs_count == 1) { Newx(ctxdata->svs, ctxdata->svs_count, SV*); } else { Renew(ctxdata->svs, ctxdata->svs_count, SV*); } ctxdata->svs[ctxdata->svs_count - 1] = SvREFCNT_inc(sv); } static JSValue _sv_to_jsvalue(pTHX_ JSContext* ctx, SV* value, SV** error); #define _MAX_ERRSV_TO_JS_TRIES 10 /* Kind of like _sv_to_jsvalue(), but we need to handle the case where the error SV’s own conversion to a JSValue fails. In that case, we warn on the 1st error, then propagate the 2nd. Repeat until there are no errors. */ static JSValue _sv_error_to_jsvalue(pTHX_ JSContext* ctx, SV* error) { SV* error2 = NULL; uint32_t tries = 0; JSValue to_js; while (1) { to_js = _sv_to_jsvalue(aTHX_ ctx, error, &error2); if (!error2) break; warn_sv(error); tries++; if (tries > _MAX_ERRSV_TO_JS_TRIES) { warn_sv(error2); return JS_NewString(ctx, "Failed to convert Perl error to JavaScript after " STRINGIFY(_MAX_ERRSV_TO_JS_TRIES) " tries!"); } error = error2; error2 = NULL; } return to_js; } static JSValue __do_perl_callback(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int jsmagic, JSValue *func_data) { #ifdef MULTIPLICITY ctx_opaque_s* ctxdata = JS_GetContextOpaque(ctx); pTHX = ctxdata->aTHX; #endif PERL_UNUSED_VAR(jsmagic); SV* cb_sv = ((SV**) func_data)[0]; SV* args[argc + 1]; args[argc] = NULL; SV* error_sv = NULL; for (int a=0; a= 0) { SvREFCNT_dec(args[a]); } break; } } if (!error_sv) { SV* from_perl = exs_call_sv_scalar_trapped(cb_sv, args, &error_sv); if (from_perl) { JSValue to_js = _sv_to_jsvalue(aTHX_ ctx, from_perl, &error_sv); sv_2mortal(from_perl); if (!error_sv) return to_js; } } JSValue jserr = _sv_error_to_jsvalue(aTHX_ ctx, error_sv); return JS_Throw(ctx, jserr); } static JSValue _sviv_to_js(pTHX_ JSContext* ctx, SV* value) { if (sizeof(IV) == sizeof(int64_t)) { return JS_NewInt64(ctx, (int64_t) SvIV(value)); } return JS_NewInt32(ctx, (int32_t) SvIV(value)); } static JSValue _sv_to_jsvalue(pTHX_ JSContext* ctx, SV* value, SV** error_svp) { SvGETMAGIC(value); switch ( exs_sv_type(value) ) { case EXS_SVTYPE_UNDEF: return JS_NULL; case EXS_SVTYPE_BOOLEAN: return JS_NewBool(ctx, SvTRUE(value)); case EXS_SVTYPE_STRING: STMT_START { STRLEN len; const char* str = SvPVutf8(value, len); return JS_NewStringLen(ctx, str, len); } STMT_END; case EXS_SVTYPE_UV: STMT_START { UV val_uv = SvUV(value); if (sizeof(UV) == sizeof(uint64_t)) { if (val_uv > IV_MAX) { return JS_NewFloat64(ctx, val_uv); } else { return JS_NewInt64(ctx, (int64_t) val_uv); } } else { return JS_NewUint32(ctx, (uint32_t) val_uv); } } STMT_END; case EXS_SVTYPE_IV: STMT_START { return _sviv_to_js(aTHX_ ctx, value); } STMT_END; case EXS_SVTYPE_NV: STMT_START { return JS_NewFloat64(ctx, (double) SvNV(value)); } STMT_END; case EXS_SVTYPE_REFERENCE: if (sv_isobject(value)) { if (sv_derived_from(value, PERL_BOOLEAN_CLASS)) { return JS_NewBool(ctx, SvTRUE(SvRV(value))); } else if (sv_derived_from(value, PQJS_JSOBJECT_CLASS)) { perl_qjs_jsobj_s* pqjs = exs_structref_ptr(value); if (LIKELY(pqjs->ctx == ctx)) { return JS_DupValue(ctx, pqjs->jsobj); } *error_svp = newSVpvf("%s for QuickJS %p given to QuickJS %p!", sv_reftype(SvRV(value), 1), pqjs->ctx, ctx); return JS_NULL; } break; } switch (SvTYPE(SvRV(value))) { case SVt_PVCV: _ctx_add_sv(aTHX_ ctx, value); /* A hack to store our callback via the func_data pointer: */ JSValue dummy = JS_MKPTR(JS_TAG_INT, value); return JS_NewCFunctionData( ctx, __do_perl_callback, 0, 0, 1, &dummy ); case SVt_PVAV: STMT_START { AV* av = (AV*) SvRV(value); JSValue jsarray = JS_NewArray(ctx); JS_SetPropertyStr(ctx, jsarray, "length", JS_NewUint32(ctx, 1 + av_len(av))); for (int32_t i=0; i <= av_len(av); i++) { SV** svp = av_fetch(av, i, 0); assert(svp); assert(*svp); JSValue jsval = _sv_to_jsvalue(aTHX_ ctx, *svp, error_svp); if (*error_svp) { JS_FreeValue(ctx, jsarray); return _sv_error_to_jsvalue(aTHX_ ctx, *error_svp); } JS_SetPropertyUint32(ctx, jsarray, i, jsval); } return jsarray; } STMT_END; case SVt_PVHV: STMT_START { HV* hv = (HV*) SvRV(value); JSValue jsobj = JS_NewObject(ctx); hv_iterinit(hv); HE* hvent; while ( (hvent = hv_iternext(hv)) ) { SV* key_sv = hv_iterkeysv(hvent); SV* val_sv = hv_iterval(hv, hvent); STRLEN keylen; const char* key = SvPVutf8(key_sv, keylen); JSValue jsval = _sv_to_jsvalue(aTHX_ ctx, val_sv, error_svp); if (*error_svp) { JS_FreeValue(ctx, jsobj); return _sv_error_to_jsvalue(aTHX_ ctx, *error_svp); } JSAtom prop = JS_NewAtomLen(ctx, key, keylen); /* NB: ctx takes over jsval. */ JS_DefinePropertyValue(ctx, jsobj, prop, jsval, JS_PROP_WRITABLE); JS_FreeAtom(ctx, prop); } return jsobj; } STMT_END; default: break; } default: break; } *error_svp = newSVpvf("Cannot convert %" SVf " to JavaScript!", value); return JS_NULL; } static JSContext* _create_new_jsctx( pTHX_ JSRuntime *rt ) { JSContext *ctx = JS_NewContext(rt); ctx_opaque_s* ctxdata; Newxz(ctxdata, 1, ctx_opaque_s); JS_SetContextOpaque(ctx, ctxdata); JSValue global = JS_GetGlobalObject(ctx); *ctxdata = (ctx_opaque_s) { .refcount = 1, .regexp_jsvalue = JS_GetPropertyStr(ctx, global, "RegExp"), .date_jsvalue = JS_GetPropertyStr(ctx, global, "Date"), .promise_jsvalue = JS_GetPropertyStr(ctx, global, "Promise"), #ifdef MULTIPLICITY .aTHX = aTHX, #endif }; JS_FreeValue(ctx, global); return ctx; } static SV* _get_exception_from_jsvalue(pTHX_ JSContext* ctx, JSValue jsret) { SV* err; JSValue jserr = JS_GetException(ctx); //err = _JSValue_to_SV(aTHX_ ctx, jserr); /* Ideal here is to capture all aspects of the error object, including its `name` and members. But for now just give a string. JSValue jslen = JS_GetPropertyStr(ctx, jserr, "name"); STRLEN namelen; const char* namestr = JS_ToCStringLen(ctx, &namelen, jslen); */ STRLEN strlen; const char* str = JS_ToCStringLen(ctx, &strlen, jserr); err = newSVpvn_flags(str, strlen, SVf_UTF8); JS_FreeCString(ctx, str); JS_FreeValue(ctx, jserr); return err; } static inline SV* _return_jsvalue_or_croak(pTHX_ JSContext* ctx, JSValue jsret) { SV* err; SV* RETVAL; if (JS_IsException(jsret)) { err = _get_exception_from_jsvalue(aTHX_ ctx, jsret); RETVAL = NULL; // silence uninitialized warning } else { err = NULL; RETVAL = _JSValue_to_SV(aTHX_ ctx, jsret, &err); } JS_FreeValue(ctx, jsret); if (err) croak_sv(err); return RETVAL; } static void _free_jsctx(pTHX_ JSContext* ctx) { ctx_opaque_s* ctxdata = JS_GetContextOpaque(ctx); if (--ctxdata->refcount == 0) { JS_FreeValue(ctx, ctxdata->regexp_jsvalue); JS_FreeValue(ctx, ctxdata->date_jsvalue); JS_FreeValue(ctx, ctxdata->promise_jsvalue); JSRuntime *rt = JS_GetRuntime(ctx); for (U32 i=0; isvs_count; i++) { SvREFCNT_dec(ctxdata->svs[i]); } if (ctxdata->ran_js_std_init_handlers) { js_std_free_handlers(rt); } Safefree(ctxdata); JS_FreeContext(ctx); JS_FreeRuntime(rt); } } static JSModuleDef *pqjs_module_loader(JSContext *ctx, const char *module_name, void *opaque) { char** module_base_path_p = (char**) opaque; char* module_base_path = *module_base_path_p; JSModuleDef *moduledef; if (module_base_path) { size_t base_path_len = strlen(module_base_path); size_t module_name_len = strlen(module_name); char real_path[1 + base_path_len + module_name_len]; memcpy(real_path, module_base_path, base_path_len); memcpy(real_path + base_path_len, module_name, module_name_len); real_path[base_path_len + module_name_len] = 0; moduledef = js_module_loader(ctx, real_path, NULL); } else { moduledef = js_module_loader(ctx, module_name, NULL); } return moduledef; } /* These must correlate to the ALIAS values below. */ static const char* _REGEXP_ACCESSORS[] = { "flags", "dotAll", "global", "hasIndices", "ignoreCase", "multiline", "source", "sticky", "unicode", "lastIndex", }; /* These must correlate to the ALIAS values below. */ static const char* _FUNCTION_ACCESSORS[] = { "length", "name", }; #define FUNC_CALL_INITIAL_ARGS 2 // returns the SV to croak. static SV* _svs_to_jsvars(pTHX_ JSContext* jsctx, int32_t params_count, SV** svs, JSValue* jsvars) { SV* error = NULL; for (int32_t i=0; i= 0) { JS_FreeValue(jsctx, jsvars[i]); } break; } jsvars[i] = jsval; } return error; } static void _import_module_to_global(pTHX_ JSContext* jsctx, const char* modname) { const char* jstemplate = "import * as theModule from '%s';\n" "globalThis.%s = theModule;\n"; char js[255] = { 0 }; snprintf(js, 255, jstemplate, modname, modname); JSValue val = JS_Eval(jsctx, js, strlen(js), "", JS_EVAL_TYPE_MODULE); if (JS_IsException(val)) { SV* errsv = _get_exception_from_jsvalue(aTHX_ jsctx, val); if (errsv) { croak_sv(errsv); } croak("Got empty exception??"); } JS_FreeValue(jsctx, val); } /* ---------------------------------------------------------------------- */ MODULE = JavaScript::QuickJS PACKAGE = JavaScript::QuickJS PROTOTYPES: DISABLE SV* _new (SV* classname_sv) CODE: JSRuntime *rt = JS_NewRuntime(); JS_SetHostPromiseRejectionTracker(rt, js_std_promise_rejection_tracker, NULL); JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL); JSContext *ctx = _create_new_jsctx(aTHX_ rt); RETVAL = exs_new_structref(perl_qjs_s, SvPVbyte_nolen(classname_sv)); perl_qjs_s* pqjs = exs_structref_ptr(RETVAL); *pqjs = (perl_qjs_s) { .ctx = ctx, .pid = getpid(), }; JS_SetModuleLoaderFunc( rt, NULL, pqjs_module_loader, &pqjs->module_base_path ); JS_SetRuntimeInfo(rt, PERL_NS_ROOT); OUTPUT: RETVAL void DESTROY (SV* self_sv) CODE: perl_qjs_s* pqjs = exs_structref_ptr(self_sv); if (PL_dirty && pqjs->pid == getpid()) { warn("DESTROYing %" SVf " at global destruction; memory leak likely!\n", self_sv); } if (pqjs->module_base_path) Safefree(pqjs->module_base_path); _free_jsctx(aTHX_ pqjs->ctx); SV* _configure (SV* self_sv, SV* max_stack_size_sv, SV* memory_limit_sv, SV* gc_threshold_sv) CODE: perl_qjs_s* pqjs = exs_structref_ptr(self_sv); JSRuntime *rt = JS_GetRuntime(pqjs->ctx); if (SvOK(max_stack_size_sv)) { JS_SetMaxStackSize(rt, exs_SvUV(max_stack_size_sv)); } if (SvOK(memory_limit_sv)) { JS_SetMemoryLimit(rt, exs_SvUV(memory_limit_sv)); } if (SvOK(gc_threshold_sv)) { JS_SetGCThreshold(rt, exs_SvUV(gc_threshold_sv)); } RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL SV* std (SV* self_sv) ALIAS: os = 1 helpers = 2 CODE: perl_qjs_s* pqjs = exs_structref_ptr(self_sv); switch (ix) { case 0: if (!pqjs->added_std) { js_init_module_std(pqjs->ctx, "std"); _import_module_to_global(aTHX_ pqjs->ctx, "std"); pqjs->added_std = true; } break; case 1: if (!pqjs->added_os) { js_init_module_os(pqjs->ctx, "os"); pqjs->added_os = true; ctx_opaque_s* ctxdata = JS_GetContextOpaque(pqjs->ctx); if (!ctxdata->ran_js_std_init_handlers) { JSRuntime *rt = JS_GetRuntime(pqjs->ctx); js_std_init_handlers(rt); ctxdata->ran_js_std_init_handlers = true; } _import_module_to_global(aTHX_ pqjs->ctx, "os"); } break; case 2: if (!pqjs->added_helpers) { js_std_add_helpers(pqjs->ctx, 0, NULL); pqjs->added_helpers = true; } break; default: croak("%s: Bad XS alias: %d\n", __func__, (int) ix); } RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL SV* unset_module_base (SV* self_sv) CODE: perl_qjs_s* pqjs = exs_structref_ptr(self_sv); if (pqjs->module_base_path) { Safefree(pqjs->module_base_path); pqjs->module_base_path = NULL; } RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL SV* set_module_base (SV* self_sv, SV* path_sv) CODE: if (!SvOK(path_sv)) croak("Give a path! (Did you want unset_module_base?)"); perl_qjs_s* pqjs = exs_structref_ptr(self_sv); const char* path = exs_SvPVbyte_nolen(path_sv); size_t path_len = strlen(path); if (pqjs->module_base_path) { Renew(pqjs->module_base_path, 2 + path_len, char); } else { Newx(pqjs->module_base_path, 2 + path_len, char); } Copy(path, pqjs->module_base_path, 2 + path_len, char); /** If the given path is “/foo/bar”, we store “/foo/bar/”. This means if “/foo/bar/” is given we store “/foo/bar//”, which is ugly but should work on all supported platforms. */ pqjs->module_base_path[path_len] = PATH_SEPARATOR; pqjs->module_base_path[1 + path_len] = 0; RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL SV* set_globals (SV* self_sv, ...) CODE: if (items < 2) croak("Need at least 1 key/value pair."); if (!(items % 2)) croak("Need an even list of key/value pairs."); I32 valscount = (items - 1) >> 1; perl_qjs_s* pqjs = exs_structref_ptr(self_sv); SV* jsname_sv, *value_sv; SV* error = NULL; JSAtom jsnames[valscount]; JSValue jsvals[valscount]; for (int i=0; i < valscount; i++) { jsname_sv = ST( 1 + (i << 1) ); value_sv = ST( 2 + (i << 1) ); STRLEN jsnamelen; const char* jsname_str = SvPVutf8(jsname_sv, jsnamelen); JSValue jsval = _sv_to_jsvalue(aTHX_ pqjs->ctx, value_sv, &error); if (error) { while (i-- > 0) { JS_FreeAtom(pqjs->ctx, jsnames[i]); JS_FreeValue(pqjs->ctx, jsvals[i]); } croak_sv(error); } jsnames[i] = JS_NewAtomLen(pqjs->ctx, jsname_str, jsnamelen); jsvals[i] = jsval; } JSValue jsglobal = JS_GetGlobalObject(pqjs->ctx); for (int i=0; i < valscount; i++) { /* NB: ctx takes over jsval. */ JS_DefinePropertyValue(pqjs->ctx, jsglobal, jsnames[i], jsvals[i], JS_PROP_WRITABLE); JS_FreeAtom(pqjs->ctx, jsnames[i]); } JS_FreeValue(pqjs->ctx, jsglobal); RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL SV* eval (SV* self_sv, SV* js_code_sv) ALIAS: eval_module = 1 CODE: perl_qjs_s* pqjs = exs_structref_ptr(self_sv); JSContext *ctx = pqjs->ctx; STRLEN js_code_len; const char* js_code = SvPVutf8(js_code_sv, js_code_len); int eval_flags = ix ? JS_EVAL_TYPE_MODULE : JS_EVAL_TYPE_GLOBAL; eval_flags |= JS_EVAL_FLAG_STRICT; JSValue jsret = JS_Eval(ctx, js_code, js_code_len, "", eval_flags); // In eval_module()’s case we want to croak if there was // an exception. If not we’ll just discard the return value RETVAL = _return_jsvalue_or_croak(aTHX_ ctx, jsret); OUTPUT: RETVAL SV* await (SV* self_sv) CODE: perl_qjs_s* pqjs = exs_structref_ptr(self_sv); JSContext *ctx = pqjs->ctx; js_std_loop(ctx); RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL # ---------------------------------------------------------------------- MODULE = JavaScript::QuickJS PACKAGE = JavaScript::QuickJS::Date SV* setTime (SV* self_sv, SV* num_sv) ALIAS: setMilliseconds = 1 setUTCMilliseconds = 2 setSeconds = 3 setUTCSeconds = 4 setMinutes = 5 setUTCMinutes = 6 setHours = 7 setUTCHours = 8 setDate = 9 setUTCDate = 10 setMonth = 11 setUTCMonth = 12 setFullYear = 13 setUTCFullYear = 14 CODE: const char* setter_name = DATE_SETTER_FROM_IX[ix]; perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); JSContext *ctx = pqjs->ctx; JSAtom prop = JS_NewAtom(ctx, setter_name); JSValue arg; NV nvval; switch (exs_sv_type(num_sv)) { // In 32-bit perls setTime() values often overflow IV_MAX. case EXS_SVTYPE_NV: case EXS_SVTYPE_STRING: nvval = SvNV(num_sv); if (nvval > IV_MAX || nvval < IV_MIN) { arg = JS_NewFloat64(ctx, (double) nvval); break; } // fallthrough default: arg = _sviv_to_js(aTHX_ ctx, num_sv); } JSValue jsret = JS_Invoke( ctx, pqjs->jsobj, prop, 1, &arg ); JS_FreeAtom(ctx, prop); JS_FreeValue(ctx, arg); RETVAL = _return_jsvalue_or_croak(aTHX_ pqjs->ctx, jsret); OUTPUT: RETVAL SV* toString (SV* self_sv, ...) ALIAS: toUTCString = 1 toGMTString = 2 toISOString = 3 toDateString = 4 toTimeString = 5 toLocaleString = 6 toLocaleDateString = 7 toLocaleTimeString = 8 getTimezoneOffset = 9 getTime = 10 getFullYear = 11 getUTCFullYear = 12 getMonth = 13 getUTCMonth = 14 getDate = 15 getUTCDate = 16 getHours = 17 getUTCHours = 18 getMinutes = 19 getUTCMinutes = 20 getSeconds = 21 getUTCSeconds = 22 getMilliseconds = 23 getUTCMilliseconds = 24 getDay = 25 getUTCDay = 26 toJSON = 27 CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); JSContext *ctx = pqjs->ctx; JSAtom prop = JS_NewAtom(ctx, DATE_GETTER_FROM_IX[ix]); JSValue jsret; if (items > 1) { int params_count = items - 1; JSValue jsargs[params_count]; SV* error = _svs_to_jsvars(aTHX_ ctx, params_count, &ST(1), jsargs); if (error) { JS_FreeAtom(pqjs->ctx, prop); croak_sv(error); } jsret = JS_Invoke( ctx, pqjs->jsobj, prop, params_count, jsargs ); for (uint32_t i=0; ijsobj, prop, 0, NULL ); } JS_FreeAtom(ctx, prop); RETVAL = _return_jsvalue_or_croak(aTHX_ pqjs->ctx, jsret); OUTPUT: RETVAL # ---------------------------------------------------------------------- MODULE = JavaScript::QuickJS PACKAGE = JavaScript::QuickJS::RegExp SV* exec (SV* self_sv, SV* specimen_sv) ALIAS: test = 1 CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); JSContext *ctx = pqjs->ctx; STRLEN specimen_len; const char* specimen = SvPVutf8(specimen_sv, specimen_len); /* TODO: optimize? */ JSAtom prop = JS_NewAtom(ctx, ix ? "test" : "exec"); JSValue specimen_js = JS_NewStringLen(ctx, specimen, specimen_len); JSValue jsret = JS_Invoke( ctx, pqjs->jsobj, prop, 1, &specimen_js ); JS_FreeValue(ctx, specimen_js); JS_FreeAtom(ctx, prop); RETVAL = _return_jsvalue_or_croak(aTHX_ pqjs->ctx, jsret); OUTPUT: RETVAL SV* flags( SV* self_sv) ALIAS: dotAll = 1 global = 2 hasIndices = 3 ignoreCase = 4 multiline = 5 source = 6 sticky = 7 unicode = 8 lastIndex = 9 CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); JSValue myret = JS_GetPropertyStr(pqjs->ctx, pqjs->jsobj, _REGEXP_ACCESSORS[ix]); SV* err = NULL; RETVAL = _JSValue_to_SV(aTHX_ pqjs->ctx, myret, &err); JS_FreeValue(pqjs->ctx, myret); if (err) croak_sv(err); OUTPUT: RETVAL # ---------------------------------------------------------------------- MODULE = JavaScript::QuickJS PACKAGE = JavaScript::QuickJS::JSObject void DESTROY( SV* self_sv ) CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); if (PL_dirty && pqjs->pid == getpid()) { warn("DESTROYing %" SVf " at global destruction; memory leak likely!\n", self_sv); } JS_FreeValue(pqjs->ctx, pqjs->jsobj); _free_jsctx(aTHX_ pqjs->ctx); # ---------------------------------------------------------------------- MODULE = JavaScript::QuickJS PACKAGE = JavaScript::QuickJS::Function SV* _give_self( SV* self_sv, ... ) CODE: RETVAL = SvREFCNT_inc(self_sv); OUTPUT: RETVAL SV* length( SV* self_sv) ALIAS: name = 1 CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); JSValue myret = JS_GetPropertyStr(pqjs->ctx, pqjs->jsobj, _FUNCTION_ACCESSORS[ix]); SV* err = NULL; RETVAL = _JSValue_to_SV(aTHX_ pqjs->ctx, myret, &err); JS_FreeValue(pqjs->ctx, myret); if (err) croak_sv(err); OUTPUT: RETVAL SV* call( SV* self_sv, SV* this_sv=&PL_sv_undef, ... ) CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); U32 params_count = items - FUNC_CALL_INITIAL_ARGS; SV* error = NULL; JSValue thisjs = _sv_to_jsvalue(aTHX_ pqjs->ctx, this_sv, &error); if (error) croak_sv(error); JSValue jsvars[params_count]; error = _svs_to_jsvars( aTHX_ pqjs->ctx, params_count, &ST(FUNC_CALL_INITIAL_ARGS), jsvars ); if (error) { JS_FreeValue(pqjs->ctx, thisjs); croak_sv(error); } JSValue jsret = JS_Call(pqjs->ctx, pqjs->jsobj, thisjs, params_count, jsvars); JS_FreeValue(pqjs->ctx, thisjs); for (uint32_t i=0; ictx, jsvars[i]); } RETVAL = _return_jsvalue_or_croak(aTHX_ pqjs->ctx, jsret); OUTPUT: RETVAL # ---------------------------------------------------------------------- MODULE = JavaScript::QuickJS PACKAGE = JavaScript::QuickJS::Promise SV* then( SV* self_sv, SV* on_success=&PL_sv_undef, SV* on_failure=&PL_sv_undef ) CODE: PERL_UNUSED_ARG(on_success); PERL_UNUSED_ARG(on_failure); perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); SV* error = NULL; JSValue jsvars[2]; int callbacks_count = sizeof(jsvars) / sizeof(jsvars[0]); error = _svs_to_jsvars( aTHX_ pqjs->ctx, callbacks_count, &ST(1), jsvars ); if (error) { croak_sv(error); } JSAtom method_name = JS_NewAtom(pqjs->ctx, "then"); JSValue jsret = JS_Invoke( pqjs->ctx, pqjs->jsobj, method_name, callbacks_count, jsvars ); JS_FreeAtom(pqjs->ctx, method_name); for (uint32_t i=0; ictx, jsvars[i]); } RETVAL = _return_jsvalue_or_croak(aTHX_ pqjs->ctx, jsret); OUTPUT: RETVAL SV* catch( SV* self_sv, SV* callback=&PL_sv_undef) ALIAS: finally = 1 CODE: perl_qjs_jsobj_s* pqjs = exs_structref_ptr(self_sv); SV* error = NULL; JSValue callbackjs = _sv_to_jsvalue(aTHX_ pqjs->ctx, callback, &error); if (error) croak_sv(error); JSAtom method_name = JS_NewAtom(pqjs->ctx, ix ? "finally" : "catch"); JSValue jsret = JS_Invoke( pqjs->ctx, pqjs->jsobj, method_name, 1, &callbackjs ); JS_FreeAtom(pqjs->ctx, method_name); JS_FreeValue(pqjs->ctx, callbackjs); RETVAL = _return_jsvalue_or_croak(aTHX_ pqjs->ctx, jsret); OUTPUT: RETVAL JavaScript-QuickJS-0.21/PaxHeader/LICENSE000644 000766 000024 00000002506 14355430271 020406 xustar00felipestaff000000 000000 27 mtime=1672884409.104999 127 LIBARCHIVE.xattr.com.apple.metadata:kMDItemTextContentLanguage=YnBsaXN0MDBSZW4IAAAAAAAAAQEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAs 108 SCHILY.xattr.com.apple.metadata:kMDItemTextContentLanguage=bplist00Ren 123 LIBARCHIVE.xattr.com.apple.metadata:kMDItemKeyphraseVersion=YnBsaXN0MDAQDAgAAAAAAAABAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACg 104 SCHILY.xattr.com.apple.metadata:kMDItemKeyphraseVersion=bplist00  279 LIBARCHIVE.xattr.com.apple.metadata:kMDItemKeyphraseLabels=YnBsaXN0MDClAQIDBAVfEBBhcnRpc3RpYyBsaWNlbnNlXxATc29mdHdhcmUgZm91bmRhdGlvbl8QFmdlbmVyYWwgcHVibGljIGxpY2Vuc2VfEBpnbnUgZ2VuZXJhbCBwdWJsaWMgbGljZW5zZV10ZXJtcyBvZiBwZXJsCA4hN1BtAAAAAAAAAQEAAAAAAAAABgAAAAAAAAAAAAAAAAAAAHs 221 SCHILY.xattr.com.apple.metadata:kMDItemKeyphraseLabels=bplist00_artistic license_software foundation_general public license_gnu general public license]terms of perl!7Pm{ 199 LIBARCHIVE.xattr.com.apple.metadata:kMDItemKeyphraseConfidences=YnBsaXN0MDClAQIDBAUjP+AWUMAAAAAjP8dvfgAAAAAjP8Pg73vW4dUjP8EEGtnt1mAjP7EG2sA7FoAIDhcgKTIAAAAAAAABAQAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAOw 162 SCHILY.xattr.com.apple.metadata:kMDItemKeyphraseConfidences=bplist00#?P#?o~#?{#?`#?; )2; JavaScript-QuickJS-0.21/LICENSE000644 000766 000024 00000050101 14355430271 016427 0ustar00felipestaff000000 000000 Terms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --------------------------------------------------------------------------- The General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS --------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End JavaScript-QuickJS-0.21/cpanfile000644 000766 000024 00000000373 14355430271 017134 0ustar00felipestaff000000 000000 configure_requires 'ExtUtils::MakeMaker::CPANfile'; configure_requires 'File::Slurper'; configure_requires 'File::Which'; test_requires 'Types::Serialiser'; test_requires 'Test::FailWarnings'; test_requires 'Test::Deep'; test_requires 'Test::Fatal'; JavaScript-QuickJS-0.21/quickjs/000755 000766 000024 00000000000 14563206245 017101 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/Changes000644 000766 000024 00000007064 14563206207 016730 0ustar00felipestaff000000 000000 Revision history for Perl extension JavaScript::QuickJS: 0.21 Sec 14 Feb 2024 - Documentation updates. (No functional changes.) 0.20 Tue 13 Feb 2024 - BREAKING CHANGE: eval_module() now returns a Promise (as QuickJS itself now does) instead of the JavaScript::QuickJS instance. - Fix integer-overflow bug in setTime() (et al.) when Perl stores the number as NV rather than IV/UV. - Properly free QuickJS resources upon failure to convert Perl parameters to JavaScript. - Add Promise support. 0.19 Fri 1 Dec 2023 - BREAKING CHANGE: Enabling std() or os() now creates globals by those names. This matches the “qjs” binary’s behavior. - Update to latest quickjs (03cc5ec). 0.18 Wed 29 Nov 2023 - Fix segfault when importing "os". 0.17 Thu 12 Jan 2023 - Add Windows support. - Fix a leftover debugging artifact. 0.16 Sun 8 Jan 2023 - Update easyxs to fix Solaris strnlen problem seen in CPAN Testers. - Small fix to docs. 0.15 Thu 8 Sep 2022 - Add Date compatibility. - QuickJS memory-management parameters are now configurable. - BigInt et al. on 64-bit no longer requires a compiler that implements int128. (e.g., CloudLinux 6 can now have BigInt) - QuickJS runtime info is now set to the module name. (Debugging aid.) - Docs improvement for memory-leak notifications. (Thank you, perlancar!) - Docs now demonstrate use of `std` module, and a test is added. 0.14 Sun 4 Sep 2022 - Fix parallel build errors. (Thank you, CPAN Testers!) 0.13 Thu 25 Aug 2022 - Detect missing gmake up-front at build time. - Detect at build time when linking to libatomic is necessary, and only link in that case. - Allow direct enable/disable of linking to libatomic. 0.12 Mon 6 Jan 2022 - Add await() so Perl can wait until JS’s pending jobs finish. - Make eval_module() return the JS object so chaining is easier. - Explicitly document interfaces that return the JS object. 0.11 Sun 15 May 2022 - BREAKING CHANGE: JavaScript Functions converted to Perl now become instances of a new class, JavaScript::QuickJS::Function. That class is overloaded to act as a coderef, so MOST calling code should still work, but anything that expects a CODE reference will now instead find a blessed object. - BUG FIX: Fix leaked scalars returned from Perl callbacks. - Tweak discussion of memory-leak detection. - Add missing regexp test. 0.10 Thu 12 May 2022 - Fix missing RegExp module. 0.09 Thu 12 May 2022 - Add RegExp compatibility. 0.08 Tue 26 Apr 2022 - BUG FIX: Avoid segfault when passing a function from JS to Perl. - BUG FIX: Avoid segfault if an invalid SV is given to a Perl/JS coderef. - BUG FIX: Free args to JS function references when call()ed. - Set strict mode to always-on. - Teach Perl->JSON conversion to recognize Types::Serialiser booleans. - Warn if funcref is destroyed at global destruction. - Document the present memory-handling weirdness. :( 0.07 Mon 25 Apr 2022 - Add ability to customize base path for ES6 module imports. 0.06 Fri 22 Apr 2022 - Fix compatibility with old Linuxes (e.g., CentOS 7 and CloudLinux 6). 0.05 Thu 7 Apr 2022 - Fix helpers() method. - Fix memory leak when std/os/helpers failed. - Fix bad assert check. 0.04 Mon 4 Apr 2022 - No production changes. - Fix typo’d test from 0.03. 0.03 Mon 4 Apr 2022 - Fix number conversion in 32-bit, non-64-bit-int perls. - Fix conversion of Perl “magic” variables to JavaScript. - Add more tests against number conversion. - Refine Perl->JS typing logic to agree with 5.36 serialization. - Patch QuickJS to support FreeBSD, OpenBSD, and Cygwin. 0.02 Mon 28 Mar 2022 - Documentation fixes 0.01 Mon 28 Mar 2022 - Initial release JavaScript-QuickJS-0.21/MANIFEST000644 000766 000024 00000004567 14563206245 016575 0ustar00felipestaff000000 000000 Changes LICENSE MANIFEST Makefile.PL QuickJS.xs README.md cpanfile easyxs/LICENSE easyxs/README.md easyxs/easyxs.h easyxs/easyxs_debug.h easyxs/easyxs_numeric.h easyxs/easyxs_perlcall.h easyxs/easyxs_scalar.h easyxs/easyxs_string.h easyxs/easyxs_structref.h easyxs/init.h easyxs/ppport.h lib/JavaScript/QuickJS.pm lib/JavaScript/QuickJS/Date.pm lib/JavaScript/QuickJS/Function.pm lib/JavaScript/QuickJS/Promise.pm lib/JavaScript/QuickJS/RegExp.pm quickjs/Changelog quickjs/LICENSE quickjs/Makefile quickjs/TODO quickjs/VERSION quickjs/cutils.c quickjs/cutils.h quickjs/doc/jsbignum.texi quickjs/doc/quickjs.texi quickjs/examples/fib.c quickjs/examples/fib_module.js quickjs/examples/hello.js quickjs/examples/hello_module.js quickjs/examples/pi_bigdecimal.js quickjs/examples/pi_bigfloat.js quickjs/examples/pi_bigint.js quickjs/examples/point.c quickjs/examples/test_fib.js quickjs/examples/test_point.js quickjs/libbf.c quickjs/libbf.h quickjs/libregexp-opcode.h quickjs/libregexp.c quickjs/libregexp.h quickjs/libunicode-table.h quickjs/libunicode.c quickjs/libunicode.h quickjs/list.h quickjs/qjs.c quickjs/qjsc.c quickjs/qjscalc.js quickjs/quickjs-atom.h quickjs/quickjs-libc.c quickjs/quickjs-libc.h quickjs/quickjs-opcode.h quickjs/quickjs.c quickjs/quickjs.h quickjs/readme.txt quickjs/release.sh quickjs/repl.js quickjs/run-test262.c quickjs/test262.conf quickjs/test262_errors.txt quickjs/test262o.conf quickjs/test262o_errors.txt quickjs/tests/bjson.c quickjs/tests/microbench.js quickjs/tests/test262.patch quickjs/tests/test_bignum.js quickjs/tests/test_bjson.js quickjs/tests/test_builtin.js quickjs/tests/test_closure.js quickjs/tests/test_language.js quickjs/tests/test_loop.js quickjs/tests/test_op_overloading.js quickjs/tests/test_qjscalc.js quickjs/tests/test_std.js quickjs/tests/test_worker.js quickjs/tests/test_worker_module.js quickjs/unicode_download.sh quickjs/unicode_gen.c quickjs/unicode_gen_def.h t/await.t t/basic.t t/callback_err.t t/callback_invalid_sv.t t/date.t t/date_invalid_input.t t/export_ref.t t/func_call_invalid_input.t t/import_os.t t/import_std.t t/import_std2.t t/js2perl.t t/js_func_to_perl.t t/jsfunc_memory_handling.t t/memory.t t/module.t t/promise.t t/regexp.t t/script_std.t t/set_globals.t t/strict.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) JavaScript-QuickJS-0.21/t/000755 000766 000024 00000000000 14563206245 015673 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/README.md000644 000766 000024 00000024643 14563206230 016712 0ustar00felipestaff000000 000000 # NAME JavaScript::QuickJS - Run JavaScript via [QuickJS](https://bellard.org/quickjs) in Perl # SYNOPSIS Quick and dirty … my $val = JavaScript::QuickJS->new()->eval( q< let foo = "bar"; [ "The", "last", "value", "is", "returned." ]; > ); … or load ES6 modules: my $js = JavaScript::QuickJS->new()->helpers(); $js->eval_module( q/ import * as coolStuff from 'cool/stuff'; for (const [key, value] of Object.entries(coolStuff)) { console.log(key, value); } / ); # DESCRIPTION This library embeds Fabrice Bellard’s [QuickJS](https://bellard.org/quickjs) engine into a Perl XS module. You can thus run JavaScript ([ES2020](https://tc39.github.io/ecma262/) specification) directly in your Perl programs. This distribution includes all needed C code; unlike with most XS modules that interface with C libraries, you don’t need QuickJS pre-installed on your system. # METHODS ## $obj = _CLASS_->new( %CONFIG\_OPTS ) Instantiates _CLASS_. %CONFIG\_OPTS have the same effect as in `configure()` below. ## $obj = _OBJ_->configure( %OPTS ) Tunes the QuickJS interpreter. Returns _OBJ_. %OPTS are any of: - `max_stack_size` - `memory_limit` - `gc_threshold` For more information on these, see QuickJS itself. ## $obj = _OBJ_->set\_globals( NAME1 => VALUE1, .. ) Sets 1 or more globals in _OBJ_. See below for details on type conversions from Perl to JavaScript. Returns _OBJ_. ## $obj = _OBJ_->helpers() Defines QuickJS’s “helpers”, e.g., `console.log`. Returns _OBJ_. ## $obj = _OBJ_->std() Enables QuickJS’s `std` module and creates a global of the same name that’s usable from both script and module modes. This resembles `qjs`’s `--std` flag except that it _only_ enables `std`, not `os`. Returns _OBJ_. ## $obj = _OBJ_->os() Like `std()` but enables QuickJS’s `os` module instead of `std`. ## $VALUE = _OBJ_->eval( $JS\_CODE ) Like running `qjs -e '...'`. Returns $JS\_CODE’s last value; see below for details on type conversions from JavaScript to Perl. Untrapped exceptions in JavaScript will be rethrown as Perl exceptions. $JS\_CODE is a _character_ string. ## $promise = _OBJ_->eval\_module( $JS\_CODE ) Runs $JS\_CODE as a module, which enables ES6 module syntax. Note that no values can be returned directly in this mode of execution. Returns a promise that resolves once the module is loaded. ## $obj = _OBJ_->await() Blocks until all of _OBJ_’s pending work (if any) is complete. For example, if you `eval()` some code that creates a promise, call this to wait for that promise to complete. Returns _OBJ_. ## $obj = _OBJ_->set\_module\_base( $PATH ) Sets a base path (a byte string) for ES6 module imports. Returns _OBJ_. ## $obj = _OBJ_->unset\_module\_base() Restores QuickJS’s default directory for ES6 module imports (as of this writing, it’s the process’s current directory). Returns _OBJ_. # TYPE CONVERSION: JAVASCRIPT → PERL This module converts returned values from JavaScript thus: - JS string primitives become _character_ strings in Perl. - JS number & boolean primitives become corresponding Perl values. - JS null & undefined become Perl undef. - JS objects … - Arrays become Perl array references. - “Plain” objects become Perl hash references. - Function, RegExp, and Date objects become Perl [JavaScript::QuickJS::Function](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3AFunction), [JavaScript::QuickJS::RegExp](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3ARegExp), and [JavaScript::QuickJS::Date](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3ADate) objects, respectively. - Behaviour is **UNDEFINED** for other object types. # TYPE CONVERSION: PERL → JAVASCRIPT Generally speaking, it’s the inverse of JS → Perl: - Perl strings, numbers, & booleans become corresponding JavaScript primitives. **IMPORTANT:** Perl versions before 5.36 don’t reliably distinguish “numeric strings” from “numbers”. If your perl predates 5.36, typecast accordingly to prevent your Perl “number” from becoming a JavaScript string. (Even in 5.36 and later it’s still a good idea.) - Perl undef becomes JS null. - Unblessed array & hash references become JavaScript arrays and “plain” objects. - [Types::Serialiser](https://metacpan.org/pod/Types%3A%3ASerialiser) booleans become JavaScript booleans. - Perl code references become JavaScript functions. - Perl [JavaScript::QuickJS::Function](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3AFunction), [JavaScript::QuickJS::RegExp](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3ARegExp), and [JavaScript::QuickJS::Date](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3ADate) objects become their original JavaScript objects. - Anything else triggers an exception. # MEMORY HANDLING NOTES If any instance of a class of this distribution is DESTROY()ed at Perl’s global destruction, we assume that this is a memory leak, and a warning is thrown. To prevent this, avoid circular references, and clean up all global instances. Callbacks make that tricky. When you give a JavaScript function to Perl, that Perl object holds a reference to the QuickJS context. Only once that object is `DESTROY()`ed do we release that QuickJS context reference. Consider the following: my $return; $js->set_globals( __return => sub { $return = shift; () } ); $js->eval('__return( a => a )'); This sets $return to be a [JavaScript::QuickJS::Function](https://metacpan.org/pod/JavaScript%3A%3AQuickJS%3A%3AFunction) instance. That object holds a reference to $js. $js also stores `__return()`, which is a Perl code reference that closes around $return. Thus, we have a reference cycle: $return refers to $js, and $js refers to $return. Those two values will thus leak, and you’ll see a warning about it at Perl’s global destruction time. To break the reference cycle, just do: undef $return; … once you’re done with that variable. You _might_ have thought you could instead do: $js->set_globals( __return => undef ) … but that doesn’t work because $js holds a reference to all Perl code references it **ever** receives. This is because QuickJS, unlike Perl, doesn’t expose object destructors (`DESTROY()` in Perl), so there’s no good way to release that reference to the code reference. # CHARACTER ENCODING NOTES QuickJS (like all JS engines) assumes its strings are text. Since Perl can’t distinguish text from bytes, though, it’s possible to convert Perl byte strings to JavaScript strings. It often yields a reasonable result, but not always. One place where this falls over, though, is ES6 modules. QuickJS, when it loads an ES6 module, decodes that module’s string literals to characters. Thus, if you pass in byte strings from Perl, QuickJS will treat your Perl byte strings’ code points as character code points, and when you combine those code points with those from your ES6 module you may get mangled output. Another place that may create trouble is if your argument to `eval()` or `eval_module()` (above) contains JSON. Perl’s popular JSON encoders output byte strings by default, but as noted above, `eval()` and `eval_module()` need _character_ strings. So either configure your JSON encoder to output characters, or decode JSON bytes to characters before calling `eval()`/`eval_module()`. For best results, _always_ interact with QuickJS via _character_ strings, and double-check that you’re doing it that way consistently. # NUMERIC PRECISION Note the following if you expect to deal with “large” numbers: - JavaScript’s numeric-precision limits apply. (cf. [Number.MAX\_SAFE\_INTEGER](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).) - Perl’s stringification of numbers may be _less_ precise than JavaScript’s storage of those numbers, or even than Perl’s own storage. For example, in Perl 5.34 `print 1000000000000001.0` prints `1e+15`. To counteract this loss of precision, add 0 to Perl’s numeric scalars (e.g., `print 0 + 1000000000000001.0`); this will encourage Perl to store numbers as integers when possible, which fixes this precision problem. - Long-double and quad-math perls may lose precision when converting numbers to/from JavaScript. To see if this affects your perl—which, if you’re unsure, it probably doesn’t—run `perl -V`, and see if that perl’s compile-time options mention long doubles or quad math. # OS SUPPORT QuickJS supports Linux, macOS, and Windows natively, so these work without issue. FreeBSD, OpenBSD, & Cygwin work after a few patches that we apply when building this library. (Hopefully these will eventually merge into QuickJS.) # LIBATOMIC QuickJS uses C11 atomics. Most platforms implement that functionality in hardware, but others (e.g., arm32) don’t. To fill that void, we need to link to libatomic. This library’s build logic detects whether libatomic is necessary and will only link to it if needed. If, for some reason, you need manual control over that linking, set `JS_QUICKJS_LINK_LIBATOMIC` in the environment to 1 or a falsy value. If you don’t know what any of that means, you can probably ignore it. # SEE ALSO Other JavaScript modules on CPAN include: - [JavaScript::Duktape::XS](https://metacpan.org/pod/JavaScript%3A%3ADuktape%3A%3AXS) and [JavaScript::Duktape](https://metacpan.org/pod/JavaScript%3A%3ADuktape) make the [Duktape](https://duktape.org) library available to Perl. They’re similar to this library, but Duktape itself (as of this writing) lacks support for several JavaScript constructs that QuickJS supports. (It’s also slower.) - [JavaScript::V8](https://metacpan.org/pod/JavaScript%3A%3AV8) and [JavaScript::V8::XS](https://metacpan.org/pod/JavaScript%3A%3AV8%3A%3AXS) expose Google’s [V8](https://v8.dev) library to Perl. Neither seems to support current V8 versions. - [JE](https://metacpan.org/pod/JE) is a pure-Perl (!) JavaScript engine. - [JavaScript](https://metacpan.org/pod/JavaScript) and [JavaScript::Lite](https://metacpan.org/pod/JavaScript%3A%3ALite) expose Mozilla’s [SpiderMonkey](https://spidermonkey.dev/) engine to Perl. # LICENSE & COPYRIGHT This library is copyright 2023 Gasper Software Consulting. This library is licensed under the same terms as Perl itself. See [perlartistic](https://metacpan.org/pod/perlartistic). QuickJS is copyright Fabrice Bellard and Charlie Gordon. It is released under the [MIT license](https://opensource.org/licenses/MIT). JavaScript-QuickJS-0.21/META.yml000644 000766 000024 00000001520 14563206245 016677 0ustar00felipestaff000000 000000 --- abstract: 'Run JavaScript via L in Perl' author: - 'Felipe Gasper (FELIPE)' build_requires: ExtUtils::MakeMaker: '0' Test::Deep: '0' Test::FailWarnings: '0' Test::Fatal: '0' Types::Serialiser: '0' configure_requires: ExtUtils::MakeMaker::CPANfile: '0.09' File::Slurper: '0' File::Which: '0' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: JavaScript-QuickJS no_index: directory: - t - inc resources: bugtracker: https://github.com/FGasper/p5-JavaScript-QuickJS/issues repository: git://github.com/FGasper/p5-JavaScript-QuickJS.git version: '0.21' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' JavaScript-QuickJS-0.21/lib/000755 000766 000024 00000000000 14563206245 016176 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/Makefile.PL000644 000766 000024 00000021365 14562333656 017417 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use ExtUtils::MakeMaker::CPANfile; use Config; use File::Temp; use File::Slurper; use File::Spec; use File::Which; use Cwd; my $GMAKE_PATH = _find_gmake(); if (!$GMAKE_PATH) { die "GNU Make ($Config{'gmake'}) is required.\n"; } elsif (!-x $GMAKE_PATH) { if ($!) { die "Failed to detect if GNU Make ($GMAKE_PATH) is executable: $!\n"; } die "GNU Make ($GMAKE_PATH) is not executable.\n"; } my $ATOMIC_ENV_KEY = 'JS_QUICKJS_LINK_LIBATOMIC'; my $PERL_QJS_MAKEFILE_PATH = File::Spec->catfile( Cwd::getcwd(), 'Makefile.quickjs'); my $libpath = File::Spec->catfile('quickjs', 'libquickjs.a'); # quickjs needs these; pre-5.20 perls didn’t include libpthread. # Note that MSWin32, if given these, will try to compile them statically # rather than dynamically, which breaks compilation. # my @libs = ($^O eq 'MSWin32') ? () : qw(-lm -ldl -lpthread); if (_need_librt()) { push @libs, '-lrt'; } _tweak_for_os(); if (!_stdatomic_h_exists()) { _avoid_stdatomic_h(); } # QuickJS’s Makefile uses the mkdir CLI tool to create this directory. # The problem is that it expects POSIX’s mkdir, which doesn’t match # Windows’s. To avoid that problem we pre-create the directory now: # mkdir( File::Spec->catdir( qw(quickjs .obj) ) ); make_libquickjs_makefile(); # RaspiOS needs this; others may, too: if (_should_link_libatomic()) { push @libs, '-latomic'; } WriteMakefile( NAME => 'JavaScript::QuickJS', VERSION_FROM => 'lib/JavaScript/QuickJS.pm', # finds $VERSION ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/JavaScript/QuickJS.pm', # retrieve abstract from module AUTHOR => [ 'Felipe Gasper (FELIPE)', ], ) : () ), INC => '-Wall --std=c99 -I.', LICENSE => "perl_5", PMLIBDIRS => ['lib'], LIBS => "@libs", OBJECT => join( q< >, '$(BASEEXT)$(OBJ_EXT)', $libpath, ), META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'git://github.com/FGasper/p5-JavaScript-QuickJS.git', web => 'https://github.com/FGasper/p5-JavaScript-QuickJS', }, bugtracker => { web => 'https://github.com/FGasper/p5-JavaScript-QuickJS/issues', }, }, }, ); #---------------------------------------------------------------------- # CPAN offers Alien::gmake, but there’s a significant dependency tree # involved there. sub _find_gmake { my $gmake; if (my $make = File::Which::which($Config{'make'})) { my $out = `$make --version`; if ($out =~ mi) { $gmake = $make; } } $gmake ||= File::Which::which($Config{'gmake'}); return $gmake; } sub _tweak_for_os { my %bsd_fix = ( Makefile => sub { return "CONFIG_DARWIN=y$/" . shift; }, ); my %edits = ( freebsd => \%bsd_fix, openbsd => \%bsd_fix, ); if (my $edits_h = $edits{$^O}) { my $touchfile_path = File::Spec->catfile('quickjs', 'js-qjs-tweaked'); if (-e $touchfile_path) { print "QuickJS is already tweaked for $^O compatibility.$/"; } else { print "Tweaking QuickJS for $^O compatibility …$/"; for my $fname (keys %$edits_h) { my $path = "quickjs/$fname"; my $content = File::Slurper::read_binary($path); my $out = $edits_h->{$fname}->($content); File::Slurper::write_binary($path, $out); } print "Done.$/"; open my $fh, '>', $touchfile_path; } } else { print "No tweaks for this OS ($^O) are available. Hopefully none are needed!$/"; } } # In CloudLinux 6, glibc is old enough to need -lrt. Test for that. # my $_cached_need_librt; sub _need_librt { return $_cached_need_librt if defined $_cached_need_librt; print "Checking whether this system needs to link to librt …\n"; my $ok = _does_this_compile( '#include ', '#ifdef __GLIBC__', '# if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 17)', '# error "This system needs librt"', '# endif', '#endif', 'int main() { return 0; }', ); print "\t… " . ($ok ? 'Guess not.' : 'Looks like it.') . "\n"; return $_cached_need_librt = !$ok; } sub _does_this_compile { my (@lines_of_c) = @_; my $dir = File::Temp::tempdir( CLEANUP => 1 ); my $path = File::Spec->catfile( $dir, 'test.c' ); { open my $fh, '>', $path or die "open($dir/test.c): $!"; syswrite $fh, join("\n", @lines_of_c, q<>); } return 0 == system $Config{'cc'}, $path; } sub _should_link_libatomic { -e $PERL_QJS_MAKEFILE_PATH or die "Need quickjs makefile!"; my $env_value = $ENV{$ATOMIC_ENV_KEY}; if (defined $env_value) { if ($env_value) { if ($env_value ne '1') { die "Set $ATOMIC_ENV_KEY to 1 or a falsy value.\n"; } print "You’ve forcibly enabled linking against libatomic.\n"; return 1; } else { print "You’ve forcibly disabled linking against libatomic.\n"; return 0; } } print "Does QuickJS need -latomic? (compiling core object file) …\n"; my $rel_objpath = File::Spec->catfile( qw( .obj quickjs.nolto.o ) ); my $objpath = File::Spec->catfile( 'quickjs', $rel_objpath ); my $needs_libatomic; eval { system $GMAKE_PATH, '-C', 'quickjs', '-f', $PERL_QJS_MAKEFILE_PATH, $rel_objpath; die if $?; my $objbin = File::Slurper::read_binary($objpath); $needs_libatomic = -1 != index($objbin, '__atomic_fetch_sub_'); }; if ($@) { print "\tFailed to detect (assuming no): $@"; } else { print "\t… " . ($needs_libatomic ? 'Looks like it.' : 'Guess not.') . "\n"; } return $needs_libatomic; } sub _stdatomic_h_exists { my $dir = File::Temp::tempdir( CLEANUP => 1 ); open my $fh, '>', "$dir/test.c"; syswrite $fh, join( "\n", '#include ', 'int main() { return 0; }', ); print "Checking whether stdatomic.h exists …\n"; my $ok = !system $Config{'cc'}, "$dir/test.c"; print "\t… " . ($ok ? 'Looks like it.' : 'Guess not.') . "\n"; return $ok; } sub _avoid_stdatomic_h { print "Tweaking QuickJS to avoid use of stdatomic.h …\n"; my $qjs_c_path = File::Spec->catfile( qw( quickjs quickjs.c ) ); my $quickjs_c = File::Slurper::read_binary($qjs_c_path); $quickjs_c =~ s<^#define\s+CONFIG_ATOMICS>m or do { warn "Did no replace for quickjs.c?\n"; }; File::Slurper::write_binary($qjs_c_path, $quickjs_c); my $qjs_libc_path = File::Spec->catfile( qw( quickjs quickjs-libc.c ) ); my $quickjs_libc_c = File::Slurper::read_binary($qjs_libc_path); $quickjs_libc_c =~ s<^#define\s+USE_WORKER>m or do { warn "Did no replace for quickjs-libc.c?\n"; }; File::Slurper::write_binary($qjs_libc_path, $quickjs_libc_c); } sub make_libquickjs_makefile { my $mfpath = File::Spec->catfile('quickjs', 'Makefile'); open my $rfh, '<', $mfpath or die "open Makefile: $!"; my $make = do { local $/; <$rfh> }; # QuickJS builds by default without position-independent code, which # means the resulting static library is only suitable for executables. # We need position-independent code so we can compile QuickJS into a # shared library. # substr($make, 0, 0, "CFLAGS+=-fPIC\n"); # In systems old enough to need -lrt (e.g., CloudLinux 6), # assume we need these other omissions as well: # if (_need_librt()) { $make =~ s<^(.*no-format-truncation)><#$1 -- J::QJS>m or do { warn "No no-format-truncation to hide?\n"; }; $make =~ s<^(CONFIG_LTO)><#$1 -- J::QJS>m or do { warn "No CONFIG_LTO to hide?\n"; }; } open my $fh, '>', $PERL_QJS_MAKEFILE_PATH or die "open($PERL_QJS_MAKEFILE_PATH): $!"; syswrite $fh, $make or die "write custom quickjs make: $!"; print "Created `$PERL_QJS_MAKEFILE_PATH`$/"; } # ---------------------------------------------------------------------- package MY; use Config; sub postamble { # QuickJS requires GNU make. my $make = ($^O =~ mi) ? $GMAKE_PATH : '$(MAKE)'; # The leading “+” is to ensure that parallel builds work properly. return <<"MAKE_FRAG" $libpath: \t+$make -C quickjs -f '$PERL_QJS_MAKEFILE_PATH' libquickjs.a MAKE_FRAG } 1; JavaScript-QuickJS-0.21/easyxs/000755 000766 000024 00000000000 14563206245 016744 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/META.json000644 000766 000024 00000002710 14563206245 017051 0ustar00felipestaff000000 000000 { "abstract" : "Run JavaScript via L in Perl", "author" : [ "Felipe Gasper (FELIPE)" ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "JavaScript-QuickJS", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker::CPANfile" : "0.09", "File::Slurper" : "0", "File::Which" : "0" } }, "test" : { "requires" : { "Test::Deep" : "0", "Test::FailWarnings" : "0", "Test::Fatal" : "0", "Types::Serialiser" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/FGasper/p5-JavaScript-QuickJS/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/FGasper/p5-JavaScript-QuickJS.git", "web" : "https://github.com/FGasper/p5-JavaScript-QuickJS" } }, "version" : "0.21", "x_serialization_backend" : "JSON::PP version 4.06" } JavaScript-QuickJS-0.21/easyxs/easyxs_string.h000644 000766 000024 00000001221 14355430321 022004 0ustar00felipestaff000000 000000 #ifndef EASYXS_STRING_H #define EASYXS_STRING_H 1 #include "init.h" static inline char* _easyxs_sv_to_str (pTHX_ SV* sv, U8 is_utf8) { if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv); char *str = is_utf8 ? SvPVutf8_nolen(sv) : SvPVbyte_nolen(sv); size_t len = strlen(str); if (len != SvCUR(sv)) { croak("Cannot convert scalar to C string (NUL byte detected, offset %" UVf ")", (UV) len); } return str; } /* ---------------------------------------------------------------------- */ #define exs_SvPVbyte_nolen(sv) _easyxs_sv_to_str(aTHX_ sv, 0) #define exs_SvPVutf8_nolen(sv) _easyxs_sv_to_str(aTHX_ sv, 1) #endif JavaScript-QuickJS-0.21/easyxs/easyxs_structref.h000644 000766 000024 00000001001 14355430321 022513 0ustar00felipestaff000000 000000 #ifndef EASYXS_STRUCTREF_H #define EASYXS_STRUCTREF_H 1 #include "init.h" #define exs_new_structref(type, classname) _exs_new_structref_f(aTHX_ sizeof(type), classname) #define exs_structref_ptr(svrv) ( (void *) SvPVX( SvRV(svrv) ) ) static inline SV* _exs_new_structref_f (pTHX_ unsigned size, const char* classname) { SV* referent = newSV(size); SvPOK_on(referent); SV* reference = newRV_noinc(referent); sv_bless(reference, gv_stashpv(classname, FALSE)); return reference; } #endif JavaScript-QuickJS-0.21/easyxs/easyxs_debug.h000644 000766 000024 00000007507 14531654173 021612 0ustar00felipestaff000000 000000 #ifndef EASYXS_DEBUG_H #define EASYXS_DEBUG_H 1 #include "init.h" /* The following is courtesy of Paul Evans: */ #define exs_debug_sv_summary(sv) S_debug_sv_summary(aTHX_ sv) /* ------------------------------------------------------------ */ static inline void S_debug_sv_summary(pTHX_ const SV *sv) { const char *type; if(!sv) { PerlIO_printf(Perl_debug_log, "NULL"); return; } if(sv == &PL_sv_undef) { PerlIO_printf(Perl_debug_log, "SV=undef"); return; } if(sv == &PL_sv_no) { PerlIO_printf(Perl_debug_log, "SV=false"); return; } if(sv == &PL_sv_yes) { PerlIO_printf(Perl_debug_log, "SV=true"); return; } switch(SvTYPE(sv)) { case SVt_NULL: type = "NULL"; break; case SVt_IV: type = "IV"; break; case SVt_NV: type = "NV"; break; case SVt_PV: type = "PV"; break; case SVt_PVIV: type = "PVIV"; break; case SVt_PVNV: type = "PVNV"; break; case SVt_PVGV: type = "PVGV"; break; case SVt_PVAV: type = "PVAV"; break; case SVt_PVHV: type = "PVHV"; break; case SVt_PVCV: type = "PVCV"; break; default: { char buf[16]; snprintf(buf, sizeof(buf), "(%d)", SvTYPE(sv)); type = buf; break; } } if(SvROK(sv)) type = "RV"; PerlIO_printf(Perl_debug_log, "SV{type=%s,refcnt=%" IVdf, type, (IV) SvREFCNT(sv)); if(SvTEMP(sv)) PerlIO_printf(Perl_debug_log, ",TEMP"); if(SvOBJECT(sv)) PerlIO_printf(Perl_debug_log, ",blessed=%s", HvNAME(SvSTASH(sv))); switch(SvTYPE(sv)) { case SVt_PVAV: PerlIO_printf(Perl_debug_log, ",FILL=%d", (int) AvFILL((AV *)sv)); break; default: /* regular scalars */ if(SvROK(sv)) PerlIO_printf(Perl_debug_log, ",ROK"); else { if(SvIOK(sv)) PerlIO_printf(Perl_debug_log, ",IV=%" IVdf, SvIVX(sv)); if(SvUOK(sv)) PerlIO_printf(Perl_debug_log, ",UV=%" UVuf, SvUVX(sv)); if(SvPOK(sv)) { PerlIO_printf(Perl_debug_log, ",PVX=\"%.10s\"", SvPVX((SV *)sv)); if(SvCUR(sv) > 10) PerlIO_printf(Perl_debug_log, "..."); } } break; } PerlIO_printf(Perl_debug_log, "}"); } #ifdef CX_CUR #define exs_debug_showstack(pattern, ...) S_debug_showstack(aTHX_ pattern, ##__VA_ARGS__) static inline void S_debug_showstack(pTHX_ const char *pattern, ...) { SV **sp; va_list ap; va_start(ap, pattern); if (!pattern) pattern = "Stack"; PerlIO_vprintf(Perl_debug_log, pattern, ap); PerlIO_printf(Perl_debug_log, "\n"); va_end(ap); PERL_CONTEXT *cx = CX_CUR(); I32 floor = cx->blk_oldsp; I32 *mark = PL_markstack + cx->blk_oldmarksp + 1; PerlIO_printf(Perl_debug_log, " TOPMARK=%d, floor = %d\n", (int) TOPMARK, (int) floor); PerlIO_printf(Perl_debug_log, " marks (TOPMARK=@%" IVdf "):\n", (IV) (TOPMARK - floor)); for(; mark <= PL_markstack_ptr; mark++) PerlIO_printf(Perl_debug_log, " @%" IVdf "\n", (IV) (*mark - floor)); mark = PL_markstack + cx->blk_oldmarksp + 1; for(sp = PL_stack_base + floor + 1; sp <= PL_stack_sp; sp++) { PerlIO_printf(Perl_debug_log, sp == PL_stack_sp ? "-> " : " "); PerlIO_printf(Perl_debug_log, "%p = ", *sp); S_debug_sv_summary(aTHX_ *sp); while(mark <= PL_markstack_ptr && PL_stack_base + *mark == sp) PerlIO_printf(Perl_debug_log, " [*M]"), mark++; PerlIO_printf(Perl_debug_log, "\n"); } } #endif /* void static inline exs_debug_showmark_stack(pTHX) { PerlIO_printf(Perl_debug_log, "MARK STACK (start=%p; cur=%p, offset=%d):\n", PL_markstack, PL_markstack_ptr, (int) (PL_markstack_ptr - PL_markstack)); I32 *mp = PL_markstack; while (mp != PL_markstack_max) { const char* pattern = (mp == PL_markstack_ptr ? "[%d]" : "%d"); PerlIO_printf(Perl_debug_log, pattern, *mp++); PerlIO_printf(Perl_debug_log, (mp == PL_markstack_max) ? "\n" : ","); } } */ #endif JavaScript-QuickJS-0.21/easyxs/PaxHeader/LICENSE000644 000766 000024 00000002220 14355430321 021707 xustar00felipestaff000000 000000 30 mtime=1672884433.103817312 127 LIBARCHIVE.xattr.com.apple.metadata:kMDItemTextContentLanguage=YnBsaXN0MDBSZW4IAAAAAAAAAQEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAs 108 SCHILY.xattr.com.apple.metadata:kMDItemTextContentLanguage=bplist00Ren 123 LIBARCHIVE.xattr.com.apple.metadata:kMDItemKeyphraseVersion=YnBsaXN0MDAQDAgAAAAAAAABAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACg 104 SCHILY.xattr.com.apple.metadata:kMDItemKeyphraseVersion=bplist00  203 LIBARCHIVE.xattr.com.apple.metadata:kMDItemKeyphraseLabels=YnBsaXN0MDCjAQIDXmZyZWUgb2YgY2hhcmdlXxATZG9jdW1lbnRhdGlvbiBmaWxlc18QEHBlcnNvbiBvYnRhaW5pbmcIDBsxAAAAAAAAAQEAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQ 164 SCHILY.xattr.com.apple.metadata:kMDItemKeyphraseLabels=bplist00^free of charge_documentation files_person obtaining 1D 169 LIBARCHIVE.xattr.com.apple.metadata:kMDItemKeyphraseConfidences=YnBsaXN0MDCjAQIDIz/UL9dPXZagIz/H4igAAAAAIz+D5yAAAAAACAwVHgAAAAAAAAEBAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAn 140 SCHILY.xattr.com.apple.metadata:kMDItemKeyphraseConfidences=bplist00#?/O]#?(#?  ' JavaScript-QuickJS-0.21/easyxs/LICENSE000644 000766 000024 00000002056 14355430321 017745 0ustar00felipestaff000000 000000 MIT License Copyright (c) 2022 Felipe Gasper Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. JavaScript-QuickJS-0.21/easyxs/easyxs_numeric.h000644 000766 000024 00000002654 14355430321 022153 0ustar00felipestaff000000 000000 #ifndef EASYXS_NUMERIC_H #define EASYXS_NUMERIC_H 1 #include "init.h" UV _easyxs_SvUV (pTHX_ SV* sv) { if (!SvOK(sv)) _EASYXS_CROAK_UNDEF("unsigned integer"); if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv); if (SvUOK(sv)) return SvUV(sv); if (SvIOK(sv)) { IV myiv = SvIV(sv); if (myiv >= 0) return myiv; } else { STRLEN pvlen; const char* pv = SvPVbyte(sv, pvlen); UV myuv; int grokked = grok_number(pv, pvlen, &myuv); if (grokked & (IS_NUMBER_IN_UV | !IS_NUMBER_NEG)) { const char* uvstr = form("%" UVuf, myuv); if (strlen(uvstr) == pvlen && strEQ(uvstr, pv)) return myuv; } } croak("`%" SVf "` given where unsigned integer expected!", sv); } #define exs_SvUV(sv) _easyxs_SvUV(aTHX_ sv) UV _easyxs_SvIV (pTHX_ SV* sv) { if (!SvOK(sv)) _EASYXS_CROAK_UNDEF("integer"); if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv); if (SvIOK(sv)) return SvIV(sv); STRLEN pvlen; const char* pv = SvPVbyte(sv, pvlen); IV myiv; int grokked = grok_number(pv, pvlen, (UV*) &myiv); if (!(grokked & IS_NUMBER_NOT_INT) && !(grokked & IS_NUMBER_IN_UV)) { const char* ivstr = form("%" IVdf, myiv); if (strlen(ivstr) == pvlen && strEQ(ivstr, pv)) return myiv; } croak("`%" SVf "` given where integer expected!", sv); } #define exs_SvIV(sv) _easyxs_SvIV(aTHX_ sv) #endif JavaScript-QuickJS-0.21/easyxs/ppport.h000644 000766 000024 00002100721 14355430321 020435 0ustar00felipestaff000000 000000 #if 0 my $void = <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.66 Automatically created by Devel::PPPort running under perl 5.028003. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.66 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list API that isn't supported all the way back --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003_07, and has been tested up to 5.35.9. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagically add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003_07. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be FULLY supported by F, and below which version of Perl they probably won't be available or work. By FULLY, we mean that support isn't provided all the way back to the first version of Perl that F supports at all. =head2 --api-info=I Show portability information for elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. Normally, only API elements are shown, but if there are no matching API elements but there are some other matching elements, those are shown. This allows you to conveniently find when functions internal to the core implementation were added; only people working on the core are likely to find this last part useful. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * Although the purpose of F is to keep you from having to concern yourself with what version you are running under, there may arise instances where you have to do so. These macros, the same ones as in base Perl, are available to you in all versions, and are what you should use: =over 4 =item C(major, minor, patch)> Returns whether or not the perl currently being compiled has the specified relationship I to the perl given by the parameters. I is one of C, C, C, C, C, C. For example, #if PERL_VERSION_GT(5,24,2) code that will only be compiled on perls after v5.24.2 #else fallback code #endif Note that this is usable in making compile-time decisions You may use the special value '*' for the final number to mean ALL possible values for it. Thus, #if PERL_VERSION_EQ(5,31,'*') means all perls in the 5.31 series. And #if PERL_VERSION_NE(5,24,'*') means all perls EXCEPT 5.24 ones. And #if PERL_VERSION_LE(5,9,'*') is effectively #if PERL_VERSION_LT(5,10,0) =back =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- caller_cx() NEED_caller_cx NEED_caller_cx_GLOBAL ck_warner() NEED_ck_warner NEED_ck_warner_GLOBAL ck_warner_d() NEED_ck_warner_d NEED_ck_warner_d_GLOBAL croak_xs_usage() NEED_croak_xs_usage NEED_croak_xs_usage_GLOBAL die_sv() NEED_die_sv NEED_die_sv_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL mess() NEED_mess NEED_mess_GLOBAL mess_nocontext() NEED_mess_nocontext NEED_mess_nocontext_GLOBAL mess_sv() NEED_mess_sv NEED_mess_sv_GLOBAL mg_findext() NEED_mg_findext NEED_mg_findext_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL my_strnlen() NEED_my_strnlen NEED_my_strnlen_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL sv_unmagicext() NEED_sv_unmagicext NEED_sv_unmagicext_GLOBAL utf8_to_uvchr_buf() NEED_utf8_to_uvchr_buf NEED_utf8_to_uvchr_buf_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vmess() NEED_vmess NEED_vmess_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS Some of the suggested edits and/or generated patches may not compile as-is without tweaking manually. This is generally due to the need for an extra parameter to be added to the call to prevent buffer overflow. If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report at L Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2013, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut # These are tools that must be included in ppport.h. It doesn't work if given # a .pl suffix. # # WARNING: Use only constructs that are legal as far back as D:P handles, as # this is run in the perl version being tested. # What revisions are legal, to be output as-is and converted into a pattern # that matches them precisely my $r_pat = "[57]"; sub format_version { # Given an input version that is acceptable to parse_version(), return a # string of the standard representation of it. my($r,$v,$s) = parse_version(shift); if ($r < 5 || ($r == 5 && $v < 6)) { my $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub parse_version { # Returns a triplet, (revision, major, minor) from the input, treated as a # string, which can be in any of several typical formats. my $ver = shift; $ver = "" unless defined $ver; my($r,$v,$s); if ( ($r, $v, $s) = $ver =~ /^([0-9]+)([0-9]{3})([0-9]{3})$/ # 5029010, from the file # names in our # parts/base/ and # parts/todo directories or ($r, $v, $s) = $ver =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/ # 5.25.7 or ($r, $v, $s) = $ver =~ /^([0-9]+)\.([0-9]{3})([0-9]{3})$/ # 5.025008, from the # output of $] or ($r, $v, $s) = $ver =~ /^([0-9]+)\.([0-9]{1,3})()$/ # 5.24, 5.004 or ($r, $v, $s) = $ver =~ /^([0-9]+)\.(00[1-5])_?([0-9]{2})$/ # 5.003_07 ) { $s = 0 unless $s; die "Only Perl $r_pat are supported '$ver'\n" unless $r =~ / ^ $r_pat $ /x; die "Invalid version number: $ver\n" if $v >= 1000 || $s >= 1000; return (0 +$r, 0 + $v, 0 + $s); } # For some safety, don't assume something is a version number if it has a # literal dot as one of the three characters. This will have to be fixed # when we reach x.46 (since 46 is ord('.')) if ($ver !~ /\./ && (($r, $v, $s) = $ver =~ /^(.)(.)(.)$/)) # vstring 5.25.7 { $r = ord $r; $v = ord $v; $s = ord $s; die "Only Perl $r_pat are supported '$ver'\n" unless $r =~ / ^ $r_pat $ /x; return ($r, $v, $s); } my $mesg = ""; $mesg = ". (In 5.00x_yz, x must be 1-5.)" if $ver =~ /_/; die "Invalid version number format: '$ver'$mesg\n"; } sub int_parse_version { # Returns integer 7 digit human-readable version, suitable for use in file # names in parts/todo parts/base. return 0 + join "", map { sprintf("%03d", $_) } parse_version(shift); } sub ivers # Shorter name for int_parse_version { return int_parse_version(shift); } sub format_version_line { # Returns a floating point representation of the input version my $version = int_parse_version(shift); $version =~ s/ ^ ( $r_pat ) \B /$1./x; return $version; } BEGIN { if ("$]" < "5.006" ) { # On early perls, the implicit pass by reference doesn't work, so we have # to use the globals to initialize. eval q[sub dictionary_order($$) { _dictionary_order($a, $b) } ]; } elsif ("$]" < "5.022" ) { eval q[sub dictionary_order($$) { _dictionary_order(@_) } ]; } else { eval q[sub dictionary_order :prototype($$) { _dictionary_order(@_) } ]; } } sub _dictionary_order { # Sort caselessly, ignoring punct my ($valid_a, $valid_b) = @_; my ($lc_a, $lc_b); my ($squeezed_a, $squeezed_b); $valid_a = '' unless defined $valid_a; $valid_b = '' unless defined $valid_b; $lc_a = lc $valid_a; $lc_b = lc $valid_b; $squeezed_a = $lc_a; $squeezed_a =~ s/^_+//g; # No leading underscores $squeezed_a =~ s/\B_+\B//g; # No connecting underscores $squeezed_a =~ s/[\W]//g; # No punct $squeezed_b = $lc_b; $squeezed_b =~ s/^_+//g; $squeezed_b =~ s/\B_+\B//g; $squeezed_b =~ s/[\W]//g; return( $squeezed_a cmp $squeezed_b or $lc_a cmp $lc_b or $valid_a cmp $valid_b); } sub sort_api_lines # Sort lines of the form flags|return|name|args... # by 'name' { $a =~ / ^ [^|]* \| [^|]* \| ( [^|]* ) /x; # 3rd field '|' is sep my $a_name = $1; $b =~ / ^ [^|]* \| [^|]* \| ( [^|]* ) /x; my $b_name = $1; return dictionary_order($a_name, $b_name); } 1; use strict; BEGIN { require warnings if "$]" > '5.006' } # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if "$]" >= "5.009004" && "$]" <= "5.009005"} my $VERSION = 3.66; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; $opt{'compat-version'} = 5.003_07 unless exists $opt{'compat-version'}; $opt{'compat-version'} = int_parse_version($opt{'compat-version'}); my $int_min_perl = int_parse_version(5.003_07); # Each element of this hash looks something like: # 'Poison' => { # 'base' => '5.008000', # 'provided' => 1, # 'todo' => '5.003007' # }, my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( noTHXarg => 1 ) : ()), (index($4, 'c') >= 0 ? ( core_only => 1 ) : ()), (index($4, 'd') >= 0 ? ( deprecated => 1 ) : ()), (index($4, 'i') >= 0 ? ( inaccessible => 1 ) : ()), (index($4, 'x') >= 0 ? ( experimental => 1 ) : ()), (index($4, 'u') >= 0 ? ( undocumented => 1 ) : ()), (index($4, 'o') >= 0 ? ( ppport_fnc => 1 ) : ()), (index($4, 'V') >= 0 ? ( unverified => 1 ) : ()), } ) : die "invalid spec: $_" } qw( ABDAY_1|5.027010||Viu ABDAY_2|5.027010||Viu ABDAY_3|5.027010||Viu ABDAY_4|5.027010||Viu ABDAY_5|5.027010||Viu ABDAY_6|5.027010||Viu ABDAY_7|5.027010||Viu ABMON_10|5.027010||Viu ABMON_11|5.027010||Viu ABMON_12|5.027010||Viu ABMON_1|5.027010||Viu ABMON_2|5.027010||Viu ABMON_3|5.027010||Viu ABMON_4|5.027010||Viu ABMON_5|5.027010||Viu ABMON_6|5.027010||Viu ABMON_7|5.027010||Viu ABMON_8|5.027010||Viu ABMON_9|5.027010||Viu ABORT|5.003007||Viu abort|5.005000||Viu abort_execution|5.025010||Viu accept|5.005000||Viu ACCEPT|5.009005||Viu ACCEPT_t8|5.035004||Viu ACCEPT_t8_p8|5.033003||Viu ACCEPT_t8_pb|5.033003||Viu ACCEPT_tb|5.035004||Viu ACCEPT_tb_p8|5.033003||Viu ACCEPT_tb_pb|5.033003||Viu access|5.005000||Viu add_above_Latin1_folds|5.021001||Viu add_cp_to_invlist|5.013011||Viu add_data|5.005000||Vniu add_multi_match|5.021004||Viu _add_range_to_invlist|5.016000||cViu add_utf16_textfilter|5.011001||Viu adjust_size_and_find_bucket|5.019003||Vniu advance_one_LB|5.023007||Viu advance_one_SB|5.021009||Viu advance_one_WB|5.021009||Viu AHOCORASICK|5.009005||Viu AHOCORASICKC|5.009005||Viu AHOCORASICKC_t8|5.035004||Viu AHOCORASICKC_t8_p8|5.033003||Viu AHOCORASICKC_t8_pb|5.033003||Viu AHOCORASICKC_tb|5.035004||Viu AHOCORASICKC_tb_p8|5.033003||Viu AHOCORASICKC_tb_pb|5.033003||Viu AHOCORASICK_t8|5.035004||Viu AHOCORASICK_t8_p8|5.033003||Viu AHOCORASICK_t8_pb|5.033003||Viu AHOCORASICK_tb|5.035004||Viu AHOCORASICK_tb_p8|5.033003||Viu AHOCORASICK_tb_pb|5.033003||Viu alloccopstash|5.017001|5.017001|x alloc_LOGOP|5.025004||xViu allocmy|5.008001||Viu ALLOC_THREAD_KEY|5.005003||Viu ALT_DIGITS|5.027010||Viu amagic_call|5.003007|5.003007|u amagic_cmp|5.009003||Viu amagic_cmp_desc|5.031011||Viu amagic_cmp_locale|5.009003||Viu amagic_cmp_locale_desc|5.031011||Viu amagic_deref_call|5.013007|5.013007|u amagic_i_ncmp|5.009003||Viu amagic_i_ncmp_desc|5.031011||Viu amagic_is_enabled|5.015008||Viu amagic_ncmp|5.009003||Viu amagic_ncmp_desc|5.031011||Viu AMG_CALLun|5.003007||Viu AMG_CALLunary|5.013009||Viu AMGfallNEVER|5.003007||Viu AMGfallNO|5.003007||Viu AMGfallYES|5.003007||Viu AMGf_assign|5.003007||Viu AMGf_noleft|5.003007||Viu AMGf_noright|5.003007||Viu AMGf_numarg|5.021009||Viu AMGf_numeric|5.013002||Viu AMGf_unary|5.003007||Viu AMGf_want_list|5.017002||Viu AM_STR|5.027010||Viu AMT_AMAGIC|5.004000||Viu AMT_AMAGIC_off|5.004000||Viu AMT_AMAGIC_on|5.004000||Viu AMTf_AMAGIC|5.004000||Viu _aMY_CXT|5.009000|5.009000|p aMY_CXT|5.009000|5.009000|p aMY_CXT_|5.009000|5.009000|p anchored_end_shift|5.009005||Viu anchored_offset|5.005000||Viu anchored_substr|5.005000||Viu anchored_utf8|5.008000||Viu ANGSTROM_SIGN|5.017003||Viu anonymise_cv_maybe|5.013003||Viu any_dup|5.006000||Vu ANYOF|5.003007||Viu ANYOF_ALNUM|5.006000||Viu ANYOF_ALNUML|5.004000||Viu ANYOF_ALPHA|5.006000||Viu ANYOF_ALPHANUMERIC|5.017008||Viu ANYOF_ASCII|5.006000||Viu ANYOF_BIT|5.004005||Viu ANYOF_BITMAP|5.006000||Viu ANYOF_BITMAP_BYTE|5.006000||Viu ANYOF_BITMAP_CLEAR|5.006000||Viu ANYOF_BITMAP_CLEARALL|5.007003||Viu ANYOF_BITMAP_SET|5.006000||Viu ANYOF_BITMAP_SETALL|5.007003||Viu ANYOF_BITMAP_SIZE|5.006000||Viu ANYOF_BITMAP_TEST|5.006000||Viu ANYOF_BITMAP_ZERO|5.006000||Viu ANYOF_BLANK|5.006001||Viu ANYOF_CASED|5.017008||Viu ANYOF_CLASS_OR|5.017007||Viu ANYOF_CLASS_SETALL|5.013011||Viu ANYOF_CLASS_TEST_ANY_SET|5.013008||Viu ANYOF_CNTRL|5.006000||Viu ANYOF_COMMON_FLAGS|5.019008||Viu ANYOFD|5.023003||Viu ANYOF_DIGIT|5.006000||Viu ANYOFD_t8|5.035004||Viu ANYOFD_t8_p8|5.033003||Viu ANYOFD_t8_pb|5.033003||Viu ANYOFD_tb|5.035004||Viu ANYOFD_tb_p8|5.033003||Viu ANYOFD_tb_pb|5.033003||Viu ANYOF_FLAGS|5.006000||Viu ANYOF_FLAGS_ALL|5.006000||Viu ANYOF_GRAPH|5.006000||Viu ANYOFH|5.029007||Viu ANYOFHb|5.031001||Viu ANYOFHb_t8|5.035004||Viu ANYOFHb_t8_p8|5.033003||Viu ANYOFHb_t8_pb|5.033003||Viu ANYOFHb_tb|5.035004||Viu ANYOFHb_tb_p8|5.033003||Viu ANYOFHb_tb_pb|5.033003||Viu ANYOF_HORIZWS|5.009005||Viu ANYOFHr|5.031002||Viu ANYOFHr_t8|5.035004||Viu ANYOFHr_t8_p8|5.033003||Viu ANYOFHr_t8_pb|5.033003||Viu ANYOFHr_tb|5.035004||Viu ANYOFHr_tb_p8|5.033003||Viu ANYOFHr_tb_pb|5.033003||Viu ANYOFHs|5.031007||Viu ANYOFHs_t8|5.035004||Viu ANYOFHs_t8_p8|5.033003||Viu ANYOFHs_t8_pb|5.033003||Viu ANYOFHs_tb|5.035004||Viu ANYOFHs_tb_p8|5.033003||Viu ANYOFHs_tb_pb|5.033003||Viu ANYOFH_t8|5.035004||Viu ANYOFH_t8_p8|5.033003||Viu ANYOFH_t8_pb|5.033003||Viu ANYOFH_tb|5.035004||Viu ANYOFH_tb_p8|5.033003||Viu ANYOFH_tb_pb|5.033003||Viu ANYOF_INVERT|5.004000||Viu ANYOFL|5.021008||Viu ANYOFL_FOLD|5.023007||Viu ANYOF_LOCALE_FLAGS|5.019005||Viu ANYOF_LOWER|5.006000||Viu ANYOFL_SHARED_UTF8_LOCALE_fold_HAS_MATCHES_nonfold_REQD|5.023007||Viu ANYOFL_SOME_FOLDS_ONLY_IN_UTF8_LOCALE|5.023007||Viu ANYOFL_t8|5.035004||Viu ANYOFL_t8_p8|5.033003||Viu ANYOFL_t8_pb|5.033003||Viu ANYOFL_tb|5.035004||Viu ANYOFL_tb_p8|5.033003||Viu ANYOFL_tb_pb|5.033003||Viu ANYOFL_UTF8_LOCALE_REQD|5.023007||Viu ANYOFM|5.027009||Viu ANYOF_MATCHES_ALL_ABOVE_BITMAP|5.021004||Viu ANYOF_MATCHES_POSIXL|5.021004||Viu ANYOF_MAX|5.006000||Viu ANYOFM_t8|5.035004||Viu ANYOFM_t8_p8|5.033003||Viu ANYOFM_t8_pb|5.033003||Viu ANYOFM_tb|5.035004||Viu ANYOFM_tb_p8|5.033003||Viu ANYOFM_tb_pb|5.033003||Viu ANYOF_NALNUM|5.006000||Viu ANYOF_NALNUML|5.004000||Viu ANYOF_NALPHA|5.006000||Viu ANYOF_NALPHANUMERIC|5.017008||Viu ANYOF_NASCII|5.006000||Viu ANYOF_NBLANK|5.006001||Viu ANYOF_NCASED|5.017008||Viu ANYOF_NCNTRL|5.006000||Viu ANYOF_NDIGIT|5.006000||Viu ANYOF_NGRAPH|5.006000||Viu ANYOF_NHORIZWS|5.009005||Viu ANYOF_NLOWER|5.006000||Viu ANYOF_NPRINT|5.006000||Viu ANYOF_NPUNCT|5.006000||Viu ANYOF_NSPACE|5.006000||Viu ANYOF_NSPACEL|5.004000||Viu ANYOF_NUPPER|5.006000||Viu ANYOF_NVERTWS|5.009005||Viu ANYOF_NWORDCHAR|5.017005||Viu ANYOF_NXDIGIT|5.006000||Viu ANYOF_ONLY_HAS_BITMAP|5.021004||Viu ANYOFPOSIXL|5.029004||Viu ANYOF_POSIXL_AND|5.019005||Viu ANYOF_POSIXL_BITMAP|5.035003||Viu ANYOF_POSIXL_CLEAR|5.019005||Viu ANYOF_POSIXL_MAX|5.019005||Viu ANYOF_POSIXL_OR|5.019005||Viu ANYOF_POSIXL_SET|5.019005||Viu ANYOF_POSIXL_SETALL|5.019005||Viu ANYOF_POSIXL_SET_TO_BITMAP|5.029004||Viu ANYOF_POSIXL_SSC_TEST_ALL_SET|5.019009||Viu ANYOF_POSIXL_SSC_TEST_ANY_SET|5.019009||Viu ANYOFPOSIXL_t8|5.035004||Viu ANYOFPOSIXL_t8_p8|5.033003||Viu ANYOFPOSIXL_t8_pb|5.033003||Viu ANYOFPOSIXL_tb|5.035004||Viu ANYOFPOSIXL_tb_p8|5.033003||Viu ANYOFPOSIXL_tb_pb|5.033003||Viu ANYOF_POSIXL_TEST|5.019005||Viu ANYOF_POSIXL_TEST_ALL_SET|5.019005||Viu ANYOF_POSIXL_TEST_ANY_SET|5.019005||Viu ANYOF_POSIXL_ZERO|5.019005||Viu ANYOF_PRINT|5.006000||Viu ANYOF_PUNCT|5.006000||Viu ANYOFR|5.031007||Viu ANYOFRb|5.031007||Viu ANYOFRbase|5.031007||Viu ANYOFR_BASE_BITS|5.031007||Viu ANYOFRb_t8|5.035004||Viu ANYOFRb_t8_p8|5.033003||Viu ANYOFRb_t8_pb|5.033003||Viu ANYOFRb_tb|5.035004||Viu ANYOFRb_tb_p8|5.033003||Viu ANYOFRb_tb_pb|5.033003||Viu ANYOFRdelta|5.031007||Viu ANYOFR_t8|5.035004||Viu ANYOFR_t8_p8|5.033003||Viu ANYOFR_t8_pb|5.033003||Viu ANYOFR_tb|5.035004||Viu ANYOFR_tb_p8|5.033003||Viu ANYOFR_tb_pb|5.033003||Viu ANYOF_SHARED_d_MATCHES_ALL_NON_UTF8_NON_ASCII_non_d_WARN_SUPER|5.023003||Viu ANYOF_SHARED_d_UPPER_LATIN1_UTF8_STRING_MATCHES_non_d_RUNTIME_USER_PROP|5.023006||Viu ANYOF_SPACE|5.006000||Viu ANYOF_SPACEL|5.004000||Viu ANYOF_t8|5.035004||Viu ANYOF_t8_p8|5.033003||Viu ANYOF_t8_pb|5.033003||Viu ANYOF_tb|5.035004||Viu ANYOF_tb_p8|5.033003||Viu ANYOF_tb_pb|5.033003||Viu ANYOF_UNIPROP|5.017006||Viu ANYOF_UPPER|5.006000||Viu ANYOF_VERTWS|5.009005||Viu ANYOF_WORDCHAR|5.017005||Viu ANYOF_XDIGIT|5.006000||Viu ao|5.005000||Viu _append_range_to_invlist|5.013010||Viu append_utf8_from_native_byte|5.019004||cVniu apply|5.003007||Viu apply_attrs|5.006000||Viu apply_attrs_my|5.007003||Viu apply_attrs_string|5.006001|5.006001|xu ARCHLIB|5.003007|5.003007|Vn ARCHLIB_EXP|5.003007|5.003007|Vn ARCHNAME|5.004000|5.004000|Vn ARG1|5.003007||Viu ARG1_LOC|5.005000||Viu ARG1_SET|5.005000||Viu ARG2|5.003007||Viu ARG2L|5.009005||Viu ARG2L_LOC|5.009005||Viu ARG2_LOC|5.005000||Viu ARG2L_SET|5.009005||Viu ARG2_SET|5.005000||Viu ARG|5.005000||Viu ARG_LOC|5.005000||Viu ARGp|5.031010||Viu ARGp_LOC|5.031010||Viu ARGp_SET|5.031010||Viu ARG__SET|5.005000||Viu ARG_SET|5.005000||Viu ARGTARG|5.003007||Viu ARG_VALUE|5.005000||Viu argvout_final|5.029006||Viu ASCIIish|5.005003||Viu ASCII_MORE_RESTRICT_PAT_MODS|5.013010||Viu ASCII_PLATFORM_UTF8_MAXBYTES|5.035004||Viu ASCII_RESTRICT_PAT_MOD|5.013009||Viu ASCII_RESTRICT_PAT_MODS|5.013009||Viu ASCII_TO_NATIVE|5.007001||Viu ASCII_TO_NEED|5.019004||dcVnu asctime|5.009000||Viu ASCTIME_R_PROTO|5.008000|5.008000|Vn assert|5.003007||Viu __ASSERT_|5.019007|5.008008|p ASSERT_CURPAD_ACTIVE|5.008001||Viu ASSERT_CURPAD_LEGAL|5.008001||Viu assert_not_glob|5.009004||Viu ASSERT_NOT_PTR|5.035004||Viu assert_not_ROK|5.008001||Viu assert_uft8_cache_coherent|5.013003||Viu assignment_type|5.021005||Viu ASSUME|5.019006|5.003007|p atfork_lock|5.007003|5.007003|nu atfork_unlock|5.007003|5.007003|nu aTHX|5.006000|5.003007|p aTHX_|5.006000|5.003007|p aTHXa|5.017006||Viu aTHXo|5.006000||Viu aTHXR||5.003007|ponu aTHXR_||5.003007|ponu aTHXx|5.006000||Viu Atof|5.006000||Viu Atol|5.006000||Viu atoll|5.008000||Viu Atoul|5.006000||Viu AvALLOC|5.003007||Viu AvARRAY|5.003007|5.003007| AvARYLEN|5.003007||Viu av_arylen_p|||cu av_clear|5.003007|5.003007| av_count|5.033001|5.003007|p av_create_and_push||| av_create_and_unshift_one||| av_delete|5.006000|5.006000| av_exists|5.006000|5.006000| av_extend|5.003007|5.003007| av_extend_guts|5.017004||Viu av_fetch|5.003007|5.003007| av_fetch_simple|5.035002||cV av_fill|5.003007|5.003007| AvFILL|5.003007|5.003007| AvFILLp|5.004005||pcV av_iter_p|||cu av_len|5.003007|5.003007| av_make|5.003007|5.003007| AvMAX|5.003007||Viu av_new_alloc|5.035001|5.035001| av_nonelem|5.027009||Viu av_pop|5.003007|5.003007| av_push|5.003007|5.003007| AvREAL|5.003007||Viu AvREALISH|5.003007||Viu AvREAL_off|5.003007||Viu AvREAL_on|5.003007||Viu AvREAL_only|5.009003||Viu AvREIFY|5.003007||Viu av_reify|5.004004||cViu AvREIFY_off|5.003007||Viu AvREIFY_on|5.003007||Viu AvREIFY_only|5.009003||Viu av_shift|5.003007|5.003007| av_store|5.003007|5.003007| av_store_simple|5.035002||cV av_tindex|5.017009|5.003007|p av_tindex_skip_len_mg|5.025010||Viu av_top_index|5.017009|5.003007|p av_top_index_skip_len_mg|5.025010||Viu av_undef|5.003007|5.003007| av_unshift|5.003007|5.003007| ax|5.003007|5.003007| backup_one_GCB|5.025003||Viu backup_one_LB|5.023007||Viu backup_one_SB|5.021009||Viu backup_one_WB|5.021009||Viu bad_type_gv|5.019002||Viu bad_type_pv|5.016000||Viu BADVERSION|5.011004||Viu BASEOP|5.003007||Viu BhkDISABLE|5.013003||xV BhkENABLE|5.013003||xV BhkENTRY|5.013003||xVi BhkENTRY_set|5.013003||xV BHKf_bhk_eval|5.013006||Viu BHKf_bhk_post_end|5.013006||Viu BHKf_bhk_pre_end|5.013006||Viu BHKf_bhk_start|5.013006||Viu BhkFLAGS|5.013003||xVi BIN|5.003007|5.003007|Vn bind|5.005000||Viu bind_match|5.003007||Viu BIN_EXP|5.004000|5.004000|Vn BIT_BUCKET|5.003007||Viu BIT_DIGITS|5.004000||Viu BITMAP_BYTE|5.009005||Viu BITMAP_TEST|5.009005||Viu blk_eval|5.003007||Viu blk_format|5.011000||Viu blk_gimme|5.003007||Viu blk_givwhen|5.027008||Viu blk_loop|5.003007||Viu blk_oldcop|5.003007||Viu blk_oldmarksp|5.003007||Viu blk_oldpm|5.003007||Viu blk_oldsaveix|5.023008||Viu blk_oldscopesp|5.003007||Viu blk_oldsp|5.003007||Viu blk_old_tmpsfloor|5.023008||Viu blk_sub|5.003007||Viu blk_u16|5.011000||Viu block_end|5.021006|5.021006| block_gimme|5.004000|5.004000|u blockhook_register|||x block_start|5.021006|5.021006| BmFLAGS|5.009005||Viu BmPREVIOUS|5.003007||Viu BmRARE|5.003007||Viu BmUSEFUL|5.003007||Viu BOL|5.003007||Viu BOL_t8|5.035004||Viu BOL_t8_p8|5.033003||Viu BOL_t8_pb|5.033003||Viu BOL_tb|5.035004||Viu BOL_tb_p8|5.033003||Viu BOL_tb_pb|5.033003||Viu BOM_UTF8|5.025005|5.003007|p BOM_UTF8_FIRST_BYTE|5.019004||Viu BOM_UTF8_TAIL|5.019004||Viu boolSV|5.004000|5.003007|p boot_core_builtin|5.035007||Viu boot_core_mro|5.009005||Viu boot_core_PerlIO|5.007002||Viu boot_core_UNIVERSAL|5.003007||Viu BOUND|5.003007||Viu BOUNDA|5.013009||Viu BOUNDA_t8|5.035004||Viu BOUNDA_t8_p8|5.033003||Viu BOUNDA_t8_pb|5.033003||Viu BOUNDA_tb|5.035004||Viu BOUNDA_tb_p8|5.033003||Viu BOUNDA_tb_pb|5.033003||Viu BOUNDL|5.004000||Viu BOUNDL_t8|5.035004||Viu BOUNDL_t8_p8|5.033003||Viu BOUNDL_t8_pb|5.033003||Viu BOUNDL_tb|5.035004||Viu BOUNDL_tb_p8|5.033003||Viu BOUNDL_tb_pb|5.033003||Viu BOUND_t8|5.035004||Viu BOUND_t8_p8|5.033003||Viu BOUND_t8_pb|5.033003||Viu BOUND_tb|5.035004||Viu BOUND_tb_p8|5.033003||Viu BOUND_tb_pb|5.033003||Viu BOUNDU|5.013009||Viu BOUNDU_t8|5.035004||Viu BOUNDU_t8_p8|5.033003||Viu BOUNDU_t8_pb|5.033003||Viu BOUNDU_tb|5.035004||Viu BOUNDU_tb_p8|5.033003||Viu BOUNDU_tb_pb|5.033003||Viu BRANCH|5.003007||Viu BRANCHJ|5.005000||Viu BRANCHJ_t8|5.035004||Viu BRANCHJ_t8_p8|5.033003||Viu BRANCHJ_t8_pb|5.033003||Viu BRANCHJ_tb|5.035004||Viu BRANCHJ_tb_p8|5.033003||Viu BRANCHJ_tb_pb|5.033003||Viu BRANCH_next|5.009005||Viu BRANCH_next_fail|5.009005||Viu BRANCH_next_fail_t8|5.035004||Viu BRANCH_next_fail_t8_p8|5.033003||Viu BRANCH_next_fail_t8_pb|5.033003||Viu BRANCH_next_fail_tb|5.035004||Viu BRANCH_next_fail_tb_p8|5.033003||Viu BRANCH_next_fail_tb_pb|5.033003||Viu BRANCH_next_t8|5.035004||Viu BRANCH_next_t8_p8|5.033003||Viu BRANCH_next_t8_pb|5.033003||Viu BRANCH_next_tb|5.035004||Viu BRANCH_next_tb_p8|5.033003||Viu BRANCH_next_tb_pb|5.033003||Viu BRANCH_t8|5.035004||Viu BRANCH_t8_p8|5.033003||Viu BRANCH_t8_pb|5.033003||Viu BRANCH_tb|5.035004||Viu BRANCH_tb_p8|5.033003||Viu BRANCH_tb_pb|5.033003||Viu BSD_GETPGRP|5.003007||Viu BSDish|5.008001||Viu BSD_SETPGRP|5.003007||Viu BUFSIZ|5.003007||Viu _byte_dump_string|5.025006||cViu BYTEORDER|5.003007|5.003007|Vn bytes_cmp_utf8|5.013007|5.013007| bytes_from_utf8|5.007001|5.007001|x bytes_from_utf8_loc|5.027001||xcVn bytes_to_utf8|5.006001|5.006001|x call_argv|5.006000|5.003007|p call_atexit|5.006000|5.006000|u CALL_BLOCK_HOOKS|5.013003||xVi CALL_CHECKER_REQUIRE_GV|5.021004|5.021004| caller_cx|5.013005|5.006000|p CALL_FPTR|5.006000||Viu call_list|5.004000|5.004000|u call_method|5.006000|5.003007|p calloc|5.029005||Vn call_pv|5.006000|5.003007|p CALLREGCOMP|5.005000||Viu CALLREGCOMP_ENG|5.009005||Viu CALLREGDUPE|5.009005||Viu CALLREGDUPE_PVT|5.009005||Viu CALLREGEXEC|5.005000||Viu CALLREGFREE|5.006000||Viu CALLREGFREE_PVT|5.009005||Viu CALLREG_INTUIT_START|5.006000||Viu CALLREG_INTUIT_STRING|5.006000||Viu CALLREG_NAMED_BUFF_ALL|5.009005||Viu CALLREG_NAMED_BUFF_CLEAR|5.009005||Viu CALLREG_NAMED_BUFF_COUNT|5.009005||Viu CALLREG_NAMED_BUFF_DELETE|5.009005||Viu CALLREG_NAMED_BUFF_EXISTS|5.009005||Viu CALLREG_NAMED_BUFF_FETCH|5.009005||Viu CALLREG_NAMED_BUFF_FIRSTKEY|5.009005||Viu CALLREG_NAMED_BUFF_NEXTKEY|5.009005||Viu CALLREG_NAMED_BUFF_SCALAR|5.009005||Viu CALLREG_NAMED_BUFF_STORE|5.009005||Viu CALLREG_NUMBUF_FETCH|5.009005||Viu CALLREG_NUMBUF_LENGTH|5.009005||Viu CALLREG_NUMBUF_STORE|5.009005||Viu CALLREG_PACKAGE|5.009005||Viu CALLRUNOPS|5.005000||Viu call_sv|5.006000|5.003007|p CAN64BITHASH|5.027001||Viu CAN_COW_FLAGS|5.009000||Viu CAN_COW_MASK|5.009000||Viu cando|5.003007||Viu CAN_PROTOTYPE|5.003007||Viu C_ARRAY_END|5.013002|5.003007|p C_ARRAY_LENGTH|5.008001|5.003007|p case_100_SBOX32|5.027001||Viu case_101_SBOX32|5.027001||Viu case_102_SBOX32|5.027001||Viu case_103_SBOX32|5.027001||Viu case_104_SBOX32|5.027001||Viu case_105_SBOX32|5.027001||Viu case_106_SBOX32|5.027001||Viu case_107_SBOX32|5.027001||Viu case_108_SBOX32|5.027001||Viu case_109_SBOX32|5.027001||Viu case_10_SBOX32|5.027001||Viu case_110_SBOX32|5.027001||Viu case_111_SBOX32|5.027001||Viu case_112_SBOX32|5.027001||Viu case_113_SBOX32|5.027001||Viu case_114_SBOX32|5.027001||Viu case_115_SBOX32|5.027001||Viu case_116_SBOX32|5.027001||Viu case_117_SBOX32|5.027001||Viu case_118_SBOX32|5.027001||Viu case_119_SBOX32|5.027001||Viu case_11_SBOX32|5.027001||Viu case_120_SBOX32|5.027001||Viu case_121_SBOX32|5.027001||Viu case_122_SBOX32|5.027001||Viu case_123_SBOX32|5.027001||Viu case_124_SBOX32|5.027001||Viu case_125_SBOX32|5.027001||Viu case_126_SBOX32|5.027001||Viu case_127_SBOX32|5.027001||Viu case_128_SBOX32|5.027001||Viu case_129_SBOX32|5.027001||Viu case_12_SBOX32|5.027001||Viu case_130_SBOX32|5.027001||Viu case_131_SBOX32|5.027001||Viu case_132_SBOX32|5.027001||Viu case_133_SBOX32|5.027001||Viu case_134_SBOX32|5.027001||Viu case_135_SBOX32|5.027001||Viu case_136_SBOX32|5.027001||Viu case_137_SBOX32|5.027001||Viu case_138_SBOX32|5.027001||Viu case_139_SBOX32|5.027001||Viu case_13_SBOX32|5.027001||Viu case_140_SBOX32|5.027001||Viu case_141_SBOX32|5.027001||Viu case_142_SBOX32|5.027001||Viu case_143_SBOX32|5.027001||Viu case_144_SBOX32|5.027001||Viu case_145_SBOX32|5.027001||Viu case_146_SBOX32|5.027001||Viu case_147_SBOX32|5.027001||Viu case_148_SBOX32|5.027001||Viu case_149_SBOX32|5.027001||Viu case_14_SBOX32|5.027001||Viu case_150_SBOX32|5.027001||Viu case_151_SBOX32|5.027001||Viu case_152_SBOX32|5.027001||Viu case_153_SBOX32|5.027001||Viu case_154_SBOX32|5.027001||Viu case_155_SBOX32|5.027001||Viu case_156_SBOX32|5.027001||Viu case_157_SBOX32|5.027001||Viu case_158_SBOX32|5.027001||Viu case_159_SBOX32|5.027001||Viu case_15_SBOX32|5.027001||Viu case_160_SBOX32|5.027001||Viu case_161_SBOX32|5.027001||Viu case_162_SBOX32|5.027001||Viu case_163_SBOX32|5.027001||Viu case_164_SBOX32|5.027001||Viu case_165_SBOX32|5.027001||Viu case_166_SBOX32|5.027001||Viu case_167_SBOX32|5.027001||Viu case_168_SBOX32|5.027001||Viu case_169_SBOX32|5.027001||Viu case_16_SBOX32|5.027001||Viu case_170_SBOX32|5.027001||Viu case_171_SBOX32|5.027001||Viu case_172_SBOX32|5.027001||Viu case_173_SBOX32|5.027001||Viu case_174_SBOX32|5.027001||Viu case_175_SBOX32|5.027001||Viu case_176_SBOX32|5.027001||Viu case_177_SBOX32|5.027001||Viu case_178_SBOX32|5.027001||Viu case_179_SBOX32|5.027001||Viu case_17_SBOX32|5.027001||Viu case_180_SBOX32|5.027001||Viu case_181_SBOX32|5.027001||Viu case_182_SBOX32|5.027001||Viu case_183_SBOX32|5.027001||Viu case_184_SBOX32|5.027001||Viu case_185_SBOX32|5.027001||Viu case_186_SBOX32|5.027001||Viu case_187_SBOX32|5.027001||Viu case_188_SBOX32|5.027001||Viu case_189_SBOX32|5.027001||Viu case_18_SBOX32|5.027001||Viu case_190_SBOX32|5.027001||Viu case_191_SBOX32|5.027001||Viu case_192_SBOX32|5.027001||Viu case_193_SBOX32|5.027001||Viu case_194_SBOX32|5.027001||Viu case_195_SBOX32|5.027001||Viu case_196_SBOX32|5.027001||Viu case_197_SBOX32|5.027001||Viu case_198_SBOX32|5.027001||Viu case_199_SBOX32|5.027001||Viu case_19_SBOX32|5.027001||Viu case_1_SBOX32|5.027001||Viu case_200_SBOX32|5.027001||Viu case_201_SBOX32|5.027001||Viu case_202_SBOX32|5.027001||Viu case_203_SBOX32|5.027001||Viu case_204_SBOX32|5.027001||Viu case_205_SBOX32|5.027001||Viu case_206_SBOX32|5.027001||Viu case_207_SBOX32|5.027001||Viu case_208_SBOX32|5.027001||Viu case_209_SBOX32|5.027001||Viu case_20_SBOX32|5.027001||Viu case_210_SBOX32|5.027001||Viu case_211_SBOX32|5.027001||Viu case_212_SBOX32|5.027001||Viu case_213_SBOX32|5.027001||Viu case_214_SBOX32|5.027001||Viu case_215_SBOX32|5.027001||Viu case_216_SBOX32|5.027001||Viu case_217_SBOX32|5.027001||Viu case_218_SBOX32|5.027001||Viu case_219_SBOX32|5.027001||Viu case_21_SBOX32|5.027001||Viu case_220_SBOX32|5.027001||Viu case_221_SBOX32|5.027001||Viu case_222_SBOX32|5.027001||Viu case_223_SBOX32|5.027001||Viu case_224_SBOX32|5.027001||Viu case_225_SBOX32|5.027001||Viu case_226_SBOX32|5.027001||Viu case_227_SBOX32|5.027001||Viu case_228_SBOX32|5.027001||Viu case_229_SBOX32|5.027001||Viu case_22_SBOX32|5.027001||Viu case_230_SBOX32|5.027001||Viu case_231_SBOX32|5.027001||Viu case_232_SBOX32|5.027001||Viu case_233_SBOX32|5.027001||Viu case_234_SBOX32|5.027001||Viu case_235_SBOX32|5.027001||Viu case_236_SBOX32|5.027001||Viu case_237_SBOX32|5.027001||Viu case_238_SBOX32|5.027001||Viu case_239_SBOX32|5.027001||Viu case_23_SBOX32|5.027001||Viu case_240_SBOX32|5.027001||Viu case_241_SBOX32|5.027001||Viu case_242_SBOX32|5.027001||Viu case_243_SBOX32|5.027001||Viu case_244_SBOX32|5.027001||Viu case_245_SBOX32|5.027001||Viu case_246_SBOX32|5.027001||Viu case_247_SBOX32|5.027001||Viu case_248_SBOX32|5.027001||Viu case_249_SBOX32|5.027001||Viu case_24_SBOX32|5.027001||Viu case_250_SBOX32|5.027001||Viu case_251_SBOX32|5.027001||Viu case_252_SBOX32|5.027001||Viu case_253_SBOX32|5.027001||Viu case_254_SBOX32|5.027001||Viu case_255_SBOX32|5.027001||Viu case_256_SBOX32|5.027001||Viu case_25_SBOX32|5.027001||Viu case_26_SBOX32|5.027001||Viu case_27_SBOX32|5.027001||Viu case_28_SBOX32|5.027001||Viu case_29_SBOX32|5.027001||Viu case_2_SBOX32|5.027001||Viu case_30_SBOX32|5.027001||Viu case_31_SBOX32|5.027001||Viu case_32_SBOX32|5.027001||Viu case_33_SBOX32|5.027001||Viu case_34_SBOX32|5.027001||Viu case_35_SBOX32|5.027001||Viu case_36_SBOX32|5.027001||Viu case_37_SBOX32|5.027001||Viu case_38_SBOX32|5.027001||Viu case_39_SBOX32|5.027001||Viu case_3_SBOX32|5.027001||Viu case_40_SBOX32|5.027001||Viu case_41_SBOX32|5.027001||Viu case_42_SBOX32|5.027001||Viu case_43_SBOX32|5.027001||Viu case_44_SBOX32|5.027001||Viu case_45_SBOX32|5.027001||Viu case_46_SBOX32|5.027001||Viu case_47_SBOX32|5.027001||Viu case_48_SBOX32|5.027001||Viu case_49_SBOX32|5.027001||Viu case_4_SBOX32|5.027001||Viu case_50_SBOX32|5.027001||Viu case_51_SBOX32|5.027001||Viu case_52_SBOX32|5.027001||Viu case_53_SBOX32|5.027001||Viu case_54_SBOX32|5.027001||Viu case_55_SBOX32|5.027001||Viu case_56_SBOX32|5.027001||Viu case_57_SBOX32|5.027001||Viu case_58_SBOX32|5.027001||Viu case_59_SBOX32|5.027001||Viu case_5_SBOX32|5.027001||Viu case_60_SBOX32|5.027001||Viu case_61_SBOX32|5.027001||Viu case_62_SBOX32|5.027001||Viu case_63_SBOX32|5.027001||Viu case_64_SBOX32|5.027001||Viu case_65_SBOX32|5.027001||Viu case_66_SBOX32|5.027001||Viu case_67_SBOX32|5.027001||Viu case_68_SBOX32|5.027001||Viu case_69_SBOX32|5.027001||Viu case_6_SBOX32|5.027001||Viu case_70_SBOX32|5.027001||Viu case_71_SBOX32|5.027001||Viu case_72_SBOX32|5.027001||Viu case_73_SBOX32|5.027001||Viu case_74_SBOX32|5.027001||Viu case_75_SBOX32|5.027001||Viu case_76_SBOX32|5.027001||Viu case_77_SBOX32|5.027001||Viu case_78_SBOX32|5.027001||Viu case_79_SBOX32|5.027001||Viu case_7_SBOX32|5.027001||Viu case_80_SBOX32|5.027001||Viu case_81_SBOX32|5.027001||Viu case_82_SBOX32|5.027001||Viu case_83_SBOX32|5.027001||Viu case_84_SBOX32|5.027001||Viu case_85_SBOX32|5.027001||Viu case_86_SBOX32|5.027001||Viu case_87_SBOX32|5.027001||Viu case_88_SBOX32|5.027001||Viu case_89_SBOX32|5.027001||Viu case_8_SBOX32|5.027001||Viu case_90_SBOX32|5.027001||Viu case_91_SBOX32|5.027001||Viu case_92_SBOX32|5.027001||Viu case_93_SBOX32|5.027001||Viu case_94_SBOX32|5.027001||Viu case_95_SBOX32|5.027001||Viu case_96_SBOX32|5.027001||Viu case_97_SBOX32|5.027001||Viu case_98_SBOX32|5.027001||Viu case_99_SBOX32|5.027001||Viu case_9_SBOX32|5.027001||Viu CASE_STD_PMMOD_FLAGS_PARSE_SET|5.009005||Viu CASTFLAGS|5.003007|5.003007|Vn cast_i32|5.006000||cVnu cast_iv|5.006000||cVnu CASTNEGFLOAT|5.003007|5.003007|Vn cast_ulong|5.003007||cVnu cast_uv|5.006000||cVnu CAT2|5.003007|5.003007|Vn CATCH_GET|5.004000||Viu CATCH_SET|5.004000||Viu category_name|5.027008||Vniu cBINOP|5.003007||Viu cBINOPo|5.004005||Viu cBINOPx|5.006000||Viu cBOOL|5.013000|5.003007|p cCOP|5.003007||Viu cCOPo|5.004005||Viu cCOPx|5.006000||Viu C_FAC_POSIX|5.009003||Viu cGVOP_gv|5.006000||Viu cGVOPo_gv|5.006000||Viu cGVOPx_gv|5.006000||Viu change_engine_size|5.029004||Viu CHANGE_MULTICALL_FLAGS|5.018000||Viu CHARBITS|5.011002|5.011002|Vn CHARSET_PAT_MODS|5.013010||Viu chdir|5.005000||Viu checkcomma|5.003007||Viu check_end_shift|5.009005||Viu check_locale_boundary_crossing|5.015006||Viu CHECK_MALLOC_TAINT|5.008001||Viu CHECK_MALLOC_TOO_LATE_FOR|5.008001||Viu check_offset_max|5.005000||Viu check_offset_min|5.005000||Viu check_substr|5.005000||Viu check_type_and_open|5.009003||Viu check_uni|5.003007||Viu check_utf8|5.008000||Viu check_utf8_print|5.013009||Viu child_offset_bits|5.009003||Viu chmod|5.005000||Viu chsize|5.005000||Viu ckDEAD|5.006000||Viu ck_entersub_args_core|||iu ck_entersub_args_list|5.013006|5.013006| ck_entersub_args_proto|5.013006|5.013006| ck_entersub_args_proto_or_list|5.013006|5.013006| ckWARN2|5.006000|5.003007|p ckWARN2_d|5.006000|5.003007|p ckWARN3|5.007003|5.003007|p ckWARN3_d|5.007003|5.003007|p ckWARN4|5.007003|5.003007|p ckWARN4_d|5.007003|5.003007|p ckWARN|5.006000|5.003007|p ckwarn_common|5.011001||Viu ckwarn|||cu ckWARN_d|5.006000|5.003007|p ckwarn_d|||cu ck_warner|5.011001||pvV ck_warner_d|5.011001||pvV CLANG_DIAG_IGNORE|5.023006||Viu CLANG_DIAG_IGNORE_DECL|5.027007||Viu CLANG_DIAG_IGNORE_STMT|5.027007||Viu CLANG_DIAG_PRAGMA|5.023006||Viu CLANG_DIAG_RESTORE|5.023006||Viu CLANG_DIAG_RESTORE_DECL|5.027007||Viu CLANG_DIAG_RESTORE_STMT|5.027007||Viu CLASS||5.003007| CLEAR_ARGARRAY|5.006000||Viu clear_defarray|5.023008|5.023008|u clearerr|5.003007||Viu CLEAR_ERRSV|5.025007|5.025007| CLEARFEATUREBITS|5.031006||Viu clear_placeholders|5.009004||xViu clear_special_blocks|5.021003||Viu cLISTOP|5.003007||Viu cLISTOPo|5.004005||Viu cLISTOPx|5.006000||Viu cLOGOP|5.003007||Viu cLOGOPo|5.004005||Viu cLOGOPx|5.006000||Viu CLONEf_CLONE_HOST|5.007002||Viu CLONEf_COPY_STACKS|5.007001||Viu CLONEf_JOIN_IN|5.008001||Viu CLONEf_KEEP_PTR_TABLE|5.007001||Viu clone_params_del|||nu clone_params_new|||nu cLOOP|5.003007||Viu cLOOPo|5.004005||Viu cLOOPx|5.006000||Viu CLOSE|5.003007||Viu close|5.005000||Viu closedir|5.005000||Viu closest_cop|5.007002||Viu CLOSE_t8|5.035004||Viu CLOSE_t8_p8|5.033003||Viu CLOSE_t8_pb|5.033003||Viu CLOSE_tb|5.035004||Viu CLOSE_tb_p8|5.033003||Viu CLOSE_tb_pb|5.033003||Viu CLUMP_2IV|5.006000||Viu CLUMP_2UV|5.006000||Viu CLUMP|5.006000||Viu CLUMP_t8|5.035004||Viu CLUMP_t8_p8|5.033003||Viu CLUMP_t8_pb|5.033003||Viu CLUMP_tb|5.035004||Viu CLUMP_tb_p8|5.033003||Viu CLUMP_tb_pb|5.033003||Viu cMETHOPx|5.021005||Viu cMETHOPx_meth|5.021005||Viu cMETHOPx_rclass|5.021007||Viu cmpchain_extend|5.031011||Viu cmpchain_finish|5.031011||Viu cmpchain_start|5.031011||Viu cmp_desc|5.031011||Viu cmp_locale_desc|5.031011||Viu cntrl_to_mnemonic|5.021004||cVniu CODESET|5.027010||Viu COMBINING_DOT_ABOVE_UTF8|5.029008||Viu COMBINING_GRAVE_ACCENT_UTF8|5.017004||Viu COMMIT|5.009005||Viu COMMIT_next|5.009005||Viu COMMIT_next_fail|5.009005||Viu COMMIT_next_fail_t8|5.035004||Viu COMMIT_next_fail_t8_p8|5.033003||Viu COMMIT_next_fail_t8_pb|5.033003||Viu COMMIT_next_fail_tb|5.035004||Viu COMMIT_next_fail_tb_p8|5.033003||Viu COMMIT_next_fail_tb_pb|5.033003||Viu COMMIT_next_t8|5.035004||Viu COMMIT_next_t8_p8|5.033003||Viu COMMIT_next_t8_pb|5.033003||Viu COMMIT_next_tb|5.035004||Viu COMMIT_next_tb_p8|5.033003||Viu COMMIT_next_tb_pb|5.033003||Viu COMMIT_t8|5.035004||Viu COMMIT_t8_p8|5.033003||Viu COMMIT_t8_pb|5.033003||Viu COMMIT_tb|5.035004||Viu COMMIT_tb_p8|5.033003||Viu COMMIT_tb_pb|5.033003||Viu compile_wildcard|5.031010||Viu compute_EXACTish|5.017003||Vniu COND_BROADCAST|5.005000||Viu COND_DESTROY|5.005000||Viu COND_INIT|5.005000||Viu COND_SIGNAL|5.005000||Viu COND_WAIT|5.005000||Viu connect|5.005000||Viu construct_ahocorasick_from_trie|5.021001||Viu CONTINUE_PAT_MOD|5.009005||Viu cop_fetch_label|5.031004|5.031004|x CopFILE|5.006000|5.003007|p CopFILEAV|5.006000|5.003007|p CopFILEAVn|5.035006|5.035006| cop_file_avn|5.035006||cVu CopFILEAVx|5.009003||Viu CopFILE_free|5.007003||Viu CopFILEGV|5.006000|5.003007|p CopFILEGV_set|5.006000|5.003007|p CopFILE_set|5.006000|5.003007|p CopFILE_setn|5.009005||Viu CopFILESV|5.006000|5.003007|p cop_free|5.006000||Viu cophh_2hv|5.013007|5.013007|x cophh_copy|5.013007|5.013007|x cophh_delete_pv|5.013007|5.013007|x cophh_delete_pvn|5.013007|5.013007|x cophh_delete_pvs|5.013007|5.013007|x cophh_delete_sv|5.013007|5.013007|x COPHH_EXISTS|5.033008||Viu cophh_exists_pv|5.033008|5.033008|x cophh_exists_pvn|5.033008|5.033008|x cophh_exists_pvs|5.033008|5.033008|x cophh_exists_sv|5.033008|5.033008|x cophh_fetch_pv|5.013007|5.013007|x cophh_fetch_pvn|5.013007|5.013007|x cophh_fetch_pvs|5.013007|5.013007|x cophh_fetch_sv|5.013007|5.013007|x cophh_free|5.013007|5.013007|x COPHH_KEY_UTF8|5.013007|5.013007| cophh_new_empty|5.013007|5.013007|x cophh_store_pv|5.013007|5.013007|x cophh_store_pvn|5.013007|5.013007|x cophh_store_pvs|5.013007|5.013007|x cophh_store_sv|5.013007|5.013007|x CopHINTHASH_get|5.013007||Viu CopHINTHASH_set|5.013007||Viu cop_hints_2hv|5.013007|5.013007| cop_hints_exists_pv|5.033008|5.033008| cop_hints_exists_pvn|5.033008|5.033008| cop_hints_exists_pvs|5.033008|5.033008| cop_hints_exists_sv|5.033008|5.033008| cop_hints_fetch_pv|5.013007|5.013007| cop_hints_fetch_pvn|5.013007|5.013007| cop_hints_fetch_pvs|5.013007|5.013007| cop_hints_fetch_sv|5.013007|5.013007| CopHINTS_get|5.009004||Viu CopHINTS_set|5.009004||Viu CopLABEL|5.009005|5.009005| CopLABEL_alloc|5.009005||Viu CopLABEL_len|5.016000|5.016000| CopLABEL_len_flags|5.016000|5.016000| CopLINE|5.006000|5.006000| CopLINE_dec|5.006000||Viu CopLINE_inc|5.006000||Viu CopLINE_set|5.006000||Viu COP_SEQMAX_INC|5.021006||Viu COP_SEQ_RANGE_HIGH|5.009005||Viu COP_SEQ_RANGE_LOW|5.009005||Viu CopSTASH|5.006000|5.003007|p CopSTASH_eq|5.006000|5.003007|p CopSTASH_ne|5.006000||Viu CopSTASHPV|5.006000|5.003007|p CopSTASHPV_set|5.017001|5.017001|p CopSTASH_set|5.006000|5.003007|p cop_store_label|5.031004|5.031004|x Copy|5.003007|5.003007| CopyD|5.009002|5.003007|p core_prototype|5.015002||Vi coresub_op|5.015003||Viu CowREFCNT|5.017007||Viu cPADOP|5.006000||Viu cPADOPo|5.006000||Viu cPADOPx|5.006000||Viu CPERLarg|5.005000||Viu CPERLscope|5.005000|5.003007|pdV cPMOP|5.003007||Viu cPMOPo|5.004005||Viu cPMOPx|5.006000||Viu CPPLAST|5.006000|5.006000|Vn CPPMINUS|5.003007|5.003007|Vn CPPRUN|5.006000|5.006000|Vn CPPSTDIN|5.003007|5.003007|Vn cPVOP|5.003007||Viu cPVOPo|5.004005||Viu cPVOPx|5.006000||Viu create_eval_scope|5.009004||xViu CR_NATIVE|5.019004||Viu CRNCYSTR|5.027010||Viu croak|5.003007||vV croak_caller|5.025004||vVniu croak_memory_wrap|5.019003||pcVnu croak_nocontext|5.006000||pvVn croak_no_mem|5.017006||Vniu croak_no_modify|5.013003|5.003007|pn croak_popstack|5.017008||cVniu croak_sv|5.013001|5.003007|p croak_xs_usage|5.010001|5.003007|pn cr_textfilter|5.006000||Viu crypt|5.009000||Viu CRYPT_R_PROTO|5.008000|5.008000|Vn CSH|5.003007|5.003007|Vn csighandler1|5.031007||cVnu csighandler3|5.031007||cVnu csighandler|5.008001||cVnu cSVOP|5.003007||Viu cSVOPo|5.004005||Viu cSVOPo_sv|5.006000||Viu cSVOP_sv|5.006000||Viu cSVOPx|5.006000||Viu cSVOPx_sv|5.006000||Viu cSVOPx_svp|5.006000||Viu ctermid|5.009000||Viu CTERMID_R_PROTO|5.008000|5.008000|Vn ctime|5.009000||Viu CTIME_R_PROTO|5.008000|5.008000|Vn Ctl|5.003007||Viu CTYPE256|5.003007||Viu cUNOP|5.003007||Viu cUNOP_AUX|5.021007||Viu cUNOP_AUXo|5.021007||Viu cUNOP_AUXx|5.021007||Viu cUNOPo|5.004005||Viu cUNOPx|5.006000||Viu CURLY|5.003007||Viu CURLY_B_max|5.009005||Viu CURLY_B_max_fail|5.009005||Viu CURLY_B_max_fail_t8|5.035004||Viu CURLY_B_max_fail_t8_p8|5.033003||Viu CURLY_B_max_fail_t8_pb|5.033003||Viu CURLY_B_max_fail_tb|5.035004||Viu CURLY_B_max_fail_tb_p8|5.033003||Viu CURLY_B_max_fail_tb_pb|5.033003||Viu CURLY_B_max_t8|5.035004||Viu CURLY_B_max_t8_p8|5.033003||Viu CURLY_B_max_t8_pb|5.033003||Viu CURLY_B_max_tb|5.035004||Viu CURLY_B_max_tb_p8|5.033003||Viu CURLY_B_max_tb_pb|5.033003||Viu CURLY_B_min|5.009005||Viu CURLY_B_min_fail|5.009005||Viu CURLY_B_min_fail_t8|5.035004||Viu CURLY_B_min_fail_t8_p8|5.033003||Viu CURLY_B_min_fail_t8_pb|5.033003||Viu CURLY_B_min_fail_tb|5.035004||Viu CURLY_B_min_fail_tb_p8|5.033003||Viu CURLY_B_min_fail_tb_pb|5.033003||Viu CURLY_B_min_t8|5.035004||Viu CURLY_B_min_t8_p8|5.033003||Viu CURLY_B_min_t8_pb|5.033003||Viu CURLY_B_min_tb|5.035004||Viu CURLY_B_min_tb_p8|5.033003||Viu CURLY_B_min_tb_pb|5.033003||Viu CURLYM|5.005000||Viu CURLYM_A|5.009005||Viu CURLYM_A_fail|5.009005||Viu CURLYM_A_fail_t8|5.035004||Viu CURLYM_A_fail_t8_p8|5.033003||Viu CURLYM_A_fail_t8_pb|5.033003||Viu CURLYM_A_fail_tb|5.035004||Viu CURLYM_A_fail_tb_p8|5.033003||Viu CURLYM_A_fail_tb_pb|5.033003||Viu CURLYM_A_t8|5.035004||Viu CURLYM_A_t8_p8|5.033003||Viu CURLYM_A_t8_pb|5.033003||Viu CURLYM_A_tb|5.035004||Viu CURLYM_A_tb_p8|5.033003||Viu CURLYM_A_tb_pb|5.033003||Viu CURLYM_B|5.009005||Viu CURLYM_B_fail|5.009005||Viu CURLYM_B_fail_t8|5.035004||Viu CURLYM_B_fail_t8_p8|5.033003||Viu CURLYM_B_fail_t8_pb|5.033003||Viu CURLYM_B_fail_tb|5.035004||Viu CURLYM_B_fail_tb_p8|5.033003||Viu CURLYM_B_fail_tb_pb|5.033003||Viu CURLYM_B_t8|5.035004||Viu CURLYM_B_t8_p8|5.033003||Viu CURLYM_B_t8_pb|5.033003||Viu CURLYM_B_tb|5.035004||Viu CURLYM_B_tb_p8|5.033003||Viu CURLYM_B_tb_pb|5.033003||Viu CURLYM_t8|5.035004||Viu CURLYM_t8_p8|5.033003||Viu CURLYM_t8_pb|5.033003||Viu CURLYM_tb|5.035004||Viu CURLYM_tb_p8|5.033003||Viu CURLYM_tb_pb|5.033003||Viu CURLYN|5.005000||Viu CURLYN_t8|5.035004||Viu CURLYN_t8_p8|5.033003||Viu CURLYN_t8_pb|5.033003||Viu CURLYN_tb|5.035004||Viu CURLYN_tb_p8|5.033003||Viu CURLYN_tb_pb|5.033003||Viu CURLY_t8|5.035004||Viu CURLY_t8_p8|5.033003||Viu CURLY_t8_pb|5.033003||Viu CURLY_tb|5.035004||Viu CURLY_tb_p8|5.033003||Viu CURLY_tb_pb|5.033003||Viu CURLYX|5.003007||Viu CURLYX_end|5.009005||Viu CURLYX_end_fail|5.009005||Viu CURLYX_end_fail_t8|5.035004||Viu CURLYX_end_fail_t8_p8|5.033003||Viu CURLYX_end_fail_t8_pb|5.033003||Viu CURLYX_end_fail_tb|5.035004||Viu CURLYX_end_fail_tb_p8|5.033003||Viu CURLYX_end_fail_tb_pb|5.033003||Viu CURLYX_end_t8|5.035004||Viu CURLYX_end_t8_p8|5.033003||Viu CURLYX_end_t8_pb|5.033003||Viu CURLYX_end_tb|5.035004||Viu CURLYX_end_tb_p8|5.033003||Viu CURLYX_end_tb_pb|5.033003||Viu CURLYX_t8|5.035004||Viu CURLYX_t8_p8|5.033003||Viu CURLYX_t8_pb|5.033003||Viu CURLYX_tb|5.035004||Viu CURLYX_tb_p8|5.033003||Viu CURLYX_tb_pb|5.033003||Viu CURRENT_FEATURE_BUNDLE|5.015007||Viu CURRENT_HINTS|5.015007||Viu current_re_engine|5.017001||cViu curse|5.013009||Viu custom_op_desc|5.007003|5.007003|d custom_op_get_field|5.019006||cViu custom_op_name|5.007003|5.007003|d custom_op_register||| CUTGROUP|5.009005||Viu CUTGROUP_next|5.009005||Viu CUTGROUP_next_fail|5.009005||Viu CUTGROUP_next_fail_t8|5.035004||Viu CUTGROUP_next_fail_t8_p8|5.033003||Viu CUTGROUP_next_fail_t8_pb|5.033003||Viu CUTGROUP_next_fail_tb|5.035004||Viu CUTGROUP_next_fail_tb_p8|5.033003||Viu CUTGROUP_next_fail_tb_pb|5.033003||Viu CUTGROUP_next_t8|5.035004||Viu CUTGROUP_next_t8_p8|5.033003||Viu CUTGROUP_next_t8_pb|5.033003||Viu CUTGROUP_next_tb|5.035004||Viu CUTGROUP_next_tb_p8|5.033003||Viu CUTGROUP_next_tb_pb|5.033003||Viu CUTGROUP_t8|5.035004||Viu CUTGROUP_t8_p8|5.033003||Viu CUTGROUP_t8_pb|5.033003||Viu CUTGROUP_tb|5.035004||Viu CUTGROUP_tb_p8|5.033003||Viu CUTGROUP_tb_pb|5.033003||Viu CvANON|5.003007||Viu CvANONCONST|5.021008||Viu CvANONCONST_off|5.021008||Viu CvANONCONST_on|5.021008||Viu CvANON_off|5.003007||Viu CvANON_on|5.003007||Viu CvAUTOLOAD|5.015004||Viu CvAUTOLOAD_off|5.015004||Viu CvAUTOLOAD_on|5.015004||Viu cv_ckproto|5.009004||Viu cv_ckproto_len_flags|5.015004||xcViu CvCLONE|5.003007||Viu cv_clone|5.015001|5.015001| CvCLONED|5.003007||Viu CvCLONED_off|5.003007||Viu CvCLONED_on|5.003007||Viu cv_clone_into|5.017004||Viu CvCLONE_off|5.003007||Viu CvCLONE_on|5.003007||Viu CvCONST|5.007001||Viu CvCONST_off|5.007001||Viu CvCONST_on|5.007001||Viu cv_const_sv|5.003007|5.003007|n cv_const_sv_or_av|5.019003||Vniu CvCVGV_RC|5.013003||Viu CvCVGV_RC_off|5.013003||Viu CvCVGV_RC_on|5.013003||Viu CvDEPTH|5.003007|5.003007|nu CvDEPTHunsafe|5.021006||Viu cv_dump|5.006000||Vi CvDYNFILE|5.015002||Viu CvDYNFILE_off|5.015002||Viu CvDYNFILE_on|5.015002||Viu CvEVAL|5.005003||Viu CvEVAL_off|5.005003||Viu CvEVAL_on|5.005003||Viu CVf_ANON|5.003007||Viu CVf_ANONCONST|5.021008||Viu CVf_AUTOLOAD|5.015004||Viu CVf_BUILTIN_ATTRS|5.008000||Viu CVf_CLONE|5.003007||Viu CVf_CLONED|5.003007||Viu CVf_CONST|5.007001||Viu CVf_CVGV_RC|5.013003||Viu CVf_DYNFILE|5.015002||Viu CVf_HASEVAL|5.017002||Viu CvFILE|5.006000||Viu CvFILEGV|5.003007||Viu CvFILE_set_from_cop|5.007002||Viu CVf_ISXSUB|5.009004||Viu CvFLAGS|5.003007||Viu CVf_LEXICAL|5.021004||Viu CVf_LVALUE|5.006000||Viu CVf_METHOD|5.005000||Viu CVf_NAMED|5.017004||Viu CVf_NODEBUG|5.004000||Viu cv_forget_slab|5.017002||Vi CVf_SIGNATURE|5.035009||Viu CVf_SLABBED|5.017002||Viu CVf_UNIQUE|5.004000||Viu CVf_WEAKOUTSIDE|5.008001||Viu cv_get_call_checker|5.013006|5.013006| cv_get_call_checker_flags|5.027003|5.027003| CvGV|5.003007|5.003007| cvgv_from_hek|||ciu cvgv_set|5.013003||cViu CvGV_set|5.013003||Viu CvHASEVAL|5.017002||Viu CvHASEVAL_off|5.017002||Viu CvHASEVAL_on|5.017002||Viu CvHASGV|5.021004||Viu CvHSCXT|5.021006||Viu CvISXSUB|5.009004||Viu CvISXSUB_off|5.009004||Viu CvISXSUB_on|5.009004||Viu CvLEXICAL|5.021004||Viu CvLEXICAL_off|5.021004||Viu CvLEXICAL_on|5.021004||Viu CvLVALUE|5.006000||Viu CvLVALUE_off|5.006000||Viu CvLVALUE_on|5.006000||Viu CvMETHOD|5.005000||Viu CvMETHOD_off|5.005000||Viu CvMETHOD_on|5.005000||Viu cv_name|5.021005|5.021005| CvNAMED|5.017004||Viu CvNAMED_off|5.017004||Viu CvNAMED_on|5.017004||Viu CvNAME_HEK_set|5.017004||Viu CV_NAME_NOTQUAL|5.021005|5.021005| CvNODEBUG|5.004000||Viu CvNODEBUG_off|5.004000||Viu CvNODEBUG_on|5.004000||Viu CvOUTSIDE|5.003007||Viu CvOUTSIDE_SEQ|5.008001||Viu CvPADLIST|5.008001|5.008001|x CvPADLIST_set|5.021006||Viu CvPROTO|5.015004||Viu CvPROTOLEN|5.015004||Viu CvROOT|5.003007||Viu cv_set_call_checker|5.013006|5.013006| cv_set_call_checker_flags|5.021004|5.021004| CvSIGNATURE|5.035009||Viu CvSIGNATURE_off|5.035009||Viu CvSIGNATURE_on|5.035009||Viu CvSLABBED|5.017002||Viu CvSLABBED_off|5.017002||Viu CvSLABBED_on|5.017002||Viu CvSPECIAL|5.005003||Viu CvSPECIAL_off|5.005003||Viu CvSPECIAL_on|5.005003||Viu CvSTART|5.003007||Viu CvSTASH|5.003007|5.003007| cvstash_set|5.013007||cViu CvSTASH_set|5.013007||Viu cv_undef|5.003007|5.003007| cv_undef_flags|5.021004||Viu CV_UNDEF_KEEP_NAME|5.021004||Viu CvUNIQUE|5.004000||Viu CvUNIQUE_off|5.004000||Viu CvUNIQUE_on|5.004000||Viu CvWEAKOUTSIDE|5.008001||Vi CvWEAKOUTSIDE_off|5.008001||Viu CvWEAKOUTSIDE_on|5.008001||Viu CvXSUB|5.003007||Viu CvXSUBANY|5.003007||Viu CX_CUR|5.023008||Viu CX_CURPAD_SAVE|5.008001||Vi CX_CURPAD_SV|5.008001||Vi CX_DEBUG|5.023008||Viu cx_dump|5.003007||cVu cx_dup|5.006000||cVu CxEVALBLOCK|5.033007||Viu CxEVAL_TXT_REFCNTED|5.025007||Viu CxFOREACH|5.009003||Viu CxHASARGS|5.010001||Viu cxinc|5.003007||cVu CXINC|5.003007||Viu CxITERVAR|5.006000||Viu CxLABEL|5.010001||Viu CxLABEL_len|5.016000||Viu CxLABEL_len_flags|5.016000||Viu CX_LEAVE_SCOPE|5.023008||Viu CxLVAL|5.010001||Viu CxMULTICALL|5.009003||Viu CxOLD_IN_EVAL|5.010001||Viu CxOLD_OP_TYPE|5.010001||Viu CxONCE|5.010001||Viu CxPADLOOP|5.006000||Viu CXp_EVALBLOCK|5.033007||Viu CXp_FINALLY|5.035008||Viu CXp_FOR_DEF|5.027008||Viu CXp_FOR_GV|5.023008||Viu CXp_FOR_LVREF|5.021005||Viu CXp_FOR_PAD|5.023008||Viu CXp_HASARGS|5.011000||Viu CXp_MULTICALL|5.009003||Viu CXp_ONCE|5.011000||Viu CX_POP|5.023008||Viu cx_popblock|5.023008||xcVu cx_popeval|5.023008||xcVu cx_popformat|5.023008||xcVu cx_popgiven|5.027008||xcVu cx_poploop|5.023008||xcVu CX_POP_SAVEARRAY|5.023008||Viu cx_popsub|5.023008||xcVu cx_popsub_args|5.023008||xcVu cx_popsub_common|5.023008||xcVu CX_POPSUBST|5.023008||Viu cx_popwhen|5.027008||xcVu CXp_REAL|5.005003||Viu CXp_SUB_RE|5.018000||Viu CXp_SUB_RE_FAKE|5.018000||Viu CXp_TRY|5.033007||Viu CXp_TRYBLOCK|5.006000||Viu cx_pushblock|5.023008||xcVu cx_pusheval|5.023008||xcVu cx_pushformat|5.023008||xcVu cx_pushgiven|5.027008||xcVu cx_pushloop_for|5.023008||xcVu cx_pushloop_plain|5.023008||xcVu cx_pushsub|5.023008||xcVu CX_PUSHSUB_GET_LVALUE_MASK|5.023008||Viu CX_PUSHSUBST|5.023008||Viu cx_pushtry|5.033007||xcVu cx_pushwhen|5.027008||xcVu CxREALEVAL|5.005003||Viu cxstack|5.005000||Viu cxstack_ix|5.005000||Viu cxstack_max|5.005000||Viu CXt_BLOCK|5.003007||Viu CXt_DEFER|5.035004||Viu CXt_EVAL|5.003007||Viu CXt_FORMAT|5.006000||Viu CXt_GIVEN|5.027008||Viu CXt_LOOP_ARY|5.023008||Viu CXt_LOOP_LAZYIV|5.011000||Viu CXt_LOOP_LAZYSV|5.011000||Viu CXt_LOOP_LIST|5.023008||Viu CXt_LOOP_PLAIN|5.011000||Viu CXt_NULL|5.003007||Viu cx_topblock|5.023008||xcVu CxTRY|5.033007||Viu CxTRYBLOCK|5.006000||Viu CXt_SUB|5.003007||Viu CXt_SUBST|5.003007||Viu CXt_WHEN|5.027008||Viu CxTYPE|5.005003||Viu cx_type|5.009005||Viu CxTYPE_is_LOOP|5.011000||Viu CXTYPEMASK|5.005003||Viu dATARGET|5.003007||Viu dAX|5.007002|5.003007|p dAXMARK|5.009003|5.003007|p DAY_1|5.027010||Viu DAY_2|5.027010||Viu DAY_3|5.027010||Viu DAY_4|5.027010||Viu DAY_5|5.027010||Viu DAY_6|5.027010||Viu DAY_7|5.027010||Viu DB_Hash_t|5.003007|5.003007|Vn DBM_ckFilter|5.008001||Viu DBM_setFilter|5.008001||Viu DB_Prefix_t|5.003007|5.003007|Vn DBVARMG_COUNT|5.021005||Viu DBVARMG_SIGNAL|5.021005||Viu DBVARMG_SINGLE|5.021005||Viu DBVARMG_TRACE|5.021005||Viu DB_VERSION_MAJOR_CFG|5.007002|5.007002|Vn DB_VERSION_MINOR_CFG|5.007002|5.007002|Vn DB_VERSION_PATCH_CFG|5.007002|5.007002|Vn deb|5.003007||vVu deb_curcv|5.007002||Viu deb_nocontext|5.006000||vVnu debop|5.005000|5.005000|u debprof|5.005000||Viu debprofdump|5.005000|5.005000|u debstack|5.007003|5.007003|u deb_stack_all|5.008001||Viu deb_stack_n|5.008001||Viu debstackptrs|5.007003|5.007003|u DEBUG|5.003007||Viu DEBUG_A|5.009001||Viu DEBUG_A_FLAG|5.009001||Viu DEBUG_A_TEST|5.009001||Viu DEBUG_B|5.011000||Viu DEBUG_B_FLAG|5.011000||Viu DEBUG_BOTH_FLAGS_TEST|5.033007||Viu DEBUG_B_TEST|5.011000||Viu DEBUG_BUFFERS_r|5.009005||Viu DEBUG_c|5.003007||Viu DEBUG_C|5.009000||Viu DEBUG_c_FLAG|5.007001||Viu DEBUG_C_FLAG|5.009000||Viu DEBUG_COMPILE_r|5.009002||Viu DEBUG_c_TEST|5.007001||Viu DEBUG_C_TEST|5.009000||Viu DEBUG_D|5.003007||Viu DEBUG_DB_RECURSE_FLAG|5.007001||Viu DEBUG_D_FLAG|5.007001||Viu DEBUG_D_TEST|5.007001||Viu DEBUG_DUMP_PRE_OPTIMIZE_r|5.031004||Viu DEBUG_DUMP_r|5.009004||Viu DEBUG_EXECUTE_r|5.009002||Viu DEBUG_EXTRA_r|5.009004||Viu DEBUG_f|5.003007||Viu DEBUG_f_FLAG|5.007001||Viu DEBUG_FLAGS_r|5.009005||Viu DEBUG_f_TEST|5.007001||Viu DEBUG_GPOS_r|5.011000||Viu DEBUG_i|5.025002||Viu DEBUG_i_FLAG|5.025002||Viu DEBUG_INTUIT_r|5.009004||Viu DEBUG_i_TEST|5.025002||Viu DEBUG_J_FLAG|5.007003||Viu DEBUG_J_TEST|5.007003||Viu DEBUG_l|5.003007||Viu DEBUG_L|5.019009||Viu DEBUG_l_FLAG|5.007001||Viu DEBUG_L_FLAG|5.019009||Viu DEBUG_l_TEST|5.007001||Viu DEBUG_L_TEST|5.019009||Viu DEBUG_Lv|5.023003||Viu DEBUG_Lv_TEST|5.023003||Viu DEBUG_m|5.003007||Viu DEBUG_M|5.027008||Viu DEBUG_MASK|5.007001||Viu DEBUG_MATCH_r|5.009004||Viu DEBUG_m_FLAG|5.007001||Viu DEBUG_M_FLAG|5.027008||Viu DEBUG_m_TEST|5.007001||Viu DEBUG_M_TEST|5.027008||Viu DEBUG_o|5.003007||Viu DEBUG_o_FLAG|5.007001||Viu DEBUG_OPTIMISE_MORE_r|5.009005||Viu DEBUG_OPTIMISE_r|5.009002||Viu DEBUG_o_TEST|5.007001||Viu DEBUG_P|5.003007||Viu DEBUG_p|5.003007||Viu DEBUG_PARSE_r|5.009004||Viu DEBUG_P_FLAG|5.007001||Viu DEBUG_p_FLAG|5.007001||Viu DEBUG_POST_STMTS|5.033008||Viu DEBUG_PRE_STMTS|5.033008||Viu DEBUG_P_TEST|5.007001||Viu DEBUG_p_TEST|5.007001||Viu DEBUG_Pv|5.013008||Viu DEBUG_Pv_TEST|5.013008||Viu DEBUG_q|5.009001||Viu DEBUG_q_FLAG|5.009001||Viu DEBUG_q_TEST|5.009001||Viu DEBUG_r|5.003007||Viu DEBUG_R|5.007001||Viu DEBUG_R_FLAG|5.007001||Viu DEBUG_r_FLAG|5.007001||Viu DEBUG_R_TEST|5.007001||Viu DEBUG_r_TEST|5.007001||Viu DEBUG_s|5.003007||Viu DEBUG_S|5.017002||Viu DEBUG_SBOX32_HASH|5.027001||Viu DEBUG_SCOPE|5.008001||Viu DEBUG_s_FLAG|5.007001||Viu DEBUG_S_FLAG|5.017002||Viu DEBUG_STACK_r|5.009005||Viu debug_start_match|5.009004||Viu DEBUG_STATE_r|5.009004||Viu DEBUG_s_TEST|5.007001||Viu DEBUG_S_TEST|5.017002||Viu DEBUG_t|5.003007||Viu DEBUG_T|5.007001||Viu DEBUG_TEST_r|5.021005||Viu DEBUG_T_FLAG|5.007001||Viu DEBUG_t_FLAG|5.007001||Viu DEBUG_TOP_FLAG|5.007001||Viu DEBUG_TRIE_COMPILE_MORE_r|5.009002||Viu DEBUG_TRIE_COMPILE_r|5.009002||Viu DEBUG_TRIE_EXECUTE_MORE_r|5.009002||Viu DEBUG_TRIE_EXECUTE_r|5.009002||Viu DEBUG_TRIE_r|5.009002||Viu DEBUG_T_TEST|5.007001||Viu DEBUG_t_TEST|5.007001||Viu DEBUG_u|5.003007||Viu DEBUG_U|5.009005||Viu DEBUG_u_FLAG|5.007001||Viu DEBUG_U_FLAG|5.009005||Viu DEBUG_u_TEST|5.007001||Viu DEBUG_U_TEST|5.009005||Viu DEBUG_Uv|5.009005||Viu DEBUG_Uv_TEST|5.009005||Viu DEBUG_v|5.008001||Viu DEBUG_v_FLAG|5.008001||Viu DEBUG_v_TEST|5.008001||Viu DEBUG_X|5.003007||Viu DEBUG_x|5.003007||Viu DEBUG_X_FLAG|5.007001||Viu DEBUG_x_FLAG|5.007001||Viu DEBUG_X_TEST|5.007001||Viu DEBUG_x_TEST|5.007001||Viu DEBUG_Xv|5.008001||Viu DEBUG_Xv_TEST|5.008001||Viu DEBUG_y|5.031007||Viu DEBUG_y_FLAG|5.031007||Viu DEBUG_y_TEST|5.031007||Viu DEBUG_yv|5.031007||Viu DEBUG_yv_TEST|5.031007||Viu DEBUG_ZAPHOD32_HASH|5.027001||Viu DECLARATION_FOR_LC_NUMERIC_MANIPULATION|5.021010|5.021010|p DECLARE_AND_GET_RE_DEBUG_FLAGS|5.031011||Viu DECLARE_AND_GET_RE_DEBUG_FLAGS_NON_REGEX|5.031011||Viu DEFAULT_INC_EXCLUDES_DOT|5.025011|5.025011|Vn DEFAULT_PAT_MOD|5.013006||Viu defelem_target|5.019002||Viu DEFINE_INC_MACROS|5.027006||Viu DEFINEP|5.009005||Viu DEFINEP_t8|5.035004||Viu DEFINEP_t8_p8|5.033003||Viu DEFINEP_t8_pb|5.033003||Viu DEFINEP_tb|5.035004||Viu DEFINEP_tb_p8|5.033003||Viu DEFINEP_tb_pb|5.033003||Viu DEFSV|5.004005|5.003007|p DEFSV_set|5.010001|5.003007|p delete_eval_scope|5.009004||xViu delimcpy|5.004000|5.004000|n delimcpy_no_escape|5.025005||cVni DEL_NATIVE|5.017010||Viu del_sv|5.005000||Viu DEPENDS_PAT_MOD|5.013009||Viu DEPENDS_PAT_MODS|5.013009||Viu deprecate|5.011001||Viu deprecate_disappears_in|5.025009||Viu deprecate_fatal_in|5.025009||Viu despatch_signals|5.007001||cVu destroy_matcher|5.027008||Viu DETACH|5.005000||Viu dEXT|5.003007||Viu dEXTCONST|5.004000||Viu DFA_RETURN_FAILURE|5.035004||Viu DFA_RETURN_SUCCESS|5.035004||Viu DFA_TEASE_APART_FF|5.035004||Viu D_FMT|5.027010||Viu DIE|5.003007||Viu die|5.003007||vV die_nocontext|5.006000||vVn die_sv|5.013001|5.003007|p die_unwind|5.013001||Viu Direntry_t|5.003007|5.003007|Vn dirp_dup|5.013007|5.013007|u dITEMS|5.007002|5.003007|p div128|5.005000||Viu dJMPENV|5.004000||Viu djSP|5.004005||Vi dMARK|5.003007|5.003007| DM_ARRAY_ISA|5.013002||Viu DM_DELAY|5.003007||Viu DM_EGID|5.003007||Viu DM_EUID|5.003007||Viu DM_GID|5.003007||Viu DM_RGID|5.003007||Viu DM_RUID|5.003007||Viu DM_UID|5.003007||Viu dMULTICALL|5.009003|5.009003| dMY_CXT|5.009000|5.009000|p dMY_CXT_INTERP|5.009003||Viu dMY_CXT_SV|5.007003|5.003007|pV dNOOP|5.006000|5.003007|p do_aexec|5.009003||Viu do_aexec5|5.006000||Viu do_aspawn|5.008000||Vu do_binmode|5.004005|5.004005|du docatch|5.005000||Vi do_chomp|5.003007||Viu do_close|5.003007|5.003007|u do_delete_local|5.011000||Viu do_dump_pad|5.008001||Vi do_eof|5.003007||Viu does_utf8_overflow|5.025006||Vniu doeval_compile|5.023008||Viu do_exec3|5.006000||Viu do_exec|5.009003||Viu dofile|5.005003||Viu dofindlabel|5.003007||Viu doform|5.005000||Viu do_gv_dump|5.006000||cVu do_gvgv_dump|5.006000||cVu do_hv_dump|5.006000||cVu doing_taint|5.008001||cVnu DOINIT|5.003007||Viu do_ipcctl|5.003007||Viu do_ipcget|5.003007||Viu do_join|5.003007|5.003007|u do_magic_dump|5.006000||cVu do_msgrcv|5.003007||Viu do_msgsnd|5.003007||Viu do_ncmp|5.015001||Viu do_oddball|5.006000||Viu dooneliner|5.006000||Viu do_op_dump|5.006000||cVu do_open|5.003007|5.003007|u do_open6|5.019010||xViu do_open9|5.006000|5.006000|du do_openn|5.007001|5.007001|u doopen_pm|5.008001||Viu do_open_raw|5.019010||xViu doparseform|5.005000||Viu do_pmop_dump|5.006000||cVu dopoptoeval|5.003007||Viu dopoptogivenfor|5.027008||Viu dopoptolabel|5.005000||Viu dopoptoloop|5.005000||Viu dopoptosub_at|5.005000||Viu dopoptowhen|5.027008||Viu do_print|5.003007||Viu do_readline|5.003007||Viu doref|5.009003|5.009003|u dORIGMARK|5.003007|5.003007| do_seek|5.003007||Viu do_semop|5.003007||Viu do_shmio|5.003007||Viu DOSISH|5.003007||Viu do_smartmatch|5.027008||Viu do_spawn|5.008000||Vu do_spawn_nowait|5.008000||Vu do_sprintf|5.003007|5.003007|u do_sv_dump|5.006000||cVu do_sysseek|5.004000||Viu do_tell|5.003007||Viu do_trans|5.003007||Viu do_trans_complex|5.006001||Viu do_trans_count|5.006001||Viu do_trans_count_invmap|5.031006||Viu do_trans_invmap|5.031006||Viu do_trans_simple|5.006001||Viu DOUBLE_BIG_ENDIAN|5.021009||Viu DOUBLE_HAS_INF|5.025003|5.025003|Vn DOUBLE_HAS_NAN|5.025003|5.025003|Vn DOUBLE_HAS_NEGATIVE_ZERO|5.025007|5.025007|Vn DOUBLE_HAS_SUBNORMALS|5.025007|5.025007|Vn DOUBLEINFBYTES|5.023000|5.023000|Vn DOUBLE_IS_CRAY_SINGLE_64_BIT|5.025006|5.025006|Vn DOUBLE_IS_IBM_DOUBLE_64_BIT|5.025006|5.025006|Vn DOUBLE_IS_IBM_SINGLE_32_BIT|5.025006|5.025006|Vn DOUBLE_IS_IEEE_754_128_BIT_BIG_ENDIAN|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_128_BIT_LITTLE_ENDIAN|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_32_BIT_BIG_ENDIAN|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_32_BIT_LITTLE_ENDIAN|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_64_BIT_BIG_ENDIAN|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_64_BIT_LITTLE_ENDIAN|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_64_BIT_MIXED_ENDIAN_BE_LE|5.021006|5.021006|Vn DOUBLE_IS_IEEE_754_64_BIT_MIXED_ENDIAN_LE_BE|5.021006|5.021006|Vn DOUBLE_IS_IEEE_FORMAT|5.025003||Viu DOUBLE_IS_UNKNOWN_FORMAT|5.021006|5.021006|Vn DOUBLE_IS_VAX_D_FLOAT|5.025003|5.025003|Vn DOUBLE_IS_VAX_F_FLOAT|5.025003|5.025003|Vn DOUBLE_IS_VAX_FLOAT|5.025003||Viu DOUBLE_IS_VAX_G_FLOAT|5.025003|5.025003|Vn DOUBLEKIND|5.021006|5.021006|Vn DOUBLE_LITTLE_ENDIAN|5.021009||Viu DOUBLEMANTBITS|5.023000|5.023000|Vn DOUBLE_MIX_ENDIAN|5.021009||Viu DOUBLENANBYTES|5.023000|5.023000|Vn DOUBLESIZE|5.005000|5.005000|Vn DOUBLE_STYLE_IEEE|5.025007|5.025007|Vn DOUBLE_VAX_ENDIAN|5.025003||Viu do_uniprop_match|5.031011||cVniu dounwind|5.003007|5.003007|u DO_UTF8|5.006000|5.006000| do_vecget|5.006000||Viu do_vecset|5.003007||Viu do_vop|5.003007||Viu dowantarray|5.003007|5.003007|u dPOPiv|5.003007||Viu dPOPnv|5.003007||Viu dPOPnv_nomg|5.013002||Viu dPOPPOPiirl|5.003007||Viu dPOPPOPnnrl|5.003007||Viu dPOPPOPssrl|5.003007||Viu dPOPss|5.003007||Viu dPOPTOPiirl|5.003007||Viu dPOPTOPiirl_nomg|5.013002||Viu dPOPTOPiirl_ul_nomg|5.013002||Viu dPOPTOPnnrl|5.003007||Viu dPOPTOPnnrl_nomg|5.013002||Viu dPOPTOPssrl|5.003007||Viu dPOPuv|5.004000||Viu dPOPXiirl|5.004000||Viu dPOPXiirl_ul_nomg|5.013002||Viu dPOPXnnrl|5.004000||Viu dPOPXssrl|5.004000||Viu DPTR2FPTR|5.009003||Viu Drand01|5.006000|5.006000| drand48_init_r|||cniu drand48_r|||cniu DRAND48_R_PROTO|5.008000|5.008000|Vn dSAVEDERRNO|5.010001||Vi dSAVE_ERRNO|5.010001||Vi dSP|5.003007|5.003007| dSS_ADD|5.017007||Viu dTARG|5.003007||Viu dTARGET|5.003007|5.003007| dTARGETSTACKED|5.003007||Viu D_T_FMT|5.027010||Viu dTHR|5.004005|5.003007|p dTHX|5.003007|5.003007|p dTHXa|5.006000|5.003007|p dTHX_DEBUGGING|5.027009||Viu dTHXo|5.006000||Viu dTHXoa|5.006001|5.003007|p dTHXR||5.003007|ponu dTHXs|5.007002||Viu dTHXx|5.006000||Viu dTOPiv|5.003007||Viu dTOPnv|5.003007||Viu dTOPss|5.003007||Viu dTOPuv|5.004000||Viu dtrace_probe_call|||ciu dtrace_probe_load|||ciu dtrace_probe_op|||ciu dtrace_probe_phase|||ciu dump_all|5.006000|5.006000| dump_all_perl|5.011000||Viu dump_c_backtrace|5.021001||V dump_eval|5.006000|5.006000|u dump_exec_pos|5.009004||Viu dump_form|5.006000|5.006000|u dump_indent|5.006000||vcVu dump_mstats|5.003007||Vu dump_packsubs|5.006000|5.006000| dump_packsubs_perl|5.011000||Viu dump_regex_sets_structures|5.025006||Viu dump_sub|5.006000|5.006000|u dump_sub_perl|5.011000||Viu dump_sv_child|5.009003||Viu dump_trie|5.009004||Viu dump_trie_interim_list|5.009004||Viu dump_trie_interim_table|5.009004||Viu dumpuntil|5.005000||Viu dump_vindent|5.006000||cVu dUNDERBAR|5.009002|5.003007|p dup2|5.005000||Viu dup|5.005000||Viu dup_attrlist|5.006000||Viu DUP_WARNINGS|5.009004||Viu dup_warnings|||ciu dVAR|5.009003|5.003007|p dXCPT|5.009002|5.003007|p dXSARGS|5.003007|5.003007| dXSBOOTARGSAPIVERCHK|5.021006||Viu dXSBOOTARGSNOVERCHK|5.021006||Viu dXSBOOTARGSXSAPIVERCHK|5.021006||Viu dXSFUNCTION|5.005000||Viu dXSI32|5.003007|5.003007|V dXSTARG|5.006000|5.003007|poVnu dXSUB_SYS|5.003007||Viu edit_distance|5.023008||Vniu EIGHT_BIT_UTF8_TO_NATIVE|5.023003||Viu ELEMENT_RANGE_MATCHES_INVLIST|5.023002||Viu EMBEDMYMALLOC|5.006000||Viu emulate_cop_io|||xciu emulate_setlocale|5.027009||Vniu END|5.003007||Viu END_EXTERN_C|5.005000|5.003007|pV endgrent|5.009000||Viu ENDGRENT_R_HAS_FPTR|5.008000||Viu ENDGRENT_R_PROTO|5.008000|5.008000|Vn endhostent|5.005000||Viu ENDHOSTENT_R_PROTO|5.008000|5.008000|Vn ENDLIKE|5.009005||Viu ENDLIKE_t8|5.035004||Viu ENDLIKE_t8_p8|5.033003||Viu ENDLIKE_t8_pb|5.033003||Viu ENDLIKE_tb|5.035004||Viu ENDLIKE_tb_p8|5.033003||Viu ENDLIKE_tb_pb|5.033003||Viu endnetent|5.005000||Viu ENDNETENT_R_PROTO|5.008000|5.008000|Vn endprotoent|5.005000||Viu ENDPROTOENT_R_PROTO|5.008000|5.008000|Vn endpwent|5.009000||Viu ENDPWENT_R_HAS_FPTR|5.008000||Viu ENDPWENT_R_PROTO|5.008000|5.008000|Vn endservent|5.005000||Viu ENDSERVENT_R_PROTO|5.008000|5.008000|Vn END_t8|5.035004||Viu END_t8_p8|5.033003||Viu END_t8_pb|5.033003||Viu END_tb|5.035004||Viu END_tb_p8|5.033003||Viu END_tb_pb|5.033003||Viu ENTER|5.003007|5.003007| ENTER_with_name|5.011002|5.011002| ENV_INIT|5.031011||Viu environ|5.003007||Viu ENV_LOCALE_LOCK|5.031011||Viu ENV_LOCALE_READ_LOCK|5.031011||Viu ENV_LOCALE_READ_UNLOCK|5.031011||Viu ENV_LOCALE_UNLOCK|5.031011||Viu ENV_LOCK|5.031011||Viu ENV_READ_LOCK|5.033005||Viu ENV_READ_UNLOCK|5.033005||Viu ENV_TERM|5.031011||Viu ENV_UNLOCK|5.031011||Viu EOF|5.003007||Viu EOF_NONBLOCK|5.003007|5.003007|Vn EOL|5.003007||Viu EOL_t8|5.035004||Viu EOL_t8_p8|5.033003||Viu EOL_t8_pb|5.033003||Viu EOL_tb|5.035004||Viu EOL_tb_p8|5.033003||Viu EOL_tb_pb|5.033003||Viu EOS|5.005000||Viu EOS_t8|5.035004||Viu EOS_t8_p8|5.033003||Viu EOS_t8_pb|5.033003||Viu EOS_tb|5.035004||Viu EOS_tb_p8|5.033003||Viu EOS_tb_pb|5.033003||Viu ERA|5.027010||Viu ERA_D_FMT|5.027010||Viu ERA_D_T_FMT|5.027010||Viu ERA_T_FMT|5.027010||Viu ERRSV|5.004005|5.003007|p ESC_NATIVE|5.021004||Viu EVAL|5.005000||Viu EVAL_B|5.025010||Viu EVAL_B_fail|5.025010||Viu EVAL_B_fail_t8|5.035004||Viu EVAL_B_fail_t8_p8|5.033003||Viu EVAL_B_fail_t8_pb|5.033003||Viu EVAL_B_fail_tb|5.035004||Viu EVAL_B_fail_tb_p8|5.033003||Viu EVAL_B_fail_tb_pb|5.033003||Viu EVAL_B_t8|5.035004||Viu EVAL_B_t8_p8|5.033003||Viu EVAL_B_t8_pb|5.033003||Viu EVAL_B_tb|5.035004||Viu EVAL_B_tb_p8|5.033003||Viu EVAL_B_tb_pb|5.033003||Viu EVAL_INEVAL|5.006000||Viu EVAL_INREQUIRE|5.007001||Viu EVAL_KEEPERR|5.006000||Viu EVAL_NULL|5.006000||Viu EVAL_postponed_AB|5.025010||Viu EVAL_postponed_AB_fail|5.025010||Viu EVAL_postponed_AB_fail_t8|5.035004||Viu EVAL_postponed_AB_fail_t8_p8|5.033003||Viu EVAL_postponed_AB_fail_t8_pb|5.033003||Viu EVAL_postponed_AB_fail_tb|5.035004||Viu EVAL_postponed_AB_fail_tb_p8|5.033003||Viu EVAL_postponed_AB_fail_tb_pb|5.033003||Viu EVAL_postponed_AB_t8|5.035004||Viu EVAL_postponed_AB_t8_p8|5.033003||Viu EVAL_postponed_AB_t8_pb|5.033003||Viu EVAL_postponed_AB_tb|5.035004||Viu EVAL_postponed_AB_tb_p8|5.033003||Viu EVAL_postponed_AB_tb_pb|5.033003||Viu eval_pv|5.006000|5.003007|p EVAL_RE_REPARSING|5.017011||Viu eval_sv|5.006000|5.003007|p EVAL_t8|5.035004||Viu EVAL_t8_p8|5.033003||Viu EVAL_t8_pb|5.033003||Viu EVAL_tb|5.035004||Viu EVAL_tb_p8|5.033003||Viu EVAL_tb_pb|5.033003||Viu EVAL_WARNONLY|5.006000||Viu EXACT|5.004000||Viu EXACTF|5.004000||Viu EXACTFAA|5.027009||Viu EXACTFAA_NO_TRIE|5.027009||Viu EXACTFAA_NO_TRIE_t8|5.035004||Viu EXACTFAA_NO_TRIE_t8_p8|5.033003||Viu EXACTFAA_NO_TRIE_t8_pb|5.033003||Viu EXACTFAA_NO_TRIE_tb|5.035004||Viu EXACTFAA_NO_TRIE_tb_p8|5.033003||Viu EXACTFAA_NO_TRIE_tb_pb|5.033003||Viu EXACTFAA_t8|5.035004||Viu EXACTFAA_t8_p8|5.033003||Viu EXACTFAA_t8_pb|5.033003||Viu EXACTFAA_tb|5.035004||Viu EXACTFAA_tb_p8|5.033003||Viu EXACTFAA_tb_pb|5.033003||Viu EXACTFL|5.004000||Viu EXACTFL_t8|5.035004||Viu EXACTFL_t8_p8|5.033003||Viu EXACTFL_t8_pb|5.033003||Viu EXACTFL_tb|5.035004||Viu EXACTFL_tb_p8|5.033003||Viu EXACTFL_tb_pb|5.033003||Viu EXACTFLU8|5.021008||Viu EXACTFLU8_t8|5.035004||Viu EXACTFLU8_t8_p8|5.033003||Viu EXACTFLU8_t8_pb|5.033003||Viu EXACTFLU8_tb|5.035004||Viu EXACTFLU8_tb_p8|5.033003||Viu EXACTFLU8_tb_pb|5.033003||Viu EXACTF_t8|5.035004||Viu EXACTF_t8_p8|5.033003||Viu EXACTF_t8_pb|5.033003||Viu EXACTF_tb|5.035004||Viu EXACTF_tb_p8|5.033003||Viu EXACTF_tb_pb|5.033003||Viu EXACTFU|5.013008||Viu EXACTFUP|5.029007||Viu EXACTFUP_t8|5.035004||Viu EXACTFUP_t8_p8|5.033003||Viu EXACTFUP_t8_pb|5.033003||Viu EXACTFUP_tb|5.035004||Viu EXACTFUP_tb_p8|5.033003||Viu EXACTFUP_tb_pb|5.033003||Viu EXACTFU_REQ8|5.031006||Viu EXACTFU_REQ8_t8|5.035004||Viu EXACTFU_REQ8_t8_p8|5.033003||Viu EXACTFU_REQ8_t8_pb|5.033003||Viu EXACTFU_REQ8_tb|5.035004||Viu EXACTFU_REQ8_tb_p8|5.033003||Viu EXACTFU_REQ8_tb_pb|5.033003||Viu EXACTFU_S_EDGE|5.029007||Viu EXACTFU_S_EDGE_t8|5.035004||Viu EXACTFU_S_EDGE_t8_p8|5.033003||Viu EXACTFU_S_EDGE_t8_pb|5.033003||Viu EXACTFU_S_EDGE_tb|5.035004||Viu EXACTFU_S_EDGE_tb_p8|5.033003||Viu EXACTFU_S_EDGE_tb_pb|5.033003||Viu EXACTFU_t8|5.035004||Viu EXACTFU_t8_p8|5.033003||Viu EXACTFU_t8_pb|5.033003||Viu EXACTFU_tb|5.035004||Viu EXACTFU_tb_p8|5.033003||Viu EXACTFU_tb_pb|5.033003||Viu EXACTL|5.021008||Viu EXACTL_t8|5.035004||Viu EXACTL_t8_p8|5.033003||Viu EXACTL_t8_pb|5.033003||Viu EXACTL_tb|5.035004||Viu EXACTL_tb_p8|5.033003||Viu EXACTL_tb_pb|5.033003||Viu EXACT_REQ8|5.031006||Viu EXACT_REQ8_t8|5.035004||Viu EXACT_REQ8_t8_p8|5.033003||Viu EXACT_REQ8_t8_pb|5.033003||Viu EXACT_REQ8_tb|5.035004||Viu EXACT_REQ8_tb_p8|5.033003||Viu EXACT_REQ8_tb_pb|5.033003||Viu EXACT_t8|5.035004||Viu EXACT_t8_p8|5.033003||Viu EXACT_t8_pb|5.033003||Viu EXACT_tb|5.035004||Viu EXACT_tb_p8|5.033003||Viu EXACT_tb_pb|5.033003||Viu EXEC_ARGV_CAST|5.007001||Viu exec_failed|5.009004||Viu execl|5.005000||Viu EXEC_PAT_MOD|5.009005||Viu EXEC_PAT_MODS|5.009005||Viu execute_wildcard|5.031010||Viu execv|5.005000||Viu execvp|5.005000||Viu exit|5.005000||Viu EXPECT|5.009004||Viu expect_number|5.007001||Viu EXT|5.003007||Viu EXTCONST|5.004000||Viu EXTEND|5.003007|5.003007| EXTEND_HWM_SET|5.027002||Viu EXTEND_MORTAL|5.004000||Viu EXTEND_SKIP|5.027002||Viu EXTERN_C|5.005000|5.003007|pV EXT_MGVTBL|5.009004||Viu EXT_PAT_MODS|5.009005||Viu EXTRA_SIZE|5.005000||Viu EXTRA_STEP_2ARGS|5.005000||Viu F0convert|5.009003||Vniu FAKE_BIT_BUCKET|5.009005||Viu FAKE_DEFAULT_SIGNAL_HANDLERS|5.009003||Viu FAKE_PERSISTENT_SIGNAL_HANDLERS|5.009003||Viu FALSE|5.003007||Viu FATAL_ABOVE_FF_MSG|5.027010||Viu F_atan2_amg|5.004000||Viu FBMcf_TAIL|5.006000||Viu FBMcf_TAIL_DOLLAR|5.006000||Viu FBMcf_TAIL_DOLLARM|5.006000||Viu FBMcf_TAIL_Z|5.006000||Viu FBMcf_TAIL_z|5.006000||Viu fbm_compile|5.005000|5.005000| fbm_instr|5.005000|5.005000| FBMrf_MULTILINE|5.006000||Viu fclose|5.003007||Viu fcntl|5.006000||Viu FCNTL_CAN_LOCK|5.007001|5.007001|Vn F_cos_amg|5.004000||Viu FD_CLR|5.008000||Viu FD_ISSET|5.008000||Viu fdopen|5.003007||Viu FD_SET|5.008000||Viu fd_set|5.008000||Viu FD_ZERO|5.008000||Viu FEATURE_BAREWORD_FILEHANDLES_BIT|5.033006||Viu FEATURE_BAREWORD_FILEHANDLES_IS_ENABLED|5.033006||Viu FEATURE_BITWISE_BIT|5.031006||Viu FEATURE_BITWISE_IS_ENABLED|5.021009||Viu FEATURE_BUNDLE_510|5.015007||Viu FEATURE_BUNDLE_511|5.015007||Viu FEATURE_BUNDLE_515|5.015007||Viu FEATURE_BUNDLE_523|5.023001||Viu FEATURE_BUNDLE_527|5.027008||Viu FEATURE_BUNDLE_535|5.035003||Viu FEATURE_BUNDLE_CUSTOM|5.015007||Viu FEATURE_BUNDLE_DEFAULT|5.015007||Viu FEATURE_DEFER_BIT|5.035004||Viu FEATURE_DEFER_IS_ENABLED|5.035004||Viu FEATURE_EVALBYTES_BIT|5.031006||Viu FEATURE_EVALBYTES_IS_ENABLED|5.015007||Viu FEATURE_FC_BIT|5.031006||Viu FEATURE_FC_IS_ENABLED|5.015008||Viu FEATURE_INDIRECT_BIT|5.031010||Viu FEATURE_INDIRECT_IS_ENABLED|5.031010||Viu FEATURE_ISA_BIT|5.031007||Viu FEATURE_ISA_IS_ENABLED|5.031007||Viu FEATURE_IS_ENABLED_MASK|5.031006||Viu FEATURE_MULTIDIMENSIONAL_BIT|5.033001||Viu FEATURE_MULTIDIMENSIONAL_IS_ENABLED|5.033001||Viu FEATURE_MYREF_BIT|5.031006||Viu FEATURE_MYREF_IS_ENABLED|5.025003||Viu FEATURE_POSTDEREF_QQ_BIT|5.031006||Viu FEATURE_POSTDEREF_QQ_IS_ENABLED|5.019005||Viu FEATURE_REFALIASING_BIT|5.031006||Viu FEATURE_REFALIASING_IS_ENABLED|5.021005||Viu FEATURE_SAY_BIT|5.031006||Viu FEATURE_SAY_IS_ENABLED|5.015007||Viu FEATURE_SIGNATURES_BIT|5.031006||Viu FEATURE_SIGNATURES_IS_ENABLED|5.019009||Viu FEATURE_STATE_BIT|5.031006||Viu FEATURE_STATE_IS_ENABLED|5.015007||Viu FEATURE___SUB___BIT|5.031006||Viu FEATURE___SUB___IS_ENABLED|5.015007||Viu FEATURE_SWITCH_BIT|5.031006||Viu FEATURE_SWITCH_IS_ENABLED|5.015007||Viu FEATURE_TRY_BIT|5.033007||Viu FEATURE_TRY_IS_ENABLED|5.033007||Viu FEATURE_UNICODE_BIT|5.031006||Viu FEATURE_UNICODE_IS_ENABLED|5.015007||Viu FEATURE_UNIEVAL_BIT|5.031006||Viu FEATURE_UNIEVAL_IS_ENABLED|5.015007||Viu feof|5.003007||Viu ferror|5.003007||Viu FETCHFEATUREBITSHH|5.031006||Viu F_exp_amg|5.004000||Viu FF_0DECIMAL|5.007001||Viu FF_BLANK|5.003007||Viu FF_CHECKCHOP|5.003007||Viu FF_CHECKNL|5.003007||Viu FF_CHOP|5.003007||Viu FF_DECIMAL|5.003007||Viu FF_END|5.003007||Viu FF_FETCH|5.003007||Viu FF_HALFSPACE|5.003007||Viu FF_ITEM|5.003007||Viu FF_LINEGLOB|5.003007||Viu FF_LINEMARK|5.003007||Viu FF_LINESNGL|5.009001||Viu FF_LITERAL|5.003007||Viu Fflush|5.003007||Viu fflush|5.003007||Viu FFLUSH_NULL|5.006000|5.006000|Vn FF_MORE|5.003007||Viu FF_NEWLINE|5.003007||Viu FF_SKIP|5.003007||Viu FF_SPACE|5.003007||Viu fgetc|5.003007||Viu fgetpos|5.003007||Viu fgets|5.003007||Viu FILE|5.003007||Viu FILE_base|5.007000|5.007000| FILE_bufsiz|5.007000|5.007000| FILE_cnt|5.007000|5.007000| fileno|5.003007||Viu FILE_ptr|5.007000|5.007000| FILL_ADVANCE_NODE_2L_ARG|5.021005||Viu FILL_ADVANCE_NODE|5.005000||Viu FILL_ADVANCE_NODE_ARG|5.005000||Viu FILL_ADVANCE_NODE_ARGp|5.031010||Viu FILL_NODE|5.029004||Viu filter_add|5.003007|5.003007| FILTER_DATA|5.003007||Viu filter_del|5.003007|5.003007|u filter_gets|5.005000||Viu FILTER_ISREADER|5.003007||Viu filter_read|5.003007|5.003007| FILTER_READ|5.003007||Viu finalize_op|5.015002||Viu finalize_optree|5.015002||Vi find_and_forget_pmops|5.009005||Viu find_array_subscript|5.009004||Viu find_beginning|5.005000||Viu find_byclass|5.006000||Viu find_default_stash|5.019004||Viu find_first_differing_byte_pos|5.031007||Vniu find_hash_subscript|5.009004||Viu find_in_my_stash|5.006001||Viu find_lexical_cv|5.019001||Viu find_next_masked|5.027009||Vniu find_runcv|5.009005|5.009005| FIND_RUNCV_level_eq|5.017002||Viu FIND_RUNCV_padid_eq|5.017004||Viu find_runcv_where|5.017002||Viu find_rundefsv|5.013002|5.013002| find_rundefsvoffset|5.009002|5.009002|d find_script|5.004005||Viu find_span_end|5.027009||Vniu find_span_end_mask|5.027009||Vniu find_uninit_var|5.009002||xVi FIRST_NON_ASCII_DECIMAL_DIGIT|5.027007||Viu first_symbol|5.009003||Vniu FITS_IN_8_BITS|5.013005||Viu fixup_errno_string|5.019007||Viu FLAGS|5.013006||Viu FLEXFILENAMES|5.003007|5.003007|Vn float_end_shift|5.009005||Viu float_max_offset|5.005000||Viu float_min_offset|5.005000||Viu float_substr|5.005000||Viu float_utf8|5.008000||Viu flock|5.005000||Viu flockfile|5.003007||Viu F_log_amg|5.004000||Viu FmLINES|5.003007||Viu fold_constants|5.003007||Viu foldEQ|5.013002|5.013002|n foldEQ_latin1|5.013008||cVnu foldEQ_latin1_s2_folded|5.029007||Vniu foldEQ_locale|5.013002|5.013002|n FOLDEQ_LOCALE|5.019009||cV FOLDEQ_S1_ALREADY_FOLDED|5.015004||cV FOLDEQ_S1_FOLDS_SANE|5.021008||cV FOLDEQ_S2_ALREADY_FOLDED|5.015004||cV FOLDEQ_S2_FOLDS_SANE|5.021008||cV foldEQ_utf8|5.013002|5.007003|p foldEQ_utf8_flags|5.013010||cVu FOLDEQ_UTF8_NOMIX_ASCII|5.013010||cV FOLD_FLAGS_FULL|5.015006||Viu FOLD_FLAGS_LOCALE|5.015006||Viu FOLD_FLAGS_NOMIX_ASCII|5.017000||Viu fopen|5.003007||Viu forbid_setid|5.005000||Viu force_ident|5.003007||Viu force_ident_maybe_lex|5.017004||Viu force_list|5.003007||Viu force_next|5.003007||Viu _force_out_malformed_utf8_message|5.025009||cVu force_strict_version|5.011004||Viu force_version|5.005000||Viu force_word|5.003007||Viu forget_pmop|5.017007||Viu form|5.004000||vV form_alien_digit_msg|5.031009||cViu form_cp_too_large_msg|5.031009||cViu form_nocontext|5.006000||vVn fp_dup|5.007003|5.007003|u Fpos_t|5.003007|5.003007|Vn F_pow_amg|5.004000||Viu FP_PINF|5.021004||Viu FP_QNAN|5.021004||Viu fprintf|5.003007||Viu fprintf_nocontext|5.006000||vdVnu FPTR2DPTR|5.009003||Viu fputc|5.003007||Viu fputs|5.003007||Viu fread|5.003007||Viu free|5.003007||Viu free_and_set_cop_warnings|5.031011||Viu free_c_backtrace|5.021001||Vi FreeOp|5.008001||Viu Free_t|5.003007|5.003007|Vn FREE_THREAD_KEY|5.006001||Viu free_tied_hv_pool|5.008001||Viu FREETMPS|5.003007|5.003007| free_tmps|5.003007||cVu freopen|5.003007||Viu frewind|5.005000||Viu FROM_INTERNAL_SIZE|5.023002||Viu fscanf|5.003007||Viu fseek|5.003007||Viu FSEEKSIZE|5.006000||Viu fsetpos|5.003007||Viu F_sin_amg|5.004000||Viu F_sqrt_amg|5.004000||Viu Fstat|5.003007||Viu fstat|5.005000||Viu ftell|5.003007||Viu ftruncate|5.006000||Viu ftrylockfile|5.003007||Viu FUNCTION|5.009003||Viu funlockfile|5.003007||Viu fwrite1|5.003007||Viu fwrite|5.003007||Viu G_ARRAY|5.003007||Viu GCB_BREAKABLE|5.025003||Viu GCB_EX_then_EM|5.025003||Viu GCB_Maybe_Emoji_NonBreak|5.029002||Viu GCB_NOBREAK|5.025003||Viu GCB_RI_then_RI|5.025003||Viu GCC_DIAG_IGNORE|5.019007||Viu GCC_DIAG_IGNORE_DECL|5.027007||Viu GCC_DIAG_IGNORE_STMT|5.027007||Viu GCC_DIAG_PRAGMA|5.021001||Viu GCC_DIAG_RESTORE|5.019007||Viu GCC_DIAG_RESTORE_DECL|5.027007||Viu GCC_DIAG_RESTORE_STMT|5.027007||Viu Gconvert|5.003007|5.003007| GDBMNDBM_H_USES_PROTOTYPES|5.032001|5.032001|Vn G_DISCARD|5.003007|5.003007| gen_constant_list|5.003007||Viu get_and_check_backslash_N_name|5.017006||cViu get_and_check_backslash_N_name_wrapper|5.029009||Viu get_ANYOF_cp_list_for_ssc|5.019005||Viu get_ANYOFM_contents|5.027009||Viu GETATARGET|5.003007||Viu get_aux_mg|5.011000||Viu get_av|5.006000|5.003007|p getc|5.003007||Viu get_c_backtrace|5.021001||Vi get_c_backtrace_dump|5.021001||V get_context|5.006000|5.006000|nu getc_unlocked|5.003007||Viu get_cv|5.006000|5.003007|p get_cvn_flags|5.009005|5.003007|p get_cvs|5.011000|5.003007|p getcwd_sv|5.007002|5.007002| get_db_sub|||iu get_debug_opts|5.008001||Viu get_deprecated_property_msg|5.031011||cVniu getegid|5.005000||Viu getenv|5.005000||Viu getenv_len|5.006000||Viu GETENV_LOCK|5.033005||Viu GETENV_PRESERVES_OTHER_THREAD|5.033005|5.033005|Vn GETENV_UNLOCK|5.033005||Viu geteuid|5.005000||Viu getgid|5.005000||Viu getgrent|5.009000||Viu GETGRENT_R_HAS_BUFFER|5.008000||Viu GETGRENT_R_HAS_FPTR|5.008000||Viu GETGRENT_R_HAS_PTR|5.008000||Viu GETGRENT_R_PROTO|5.008000|5.008000|Vn getgrgid|5.009000||Viu GETGRGID_R_HAS_BUFFER|5.008000||Viu GETGRGID_R_HAS_PTR|5.008000||Viu GETGRGID_R_PROTO|5.008000|5.008000|Vn getgrnam|5.009000||Viu GETGRNAM_R_HAS_BUFFER|5.008000||Viu GETGRNAM_R_HAS_PTR|5.008000||Viu GETGRNAM_R_PROTO|5.008000|5.008000|Vn get_hash_seed|5.008001||Viu gethostbyaddr|5.005000||Viu GETHOSTBYADDR_R_HAS_BUFFER|5.008000||Viu GETHOSTBYADDR_R_HAS_ERRNO|5.008000||Viu GETHOSTBYADDR_R_HAS_PTR|5.008000||Viu GETHOSTBYADDR_R_PROTO|5.008000|5.008000|Vn gethostbyname|5.005000||Viu GETHOSTBYNAME_R_HAS_BUFFER|5.008000||Viu GETHOSTBYNAME_R_HAS_ERRNO|5.008000||Viu GETHOSTBYNAME_R_HAS_PTR|5.008000||Viu GETHOSTBYNAME_R_PROTO|5.008000|5.008000|Vn gethostent|5.005000||Viu GETHOSTENT_R_HAS_BUFFER|5.008000||Viu GETHOSTENT_R_HAS_ERRNO|5.008000||Viu GETHOSTENT_R_HAS_PTR|5.008000||Viu GETHOSTENT_R_PROTO|5.008000|5.008000|Vn gethostname|5.005000||Viu get_hv|5.006000|5.003007|p get_invlist_iter_addr|5.015001||Vniu get_invlist_offset_addr|5.019002||Vniu get_invlist_previous_index_addr|5.017004||Vniu getlogin|5.005000||Viu GETLOGIN_R_PROTO|5.008000|5.008000|Vn get_mstats|5.006000||Vu getnetbyaddr|5.005000||Viu GETNETBYADDR_R_HAS_BUFFER|5.008000||Viu GETNETBYADDR_R_HAS_ERRNO|5.008000||Viu GETNETBYADDR_R_HAS_PTR|5.008000||Viu GETNETBYADDR_R_PROTO|5.008000|5.008000|Vn getnetbyname|5.005000||Viu GETNETBYNAME_R_HAS_BUFFER|5.008000||Viu GETNETBYNAME_R_HAS_ERRNO|5.008000||Viu GETNETBYNAME_R_HAS_PTR|5.008000||Viu GETNETBYNAME_R_PROTO|5.008000|5.008000|Vn getnetent|5.005000||Viu GETNETENT_R_HAS_BUFFER|5.008000||Viu GETNETENT_R_HAS_ERRNO|5.008000||Viu GETNETENT_R_HAS_PTR|5.008000||Viu GETNETENT_R_PROTO|5.008000|5.008000|Vn get_no_modify|5.005000||Viu get_num|5.008001||Viu get_opargs|5.005000||Viu get_op_descs|5.005000|5.005000|u get_op_names|5.005000|5.005000|u getpeername|5.005000||Viu getpid|5.006000||Viu get_ppaddr|5.006000|5.006000|u get_prop_definition|5.031011||cViu get_prop_values|5.031011||cVniu getprotobyname|5.005000||Viu GETPROTOBYNAME_R_HAS_BUFFER|5.008000||Viu GETPROTOBYNAME_R_HAS_PTR|5.008000||Viu GETPROTOBYNAME_R_PROTO|5.008000|5.008000|Vn getprotobynumber|5.005000||Viu GETPROTOBYNUMBER_R_HAS_BUFFER|5.008000||Viu GETPROTOBYNUMBER_R_HAS_PTR|5.008000||Viu GETPROTOBYNUMBER_R_PROTO|5.008000|5.008000|Vn getprotoent|5.005000||Viu GETPROTOENT_R_HAS_BUFFER|5.008000||Viu GETPROTOENT_R_HAS_PTR|5.008000||Viu GETPROTOENT_R_PROTO|5.008000|5.008000|Vn getpwent|5.009000||Viu GETPWENT_R_HAS_BUFFER|5.008000||Viu GETPWENT_R_HAS_FPTR|5.008000||Viu GETPWENT_R_HAS_PTR|5.008000||Viu GETPWENT_R_PROTO|5.008000|5.008000|Vn getpwnam|5.009000||Viu GETPWNAM_R_HAS_BUFFER|5.008000||Viu GETPWNAM_R_HAS_PTR|5.008000||Viu GETPWNAM_R_PROTO|5.008000|5.008000|Vn getpwuid|5.009000||Viu GETPWUID_R_HAS_PTR|5.008000||Viu GETPWUID_R_PROTO|5.008000|5.008000|Vn get_quantifier_value|5.033006||Viu get_re_arg|||xciu get_re_gclass_nonbitmap_data|5.031011||Viu get_regclass_nonbitmap_data|5.031011||Viu get_regex_charset_name|5.031004||Vniu getservbyname|5.005000||Viu GETSERVBYNAME_R_HAS_BUFFER|5.008000||Viu GETSERVBYNAME_R_HAS_PTR|5.008000||Viu GETSERVBYNAME_R_PROTO|5.008000|5.008000|Vn getservbyport|5.005000||Viu GETSERVBYPORT_R_HAS_BUFFER|5.008000||Viu GETSERVBYPORT_R_HAS_PTR|5.008000||Viu GETSERVBYPORT_R_PROTO|5.008000|5.008000|Vn getservent|5.005000||Viu GETSERVENT_R_HAS_BUFFER|5.008000||Viu GETSERVENT_R_HAS_PTR|5.008000||Viu GETSERVENT_R_PROTO|5.008000|5.008000|Vn getsockname|5.005000||Viu getsockopt|5.005000||Viu getspnam|5.009000||Viu GETSPNAM_R_HAS_BUFFER|5.031011||Viu GETSPNAM_R_HAS_PTR|5.008000||Viu GETSPNAM_R_PROTO|5.008000|5.008000|Vn get_sv|5.006000|5.003007|p GETTARGET|5.003007||Viu GETTARGETSTACKED|5.003007||Viu gettimeofday|5.008000||Viu getuid|5.005000||Viu get_vtbl|5.005003|5.005003|u getw|5.003007||Viu G_EVAL|5.003007|5.003007| G_FAKINGEVAL|5.009004||Viu Gid_t|5.003007|5.003007|Vn Gid_t_f|5.006000|5.006000|Vn Gid_t_sign|5.006000|5.006000|Vn Gid_t_size|5.006000|5.006000|Vn GIMME|5.003007|5.003007|d GIMME_V|5.004000|5.004000| gimme_V|5.031005||xcVu G_KEEPERR|5.003007|5.003007| G_LIST|5.035001|5.003007| glob_2number|5.009004||Viu GLOBAL_PAT_MOD|5.009005||Viu glob_assign_glob|5.009004||Viu G_METHOD|5.006001|5.003007|p G_METHOD_NAMED|5.019002|5.019002| gmtime|5.031011||Viu GMTIME_MAX|5.010001|5.010001|Vn GMTIME_MIN|5.010001|5.010001|Vn GMTIME_R_PROTO|5.008000|5.008000|Vn G_NOARGS|5.003007|5.003007| G_NODEBUG|5.004005||Viu GOSUB|5.009005||Viu GOSUB_t8|5.035004||Viu GOSUB_t8_p8|5.033003||Viu GOSUB_t8_pb|5.033003||Viu GOSUB_tb|5.035004||Viu GOSUB_tb_p8|5.033003||Viu GOSUB_tb_pb|5.033003||Viu gp_dup|5.007003|5.007003|u gp_free|5.003007|5.003007|u GPOS|5.004000||Viu GPOS_t8|5.035004||Viu GPOS_t8_p8|5.033003||Viu GPOS_t8_pb|5.033003||Viu GPOS_tb|5.035004||Viu GPOS_tb_p8|5.033003||Viu GPOS_tb_pb|5.033003||Viu gp_ref|5.003007|5.003007|u GREEK_CAPITAL_LETTER_MU|5.013011||Viu GREEK_SMALL_LETTER_MU|5.013008||Viu G_RE_REPARSING|5.017011||Viu G_RETHROW|5.031002|5.003007|p grok_atoUV|5.021010||cVni grok_bin|5.007003|5.003007|p grok_bin_oct_hex|5.031008||cVu grok_bslash_c|5.013001||cViu grok_bslash_N|5.017003||Viu grok_bslash_o|5.013003||cViu grok_bslash_x|5.017002||cViu grok_hex|5.007003|5.003007|p grok_infnan|5.021004|5.021004| grok_number|5.007002|5.003007|p grok_number_flags|5.021002|5.021002| GROK_NUMERIC_RADIX|5.007002|5.003007|p grok_numeric_radix|5.007002|5.003007|p grok_oct|5.007003|5.003007|p group_end|5.007003||Viu GROUPP|5.005000||Viu GROUPPN|5.031001||Viu GROUPPN_t8|5.035004||Viu GROUPPN_t8_p8|5.033003||Viu GROUPPN_t8_pb|5.033003||Viu GROUPPN_tb|5.035004||Viu GROUPPN_tb_p8|5.033003||Viu GROUPPN_tb_pb|5.033003||Viu GROUPP_t8|5.035004||Viu GROUPP_t8_p8|5.033003||Viu GROUPP_t8_pb|5.033003||Viu GROUPP_tb|5.035004||Viu GROUPP_tb_p8|5.033003||Viu GROUPP_tb_pb|5.033003||Viu Groups_t|5.003007|5.003007|Vn GRPASSWD|5.005000|5.005000|Vn G_SCALAR|5.003007|5.003007| G_UNDEF_FILL|5.013001||Viu GV_ADD|5.003007|5.003007| gv_add_by_type|5.011000|5.011000|u GV_ADDMG|5.015003|5.015003| GV_ADDMULTI|5.003007|5.003007| GV_ADDWARN|5.003007|5.003007| Gv_AMG|5.003007||Viu Gv_AMupdate|5.011000|5.011000|u GvASSUMECV|5.003007||Viu GvASSUMECV_off|5.003007||Viu GvASSUMECV_on|5.003007||Viu gv_autoload4|5.004000|5.004000| GV_AUTOLOAD|5.011000||Viu GV_AUTOLOAD_ISMETHOD|5.015004||Viu gv_autoload_pv|5.015004|5.015004|u gv_autoload_pvn|5.015004|5.015004|u gv_autoload_sv|5.015004|5.015004|u GvAV|5.003007|5.003007| gv_AVadd|5.003007|5.003007|u GvAVn|5.003007||Viu GV_CACHE_ONLY|5.021004||Vi gv_check|5.003007||cVu gv_const_sv|5.009003|5.009003| GV_CROAK|5.011000||Viu GvCV|5.003007|5.003007| GvCVGEN|5.003007||Viu GvCV_set|5.013010||Viu GvCVu|5.004000||Viu gv_dump|5.006000|5.006000|u gv_efullname3|5.003007|5.003007|u gv_efullname4|5.006001|5.006001|u gv_efullname|5.003007|5.003007|du GvEGV|5.003007||Viu GvEGVx|5.013000||Viu GvENAME|5.003007||Viu GvENAME_HEK|5.015004||Viu GvENAMELEN|5.015004||Viu GvENAMEUTF8|5.015004||Viu GvESTASH|5.003007||Viu GVf_ASSUMECV|5.003007||Viu gv_fetchfile|5.003007|5.003007| gv_fetchfile_flags|5.009005|5.009005| gv_fetchmeth|5.003007|5.003007| gv_fetchmeth_autoload|5.007003|5.007003| gv_fetchmeth_internal|5.021007||Viu gv_fetchmethod|5.003007|5.003007| gv_fetchmethod_autoload|5.004000|5.004000| gv_fetchmethod_flags|5.015004||Viu gv_fetchmethod_pv_flags|5.015004|5.015004|xu gv_fetchmethod_pvn_flags|5.015004|5.015004|xu gv_fetchmethod_sv_flags|5.015004|5.015004|xu gv_fetchmeth_pv|5.015004|5.015004| gv_fetchmeth_pv_autoload|5.015004|5.015004| gv_fetchmeth_pvn|5.015004|5.015004| gv_fetchmeth_pvn_autoload|5.015004|5.015004| gv_fetchmeth_sv|5.015004|5.015004| gv_fetchmeth_sv_autoload|5.015004|5.015004| gv_fetchpv|5.003007|5.003007| gv_fetchpvn|5.013006|5.013006| gv_fetchpvn_flags|5.009002|5.003007|p gv_fetchpvs|5.009004|5.003007|p gv_fetchsv|5.009002|5.003007|p gv_fetchsv_nomg|5.015003|5.015003| GvFILE|5.006000||Viu GvFILEGV|5.003007||Viu GvFILE_HEK|5.009004||Viu GvFILEx|5.019006||Viu GVf_IMPORTED|5.003007||Viu GVf_IMPORTED_AV|5.003007||Viu GVf_IMPORTED_CV|5.003007||Viu GVf_IMPORTED_HV|5.003007||Viu GVf_IMPORTED_SV|5.003007||Viu GVf_INTRO|5.003007||Viu GvFLAGS|5.003007||Viu GVf_MULTI|5.003007||Viu GVF_NOADD|5.035006||Viu GvFORM|5.003007||Viu gv_fullname3|5.003007|5.003007|u gv_fullname4|5.006001|5.006001|u gv_fullname|5.003007|5.003007|du GvGP|5.003007||Viu GvGPFLAGS|5.021004||Viu GvGP_set|5.013010||Viu gv_handler|5.007001|5.007001|u GvHV|5.003007|5.003007| gv_HVadd|5.003007|5.003007|u GvHVn|5.003007||Viu GvIMPORTED|5.003007||Viu GvIMPORTED_AV|5.003007||Viu GvIMPORTED_AV_off|5.003007||Viu GvIMPORTED_AV_on|5.003007||Viu GvIMPORTED_CV|5.003007||Viu GvIMPORTED_CV_off|5.003007||Viu GvIMPORTED_CV_on|5.003007||Viu GvIMPORTED_HV|5.003007||Viu GvIMPORTED_HV_off|5.003007||Viu GvIMPORTED_HV_on|5.003007||Viu GvIMPORTED_off|5.003007||Viu GvIMPORTED_on|5.003007||Viu GvIMPORTED_SV|5.003007||Viu GvIMPORTED_SV_off|5.003007||Viu GvIMPORTED_SV_on|5.003007||Viu gv_init|5.003007|5.003007| gv_init_pv|5.015004|5.015004| gv_init_pvn|5.015004|5.003007|p gv_init_sv|5.015004|5.015004| gv_init_svtype|5.015004||Viu GvIN_PAD|5.006000||Viu GvIN_PAD_off|5.006000||Viu GvIN_PAD_on|5.006000||Viu GvINTRO|5.003007||Viu GvINTRO_off|5.003007||Viu GvINTRO_on|5.003007||Viu GvIO|5.003007||Viu gv_IOadd|5.003007|5.003007|u GvIOn|5.003007||Viu GvIOp|5.003007||Viu gv_is_in_main|5.019004||Viu GvLINE|5.003007||Viu gv_magicalize|5.019004||Viu gv_magicalize_isa|5.013005||Viu gv_method_changed|5.017007||Viu GvMULTI|5.003007||Viu GvMULTI_off|5.003007||Viu GvMULTI_on|5.003007||Viu GvNAME|5.003007||Viu GvNAME_get|5.009004||Viu GvNAME_HEK|5.009004||Viu GvNAMELEN|5.003007||Viu GvNAMELEN_get|5.009004||Viu gv_name_set|5.009004|5.009004|u GvNAMEUTF8|5.015004||Viu GV_NOADD_MASK|5.009005||Viu GV_NOADD_NOINIT|5.009003|5.009003| GV_NOEXPAND|5.009003|5.009003| GV_NOINIT|5.004005|5.004005| GV_NO_SVGMAGIC|5.015003|5.015003| GV_NOTQUAL|5.009004|5.009004| GV_NOUNIVERSAL|5.033009||Viu G_VOID|5.004000|5.004000| gv_override|5.019006||Viu GvREFCNT|5.003007||Viu gv_setref|5.021005||Viu GvSTASH|5.003007||Viu gv_stashpv|5.003007|5.003007| gv_stashpvn|5.003007|5.003007|p gv_stashpvn_internal|5.021004||Viu gv_stashpvs|5.009003|5.003007|p gv_stashsv|5.003007|5.003007| gv_stashsvpvn_cached|5.021004||Vi GV_SUPER|5.017004|5.017004| GvSV|5.003007|5.003007| gv_SVadd|5.011000||Vu GvSVn|5.009003|5.003007|p gv_try_downgrade|5.011002||xcVi GvXPVGV|5.003007||Viu G_WANT|5.010001||Viu G_WARN_ALL_MASK|5.006000||Viu G_WARN_ALL_OFF|5.006000||Viu G_WARN_ALL_ON|5.006000||Viu G_WARN_OFF|5.006000||Viu G_WARN_ON|5.006000||Viu G_WARN_ONCE|5.006000||Viu G_WRITING_TO_STDERR|5.013009||Viu handle_named_backref|5.023008||Viu handle_names_wildcard|5.031011||Viu handle_possible_posix|5.023008||Viu handle_regex_sets|5.017009||Viu handle_user_defined_property|5.029008||Viu HAS_ACCEPT4|5.027008|5.027008|Vn HAS_ACCESS|5.006000|5.006000|Vn HAS_ACOSH|5.021004|5.021004|Vn HAS_ALARM|5.003007|5.003007|Vn HAS_ASCTIME_R|5.010000|5.010000|Vn HAS_ASINH|5.021006|5.021006|Vn HAS_ATANH|5.021006|5.021006|Vn HAS_ATOLL|5.006000|5.006000|Vn HASATTRIBUTE_ALWAYS_INLINE|5.031007|5.031007|Vn HASATTRIBUTE_DEPRECATED|5.010001|5.010001|Vn HASATTRIBUTE_FORMAT|5.009003|5.009003|Vn HASATTRIBUTE_MALLOC|5.009003|5.009003|Vn HASATTRIBUTE_NONNULL|5.009003|5.009003|Vn HASATTRIBUTE_NORETURN|5.009003|5.009003|Vn HASATTRIBUTE_PURE|5.009003|5.009003|Vn HASATTRIBUTE_UNUSED|5.009003|5.009003|Vn HASATTRIBUTE_WARN_UNUSED_RESULT|5.009003|5.009003|Vn HAS_BACKTRACE|5.021001|5.021001|Vn HAS_BUILTIN_CHOOSE_EXPR|5.009004|5.009004|Vn HAS_BUILTIN_EXPECT|5.010001|5.010001|Vn HAS_BUILTIN_UNREACHABLE|5.033003||Viu HAS_C99|5.021004||Viu HAS_C99_VARIADIC_MACROS|5.009004|5.009004|Vn HAS_CBRT|5.021006|5.021006|Vn HAS_CF_AUX_TABLES|5.027011||Viu HAS_CHOWN|5.003007|5.003007|Vn HAS_CHROOT|5.003007|5.003007|Vn HAS_CHSIZE|5.004005|5.004005|Vn HAS_CLEARENV|5.009003|5.009003|Vn HAS_COPYSIGN|5.021006|5.021006|Vn HAS_COPYSIGNL|5.008001|5.008001|Vn HAS_CRYPT|5.003007|5.003007|Vn HAS_CRYPT_R|5.010000|5.010000|Vn HAS_CSH|5.005000|5.005000|Vn HAS_CTERMID|5.009005|5.009005|Vn HAS_CTIME_R|5.010000|5.010000|Vn HAS_CUSERID|5.003007|5.003007|Vn HAS_DBMINIT_PROTO|5.032001|5.032001|Vn HAS_DIFFTIME|5.003007|5.003007|Vn HAS_DIRFD|5.007003|5.007003|Vn HAS_DLADDR|5.021001|5.021001|Vn HAS_DLERROR|5.003007|5.003007|Vn HAS_DRAND48_PROTO|5.006000|5.006000|Vn HAS_DRAND48_R|5.010000|5.010000|Vn HAS_DUP2|5.003007|5.003007|Vn HAS_DUP3|5.027008|5.027008|Vn HAS_DUPLOCALE|5.027011|5.027011|Vn HAS_EACCESS|5.006000|5.006000|Vn HAS_ENDGRENT|5.005000|5.005000|Vn HAS_ENDHOSTENT|5.005000|5.005000|Vn HAS_ENDNETENT|5.005000|5.005000|Vn HAS_ENDPROTOENT|5.005000|5.005000|Vn HAS_ENDPWENT|5.005000|5.005000|Vn HAS_ENDSERVENT|5.005000|5.005000|Vn HAS_ERF|5.021006|5.021006|Vn HAS_ERFC|5.021006|5.021006|Vn HAS_EXP2|5.021006|5.021006|Vn HAS_EXPM1|5.021006|5.021006|Vn HAS_EXTRA_LONG_UTF8|5.035004||Viu HAS_FAST_STDIO|5.008001|5.008001|Vn HAS_FCHDIR|5.007002|5.007002|Vn HAS_FCHMOD|5.003007|5.003007|Vn HAS_FCHMODAT|5.027004|5.027004|Vn HAS_FCHOWN|5.003007|5.003007|Vn HAS_FCNTL|5.003007|5.003007|Vn HAS_FDIM|5.021006|5.021006|Vn HAS_FD_SET|5.006000|5.006000|Vn HAS_FEGETROUND|5.021004|5.021004|Vn HAS_FFS|5.035001|5.035001|Vn HAS_FFSL|5.035001|5.035001|Vn HAS_FGETPOS|5.003007|5.003007|Vn HAS_FINITE|5.007003|5.007003|Vn HAS_FINITEL|5.007003|5.007003|Vn HAS_FLOCK|5.003007|5.003007|Vn HAS_FLOCK_PROTO|5.007002|5.007002|Vn HAS_FMA|5.021006|5.021006|Vn HAS_FMAX|5.021006|5.021006|Vn HAS_FMIN|5.021006|5.021006|Vn HAS_FORK|5.003007|5.003007|Vn HAS_FPATHCONF|5.003007|5.003007|Vn HAS_FPCLASSIFY|5.021004|5.021004|Vn HAS_FREELOCALE|5.023009|5.023009|Vn HAS_FREXPL|5.006001|5.006001|Vn HAS_FSEEKO|5.006000|5.006000|Vn HAS_FSETPOS|5.003007|5.003007|Vn HAS_FSTATFS|5.023005|5.023005|Vn HAS_FSTATVFS|5.023005|5.023005|Vn HAS_FSYNC|5.007001|5.007001|Vn HAS_FTELLO|5.006000|5.006000|Vn HAS_FUTIMES|5.009003|5.009003|Vn HAS_GAI_STRERROR|5.025004|5.025004|Vn HAS_GETADDRINFO|5.010001|5.010001|Vn HAS_GETCWD|5.006000|5.006000|Vn HAS_GETGRENT|5.005000|5.005000|Vn HAS_GETGRENT_R|5.010000|5.010000|Vn HAS_GETGRGID_R|5.010000|5.010000|Vn HAS_GETGRNAM_R|5.010000|5.010000|Vn HAS_GETGROUPS|5.003007|5.003007|Vn HAS_GETHOSTBYADDR|5.005000|5.005000|Vn HAS_GETHOSTBYADDR_R|5.010000|5.010000|Vn HAS_GETHOSTBYNAME|5.005000|5.005000|Vn HAS_GETHOSTBYNAME_R|5.010000|5.010000|Vn HAS_GETHOSTENT|5.003007|5.003007|Vn HAS_GETHOSTENT_R|5.010000|5.010000|Vn HAS_GETHOSTNAME|5.006000|5.006000|Vn HAS_GETHOST_PROTOS|5.005000|5.005000|Vn HAS_GETITIMER|5.007001|5.007001|Vn HAS_GETLOGIN|5.003007|5.003007|Vn HAS_GETLOGIN_R|5.010000|5.010000|Vn HAS_GETMNTENT|5.023005|5.023005|Vn HAS_GETNAMEINFO|5.010001|5.010001|Vn HAS_GETNETBYADDR|5.005000|5.005000|Vn HAS_GETNETBYADDR_R|5.010000|5.010000|Vn HAS_GETNETBYNAME|5.005000|5.005000|Vn HAS_GETNETBYNAME_R|5.010000|5.010000|Vn HAS_GETNETENT|5.005000|5.005000|Vn HAS_GETNETENT_R|5.010000|5.010000|Vn HAS_GETNET_PROTOS|5.005000|5.005000|Vn HAS_GETPAGESIZE|5.007001|5.007001|Vn HAS_GETPGID|5.003007|5.003007|Vn HAS_GETPGRP|5.003007|5.003007|Vn HAS_GETPPID|5.003007|5.003007|Vn HAS_GETPRIORITY|5.003007|5.003007|Vn HAS_GETPROTOBYNAME|5.005000|5.005000|Vn HAS_GETPROTOBYNAME_R|5.010000|5.010000|Vn HAS_GETPROTOBYNUMBER|5.005000|5.005000|Vn HAS_GETPROTOBYNUMBER_R|5.010000|5.010000|Vn HAS_GETPROTOENT|5.005000|5.005000|Vn HAS_GETPROTOENT_R|5.010000|5.010000|Vn HAS_GETPROTO_PROTOS|5.005000|5.005000|Vn HAS_GETPWENT|5.005000|5.005000|Vn HAS_GETPWENT_R|5.010000|5.010000|Vn HAS_GETPWNAM_R|5.010000|5.010000|Vn HAS_GETPWUID_R|5.010000|5.010000|Vn HAS_GETSERVBYNAME|5.005000|5.005000|Vn HAS_GETSERVBYNAME_R|5.010000|5.010000|Vn HAS_GETSERVBYPORT|5.005000|5.005000|Vn HAS_GETSERVBYPORT_R|5.010000|5.010000|Vn HAS_GETSERVENT|5.005000|5.005000|Vn HAS_GETSERVENT_R|5.010000|5.010000|Vn HAS_GETSERV_PROTOS|5.005000|5.005000|Vn HAS_GETSPNAM|5.006000|5.006000|Vn HAS_GETSPNAM_R|5.010000|5.010000|Vn HAS_GETTIMEOFDAY|5.004000|5.004000|Vn HAS_GMTIME_R|5.010000|5.010000|Vn HAS_GNULIBC|5.004005|5.004005|Vn HAS_GROUP|5.003007||Viu HAS_HASMNTOPT|5.023005|5.023005|Vn HAS_HTONL|5.003007|5.003007|Vn HAS_HTONS|5.003007|5.003007|Vn HAS_HYPOT|5.021006|5.021006|Vn HAS_ILOGB|5.021006|5.021006|Vn HAS_ILOGBL|5.008001|5.008001|Vn HAS_INET_ATON|5.004000|5.004000|Vn HAS_INETNTOP|5.010001|5.010001|Vn HAS_INETPTON|5.010001|5.010001|Vn HAS_INT64_T|5.006000|5.006000|Vn HAS_IOCTL|5.003007||Viu HAS_IP_MREQ|5.017002|5.017002|Vn HAS_IP_MREQ_SOURCE|5.017004|5.017004|Vn HAS_IPV6_MREQ|5.015008|5.015008|Vn HAS_ISASCII|5.003007|5.003007|Vn HAS_ISBLANK|5.015007|5.015007|Vn HAS_ISFINITE|5.021004|5.021004|Vn HAS_ISINF|5.007003|5.007003|Vn HAS_ISINFL|5.021004|5.021004|Vn HAS_ISLESS|5.031007|5.031007|Vn HAS_ISNAN|5.006001|5.006001|Vn HAS_ISNANL|5.006001|5.006001|Vn HAS_ISNORMAL|5.021006|5.021006|Vn HAS_IVCF_AUX_TABLES|5.027011||Viu HAS_J0|5.021004|5.021004|Vn HAS_J0L|5.021004|5.021004|Vn HAS_KILL|5.003007||Viu HAS_KILLPG|5.003007|5.003007|Vn HAS_LC_AUX_TABLES|5.027011||Viu HAS_LCHOWN|5.005000|5.005000|Vn HAS_LC_MONETARY_2008|5.021005|5.021005|Vn HAS_LDBL_DIG|5.006000|5.006000|Vn HAS_LDEXPL|5.021003|5.021003|Vn HAS_LGAMMA|5.021006|5.021006|Vn HAS_LGAMMA_R|5.021006|5.021006|Vn HAS_LINK|5.003007|5.003007|Vn HAS_LINKAT|5.027004|5.027004|Vn HAS_LLRINT|5.021006|5.021006|Vn HAS_LLRINTL|5.021009|5.021009|Vn HAS_LLROUND|5.021006|5.021006|Vn HAS_LLROUNDL|5.021009|5.021009|Vn HAS_LOCALECONV|5.003007|5.003007|Vn HAS_LOCALTIME_R|5.010000|5.010000|Vn HAS_LOCKF|5.003007|5.003007|Vn HAS_LOG1P|5.021006|5.021006|Vn HAS_LOG2|5.021006|5.021006|Vn HAS_LOGB|5.021006|5.021006|Vn HAS_LONG_DOUBLE|5.005000|5.005000|Vn HAS_LONG_LONG|5.005000|5.005000|Vn HAS_LRINT|5.021006|5.021006|Vn HAS_LRINTL|5.021009|5.021009|Vn HAS_LROUND|5.021006|5.021006|Vn HAS_LROUNDL|5.021009|5.021009|Vn HAS_LSEEK_PROTO|5.006000|5.006000|Vn HAS_LSTAT|5.003007|5.003007|Vn HAS_MADVISE|5.006000|5.006000|Vn HAS_MBLEN|5.003007|5.003007|Vn HAS_MBRLEN|5.027006|5.027006|Vn HAS_MBRTOWC|5.027006|5.027006|Vn HAS_MBSTOWCS|5.003007|5.003007|Vn HAS_MBTOWC|5.003007|5.003007|Vn HAS_MEMMEM|5.024000|5.024000|Vn HAS_MEMRCHR|5.027005|5.027005|Vn HAS_MKDIR|5.003007|5.003007|Vn HAS_MKDTEMP|5.006000|5.006000|Vn HAS_MKFIFO|5.003007|5.003007|Vn HAS_MKOSTEMP|5.027008|5.027008|Vn HAS_MKSTEMP|5.006000|5.006000|Vn HAS_MKSTEMPS|5.006000|5.006000|Vn HAS_MKTIME|5.003007|5.003007|Vn HAS_MMAP|5.006000|5.006000|Vn HAS_MODFL|5.006001|5.006001|Vn HAS_MODFL_PROTO|5.009003|5.009003|Vn HAS_MPROTECT|5.006000|5.006000|Vn HAS_MSG|5.003007|5.003007|Vn HAS_MSYNC|5.006000|5.006000|Vn HAS_MUNMAP|5.006000|5.006000|Vn HAS_NAN|5.021006|5.021006|Vn HAS_NANOSLEEP|5.027006|5.027006|Vn HAS_NEARBYINT|5.021006|5.021006|Vn HAS_NEWLOCALE|5.023009|5.023009|Vn HAS_NEXTAFTER|5.021006|5.021006|Vn HAS_NEXTTOWARD|5.021006|5.021006|Vn HAS_NICE|5.003007|5.003007|Vn HAS_NL_LANGINFO|5.007002|5.007002|Vn HAS_NL_LANGINFO_L|5.035001|5.035001|Vn HAS_NON_INT_BITFIELDS|5.035001|5.035001|Vn HAS_NONLATIN1_FOLD_CLOSURE|5.033005||Viu HAS_NONLATIN1_SIMPLE_FOLD_CLOSURE|5.033005||Viu HAS_NTOHL|5.003007|5.003007|Vn HAS_NTOHS|5.003007|5.003007|Vn HAS_OFF64_T|5.010000|5.010000|Vn HAS_OPEN3|5.003007|5.003007|Vn HAS_OPENAT|5.027004|5.027004|Vn HAS_PASSWD|5.003007||Viu HAS_PATHCONF|5.003007|5.003007|Vn HAS_PAUSE|5.003007|5.003007|Vn HAS_PIPE2|5.027008|5.027008|Vn HAS_PIPE|5.003007|5.003007|Vn HAS_POLL|5.003007|5.003007|Vn HAS_POSIX_2008_LOCALE|5.027003||Viu HAS_PRCTL|5.013000|5.013000|Vn HAS_PRCTL_SET_NAME|5.013000|5.013000|Vn HAS_PROCSELFEXE|5.007003|5.007003|Vn HAS_PTHREAD_ATFORK|5.010000|5.010000|Vn HAS_PTHREAD_ATTR_SETSCOPE|5.008001|5.008001|Vn HAS_PTHREAD_UNCHECKED_GETSPECIFIC_NP|5.007002||Viu HAS_PTHREAD_YIELD|5.009005|5.009005|Vn HAS_PTRDIFF_T|5.021001|5.021001|Vn HAS_QUAD|5.003007|5.003007|Vn HAS_RANDOM_R|5.010000|5.010000|Vn HAS_READDIR|5.003007|5.003007|Vn HAS_READDIR64_R|5.010000|5.010000|Vn HAS_READDIR_R|5.010000|5.010000|Vn HAS_READLINK|5.003007|5.003007|Vn HAS_READV|5.007001|5.007001|Vn HAS_RECVMSG|5.007001|5.007001|Vn HAS_REGCOMP|5.021007|5.021007|Vn HAS_REMAINDER|5.021006|5.021006|Vn HAS_REMQUO|5.021006|5.021006|Vn HAS_RENAME|5.003007|5.003007|Vn HAS_RENAMEAT|5.027004|5.027004|Vn HAS_REWINDDIR|5.003007|5.003007|Vn HAS_RINT|5.021006|5.021006|Vn HAS_RMDIR|5.003007|5.003007|Vn HAS_ROUND|5.021006|5.021006|Vn HAS_SBRK_PROTO|5.007001|5.007001|Vn HAS_SCALBN|5.021006|5.021006|Vn HAS_SCALBNL|5.008001|5.008001|Vn HAS_SCHED_YIELD|5.005000|5.005000|Vn HAS_SCX_AUX_TABLES|5.027008||Viu HAS_SEEKDIR|5.003007|5.003007|Vn HAS_SELECT|5.003007|5.003007|Vn HAS_SEM|5.003007|5.003007|Vn HAS_SENDMSG|5.007001|5.007001|Vn HAS_SETEGID|5.003007|5.003007|Vn HAS_SETEUID|5.003007|5.003007|Vn HAS_SETGRENT|5.005000|5.005000|Vn HAS_SETGROUPS|5.004000|5.004000|Vn HAS_SETHOSTENT|5.005000|5.005000|Vn HAS_SETITIMER|5.007001|5.007001|Vn HAS_SETLINEBUF|5.003007|5.003007|Vn HAS_SETLOCALE|5.003007|5.003007|Vn HAS_SETNETENT|5.005000|5.005000|Vn HAS_SETPGID|5.003007|5.003007|Vn HAS_SETPGRP|5.003007|5.003007|Vn HAS_SETPRIORITY|5.003007|5.003007|Vn HAS_SETPROTOENT|5.005000|5.005000|Vn HAS_SETPWENT|5.005000|5.005000|Vn HAS_SETREGID|5.003007|5.003007|Vn HAS_SETRESGID|5.003007|5.003007|Vn HAS_SETRESGID_PROTO|5.010000|5.010000|Vn HAS_SETRESUID|5.003007|5.003007|Vn HAS_SETRESUID_PROTO|5.010000|5.010000|Vn HAS_SETREUID|5.003007|5.003007|Vn HAS_SETSERVENT|5.005000|5.005000|Vn HAS_SETSID|5.003007|5.003007|Vn HAS_SETVBUF|5.005000|5.005000|Vn HAS_SHM|5.003007|5.003007|Vn HAS_SHMAT_PROTOTYPE|5.003007|5.003007|Vn HAS_SIGACTION|5.003007|5.003007|Vn HAS_SIGINFO_SI_ADDR|5.023008|5.023008|Vn HAS_SIGINFO_SI_BAND|5.023008|5.023008|Vn HAS_SIGINFO_SI_ERRNO|5.023008|5.023008|Vn HAS_SIGINFO_SI_PID|5.023008|5.023008|Vn HAS_SIGINFO_SI_STATUS|5.023008|5.023008|Vn HAS_SIGINFO_SI_UID|5.023008|5.023008|Vn HAS_SIGINFO_SI_VALUE|5.023008|5.023008|Vn HAS_SIGNBIT|5.009005|5.009005|Vn HAS_SIGPROCMASK|5.007001|5.007001|Vn HAS_SIGSETJMP|5.003007|5.003007|Vn HAS_SIN6_SCOPE_ID|5.013009|5.013009|Vn HAS_SKIP_LOCALE_INIT|5.019002||Viu HAS_SNPRINTF|5.009003|5.009003|Vn HAS_SOCKADDR_IN6|5.015008|5.015008|Vn HAS_SOCKADDR_STORAGE|5.032001|5.032001|Vn HAS_SOCKATMARK|5.007001|5.007001|Vn HAS_SOCKATMARK_PROTO|5.007002|5.007002|Vn HAS_SOCKET|5.003007|5.003007|Vn HAS_SOCKETPAIR|5.003007|5.003007|Vn HAS_SQRTL|5.006000|5.006000|Vn HAS_SRAND48_R|5.010000|5.010000|Vn HAS_SRANDOM_R|5.010000|5.010000|Vn HAS_STAT|5.021007|5.021007|Vn HAS_STATIC_INLINE|5.013004|5.013004|Vn HAS_STRCOLL|5.003007|5.003007|Vn HAS_STRERROR_L|5.025002|5.025002|Vn HAS_STRERROR_R|5.010000|5.010000|Vn HAS_STRFTIME|5.007002|5.007002|Vn HAS_STRNLEN|5.027006|5.027006|Vn HAS_STRTOD|5.004000|5.004000|Vn HAS_STRTOD_L|5.027011|5.027011|Vn HAS_STRTOL|5.004000|5.004000|Vn HAS_STRTOLD|5.006000|5.006000|Vn HAS_STRTOLD_L|5.027006|5.027006|Vn HAS_STRTOLL|5.006000|5.006000|Vn HAS_STRTOQ|5.007001|5.007001|Vn HAS_STRTOUL|5.004000|5.004000|Vn HAS_STRTOULL|5.006000|5.006000|Vn HAS_STRTOUQ|5.006000|5.006000|Vn HAS_STRUCT_CMSGHDR|5.007001|5.007001|Vn HAS_STRUCT_MSGHDR|5.007001|5.007001|Vn HAS_STRUCT_STATFS|5.023005|5.023005|Vn HAS_STRUCT_STATFS_F_FLAGS|5.023005|5.023005|Vn HAS_STRXFRM|5.003007|5.003007|Vn HAS_STRXFRM_L|5.035001|5.035001|Vn HAS_SYMLINK|5.003007|5.003007|Vn HAS_SYSCALL|5.003007|5.003007|Vn HAS_SYSCALL_PROTO|5.007002|5.007002|Vn HAS_SYSCONF|5.003007|5.003007|Vn HAS_SYS_ERRLIST|5.003007|5.003007|Vn HAS_SYSTEM|5.003007|5.003007|Vn HAS_TC_AUX_TABLES|5.027011||Viu HAS_TCGETPGRP|5.003007|5.003007|Vn HAS_TCSETPGRP|5.003007|5.003007|Vn HAS_TELLDIR|5.003007|5.003007|Vn HAS_TELLDIR_PROTO|5.006000|5.006000|Vn HAS_TGAMMA|5.021006|5.021006|Vn HAS_THREAD_SAFE_NL_LANGINFO_L|5.027006|5.027006|Vn HAS_TIME|5.008000|5.008000|Vn HAS_TIMEGM|5.010001|5.010001|Vn HAS_TIMES|5.003007|5.003007|Vn HAS_TMPNAM_R|5.010000|5.010000|Vn HAS_TM_TM_GMTOFF|5.008001|5.008001|Vn HAS_TM_TM_ZONE|5.008000|5.008000|Vn HAS_TOWLOWER|5.029009|5.029009|Vn HAS_TOWUPPER|5.029009|5.029009|Vn HAS_TRUNC|5.021006|5.021006|Vn HAS_TRUNCATE|5.003007|5.003007|Vn HAS_TRUNCL|5.021004|5.021004|Vn HAS_TTYNAME_R|5.010000|5.010000|Vn HAS_TZNAME|5.003007|5.003007|Vn HAS_UALARM|5.007001|5.007001|Vn HAS_UC_AUX_TABLES|5.027011||Viu HAS_UMASK|5.003007|5.003007|Vn HAS_UNAME|5.003007|5.003007|Vn HAS_UNLINKAT|5.027004|5.027004|Vn HAS_UNSETENV|5.009003|5.009003|Vn HAS_USELOCALE|5.023009|5.023009|Vn HAS_USLEEP|5.007001|5.007001|Vn HAS_USLEEP_PROTO|5.007002|5.007002|Vn HAS_USTAT|5.023005|5.023005|Vn HAS_UTIME|5.003007||Viu HAS_VSNPRINTF|5.009003|5.009003|Vn HAS_WAIT4|5.003007|5.003007|Vn HAS_WAIT|5.003007||Viu HAS_WAITPID|5.003007|5.003007|Vn HAS_WCRTOMB|5.031007|5.031007|Vn HAS_WCSCMP|5.021001|5.021001|Vn HAS_WCSTOMBS|5.003007|5.003007|Vn HAS_WCSXFRM|5.021001|5.021001|Vn HAS_WCTOMB|5.003007|5.003007|Vn HAS_WRITEV|5.007001|5.007001|Vn HE_ARENA_ROOT_IX|5.035005||Viu he_dup|5.007003|5.007003|u HEf_SVKEY|5.003007|5.003007|p HeHASH|5.003007|5.003007| HEK_BASESIZE|5.004000||Viu hek_dup|5.009000|5.009000|u HeKEY|5.003007|5.003007| HeKEY_hek|5.004000||Viu HeKEY_sv|5.004000||Viu HEKf256|5.015004||Viu HEKf|5.015004||Viu HEKfARG|5.015004||Viu HEK_FLAGS|5.008000||Viu HeKFLAGS|5.008000||Viu HEK_HASH|5.004000||Viu HEK_KEY|5.004000||Viu HeKLEN|5.003007|5.003007| HEK_LEN|5.004000||Viu HeKLEN_UTF8|5.007001||Viu HEK_UTF8|5.007001||Viu HeKUTF8|5.007001||Viu HEK_UTF8_off|5.008000||Viu HEK_UTF8_on|5.008000||Viu HEK_WASUTF8|5.008000||Viu HeKWASUTF8|5.008000||Viu HEK_WASUTF8_off|5.008000||Viu HEK_WASUTF8_on|5.008000||Viu HeNEXT|5.003007||Viu HePV|5.004000|5.004000| HeSVKEY|5.003007|5.003007| HeSVKEY_force|5.003007|5.003007| HeSVKEY_set|5.004000|5.004000| HeUTF8|5.010001|5.008000|p HeVAL|5.003007|5.003007| hfree_next_entry|||iu HIGHEST_ANYOF_HRx_BYTE|5.031002||Viu HIGHEST_CASE_CHANGING_CP|5.033005||Viu HINT_ALL_STRICT|5.033002||Viu HINT_BLOCK_SCOPE|5.003007||Viu HINT_BYTES|5.007002||Viu HINT_EXPLICIT_STRICT_REFS|5.016000||Viu HINT_EXPLICIT_STRICT_SUBS|5.016000||Viu HINT_EXPLICIT_STRICT_VARS|5.016000||Viu HINT_FEATURE_MASK|5.015007||Viu HINT_FEATURE_SHIFT|5.015007||Viu HINT_FILETEST_ACCESS|5.006000||Viu HINT_INTEGER|5.003007||Viu HINT_LEXICAL_IO_IN|5.009005||Viu HINT_LEXICAL_IO_OUT|5.009005||Viu HINT_LOCALE|5.004000||Viu HINT_LOCALE_PARTIAL|5.021001||Viu HINT_LOCALIZE_HH|5.005000||Viu HINT_NEW_BINARY|5.005000||Viu HINT_NEW_FLOAT|5.005000||Viu HINT_NEW_INTEGER|5.005000||Viu HINT_NEW_RE|5.005000||Viu HINT_NEW_STRING|5.005000||Viu HINT_NO_AMAGIC|5.010001||Viu HINT_RE_EVAL|5.005000||Viu HINT_RE_FLAGS|5.013007||Viu HINT_RE_TAINT|5.004005||Viu HINTS_DEFAULT|5.033002||Viu HINTS_REFCNT_INIT|5.009004||Viu HINTS_REFCNT_LOCK|5.009004||Viu HINTS_REFCNT_TERM|5.009004||Viu HINTS_REFCNT_UNLOCK|5.009004||Viu HINT_STRICT_REFS|5.003007||Viu HINT_STRICT_SUBS|5.003007||Viu HINT_STRICT_VARS|5.003007||Viu HINT_UNI_8_BIT|5.011002||Viu HINT_UTF8|5.006000||Viu H_PERL|5.003007||Viu HS_APIVERLEN_MAX|5.021006||Viu HS_CXT|5.021006||Viu HSf_IMP_CXT|5.021006||Viu HSf_NOCHK|5.021006||Viu HSf_POPMARK|5.021006||Viu HSf_SETXSUBFN|5.021006||Viu HS_GETAPIVERLEN|5.021006||Viu HS_GETINTERPSIZE|5.021006||Viu HS_GETXSVERLEN|5.021006||Viu HS_KEY|5.021006||Viu HS_KEYp|5.021006||Viu HSm_APIVERLEN|5.021006||Viu HSm_INTRPSIZE|5.021006||Viu HSm_KEY_MATCH|5.021006||Viu HSm_XSVERLEN|5.021006||Viu hsplit|5.005000||Viu HS_XSVERLEN_MAX|5.021006||Viu htoni|5.003007||Viu htonl|5.003007||Viu htons|5.003007||Viu htovl|5.003007||Viu htovs|5.003007||Viu HvAMAGIC|5.017000||Viu HvAMAGIC_off|5.017000||Viu HvAMAGIC_on|5.017000||Viu HvARRAY|5.003007||Viu hv_assert||| HvAUX|5.009003||Viu hv_auxalloc|||iu HVAUX_ARENA_ROOT_IX|5.035005||Viu HvAUXf_NO_DEREF|5.019010||Viu HvAUXf_SCAN_STASH|5.019010||Viu hv_auxinit|5.009003||Viu hv_backreferences_p|||xiu hv_bucket_ratio|5.025003|5.025003|x hv_clear|5.003007|5.003007| hv_clear_placeholders|5.009001|5.009001| hv_common|5.010000||cVu hv_common_key_len|5.010000||cVu hv_copy_hints_hv|5.013005|5.013005| hv_delayfree_ent|5.004000|5.004000|u hv_delete|5.003007|5.003007| HV_DELETE|5.009005||Viu hv_delete_common|5.009001||xViu hv_delete_ent|5.003007|5.003007| hv_deletehek|5.019006||Viu hv_deletes|5.025006||Viu HV_DISABLE_UVAR_XKEY|5.010000||Viu HvEITER|5.003007||Viu HvEITER_get|5.009003||Viu hv_eiter_p|||u HvEITER_set|5.009003||Viu hv_eiter_set|||u HvENAME|5.013007|5.013007| hv_ename_add|5.013007||Vi hv_ename_delete|5.013007||Vi HvENAME_get|5.013007||Viu HvENAME_HEK|5.013007||Viu HvENAME_HEK_NN|5.013007||Viu HvENAMELEN|5.015004|5.015004| HvENAMELEN_get|5.013007||Viu HvENAMEUTF8|5.015004|5.015004| hv_exists|5.003007|5.003007| hv_exists_ent|5.003007|5.003007| hv_existshek|5.035003||Viu hv_existss|5.025006||Viu hv_fetch|5.003007|5.003007| HV_FETCH_EMPTY_HE|5.013007||Viu hv_fetch_ent|5.003007|5.003007| hv_fetchhek|5.019006||Viu HV_FETCH_ISEXISTS|5.009005||Viu HV_FETCH_ISSTORE|5.009005||Viu HV_FETCH_JUST_SV|5.009005||Viu HV_FETCH_LVALUE|5.009005||Viu hv_fetchs|5.009003|5.003007|p hv_fill||| HvFILL|5.003007|5.003007| hv_free_ent|5.004000|5.004000|u hv_free_ent_ret|5.015000||Viu hv_free_entries|5.027002||Viu HvHASKFLAGS|5.008000||Viu HvHASKFLAGS_off|5.008000||Viu HvHASKFLAGS_on|5.008000||Viu HVhek_ENABLEHVKFLAGS|5.008002||Viu HVhek_FREEKEY|5.008000||Viu HVhek_KEYCANONICAL|5.010001||Viu HVhek_MASK|5.008000||Viu HVhek_PLACEHOLD|5.008000||Viu HVhek_UNSHARED|5.009004||Viu HVhek_UTF8|5.008000||Viu HVhek_WASUTF8|5.008000||Viu hv_iterinit|5.003007|5.003007| hv_iterkey|5.003007|5.003007| hv_iterkeysv|5.003007|5.003007| hv_iternext|5.003007|5.003007| hv_iternext_flags|5.008000|5.008000|x hv_iternextsv|5.003007|5.003007| HV_ITERNEXT_WANTPLACEHOLDERS|5.008000|5.008000| hv_iterval|5.003007|5.003007| HvKEYS|5.003007||Viu hv_kill_backrefs|||xiu hv_ksplit|5.003007|5.003007|u HvLASTRAND_get|5.017011||Viu HvLAZYDEL|5.003007||Viu HvLAZYDEL_off|5.003007||Viu HvLAZYDEL_on|5.003007||Viu hv_magic|5.003007|5.003007| hv_magic_check|5.006000||Vniu HvMAX|5.003007||Viu HvMROMETA|5.010001|5.010001| HvNAME|5.003007|5.003007| HvNAME_get|5.009003||pcV HvNAME_HEK|5.009003||Viu HvNAME_HEK_NN|5.013007||Viu HvNAMELEN|5.015004|5.015004| HvNAMELEN_get|5.009003|5.003007|p hv_name_set|5.009003|5.009003|u HV_NAME_SETALL|5.013008||Viu hv_name_sets|5.025006||Viu HvNAMEUTF8|5.015004|5.015004| hv_notallowed|5.008000||Viu HvPLACEHOLDERS|5.007003||Viu HvPLACEHOLDERS_get|5.009003||Viu hv_placeholders_get|||u hv_placeholders_p|||ciu HvPLACEHOLDERS_set|5.009003||Viu hv_placeholders_set|||u hv_pushkv|5.027003||Viu HvRAND_get|5.017011||Viu hv_rand_set|5.018000|5.018000|u HVrhek_delete|5.009004||Viu HVrhek_IV|5.009004||Viu HVrhek_PV|5.009004||Viu HVrhek_PV_UTF8|5.009005||Viu HVrhek_typemask|5.009004||Viu HVrhek_undef|5.009004||Viu HVrhek_UV|5.009004||Viu HvRITER|5.003007||Viu HvRITER_get|5.009003||Viu hv_riter_p|||u HvRITER_set|5.009003||Viu hv_riter_set|||u hv_scalar|5.009001|5.009001| HvSHAREKEYS|5.003007||Viu HvSHAREKEYS_off|5.003007||Viu HvSHAREKEYS_on|5.003007||Viu hv_store|5.003007|5.003007| hv_store_ent|5.003007|5.003007| hv_store_flags|5.008000|5.008000|xu hv_storehek|5.019006||Viu hv_stores|5.009004|5.003007|p HvTOTALKEYS|5.007003||Viu hv_undef|5.003007|5.003007| hv_undef_flags|||ciu HvUSEDKEYS|5.007003||Viu HYPHEN_UTF8|5.017004||Viu I16_MAX|5.003007||Viu I16_MIN|5.003007||Viu I16SIZE|5.006000|5.006000|Vn I16TYPE|5.006000|5.006000|Vn I_32|5.006000|5.003007| I32_MAX|5.003007||Viu I32_MAX_P1|5.007002||Viu I32_MIN|5.003007||Viu I32SIZE|5.006000|5.006000|Vn I32TYPE|5.006000|5.006000|Vn I64SIZE|5.006000|5.006000|Vn I64TYPE|5.006000|5.006000|Vn I8SIZE|5.006000|5.006000|Vn I8_TO_NATIVE|5.015006||Viu I8_TO_NATIVE_UTF8|5.019004||Viu I8TYPE|5.006000|5.006000|Vn I_ARPA_INET|5.005000|5.005000|Vn ibcmp|5.003007|5.003007| ibcmp_locale|5.004000|5.004000| ibcmp_utf8|5.007003|5.007003| I_CRYPT|5.008000|5.008000|Vn I_DBM|5.032001|5.032001|Vn I_DIRENT|5.003007|5.003007|Vn I_DLFCN|5.003007|5.003007|Vn I_EXECINFO|5.021001|5.021001|Vn I_FENV|5.021004|5.021004|Vn IFMATCH|5.003007||Viu IFMATCH_A|5.009005||Viu IFMATCH_A_fail|5.009005||Viu IFMATCH_A_fail_t8|5.035004||Viu IFMATCH_A_fail_t8_p8|5.033003||Viu IFMATCH_A_fail_t8_pb|5.033003||Viu IFMATCH_A_fail_tb|5.035004||Viu IFMATCH_A_fail_tb_p8|5.033003||Viu IFMATCH_A_fail_tb_pb|5.033003||Viu IFMATCH_A_t8|5.035004||Viu IFMATCH_A_t8_p8|5.033003||Viu IFMATCH_A_t8_pb|5.033003||Viu IFMATCH_A_tb|5.035004||Viu IFMATCH_A_tb_p8|5.033003||Viu IFMATCH_A_tb_pb|5.033003||Viu IFMATCH_t8|5.035004||Viu IFMATCH_t8_p8|5.033003||Viu IFMATCH_t8_pb|5.033003||Viu IFMATCH_tb|5.035004||Viu IFMATCH_tb_p8|5.033003||Viu IFMATCH_tb_pb|5.033003||Viu IFTHEN|5.005000||Viu IFTHEN_t8|5.035004||Viu IFTHEN_t8_p8|5.033003||Viu IFTHEN_t8_pb|5.033003||Viu IFTHEN_tb|5.035004||Viu IFTHEN_tb_p8|5.033003||Viu IFTHEN_tb_pb|5.033003||Viu I_GDBM|5.021007|5.021007|Vn I_GDBMNDBM|5.021007|5.021007|Vn IGNORE_PAT_MOD|5.009005||Viu I_GRP|5.003007|5.003007|Vn I_INTTYPES|5.006000|5.006000|Vn I_LANGINFO|5.007002|5.007002|Vn I_LIMITS|5.003007||Viu ILLEGAL_UTF8_BYTE|5.019004||Viu I_LOCALE|5.003007|5.003007|Vn I_MNTENT|5.023005|5.023005|Vn IN_BYTES|5.007002||Viu incline|5.005000||Viu INCLUDE_PROTOTYPES|5.007001||Viu INCMARK|5.023005||Viu incpush|5.005000||Viu INCPUSH_APPLLIB_EXP|5.027006||Viu INCPUSH_APPLLIB_OLD_EXP|5.027006||Viu INCPUSH_ARCHLIB_EXP|5.027006||Viu incpush_if_exists|5.009003||Viu INCPUSH_PERL5LIB|5.027006||Viu INCPUSH_PERL_OTHERLIBDIRS|5.027006||Viu INCPUSH_PERL_OTHERLIBDIRS_ARCHONLY|5.027006||Viu INCPUSH_PERL_VENDORARCH_EXP|5.027006||Viu INCPUSH_PERL_VENDORLIB_EXP|5.027006||Viu INCPUSH_PERL_VENDORLIB_STEM|5.027006||Viu INCPUSH_PRIVLIB_EXP|5.027006||Viu INCPUSH_SITEARCH_EXP|5.027006||Viu INCPUSH_SITELIB_EXP|5.027006||Viu INCPUSH_SITELIB_STEM|5.027006||Viu incpush_use_sep|5.011000||Viu I_NDBM|5.032001|5.032001|Vn inet_addr|5.005000||Viu I_NETDB|5.005000|5.005000|Vn I_NETINET_IN|5.003007|5.003007|Vn I_NETINET_TCP|5.006000|5.006000|Vn inet_ntoa|5.005000||Viu INFNAN_NV_U8_DECL|5.023000||Viu INFNAN_U8_NV_DECL|5.023000||Viu ingroup|5.003007||Viu INIT|5.003007||Viu init_argv_symbols|5.007003||Viu init_constants|5.017003||Viu init_dbargs|||iu init_debugger|5.005000||Viu init_i18nl10n|5.006000||cVu init_i18nl14n|5.006000||dcVu initialize_invlist_guts|5.029002||Viu init_ids|5.005000||Viu init_interp|5.005000||Viu init_main_stash|5.005000||Viu init_named_cv|5.027010||cViu init_os_extras|5.005000||Viu init_perllib|5.005000||Viu init_postdump_symbols|5.005000||Viu init_predump_symbols|5.005000||Viu init_stacks|5.005000|5.005000|u INIT_THREADS|5.005000||Viu init_tm|5.007002|5.007002|u INIT_TRACK_MEMPOOL|5.009004||Viu init_uniprops|5.027011||Viu IN_LC|5.021001||Viu IN_LC_ALL_COMPILETIME|5.021001||Viu IN_LC_ALL_RUNTIME|5.021001||Viu IN_LC_COMPILETIME|5.021001||Viu IN_LC_PARTIAL_COMPILETIME|5.021001||Viu IN_LC_PARTIAL_RUNTIME|5.021001||Viu IN_LC_RUNTIME|5.021001||Viu IN_LOCALE|5.007002|5.004000|p IN_LOCALE_COMPILETIME|5.007002|5.004000|p IN_LOCALE_RUNTIME|5.007002|5.004000|p IN_PERL_COMPILETIME|5.008001|5.003007|p IN_PERL_RUNTIME|5.008001|5.008001| inplace_aassign|5.015003||Viu inRANGE|5.029010||Viu inRANGE_helper|5.033005||Viu IN_SOME_LOCALE_FORM|5.015008||Viu IN_SOME_LOCALE_FORM_COMPILETIME|5.015008||Viu IN_SOME_LOCALE_FORM_RUNTIME|5.015008||Viu instr|5.003007|5.003007|n INSUBP|5.009005||Viu INSUBP_t8|5.035004||Viu INSUBP_t8_p8|5.033003||Viu INSUBP_t8_pb|5.033003||Viu INSUBP_tb|5.035004||Viu INSUBP_tb_p8|5.033003||Viu INSUBP_tb_pb|5.033003||Viu INT16_C|5.003007|5.003007| INT2PTR|5.006000|5.003007|p INT32_C|5.003007|5.003007| INT32_MIN|5.007002||Viu INT64_C|5.023002|5.023002| INT64_MIN|5.007002||Viu INT_64_T|5.011000||Viu INTMAX_C|5.003007|5.003007| INT_PAT_MODS|5.009005||Viu intro_my|5.021006|5.021006| INTSIZE|5.003007|5.003007|Vn intuit_method|5.005000||Viu intuit_more|5.003007||Viu IN_UNI_8_BIT|5.011002||Viu IN_UTF8_CTYPE_LOCALE|5.019009||Viu _inverse_folds|5.027011||cViu invert|5.003007||Viu invlist_array|5.013010||Vniu _invlist_array_init|5.015001||Vniu invlist_clear|5.023009||Viu invlist_clone|5.015001||cViu _invlist_contains_cp|5.017003||Vniu invlist_contents|5.023008||Viu _invlist_dump|5.019003||cViu _invlistEQ|5.023006||cViu invlist_extend|5.013010||Viu invlist_highest|5.017002||Vniu _invlist_intersection|5.015001||Viu _invlist_intersection_maybe_complement_2nd|5.015008||cViu _invlist_invert|5.015001||cViu invlist_is_iterating|5.017008||Vniu invlist_iterfinish|5.017008||Vniu invlist_iterinit|5.015001||Vniu invlist_iternext|5.015001||Vniu _invlist_len|5.017004||Vniu invlist_lowest|5.031007||xVniu invlist_max|5.013010||Vniu invlist_previous_index|5.017004||Vniu invlist_replace_list_destroys_src|5.023009||Viu _invlist_search|5.017003||cVniu invlist_set_len|5.013010||Viu invlist_set_previous_index|5.017004||Vniu _invlist_subtract|5.015001||Viu invlist_trim|5.013010||Vniu _invlist_union|5.015001||cVu _invlist_union_maybe_complement_2nd|5.015008||cViu invmap_dump|5.031006||Viu invoke_exception_hook|5.013001||Viu IoANY|5.006001||Viu IoBOTTOM_GV|5.003007||Viu IoBOTTOM_NAME|5.003007||Viu io_close|5.003007||Viu IOCPARM_LEN|5.003007||Viu ioctl|5.005000||Viu IoDIRP|5.003007||Viu IOf_ARGV|5.003007||Viu IOf_DIDTOP|5.003007||Viu IOf_FAKE_DIRP|5.006000||Viu IOf_FLUSH|5.003007||Viu IoFLAGS|5.003007||Viu IoFMT_GV|5.003007||Viu IoFMT_NAME|5.003007||Viu IOf_NOLINE|5.005003||Viu IOf_START|5.003007||Viu IOf_UNTAINT|5.003007||Viu IoIFP|5.003007||Viu IoLINES|5.003007||Viu IoLINES_LEFT|5.003007||Viu IoOFP|5.003007||Viu IoPAGE|5.003007||Viu IoPAGE_LEN|5.003007||Viu IoTOP_GV|5.003007||Viu IoTOP_NAME|5.003007||Viu IoTYPE|5.003007||Viu IoTYPE_APPEND|5.006001||Viu IoTYPE_CLOSED|5.006001||Viu IoTYPE_IMPLICIT|5.008001||Viu IoTYPE_NUMERIC|5.008001||Viu IoTYPE_PIPE|5.006001||Viu IoTYPE_RDONLY|5.006001||Viu IoTYPE_RDWR|5.006001||Viu IoTYPE_SOCKET|5.006001||Viu IoTYPE_STD|5.006001||Viu IoTYPE_WRONLY|5.006001||Viu I_POLL|5.006000|5.006000|Vn I_PTHREAD|5.005003|5.005003|Vn I_PWD|5.003007|5.003007|Vn isALNUM|5.003007|5.003007|p isALNUM_A|5.031003|5.003007|p isALNUMC|5.006000|5.003007|p isALNUMC_A|5.013006|5.003007|p isALNUMC_L1|5.013006|5.003007|p isALNUMC_LC|5.006000|5.006000| isALNUMC_LC_utf8_safe|5.031007||Viu isALNUMC_LC_uvchr|5.017007|5.017007| isALNUMC_uni|5.017007||Viu isALNUMC_utf8|5.017007||Viu isALNUMC_utf8_safe|5.031007||Viu isALNUM_lazy_if_safe|5.031007||Viu isALNUM_LC|5.004000|5.004000| isALNUM_LC_utf8|5.006000||Viu isALNUM_LC_utf8_safe|5.031007||Viu isALNUM_LC_uvchr|5.007001|5.007001| isALNUMU|5.011005||Viu isALNUM_uni|5.006000||Viu isALNUM_utf8|5.006000||Viu isALNUM_utf8_safe|5.031007||Viu isa_lookup|5.005000||Viu isALPHA|5.003007|5.003007|p isALPHA_A|5.013006|5.003007|p isALPHA_FOLD_EQ|5.021004||Viu isALPHA_FOLD_NE|5.021004||Viu isALPHA_L1|5.013006|5.003007|p isALPHA_LC|5.004000|5.004000| isALPHA_LC_utf8|5.006000||Viu isALPHA_LC_utf8_safe|5.025009|5.006000|p isALPHA_LC_uvchr|5.007001|5.007001| isALPHANUMERIC|5.017008|5.003007|p isALPHANUMERIC_A|5.017008|5.003007|p isALPHANUMERIC_L1|5.017008|5.003007|p isALPHANUMERIC_LC|5.017008|5.004000|p isALPHANUMERIC_LC_utf8|5.017008||Viu isALPHANUMERIC_LC_utf8_safe|5.025009|5.006000|p isALPHANUMERIC_LC_uvchr|5.017008|5.017008| isALPHANUMERIC_uni|5.017008||Viu isALPHANUMERIC_utf8|5.031005|5.031005| isALPHANUMERIC_utf8_safe|5.025009|5.006000|p isALPHANUMERIC_uvchr|5.023009|5.006000|p isALPHAU|5.011005||Viu isALPHA_uni|5.006000||Viu isALPHA_utf8|5.031005|5.031005| isALPHA_utf8_safe|5.025009|5.006000|p isALPHA_uvchr|5.023009|5.006000|p is_an_int|5.005000||Viu is_ANYOF_SYNTHETIC|5.019009||Viu IS_ANYOF_TRIE|5.009005||Viu isASCII|5.006000|5.003007|p isASCII_A|5.013006|5.003007|p isASCII_L1|5.015004|5.003007|p isASCII_LC|5.015008|5.003007|p isASCII_LC_utf8|5.017007||Viu isASCII_LC_utf8_safe|5.025009|5.025009| isASCII_LC_uvchr|5.017007|5.017007| is_ascii_string|5.011000|5.011000|n isASCII_uni|5.006000||Viu isASCII_utf8|5.031005|5.031005| isASCII_utf8_safe|5.025009|5.003007|p isASCII_uvchr|5.023009|5.003007|p isatty|5.005000||Viu ISA_VERSION_OBJ|5.019008||Viu isBLANK|5.006001|5.003007|p isBLANK_A|5.013006|5.003007|p isBLANK_L1|5.013006|5.003007|p isBLANK_LC|5.006001|5.003007|p isBLANK_LC_uni|5.006001||Viu isBLANK_LC_utf8|5.006001||Viu isBLANK_LC_utf8_safe|5.025009|5.006000|p isBLANK_LC_uvchr|5.017007|5.017007| isBLANK_uni|5.006001||Viu isBLANK_utf8|5.031005|5.031005| isBLANK_utf8_safe|5.025009|5.006000|p isBLANK_uvchr|5.023009|5.006000|p isC9_STRICT_UTF8_CHAR|5.025005|5.025005|n is_c9strict_utf8_string|5.025006|5.025006|n is_c9strict_utf8_string_loc|5.025006|5.025006|n is_c9strict_utf8_string_loclen|5.025006|5.025006|n isCHARNAME_CONT|5.011005||Viu isCNTRL|5.006000|5.003007|p isCNTRL_A|5.013006|5.003007|p isCNTRL_L1|5.013006|5.003007|p isCNTRL_LC|5.006000|5.006000| isCNTRL_LC_utf8|5.006000||Viu isCNTRL_LC_utf8_safe|5.025009|5.006000|p isCNTRL_LC_uvchr|5.007001|5.007001| isCNTRL_uni|5.006000||Viu isCNTRL_utf8|5.031005|5.031005| isCNTRL_utf8_safe|5.025009|5.006000|p isCNTRL_uvchr|5.023009|5.006000|p _is_cur_LC_category_utf8|5.021001||cVu isDEBUG_WILDCARD|5.031011||Viu isDIGIT|5.003007|5.003007|p isDIGIT_A|5.013006|5.003007|p isDIGIT_L1|5.013006|5.003007|p isDIGIT_LC|5.004000|5.004000| isDIGIT_LC_utf8|5.006000||Viu isDIGIT_LC_utf8_safe|5.025009|5.006000|p isDIGIT_LC_uvchr|5.007001|5.007001| isDIGIT_uni|5.006000||Viu isDIGIT_utf8|5.031005|5.031005| isDIGIT_utf8_safe|5.025009|5.006000|p isDIGIT_uvchr|5.023009|5.006000|p isEXACTFish|5.033003||Viu isEXACT_REQ8|5.033003||Viu isFF_overlong|5.035004||Vniu is_FOLDS_TO_MULTI_utf8|5.019009||Viu isFOO_lc|5.017007||Viu isFOO_utf8_lc|5.017008||Viu isGCB|5.021009||Viu isGRAPH|5.006000|5.003007|p isGRAPH_A|5.013006|5.003007|p is_grapheme|5.031007||Viu isGRAPH_L1|5.013006|5.003007|p isGRAPH_LC|5.006000|5.006000| isGRAPH_LC_utf8|5.006000||Viu isGRAPH_LC_utf8_safe|5.025009|5.006000|p isGRAPH_LC_uvchr|5.007001|5.007001| isGRAPH_uni|5.006000||Viu isGRAPH_utf8|5.031005|5.031005| isGRAPH_utf8_safe|5.025009|5.006000|p isGRAPH_uvchr|5.023009|5.006000|p isGV|5.003007||Viu isGV_or_RVCV|5.027005||Viu isGV_with_GP|5.009004|5.003007|p isGV_with_GP_off|5.009005||Viu isGV_with_GP_on|5.009005||Viu I_SHADOW|5.006000|5.006000|Vn is_handle_constructor|5.006000||Vniu is_HANGUL_ED_utf8_safe|5.029001||Viu is_HORIZWS_cp_high|5.017006||Viu is_HORIZWS_high|5.017006||Viu isIDCONT|5.017008|5.003007|p isIDCONT_A|5.017008|5.003007|p isIDCONT_L1|5.017008|5.003007|p isIDCONT_LC|5.017008|5.004000|p isIDCONT_LC_utf8|5.017008||Viu isIDCONT_LC_utf8_safe|5.025009|5.006000|p isIDCONT_LC_uvchr|5.017008|5.017008| isIDCONT_uni|5.017008||Viu isIDCONT_utf8|5.031005|5.031005| isIDCONT_utf8_safe|5.025009|5.006000|p isIDCONT_uvchr|5.023009|5.006000|p isIDFIRST|5.003007|5.003007|p isIDFIRST_A|5.013006|5.003007|p isIDFIRST_L1|5.013006|5.003007|p isIDFIRST_lazy_if_safe|5.025009||Viu isIDFIRST_LC|5.004000|5.004000|p isIDFIRST_LC_utf8|5.006000||Viu isIDFIRST_LC_utf8_safe|5.025009|5.006000|p isIDFIRST_LC_uvchr|5.007001|5.007001| isIDFIRST_uni|5.006000||Viu isIDFIRST_utf8|5.031005|5.031005| isIDFIRST_utf8_safe|5.025009|5.006000|p isIDFIRST_uvchr|5.023009|5.006000|p isinfnan|5.021004|5.021004|n isinfnansv|5.021005||Vi _is_in_locale_category|5.021001||cViu IS_IN_SOME_FOLD_L1|5.033005||Viu is_invariant_string|5.021007|5.011000|pn is_invlist|5.029002||Vniu is_LARGER_NON_CHARS_utf8|5.035003||Viu is_LAX_VERSION|5.011004||Viu isLB|5.023007||Viu isLEXWARN_off|5.006000||Viu isLEXWARN_on|5.006000||Viu is_LNBREAK_latin1_safe|5.009005||Viu is_LNBREAK_safe|5.009005||Viu is_LNBREAK_utf8_safe|5.009005||Viu isLOWER|5.003007|5.003007|p isLOWER_A|5.013006|5.003007|p isLOWER_L1|5.013006|5.003007|p isLOWER_LC|5.004000|5.004000| isLOWER_LC_utf8|5.006000||Viu isLOWER_LC_utf8_safe|5.025009|5.006000|p isLOWER_LC_uvchr|5.007001|5.007001| isLOWER_uni|5.006000||Viu isLOWER_utf8|5.031005|5.031005| isLOWER_utf8_safe|5.025009|5.006000|p isLOWER_uvchr|5.023009|5.006000|p is_lvalue_sub|5.007001|5.007001|u isMNEMONIC_CNTRL|5.031009||Viu is_MULTI_CHAR_FOLD_latin1_safe|5.019010||Viu is_MULTI_CHAR_FOLD_utf8_safe|5.019010||Viu is_MULTI_CHAR_FOLD_utf8_safe_part0|5.019010||Viu is_MULTI_CHAR_FOLD_utf8_safe_part1|5.019010||Viu is_MULTI_CHAR_FOLD_utf8_safe_part2|5.025008||Viu is_MULTI_CHAR_FOLD_utf8_safe_part3|5.025008||Viu is_NONCHAR_utf8_safe|5.025005||Viu IS_NON_FINAL_FOLD|5.033005||Viu isnormal|5.021004||Viu IS_NUMBER_GREATER_THAN_UV_MAX|5.007002|5.003007|p IS_NUMBER_INFINITY|5.007002|5.003007|p IS_NUMBER_IN_UV|5.007002|5.003007|p IS_NUMBER_NAN|5.007003|5.003007|p IS_NUMBER_NEG|5.007002|5.003007|p IS_NUMBER_NOT_INT|5.007002|5.003007|p IS_NUMBER_TRAILING|5.021002||Viu IS_NUMERIC_RADIX|5.006000||Viu isOCTAL|5.013005|5.003007|p isOCTAL_A|5.013006|5.003007|p isOCTAL_L1|5.013006|5.003007|p IS_PADCONST|5.006000||Viu IS_PADGV|5.006000||Viu is_PATWS_safe|5.017008||Viu isPOWER_OF_2|5.029006||Viu isPRINT|5.004000|5.003007|p isPRINT_A|5.013006|5.003007|p isPRINT_L1|5.013006|5.003007|p isPRINT_LC|5.004000|5.004000| isPRINT_LC_utf8|5.006000||Viu isPRINT_LC_utf8_safe|5.025009|5.006000|p isPRINT_LC_uvchr|5.007001|5.007001| isPRINT_uni|5.006000||Viu isPRINT_utf8|5.031005|5.031005| isPRINT_utf8_safe|5.025009|5.006000|p isPRINT_uvchr|5.023009|5.006000|p is_PROBLEMATIC_LOCALE_FOLD_cp|5.019009||Viu is_PROBLEMATIC_LOCALE_FOLDEDS_START_cp|5.019009||Viu is_PROBLEMATIC_LOCALE_FOLDEDS_START_utf8|5.019009||Viu is_PROBLEMATIC_LOCALE_FOLD_utf8|5.019009||Viu isPSXSPC|5.006001|5.003007|p isPSXSPC_A|5.013006|5.003007|p isPSXSPC_L1|5.013006|5.003007|p isPSXSPC_LC|5.006001|5.006001| isPSXSPC_LC_utf8|5.006001||Viu isPSXSPC_LC_utf8_safe|5.025009|5.006000|p isPSXSPC_LC_uvchr|5.017007|5.017007| isPSXSPC_uni|5.006001||Viu isPSXSPC_utf8|5.031005|5.031005| isPSXSPC_utf8_safe|5.025009|5.006000|p isPSXSPC_uvchr|5.023009|5.006000|p isPUNCT|5.006000|5.003007|p isPUNCT_A|5.013006|5.003007|p isPUNCT_L1|5.013006|5.003007|p isPUNCT_LC|5.006000|5.006000| isPUNCT_LC_utf8|5.006000||Viu isPUNCT_LC_utf8_safe|5.025009|5.006000|p isPUNCT_LC_uvchr|5.007001|5.007001| isPUNCT_uni|5.006000||Viu isPUNCT_utf8|5.031005|5.031005| isPUNCT_utf8_safe|5.025009|5.006000|p isPUNCT_uvchr|5.023009|5.006000|p is_QUOTEMETA_high|5.017004||Viu isREGEXP|5.017006||Viu IS_SAFE_PATHNAME|5.019004||Viu IS_SAFE_SYSCALL|5.019004|5.019004| is_safe_syscall|5.019004|5.019004| isSB|5.021009||Viu isSCRIPT_RUN|5.027008||cVi is_SHORTER_NON_CHARS_utf8|5.035003||Viu isSPACE|5.003007|5.003007|p isSPACE_A|5.013006|5.003007|p isSPACE_L1|5.013006|5.003007|p isSPACE_LC|5.004000|5.004000| isSPACE_LC_utf8|5.006000||Viu isSPACE_LC_utf8_safe|5.025009|5.006000|p isSPACE_LC_uvchr|5.007001|5.007001| isSPACE_uni|5.006000||Viu isSPACE_utf8|5.031005|5.031005| isSPACE_utf8_safe|5.025009|5.006000|p isSPACE_uvchr|5.023009|5.006000|p is_ssc_worth_it|5.021005||Vniu isSTRICT_UTF8_CHAR|5.025005|5.025005|n is_strict_utf8_string|5.025006|5.025006|n is_strict_utf8_string_loc|5.025006|5.025006|n is_strict_utf8_string_loclen|5.025006|5.025006|n is_STRICT_VERSION|5.011004||Viu is_SURROGATE_utf8|5.035004||Viu is_SURROGATE_utf8_safe|5.025005||Viu I_STDARG|5.003007||Viu I_STDBOOL|5.015003|5.015003|Vn I_STDINT|5.021004|5.021004|Vn is_THREE_CHAR_FOLD_HEAD_latin1_safe|5.031007||Viu is_THREE_CHAR_FOLD_HEAD_utf8_safe|5.031007||Viu is_THREE_CHAR_FOLD_latin1_safe|5.031007||Viu is_THREE_CHAR_FOLD_utf8_safe|5.031007||Viu IS_TRIE_AC|5.009005||Viu isUNICODE_POSSIBLY_PROBLEMATIC|5.035004||Viu _is_uni_FOO|5.017008||cVu _is_uni_perl_idcont|5.017008||cVu _is_uni_perl_idstart|5.017007||cVu isUPPER|5.003007|5.003007|p isUPPER_A|5.013006|5.003007|p isUPPER_L1|5.013006|5.003007|p isUPPER_LC|5.004000|5.004000| isUPPER_LC_utf8|5.006000||Viu isUPPER_LC_utf8_safe|5.025009|5.006000|p isUPPER_LC_uvchr|5.007001|5.007001| isUPPER_uni|5.006000||Viu isUPPER_utf8|5.031005|5.031005| isUPPER_utf8_safe|5.025009|5.006000|p isUPPER_uvchr|5.023009|5.006000|p is_utf8_char|5.006000|5.006000|dn IS_UTF8_CHAR|5.009003||Viu isUTF8_CHAR|5.021001|5.006001|pn is_utf8_char_buf|5.015008|5.015008|n isUTF8_CHAR_flags|5.025005|5.025005|n is_utf8_char_helper_|5.035004||cVnu is_utf8_common|5.009003||Viu is_utf8_FF_helper_|5.035004||cVnu is_utf8_fixed_width_buf_flags|5.025006|5.025006|n is_utf8_fixed_width_buf_loc_flags|5.025006|5.025006|n is_utf8_fixed_width_buf_loclen_flags|5.025006|5.025006|n _is_utf8_FOO|5.031006||cVu is_utf8_invariant_string|5.025005|5.011000|pn is_utf8_invariant_string_loc|5.027001|5.027001|n is_utf8_non_invariant_string|5.027007||cVni is_utf8_overlong|5.035004||Vniu _is_utf8_perl_idcont|5.031006||cVu _is_utf8_perl_idstart|5.031006||cVu isUTF8_POSSIBLY_PROBLEMATIC|5.023003||Viu is_utf8_string|5.006001|5.006001|n is_utf8_string_flags|5.025006|5.025006|n is_utf8_string_loc|5.008001|5.008001|n is_utf8_string_loc_flags|5.025006|5.025006|n is_utf8_string_loclen|5.009003|5.009003|n is_utf8_string_loclen_flags|5.025006|5.025006|n is_utf8_valid_partial_char|5.025005|5.025005|n is_utf8_valid_partial_char_flags|5.025005|5.025005|n is_VERTWS_cp_high|5.017006||Viu is_VERTWS_high|5.017006||Viu isVERTWS_uni|5.017006||Viu isVERTWS_utf8|5.017006||Viu isVERTWS_utf8_safe|5.025009||Viu isVERTWS_uvchr|5.023009||Viu isWARNf_on|5.006001||Viu isWARN_on|5.006000||Viu isWARN_ONCE|5.006000||Viu isWB|5.021009||Viu isWORDCHAR|5.013006|5.003007|p isWORDCHAR_A|5.013006|5.003007|p isWORDCHAR_L1|5.013006|5.003007|p isWORDCHAR_lazy_if_safe|5.025009||Viu isWORDCHAR_LC|5.017007|5.004000|p isWORDCHAR_LC_utf8|5.017007||Viu isWORDCHAR_LC_utf8_safe|5.025009|5.006000|p isWORDCHAR_LC_uvchr|5.017007|5.017007| isWORDCHAR_uni|5.017006||Viu isWORDCHAR_utf8|5.031005|5.031005| isWORDCHAR_utf8_safe|5.025009|5.006000|p isWORDCHAR_uvchr|5.023009|5.006000|p isXDIGIT|5.006000|5.003007|p isXDIGIT_A|5.013006|5.003007|p is_XDIGIT_cp_high|5.017006||Viu is_XDIGIT_high|5.017006||Viu isXDIGIT_L1|5.013006|5.003007|p isXDIGIT_LC|5.017007|5.003007|p isXDIGIT_LC_utf8|5.017007||Viu isXDIGIT_LC_utf8_safe|5.025009|5.006000|p isXDIGIT_LC_uvchr|5.017007|5.017007| isXDIGIT_uni|5.006000||Viu isXDIGIT_utf8|5.031005|5.031005| isXDIGIT_utf8_safe|5.025009|5.006000|p isXDIGIT_uvchr|5.023009|5.006000|p is_XPERLSPACE_cp_high|5.017006||Viu is_XPERLSPACE_high|5.017006||Viu I_SYS_DIR|5.003007|5.003007|Vn I_SYS_FILE|5.003007|5.003007|Vn I_SYS_IOCTL|5.003007|5.003007|Vn I_SYSLOG|5.006000|5.006000|Vn I_SYS_MOUNT|5.023005|5.023005|Vn I_SYS_PARAM|5.003007|5.003007|Vn I_SYS_POLL|5.010001|5.010001|Vn I_SYS_RESOURCE|5.003007|5.003007|Vn I_SYS_SELECT|5.003007|5.003007|Vn I_SYS_STAT|5.003007|5.003007|Vn I_SYS_STATFS|5.023005|5.023005|Vn I_SYS_STATVFS|5.023005|5.023005|Vn I_SYS_TIME|5.003007|5.003007|Vn I_SYS_TIMES|5.003007|5.003007|Vn I_SYS_TYPES|5.003007|5.003007|Vn I_SYSUIO|5.006000|5.006000|Vn I_SYS_UN|5.003007|5.003007|Vn I_SYSUTSNAME|5.006000|5.006000|Vn I_SYS_VFS|5.023005|5.023005|Vn I_SYS_WAIT|5.003007|5.003007|Vn items||5.003007| I_TERMIOS|5.003007|5.003007|Vn I_TIME|5.003007|5.003007|Vn I_UNISTD|5.003007|5.003007|Vn I_USTAT|5.023005|5.023005|Vn I_UTIME|5.003007|5.003007|Vn I_V|5.006000|5.003007| IVdf|5.006000|5.003007|poVn IV_DIG|5.006000||Viu IV_IS_QUAD|5.006000||Viu IV_MAX|5.003007|5.003007| IV_MAX_P1|5.007002||Viu IV_MIN|5.003007|5.003007| IVSIZE|5.006000|5.003007|poVn IVTYPE|5.006000|5.003007|poVn I_WCHAR|5.027006|5.027006|Vn I_WCTYPE|5.029009|5.029009|Vn ix||5.003007| I_XLOCALE|5.025004|5.025004|Vn JE_OLD_STACK_HWM_restore|5.027002||Viu JE_OLD_STACK_HWM_save|5.027002||Viu JE_OLD_STACK_HWM_zero|5.027002||Viu jmaybe|5.003007||Viu JMPENV_BOOTSTRAP|5.006000||Viu JMPENV_JUMP|5.004000|5.004000| JMPENV_POP|5.004000||Viu JMPENV_PUSH|5.004000||Viu JOIN|5.005000||Viu join_exact|5.009004||Viu kBINOP|5.003007||Viu kCOP|5.003007||Viu KEEPCOPY_PAT_MOD|5.009005||Viu KEEPCOPY_PAT_MODS|5.009005||Viu KEEPS|5.009005||Viu KEEPS_next|5.009005||Viu KEEPS_next_fail|5.009005||Viu KEEPS_next_fail_t8|5.035004||Viu KEEPS_next_fail_t8_p8|5.033003||Viu KEEPS_next_fail_t8_pb|5.033003||Viu KEEPS_next_fail_tb|5.035004||Viu KEEPS_next_fail_tb_p8|5.033003||Viu KEEPS_next_fail_tb_pb|5.033003||Viu KEEPS_next_t8|5.035004||Viu KEEPS_next_t8_p8|5.033003||Viu KEEPS_next_t8_pb|5.033003||Viu KEEPS_next_tb|5.035004||Viu KEEPS_next_tb_p8|5.033003||Viu KEEPS_next_tb_pb|5.033003||Viu KEEPS_t8|5.035004||Viu KEEPS_t8_p8|5.033003||Viu KEEPS_t8_pb|5.033003||Viu KEEPS_tb|5.035004||Viu KEEPS_tb_p8|5.033003||Viu KEEPS_tb_pb|5.033003||Viu KELVIN_SIGN|5.017003||Viu KERNEL|5.003007||Viu KEY_abs|5.003007||Viu KEY_accept|5.003007||Viu KEY_alarm|5.003007||Viu KEY_and|5.003007||Viu KEY_atan2|5.003007||Viu KEY_AUTOLOAD|5.003007||Viu KEY_BEGIN|5.003007||Viu KEY_bind|5.003007||Viu KEY_binmode|5.003007||Viu KEY_bless|5.003007||Viu KEY_break|5.027008||Viu KEY_caller|5.003007||Viu KEY_catch|5.033007||Viu KEY_chdir|5.003007||Viu KEY_CHECK|5.006000||Viu KEY_chmod|5.003007||Viu KEY_chomp|5.003007||Viu KEY_chop|5.003007||Viu KEY_chown|5.003007||Viu KEY_chr|5.003007||Viu KEY_chroot|5.003007||Viu KEY_close|5.003007||Viu KEY_closedir|5.003007||Viu KEY_cmp|5.003007||Viu KEY_connect|5.003007||Viu KEY_continue|5.003007||Viu KEY_cos|5.003007||Viu KEY_crypt|5.003007||Viu KEY___DATA|5.003007||Viu KEY_dbmclose|5.003007||Viu KEY_dbmopen|5.003007||Viu KEY_default|5.027008||Viu KEY_defer|5.035004||Viu KEY_defined|5.003007||Viu KEY_delete|5.003007||Viu KEY_DESTROY|5.003007||Viu KEY_die|5.003007||Viu KEY_do|5.003007||Viu KEY_dump|5.003007||Viu KEY_each|5.003007||Viu KEY_else|5.003007||Viu KEY_elsif|5.003007||Viu KEY___END|5.003007||Viu KEY_END|5.003007||Viu KEY_endgrent|5.003007||Viu KEY_endhostent|5.003007||Viu KEY_endnetent|5.003007||Viu KEY_endprotoent|5.003007||Viu KEY_endpwent|5.003007||Viu KEY_endservent|5.003007||Viu KEY_eof|5.003007||Viu KEY_eq|5.003007||Viu KEY_eval|5.003007||Viu KEY_evalbytes|5.015005||Viu KEY_exec|5.003007||Viu KEY_exists|5.003007||Viu KEY_exit|5.003007||Viu KEY_exp|5.003007||Viu KEY_fc|5.015008||Viu KEY_fcntl|5.003007||Viu KEY___FILE|5.003007||Viu KEY_fileno|5.003007||Viu KEY_finally|5.035008||Viu KEY_flock|5.003007||Viu KEY_for|5.003007||Viu KEY_foreach|5.003007||Viu KEY_fork|5.003007||Viu KEY_format|5.003007||Viu KEY_formline|5.003007||Viu KEY_ge|5.003007||Viu KEY_getc|5.003007||Viu KEY_getgrent|5.003007||Viu KEY_getgrgid|5.003007||Viu KEY_getgrnam|5.003007||Viu KEY_gethostbyaddr|5.003007||Viu KEY_gethostbyname|5.003007||Viu KEY_gethostent|5.003007||Viu KEY_getlogin|5.003007||Viu KEY_getnetbyaddr|5.003007||Viu KEY_getnetbyname|5.003007||Viu KEY_getnetent|5.003007||Viu KEY_getpeername|5.003007||Viu KEY_getpgrp|5.003007||Viu KEY_getppid|5.003007||Viu KEY_getpriority|5.003007||Viu KEY_getprotobyname|5.003007||Viu KEY_getprotobynumber|5.003007||Viu KEY_getprotoent|5.003007||Viu KEY_getpwent|5.003007||Viu KEY_getpwnam|5.003007||Viu KEY_getpwuid|5.003007||Viu KEY_getservbyname|5.003007||Viu KEY_getservbyport|5.003007||Viu KEY_getservent|5.003007||Viu KEY_getsockname|5.003007||Viu KEY_getsockopt|5.003007||Viu KEY_getspnam|5.031011||Viu KEY_given|5.009003||Viu KEY_glob|5.003007||Viu KEY_gmtime|5.003007||Viu KEY_goto|5.003007||Viu KEY_grep|5.003007||Viu KEY_gt|5.003007||Viu KEY_hex|5.003007||Viu KEY_if|5.003007||Viu KEY_index|5.003007||Viu KEY_INIT|5.005000||Viu KEY_int|5.003007||Viu KEY_ioctl|5.003007||Viu KEY_isa|5.031007||Viu KEY_join|5.003007||Viu KEY_keys|5.003007||Viu KEY_kill|5.003007||Viu KEY_last|5.003007||Viu KEY_lc|5.003007||Viu KEY_lcfirst|5.003007||Viu KEY_le|5.003007||Viu KEY_length|5.003007||Viu KEY___LINE|5.003007||Viu KEY_link|5.003007||Viu KEY_listen|5.003007||Viu KEY_local|5.003007||Viu KEY_localtime|5.003007||Viu KEY_lock|5.005000||Viu KEY_log|5.003007||Viu KEY_lstat|5.003007||Viu KEY_lt|5.003007||Viu KEY_m|5.003007||Viu KEY_map|5.003007||Viu KEY_mkdir|5.003007||Viu KEY_msgctl|5.003007||Viu KEY_msgget|5.003007||Viu KEY_msgrcv|5.003007||Viu KEY_msgsnd|5.003007||Viu KEY_my|5.003007||Viu KEY_ne|5.003007||Viu KEY_next|5.003007||Viu KEY_no|5.003007||Viu KEY_not|5.003007||Viu KEY_NULL|5.003007||Viu KEY_oct|5.003007||Viu KEY_open|5.003007||Viu KEY_opendir|5.003007||Viu KEY_or|5.003007||Viu KEY_ord|5.003007||Viu KEY_our|5.006000||Viu KEY_pack|5.003007||Viu KEY_package|5.003007||Viu KEY___PACKAGE|5.004000||Viu KEY_pipe|5.003007||Viu KEY_pop|5.003007||Viu KEY_pos|5.003007||Viu KEY_print|5.003007||Viu KEY_printf|5.003007||Viu KEY_prototype|5.003007||Viu KEY_push|5.003007||Viu KEY_q|5.003007||Viu KEY_qq|5.003007||Viu KEY_qr|5.005000||Viu KEY_quotemeta|5.003007||Viu KEY_qw|5.003007||Viu KEY_qx|5.003007||Viu KEY_rand|5.003007||Viu KEY_read|5.003007||Viu KEY_readdir|5.003007||Viu KEY_readline|5.003007||Viu KEY_readlink|5.003007||Viu KEY_readpipe|5.003007||Viu KEY_recv|5.003007||Viu KEY_redo|5.003007||Viu KEY_ref|5.003007||Viu KEY_rename|5.003007||Viu KEY_require|5.003007||Viu KEY_reset|5.003007||Viu KEY_return|5.003007||Viu KEY_reverse|5.003007||Viu KEY_rewinddir|5.003007||Viu KEY_rindex|5.003007||Viu KEY_rmdir|5.003007||Viu KEY_s|5.003007||Viu KEY_say|5.009003||Viu KEY_scalar|5.003007||Viu KEY_seek|5.003007||Viu KEY_seekdir|5.003007||Viu KEY_select|5.003007||Viu KEY_semctl|5.003007||Viu KEY_semget|5.003007||Viu KEY_semop|5.003007||Viu KEY_send|5.003007||Viu KEY_setgrent|5.003007||Viu KEY_sethostent|5.003007||Viu KEY_setnetent|5.003007||Viu KEY_setpgrp|5.003007||Viu KEY_setpriority|5.003007||Viu KEY_setprotoent|5.003007||Viu KEY_setpwent|5.003007||Viu KEY_setservent|5.003007||Viu KEY_setsockopt|5.003007||Viu KEY_shift|5.003007||Viu KEY_shmctl|5.003007||Viu KEY_shmget|5.003007||Viu KEY_shmread|5.003007||Viu KEY_shmwrite|5.003007||Viu KEY_shutdown|5.003007||Viu KEY_sigvar|5.025004||Viu KEY_sin|5.003007||Viu KEY_sleep|5.003007||Viu KEY_socket|5.003007||Viu KEY_socketpair|5.003007||Viu KEY_sort|5.003007||Viu KEY_splice|5.003007||Viu KEY_split|5.003007||Viu KEY_sprintf|5.003007||Viu KEY_sqrt|5.003007||Viu KEY_srand|5.003007||Viu KEY_stat|5.003007||Viu KEY_state|5.009004||Viu KEY_study|5.003007||Viu KEY_sub|5.003007||Viu KEY___SUB|5.015006||Viu KEY_substr|5.003007||Viu KEY_symlink|5.003007||Viu KEY_syscall|5.003007||Viu KEY_sysopen|5.003007||Viu KEY_sysread|5.003007||Viu KEY_sysseek|5.004000||Viu KEY_system|5.003007||Viu KEY_syswrite|5.003007||Viu KEY_tell|5.003007||Viu KEY_telldir|5.003007||Viu KEY_tie|5.003007||Viu KEY_tied|5.003007||Viu KEY_time|5.003007||Viu KEY_times|5.003007||Viu KEY_tr|5.003007||Viu KEY_truncate|5.003007||Viu KEY_try|5.033007||Viu KEY_uc|5.003007||Viu KEY_ucfirst|5.003007||Viu KEY_umask|5.003007||Viu KEY_undef|5.003007||Viu KEY_UNITCHECK|5.009005||Viu KEY_unless|5.003007||Viu KEY_unlink|5.003007||Viu KEY_unpack|5.003007||Viu KEY_unshift|5.003007||Viu KEY_untie|5.003007||Viu KEY_until|5.003007||Viu KEY_use|5.003007||Viu KEY_utime|5.003007||Viu KEY_values|5.003007||Viu KEY_vec|5.003007||Viu KEY_wait|5.003007||Viu KEY_waitpid|5.003007||Viu KEY_wantarray|5.003007||Viu KEY_warn|5.003007||Viu KEY_when|5.027008||Viu KEY_while|5.003007||Viu keyword|5.003007||Viu KEYWORD_PLUGIN_DECLINE|5.011002||Viu KEYWORD_PLUGIN_EXPR|5.011002||Viu KEYWORD_PLUGIN_MUTEX_INIT|5.027006||Viu KEYWORD_PLUGIN_MUTEX_LOCK|5.027006||Viu KEYWORD_PLUGIN_MUTEX_TERM|5.027006||Viu KEYWORD_PLUGIN_MUTEX_UNLOCK|5.027006||Viu keyword_plugin_standard|||iu KEYWORD_PLUGIN_STMT|5.011002||Viu KEY_write|5.003007||Viu KEY_x|5.003007||Viu KEY_xor|5.003007||Viu KEY_y|5.003007||Viu kGVOP_gv|5.006000||Viu kill|5.005000||Viu killpg|5.005000||Viu kLISTOP|5.003007||Viu kLOGOP|5.003007||Viu kLOOP|5.003007||Viu kPADOP|5.006000||Viu kPMOP|5.003007||Viu kPVOP|5.003007||Viu kSVOP|5.003007||Viu kSVOP_sv|5.006000||Viu kUNOP|5.003007||Viu kUNOP_AUX|5.021007||Viu LATIN1_TO_NATIVE|5.019004|5.003007|p LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE|5.013011||Viu LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE_NATIVE|5.017004||Viu LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE|5.023002||Viu LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE_UTF8|5.023002||Viu LATIN_CAPITAL_LETTER_SHARP_S|5.014000||Viu LATIN_CAPITAL_LETTER_SHARP_S_UTF8|5.019001||Viu LATIN_CAPITAL_LETTER_Y_WITH_DIAERESIS|5.013011||Viu LATIN_SMALL_LETTER_A_WITH_RING_ABOVE|5.013011||Viu LATIN_SMALL_LETTER_A_WITH_RING_ABOVE_NATIVE|5.017004||Viu LATIN_SMALL_LETTER_DOTLESS_I|5.023002||Viu LATIN_SMALL_LETTER_DOTLESS_I_UTF8|5.023002||Viu LATIN_SMALL_LETTER_LONG_S|5.017003||Viu LATIN_SMALL_LETTER_LONG_S_UTF8|5.019001||Viu LATIN_SMALL_LETTER_SHARP_S|5.011002||Viu LATIN_SMALL_LETTER_SHARP_S_NATIVE|5.017004||Viu LATIN_SMALL_LETTER_SHARP_S_UTF8|5.033003||Viu LATIN_SMALL_LETTER_Y_WITH_DIAERESIS|5.011002||Viu LATIN_SMALL_LETTER_Y_WITH_DIAERESIS_NATIVE|5.017004||Viu LATIN_SMALL_LIGATURE_LONG_S_T|5.019004||Viu LATIN_SMALL_LIGATURE_LONG_S_T_UTF8|5.019004||Viu LATIN_SMALL_LIGATURE_ST|5.019004||Viu LATIN_SMALL_LIGATURE_ST_UTF8|5.019004||Viu LB_BREAKABLE|5.023007||Viu LB_CM_ZWJ_foo|5.025003||Viu LB_HY_or_BA_then_foo|5.023007||Viu LB_NOBREAK|5.023007||Viu LB_NOBREAK_EVEN_WITH_SP_BETWEEN|5.023007||Viu LB_PR_or_PO_then_OP_or_HY|5.023007||Viu LB_RI_then_RI|5.025003||Viu LB_SP_foo|5.023007||Viu LB_SY_or_IS_then_various|5.023007||Viu LB_various_then_PO_or_PR|5.023007||Viu LC_NUMERIC_LOCK|5.027009||pVu LC_NUMERIC_UNLOCK|5.027009||pVu LDBL_DIG|5.006000||Viu LEAVE|5.003007|5.003007| leave_adjust_stacks|5.023008|5.023008|xu leave_scope|5.003007|5.003007|u LEAVE_SCOPE|5.003007||Viu LEAVE_with_name|5.011002|5.011002| LEXACT|5.031005||Viu LEXACT_REQ8|5.031006||Viu LEXACT_REQ8_t8|5.035004||Viu LEXACT_REQ8_t8_p8|5.033003||Viu LEXACT_REQ8_t8_pb|5.033003||Viu LEXACT_REQ8_tb|5.035004||Viu LEXACT_REQ8_tb_p8|5.033003||Viu LEXACT_REQ8_tb_pb|5.033003||Viu LEXACT_t8|5.035004||Viu LEXACT_t8_p8|5.033003||Viu LEXACT_t8_pb|5.033003||Viu LEXACT_tb|5.035004||Viu LEXACT_tb_p8|5.033003||Viu LEXACT_tb_pb|5.033003||Viu lex_bufutf8|5.011002|5.011002|x lex_discard_to|5.011002|5.011002|x LEX_DONT_CLOSE_RSFP|5.015009||Viu LEX_EVALBYTES|5.015005||Viu lex_grow_linestr|5.011002|5.011002|x LEX_IGNORE_UTF8_HINTS|5.015005||Viu LEX_KEEP_PREVIOUS|5.011002|5.011002| lex_next_chunk|5.011002|5.011002|x LEX_NOTPARSING|5.004004||Viu lex_peek_unichar|5.011002|5.011002|x lex_read_space|5.011002|5.011002|x lex_read_to|5.011002|5.011002|x lex_read_unichar|5.011002|5.011002|x lex_start|5.013007|5.013007|x LEX_START_COPIED|5.015005||Viu LEX_START_FLAGS|5.015005||Viu LEX_START_SAME_FILTER|5.014000||Viu lex_stuff_pv|5.013006|5.013006|x lex_stuff_pvn|5.011002|5.011002|x lex_stuff_pvs|5.013005|5.013005|x lex_stuff_sv|5.011002|5.011002|x LEX_STUFF_UTF8|5.011002|5.011002| lex_unstuff|5.011002|5.011002|x LF_NATIVE|5.019004||Viu LIB_INVARG|5.008001||Viu LIBM_LIB_VERSION|5.009003|5.009003|Vn LIKELY|5.009004|5.003007|p link|5.006000||Viu LINKLIST|5.013006|5.013006| list|5.003007||Viu listen|5.005000||Viu listkids|5.003007||Viu LNBREAK|5.009005||Viu LNBREAK_t8|5.035004||Viu LNBREAK_t8_p8|5.033003||Viu LNBREAK_t8_pb|5.033003||Viu LNBREAK_tb|5.035004||Viu LNBREAK_tb_p8|5.033003||Viu LNBREAK_tb_pb|5.033003||Viu load_charnames|5.031010||cViu load_module|5.006000|5.003007|pv load_module_nocontext|5.013006|5.013006|vn LOCALECONV_LOCK|5.033005||Viu LOCALECONV_UNLOCK|5.033005||Viu LOCALE_INIT|5.024000||Viu LOCALE_INIT_LC_NUMERIC|5.033005||Viu LOCALE_LOCK|5.024000||Viu LOCALE_PAT_MOD|5.013006||Viu LOCALE_PAT_MODS|5.013006||Viu LOCALE_READ_LOCK|5.033005||Viu LOCALE_READ_UNLOCK|5.033005||Viu LOCALE_TERM|5.024000||Viu LOCALE_TERM_LC_NUMERIC|5.033005||Viu LOCALE_TERM_POSIX_2008|5.033005||Viu LOCALE_UNLOCK|5.024000||Viu localize|5.003007||Viu LOCAL_PATCH_COUNT|5.003007||Viu localtime|5.031011||Viu LOCALTIME_MAX|5.010001|5.010001|Vn LOCALTIME_MIN|5.010001|5.010001|Vn LOCALTIME_R_NEEDS_TZSET|5.010000|5.010000|Vn LOCALTIME_R_PROTO|5.008000|5.008000|Vn LOCK_DOLLARZERO_MUTEX|5.008001||Viu lockf|5.006000||Viu LOCK_LC_NUMERIC_STANDARD|5.021010||poVnu LOCK_NUMERIC_STANDARD|||piu LOC_SED|5.003007|5.003007|Vn LOGICAL|5.005000||Viu LOGICAL_t8|5.035004||Viu LOGICAL_t8_p8|5.033003||Viu LOGICAL_t8_pb|5.033003||Viu LOGICAL_tb|5.035004||Viu LOGICAL_tb_p8|5.033003||Viu LOGICAL_tb_pb|5.033003||Viu LONGDBLINFBYTES|5.023000|5.023000|Vn LONGDBLMANTBITS|5.023000|5.023000|Vn LONGDBLNANBYTES|5.023000|5.023000|Vn LONGDOUBLE_BIG_ENDIAN|5.021009||Viu LONGDOUBLE_DOUBLEDOUBLE|5.021009||Viu LONG_DOUBLE_EQUALS_DOUBLE|5.007001||Viu LONG_DOUBLE_IS_DOUBLE|5.021003|5.021003|Vn LONG_DOUBLE_IS_DOUBLEDOUBLE_128_BIT_BE_BE|5.023006|5.023006|Vn LONG_DOUBLE_IS_DOUBLEDOUBLE_128_BIT_BE_LE|5.023006|5.023006|Vn LONG_DOUBLE_IS_DOUBLEDOUBLE_128_BIT_BIG_ENDIAN|5.021003|5.021003|Vn LONG_DOUBLE_IS_DOUBLEDOUBLE_128_BIT_LE_BE|5.023006|5.023006|Vn LONG_DOUBLE_IS_DOUBLEDOUBLE_128_BIT_LE_LE|5.023006|5.023006|Vn LONG_DOUBLE_IS_DOUBLEDOUBLE_128_BIT_LITTLE_ENDIAN|5.021003|5.021003|Vn LONG_DOUBLE_IS_IEEE_754_128_BIT_BIG_ENDIAN|5.021003|5.021003|Vn LONG_DOUBLE_IS_IEEE_754_128_BIT_LITTLE_ENDIAN|5.021003|5.021003|Vn LONG_DOUBLE_IS_UNKNOWN_FORMAT|5.021003|5.021003|Vn LONG_DOUBLE_IS_VAX_H_FLOAT|5.025004|5.025004|Vn LONG_DOUBLE_IS_X86_80_BIT_BIG_ENDIAN|5.021003|5.021003|Vn LONG_DOUBLE_IS_X86_80_BIT_LITTLE_ENDIAN|5.021003|5.021003|Vn LONG_DOUBLEKIND|5.021003|5.021003|Vn LONGDOUBLE_LITTLE_ENDIAN|5.021009||Viu LONGDOUBLE_MIX_ENDIAN|5.023006||Viu LONG_DOUBLESIZE|5.005000|5.005000|Vn LONG_DOUBLE_STYLE_IEEE|5.025007|5.025007|Vn LONG_DOUBLE_STYLE_IEEE_EXTENDED|5.025007|5.025007|Vn LONGDOUBLE_VAX_ENDIAN|5.025004||Viu LONGDOUBLE_X86_80_BIT|5.021009||Viu LONGJMP|5.005000||Viu longjmp|5.005000||Viu LONGJMP_t8|5.035004||Viu LONGJMP_t8_p8|5.033003||Viu LONGJMP_t8_pb|5.033003||Viu LONGJMP_tb|5.035004||Viu LONGJMP_tb_p8|5.033003||Viu LONGJMP_tb_pb|5.033003||Viu LONGLONGSIZE|5.005000|5.005000|Vn LONGSIZE|5.004000|5.003007|oVn LOOKBEHIND_END_t8_p8|||Viu LOOKBEHIND_END_t8_pb|||Viu LOOKBEHIND_END_t8|||Viu LOOKBEHIND_END_tb_p8|||Viu LOOKBEHIND_END_tb_pb|||Viu LOOKBEHIND_END_tb|||Viu LOOKBEHIND_END|||Viu looks_like_bool|5.027008||Viu looks_like_number|5.003007|5.003007| LOOP_PAT_MODS|5.009005||Viu lop|5.005000||Viu lossless_NV_to_IV|5.031001||Vniu LOWEST_ANYOF_HRx_BYTE|5.031002||Viu L_R_TZSET|5.009005|5.009005|Vn lsbit_pos32|5.035003||cVnu lsbit_pos|5.035004||Viu lsbit_pos64|5.035003||cVnu lsbit_pos_uintmax|5.035003||Viu lseek|5.005000||Viu LSEEKSIZE|5.006000|5.006000|Vn lstat|5.005000||Viu LvFLAGS|5.015006||Viu LVf_NEG_LEN|5.027001||Viu LVf_NEG_OFF|5.027001||Viu LVf_OUT_OF_RANGE|5.027001||Viu LVRET|5.007001||Vi LvSTARGOFF|5.019004||Viu LvTARG|5.003007||Viu LvTARGLEN|5.003007||Viu LvTARGOFF|5.003007||Viu LvTYPE|5.003007||Viu LZC_TO_MSBIT_POS|5.035003||Viu magic_clear_all_env|5.004001||Viu magic_cleararylen_p|5.017002||Viu magic_clearenv|5.003007||Viu magic_clearhint|5.009004||Vi magic_clearhints|5.011000||Vi magic_clearisa|5.010001||Viu magic_clearpack|5.003007||Viu magic_clearsig|5.003007||Viu magic_copycallchecker|5.017000||Viu magic_dump|5.006000|5.006000|u magic_existspack|5.003007||Viu magic_freearylen_p|5.009003||Viu magic_freecollxfrm|5.033004||Viu magic_freemglob|5.033004||Viu magic_freeovrld|5.007001||Viu magic_freeutf8|5.033004||Viu magic_get|5.003007||Viu magic_getarylen|5.003007||Viu magic_getdebugvar|5.021005||Viu magic_getdefelem|5.004000||Viu magic_getnkeys|5.004005||Viu magic_getpack|5.003007||Viu magic_getpos|5.003007||Viu magic_getsig|5.003007||Viu magic_getsubstr|5.004005||Viu magic_gettaint|5.003007||Viu magic_getuvar|5.003007||Viu magic_getvec|5.004005||Viu magic_killbackrefs|5.006000||Viu magic_methcall1|5.013001||Viu magic_methcall|||vi magic_methpack|5.005000||Viu magic_nextpack|5.003007||Viu magic_regdata_cnt|5.006000||Viu magic_regdatum_get|5.006000||Viu magic_regdatum_set|5.006001||Viu magic_scalarpack|5.009001||Viu magic_set|5.003007||Viu magic_set_all_env|5.004004||Viu magic_setarylen|5.003007||Viu magic_setcollxfrm|5.004000||Viu magic_setdbline|5.003007||Viu magic_setdebugvar|5.021005||Viu magic_setdefelem|5.004000||Viu magic_setenv|5.003007||Viu magic_sethint|5.009004||Vi magic_sethint_feature|5.031007||Viu magic_setisa|5.003007||Viu magic_setlvref|5.021005||Viu magic_setmglob|5.003007||Viu magic_setnkeys|5.003007||Viu magic_setnonelem|5.027009||Viu magic_setpack|5.003007||Viu magic_setpos|5.003007||Viu magic_setregexp|5.008001||Viu magic_setsig|5.003007||Viu magic_setsigall|5.035001||Viu magic_setsubstr|5.003007||Viu magic_settaint|5.003007||Viu magic_setutf8|5.008001||Viu magic_setuvar|5.003007||Viu magic_setvec|5.003007||Viu magic_sizepack|5.005000||Viu magic_wipepack|5.003007||Viu make_exactf_invlist|5.031006||Viu make_matcher|5.027008||Viu make_trie|5.009002||Viu malloc|5.003007||Vn MALLOC_CHECK_TAINT2|5.008001||Viu MALLOC_CHECK_TAINT|5.008001||Viu malloced_size|5.005000||Vniu malloc_good_size|5.010001||Vniu MALLOC_INIT|5.005000||Viu MALLOC_OVERHEAD|5.006000||Viu Malloc_t|5.003007|5.003007|Vn MALLOC_TERM|5.005000||Viu MALLOC_TOO_LATE_FOR|5.008001||Viu MARK|5.003007|5.003007| MARKPOINT|5.009005||Viu MARKPOINT_next|5.009005||Viu MARKPOINT_next_fail|5.009005||Viu MARKPOINT_next_fail_t8|5.035004||Viu MARKPOINT_next_fail_t8_p8|5.033003||Viu MARKPOINT_next_fail_t8_pb|5.033003||Viu MARKPOINT_next_fail_tb|5.035004||Viu MARKPOINT_next_fail_tb_p8|5.033003||Viu MARKPOINT_next_fail_tb_pb|5.033003||Viu MARKPOINT_next_t8|5.035004||Viu MARKPOINT_next_t8_p8|5.033003||Viu MARKPOINT_next_t8_pb|5.033003||Viu MARKPOINT_next_tb|5.035004||Viu MARKPOINT_next_tb_p8|5.033003||Viu MARKPOINT_next_tb_pb|5.033003||Viu MARKPOINT_t8|5.035004||Viu MARKPOINT_t8_p8|5.033003||Viu MARKPOINT_t8_pb|5.033003||Viu MARKPOINT_tb|5.035004||Viu MARKPOINT_tb_p8|5.033003||Viu MARKPOINT_tb_pb|5.033003||Viu markstack_grow|5.021001|5.021001|u matcher_matches_sv|5.027008||Viu MAX|5.025006||Viu MAX_ANYOF_HRx_BYTE|5.031002||Viu MAXARG|5.003007||Viu MAX_CHARSET_NAME_LENGTH|5.013009||Viu MAX_FEATURE_LEN|5.013010||Viu MAX_FOLD_FROMS|5.029006||Viu MAX_LEGAL_CP|5.029002||Viu MAX_MATCHES|5.033005||Viu MAXO|5.003007||Viu MAXPATHLEN|5.006000||Viu MAX_PORTABLE_UTF8_TWO_BYTE|5.011002||Viu MAX_PRINT_A|5.033005||Viu MAX_RECURSE_EVAL_NOCHANGE_DEPTH|5.009005||Viu MAXSYSFD|5.003007||Viu MAX_UNICODE_UTF8|5.027006||Viu MAX_UNI_KEYWORD_INDEX|5.027011||Viu MAX_UTF8_TWO_BYTE|5.019004||Viu MAYBE_DEREF_GV|5.015003||Viu MAYBE_DEREF_GV_flags|5.015003||Viu MAYBE_DEREF_GV_nomg|5.015003||Viu maybe_multimagic_gv|5.019004||Viu mayberelocate|5.015006||Viu MBLEN_LOCK|5.033005||Viu MBLEN_UNLOCK|5.033005||Viu MBOL|5.003007||Viu MBOL_t8|5.035004||Viu MBOL_t8_p8|5.033003||Viu MBOL_t8_pb|5.033003||Viu MBOL_tb|5.035004||Viu MBOL_tb_p8|5.033003||Viu MBOL_tb_pb|5.033003||Viu MBTOWC_LOCK|5.033005||Viu MBTOWC_UNLOCK|5.033005||Viu MDEREF_ACTION_MASK|5.021007||Viu MDEREF_AV_gvav_aelem|5.021007||Viu MDEREF_AV_gvsv_vivify_rv2av_aelem|5.021007||Viu MDEREF_AV_padav_aelem|5.021007||Viu MDEREF_AV_padsv_vivify_rv2av_aelem|5.021007||Viu MDEREF_AV_pop_rv2av_aelem|5.021007||Viu MDEREF_AV_vivify_rv2av_aelem|5.021007||Viu MDEREF_FLAG_last|5.021007||Viu MDEREF_HV_gvhv_helem|5.021007||Viu MDEREF_HV_gvsv_vivify_rv2hv_helem|5.021007||Viu MDEREF_HV_padhv_helem|5.021007||Viu MDEREF_HV_padsv_vivify_rv2hv_helem|5.021007||Viu MDEREF_HV_pop_rv2hv_helem|5.021007||Viu MDEREF_HV_vivify_rv2hv_helem|5.021007||Viu MDEREF_INDEX_const|5.021007||Viu MDEREF_INDEX_gvsv|5.021007||Viu MDEREF_INDEX_MASK|5.021007||Viu MDEREF_INDEX_none|5.021007||Viu MDEREF_INDEX_padsv|5.021007||Viu MDEREF_MASK|5.021007||Viu MDEREF_reload|5.021007||Viu MDEREF_SHIFT|5.021007||Viu measure_struct|5.007003||Viu MEM_ALIGNBYTES|5.003007|5.003007|Vn memBEGINPs|5.027006||Viu memBEGINs|5.027006||Viu MEMBER_TO_FPTR|5.006000||Viu memCHRs|5.031008|5.003007|p mem_collxfrm|5.003007||dViu _mem_collxfrm|5.025002||Viu memENDPs|5.027006||Viu memENDs|5.027006||Viu memEQ|5.004000|5.003007|p memEQs|5.009005|5.003007|p memGE|5.025005||Viu memGT|5.025005||Viu memLE|5.025005||Viu MEM_LOG_ALLOC|5.009003||Viu mem_log_alloc|5.024000||Vniu mem_log_common|5.010001||Vniu MEM_LOG_FREE|5.009003||Viu mem_log_free|5.024000||Vniu MEM_LOG_REALLOC|5.009003||Viu mem_log_realloc|5.024000||Vniu memLT|5.025005||Viu memNE|5.004000|5.003007|p memNEs|5.009005|5.003007|p MEM_SIZE|5.003007||Viu MEM_SIZE_MAX|5.009005||Viu MEM_WRAP_CHECK_1|5.009002||Viu MEM_WRAP_CHECK|5.009002||Viu MEM_WRAP_CHECK_s|5.027010||Viu memzero|5.003007|5.003007| MEOL|5.003007||Viu MEOL_t8|5.035004||Viu MEOL_t8_p8|5.033003||Viu MEOL_t8_pb|5.033003||Viu MEOL_tb|5.035004||Viu MEOL_tb_p8|5.033003||Viu MEOL_tb_pb|5.033003||Viu mess|5.003007||pvV mess_alloc|5.005000||Viu mess_nocontext|5.006000||pvVn mess_sv|5.013001|5.004000|p MEXTEND|5.003007||Viu mfree|||nu MgBYTEPOS|5.019004||Viu MgBYTEPOS_set|5.019004||Viu mg_clear|5.003007|5.003007| mg_copy|5.003007|5.003007| mg_dup|5.007003|5.007003|u MGf_BYTES|5.019004||Viu MGf_COPY|5.007003||Viu MGf_DUP|5.007003||Viu MGf_GSKIP|5.003007||Viu mg_find|5.003007|5.003007|n mg_findext|5.013008|5.003007|pn mg_find_mglob|5.019002||cViu MGf_LOCAL|5.009003||Viu MGf_MINMATCH|5.003007||Viu MGf_PERSIST|5.021005||Viu mg_free|5.003007|5.003007| mg_freeext|5.027004|5.027004| mg_free_type|5.013006|5.013006| MGf_REFCOUNTED|5.003007||Viu MGf_REQUIRE_GV|5.021004||Viu MGf_TAINTEDDIR|5.003007||Viu mg_get|5.003007|5.003007| mg_length|5.005000|5.005000|d mg_localize|5.009003||Vi mg_magical|5.003007|5.003007|n MgPV|5.003007||Viu MgPV_const|5.009003||Viu MgPV_nolen_const|5.009003||Viu mg_set|5.003007|5.003007| mg_size|5.005000|5.005000|u MgSV|5.033009||Viu MgTAINTEDDIR|5.003007||Viu MgTAINTEDDIR_off|5.004000||Viu MgTAINTEDDIR_on|5.003007||Viu MICRO_SIGN|5.011002||Viu MICRO_SIGN_NATIVE|5.017004||Viu MICRO_SIGN_UTF8|5.033003||Viu MIN|5.025006||Viu mini_mktime|5.007002|5.007002|n MINMOD|5.003007||Viu MINMOD_t8|5.035004||Viu MINMOD_t8_p8|5.033003||Viu MINMOD_t8_pb|5.033003||Viu MINMOD_tb|5.035004||Viu MINMOD_tb_p8|5.033003||Viu MINMOD_tb_pb|5.033003||Viu minus_v|5.015006||Viu missingterm|5.005000||Viu Mkdir|5.004000||Viu mkdir|5.005000||Viu mktemp|5.005000||Viu Mmap_t|5.006000|5.006000|Vn mode_from_discipline|5.006000||Viu Mode_t|5.003007|5.003007|Vn modkids|5.003007||Viu MON_10|5.027010||Viu MON_11|5.027010||Viu MON_12|5.027010||Viu MON_1|5.027010||Viu MON_2|5.027010||Viu MON_3|5.027010||Viu MON_4|5.027010||Viu MON_5|5.027010||Viu MON_6|5.027010||Viu MON_7|5.027010||Viu MON_8|5.027010||Viu MON_9|5.027010||Viu more_bodies|||iu more_sv|5.009004||Viu moreswitches|5.003007||cVu mortal_getenv|5.031011||cVnu Move|5.003007|5.003007| MoveD|5.009002|5.003007|p move_proto_attr|5.019005||Viu M_PAT_MODS|5.009005||Viu MPH_BUCKETS|5.027011||Viu MPH_RSHIFT|5.027011||Viu MPH_VALt|5.027011||Viu mPUSHi|5.009002|5.003007|p mPUSHn|5.009002|5.003007|p mPUSHp|5.009002|5.003007|p mPUSHs|5.010001|5.003007|p mPUSHu|5.009002|5.003007|p mro_clean_isarev|5.013007||Viu mro_gather_and_rename|5.013007||Viu mro_get_from_name|||u mro_get_linear_isa|5.009005|5.009005| mro_get_linear_isa_c3|||i mro_get_linear_isa_dfs|5.009005||Vi MRO_GET_PRIVATE_DATA|5.010001|5.010001| mro_get_private_data|||cu mro_isa_changed_in|5.009005||Vi mro_meta_dup|5.009005||Viu mro_meta_init|||ciu mro_method_changed_in|5.009005|5.009005| mro_package_moved|5.013006||Vi mro_register||| mro_set_mro|||u mro_set_private_data||| msbit_pos32|5.035003||cVnu msbit_pos|5.035004||Viu msbit_pos64|5.035003||cVnu msbit_pos_uintmax|5.035003||Viu MSPAGAIN|5.003007||Viu MSVC_DIAG_IGNORE|5.029010||Viu MSVC_DIAG_IGNORE_DECL|5.029010||Viu MSVC_DIAG_IGNORE_STMT|5.029010||Viu MSVC_DIAG_RESTORE|5.029010||Viu MSVC_DIAG_RESTORE_DECL|5.029010||Viu MSVC_DIAG_RESTORE_STMT|5.029010||Viu mul128|5.005000||Viu MULTICALL|5.009003|5.009003| multiconcat_stringify|5.027006||cViu multideref_stringify|5.021009||cViu MULTILINE_PAT_MOD|5.009005||Viu MULTIPLICITY|5.006000|5.006000|Vn MUTABLE_AV|5.010001|5.003007|p MUTABLE_CV|5.010001|5.003007|p MUTABLE_GV|5.010001|5.003007|p MUTABLE_HV|5.010001|5.003007|p MUTABLE_IO|5.010001|5.003007|p MUTABLE_PTR|5.010001|5.003007|p MUTABLE_SV|5.010001|5.003007|p MUTEX_DESTROY|5.005000||Viu MUTEX_INIT|5.005000||Viu MUTEX_INIT_NEEDS_MUTEX_ZEROED|5.005003||Viu MUTEX_LOCK|5.005000||Viu MUTEX_UNLOCK|5.005000||Viu mXPUSHi|5.009002|5.003007|p mXPUSHn|5.009002|5.003007|p mXPUSHp|5.009002|5.003007|p mXPUSHs|5.010001|5.003007|p mXPUSHu|5.009002|5.003007|p my|5.011000||Viu my_atof2|5.029000||cVu my_atof3|5.029000||cVu my_atof|5.006000|5.006000| my_attrs|5.006000||Viu my_binmode|5.006000||Viu my_bytes_to_utf8|5.021009||Vniu my_chsize|5.003007||Vu my_clearenv|5.009003||Viu MY_CXT|5.009000|5.009000|p MY_CXT_CLONE|5.009002|5.009000|p MY_CXT_INDEX|5.009005||Viu MY_CXT_INIT|5.009000|5.009000|p MY_CXT_INIT_ARG|5.013005||Viu MY_CXT_INIT_INTERP|5.009003||Viu my_cxt_init|||u my_dirfd|5.009005|5.009005|nu my_exit|5.003007|5.003007| my_exit_jump|5.005000||Viu my_failure_exit|5.004000|5.004000|u my_fflush_all|5.006000|5.006000|u my_fork|5.007003|5.007003|nu my_kid|5.006000||Viu my_lstat|5.013003||Viu my_lstat_flags|5.013003||cViu my_memrchr|5.027006||Vniu my_mkostemp_cloexec|||niu my_mkostemp|||niu my_mkstemp_cloexec|||niu my_mkstemp|||niu my_nl_langinfo|5.027006||Vniu my_pclose|5.003007|5.003007|u my_popen|5.003007|5.003007|u my_popen_list|5.007001|5.007001|u my_setenv|5.003007|5.003007| my_snprintf|5.009004||pvVn my_socketpair|5.007003|5.007003|nu my_sprintf|5.009003|5.003007|pdn my_stat|5.013003||Viu my_stat_flags|5.013003||cViu my_strerror|5.021001||Viu my_strftime|5.007002||V my_strlcat|5.009004|5.003007|pn my_strlcpy|5.009004|5.003007|pn my_strnlen|5.027006|5.003007|pn my_strtod|5.029010|5.029010|n my_unexec|5.003007||Viu my_vsnprintf|5.009004|5.009004|n N0|5.029001||Viu N10|5.029001||Viu N11|5.029001||Viu N1|5.029001||Viu N2|5.029001||Viu N3|5.029001||Viu N4|5.029001||Viu N5|5.029001||Viu N6|5.029001||Viu N7|5.029001||Viu N8|5.029001||Viu N9|5.029001||Viu NAN_COMPARE_BROKEN|5.021005||Viu NANYOFM|5.029005||Viu NANYOFM_t8|5.035004||Viu NANYOFM_t8_p8|5.033003||Viu NANYOFM_t8_pb|5.033003||Viu NANYOFM_tb|5.035004||Viu NANYOFM_tb_p8|5.033003||Viu NANYOFM_tb_pb|5.033003||Viu NATIVE8_TO_UNI|5.011000||Viu NATIVE_BYTE_IS_INVARIANT|5.019004||Viu NATIVE_SKIP|5.019004||Viu NATIVE_TO_ASCII|5.007001||Viu NATIVE_TO_I8|5.015006||Viu NATIVE_TO_LATIN1|5.019004|5.003007|p NATIVE_TO_NEED|5.019004||dcVnu NATIVE_TO_UNI|5.007001|5.003007|p NATIVE_TO_UTF|5.007001||Viu NATIVE_UTF8_TO_I8|5.019004||Viu nBIT_MASK|5.033001||Viu nBIT_UMAX|5.033001||Viu NBOUND|5.003007||Viu NBOUNDA|5.013009||Viu NBOUNDA_t8|5.035004||Viu NBOUNDA_t8_p8|5.033003||Viu NBOUNDA_t8_pb|5.033003||Viu NBOUNDA_tb|5.035004||Viu NBOUNDA_tb_p8|5.033003||Viu NBOUNDA_tb_pb|5.033003||Viu NBOUNDL|5.004000||Viu NBOUNDL_t8|5.035004||Viu NBOUNDL_t8_p8|5.033003||Viu NBOUNDL_t8_pb|5.033003||Viu NBOUNDL_tb|5.035004||Viu NBOUNDL_tb_p8|5.033003||Viu NBOUNDL_tb_pb|5.033003||Viu NBOUND_t8|5.035004||Viu NBOUND_t8_p8|5.033003||Viu NBOUND_t8_pb|5.033003||Viu NBOUND_tb|5.035004||Viu NBOUND_tb_p8|5.033003||Viu NBOUND_tb_pb|5.033003||Viu NBOUNDU|5.013009||Viu NBOUNDU_t8|5.035004||Viu NBOUNDU_t8_p8|5.033003||Viu NBOUNDU_t8_pb|5.033003||Viu NBOUNDU_tb|5.035004||Viu NBOUNDU_tb_p8|5.033003||Viu NBOUNDU_tb_pb|5.033003||Viu NBSP_NATIVE|5.021001||Viu NBSP_UTF8|5.021001||Viu NDBM_H_USES_PROTOTYPES|5.032001|5.032001|Vn NDEBUG|5.021007||Viu need_utf8|5.009003||Vniu NEED_VA_COPY|5.007001|5.007001|Vn NEGATIVE_INDICES_VAR|5.008001||Viu Netdb_hlen_t|5.005000|5.005000|Vn Netdb_host_t|5.005000|5.005000|Vn Netdb_name_t|5.005000|5.005000|Vn Netdb_net_t|5.005000|5.005000|Vn NETDB_R_OBSOLETE|5.008000||Viu New|5.003007||Viu newANONATTRSUB|5.006000|5.006000|u newANONHASH|5.003007|5.003007|u newANONLIST|5.003007|5.003007|u newANONSUB|5.003007|5.003007|u newASSIGNOP|5.003007|5.003007| newATTRSUB|5.006000|5.006000| newATTRSUB_x|5.019008||cVi newAV|5.003007|5.003007| newAV_alloc_x|5.035001|5.035001| newAV_alloc_xz|5.035001|5.035001| newAVREF|5.003007|5.003007|u newBINOP|5.003007|5.003007| Newc|5.003007||Viu new_collate|5.006000||Viu newCONDOP|5.003007|5.003007| new_constant|||iu newCONSTSUB|5.004005|5.003007|p newCONSTSUB_flags|5.015006|5.015006| new_ctype|5.006000||Viu newCVREF|5.003007|5.003007|u newDEFEROP|5.035004|5.035004|x newDEFSVOP|5.021006|5.021006| newFORM|5.003007|5.003007|u newFOROP|5.013007|5.013007| newGIVENOP|5.009003|5.009003| newGIVWHENOP|5.027008||Viu newGP|||xiu newGVgen|5.003007|5.003007|u newGVgen_flags|5.015004|5.015004|u newGVOP|5.003007|5.003007| newGVREF|5.003007|5.003007|u new_he|5.005000||Viu newHV|5.003007|5.003007| newHVhv|5.005000|5.005000|u newHVREF|5.003007|5.003007|u _new_invlist|5.013010||cViu _new_invlist_C_array|5.015008||cViu newIO|5.003007|5.003007|u newLISTOP|5.003007|5.003007| newLOGOP|5.003007|5.003007| new_logop|5.005000||Viu newLOOPEX|5.003007|5.003007| newLOOPOP|5.003007|5.003007| newMETHOP|5.021005|5.021005| newMETHOP_internal|5.021005||Viu newMETHOP_named|5.021005|5.021005| new_msg_hv|5.027009||Viu newMYSUB|5.017004|5.017004|u newNULLLIST|5.003007|5.003007| new_numeric|5.006000||Viu newOP|5.003007|5.003007| NewOp|5.008001||Viu newPADNAMELIST|5.021007|5.021007|xn newPADNAMEouter|5.021007|5.021007|xn newPADNAMEpvn|5.021007|5.021007|xn newPADOP|5.006000||V newPMOP|5.003007|5.003007| newPROG|5.003007|5.003007|u newPVOP|5.003007|5.003007| newRANGE|5.003007|5.003007| newRV|5.003007|5.003007| newRV_inc|5.004000|5.003007|p newRV_noinc|5.004000|5.003007|p newSLICEOP|5.003007|5.003007| new_stackinfo|5.005000|5.005000|u newSTATEOP|5.003007|5.003007| newSTUB|5.017001||Viu newSUB|5.003007|5.003007| newSV|5.003007|5.003007| NEWSV|5.003007||Viu newSVavdefelem|5.019004||Viu newSVhek|5.009003|5.009003| newSViv|5.003007|5.003007| newSVnv|5.006000|5.003007| newSVOP|5.003007|5.003007| newSVpadname|5.017004|5.017004|x newSVpv|5.003007|5.003007| newSVpvf|5.004000||vV newSVpvf_nocontext|5.006000||vVn newSVpvn|5.004005|5.003007|p newSVpvn_flags|5.010001|5.003007|p newSVpvn_share|5.007001|5.003007|p newSVpvn_utf8|5.010001|5.003007|p newSVpvs|5.009003|5.003007|p newSVpvs_flags|5.010001|5.003007|p newSVpv_share|5.013006|5.013006| newSVpvs_share|5.009003|5.003007|p newSVREF|5.003007|5.003007|u newSVrv|5.003007|5.003007| newSVsv|5.003007|5.003007| newSVsv_flags|5.029009|5.003007|p newSVsv_nomg|5.029009|5.003007|p newSV_type|5.009005|5.003007|p newSVuv|5.006000|5.003007|p newTRYCATCHOP|5.033007|5.033007|x newUNOP|5.003007|5.003007| newUNOP_AUX|5.021007|5.021007| new_version|5.009000|5.009000| NEW_VERSION|5.019008||Viu new_warnings_bitfield|||xciu newWHENOP|5.027008|5.027008| newWHILEOP|5.013007|5.013007| Newx|5.009003|5.003007|p Newxc|5.009003|5.003007|p newXS|5.006000|5.006000| newXS_deffile|5.021006||cViu newXS_flags|5.009004|5.009004|xu newXS_len_flags|5.015006||Vi newXSproto|5.006000|5.006000| Newxz|5.009003|5.003007|p Newz|5.003007||Viu nextargv|5.003007||Viu nextchar|5.005000||Viu NEXT_LINE_CHAR|5.007003||Viu NEXT_OFF|5.005000||Viu NEXTOPER|5.003007||Viu next_symbol|5.007003||Viu ninstr|5.003007|5.003007|n NL_LANGINFO_LOCK|5.033005||Viu NL_LANGINFO_UNLOCK|5.033005||Viu no_bareword_allowed|5.005004||Viu no_bareword_filehandle|5.033006||Viu NOCAPTURE_PAT_MOD|5.021008||Viu NOCAPTURE_PAT_MODS|5.021008||Viu NODE_ALIGN|5.005000||Viu NODE_ALIGN_FILL|5.005000||Viu NODE_STEP_REGNODE|5.005000||Viu NODE_SZ_STR|5.006000||Viu NO_ENV_ARRAY_IN_MAIN|5.009004||Viu NOEXPR|5.027010||Viu NofAMmeth|5.003007||Viu no_fh_allowed|5.003007||Viu NOLINE|5.003007||Viu NO_LOCALE|5.007000||Viu NONDESTRUCT_PAT_MOD|5.013002||Viu NONDESTRUCT_PAT_MODS|5.013002||Viu NON_OTHER_COUNT|5.033005||Viu no_op|5.003007||Viu NOOP|5.005000|5.003007|p noperl_die|5.021006||vVniu NORETURN_FUNCTION_END|5.009003||Viu NORMAL|5.003007||Viu NOSTR|5.027010||Viu NO_TAINT_SUPPORT|5.017006||Viu not_a_number|5.005000||Viu NOTE3|5.027001||Viu NOTHING|5.003007||Viu NOTHING_t8|5.035004||Viu NOTHING_t8_p8|5.033003||Viu NOTHING_t8_pb|5.033003||Viu NOTHING_tb|5.035004||Viu NOTHING_tb_p8|5.033003||Viu NOTHING_tb_pb|5.033003||Viu nothreadhook|5.008000|5.008000| notify_parser_that_changed_to_utf8|5.025010||Viu not_incrementable|5.021002||Viu NOT_IN_PAD|5.005000||Viu NOT_REACHED|5.019006|5.003007|poVnu NPOSIXA|5.017003||Viu NPOSIXA_t8|5.035004||Viu NPOSIXA_t8_p8|5.033003||Viu NPOSIXA_t8_pb|5.033003||Viu NPOSIXA_tb|5.035004||Viu NPOSIXA_tb_p8|5.033003||Viu NPOSIXA_tb_pb|5.033003||Viu NPOSIXD|5.017003||Viu NPOSIXD_t8|5.035004||Viu NPOSIXD_t8_p8|5.033003||Viu NPOSIXD_t8_pb|5.033003||Viu NPOSIXD_tb|5.035004||Viu NPOSIXD_tb_p8|5.033003||Viu NPOSIXD_tb_pb|5.033003||Viu NPOSIXL|5.017003||Viu NPOSIXL_t8|5.035004||Viu NPOSIXL_t8_p8|5.033003||Viu NPOSIXL_t8_pb|5.033003||Viu NPOSIXL_tb|5.035004||Viu NPOSIXL_tb_p8|5.033003||Viu NPOSIXL_tb_pb|5.033003||Viu NPOSIXU|5.017003||Viu NPOSIXU_t8|5.035004||Viu NPOSIXU_t8_p8|5.033003||Viu NPOSIXU_t8_pb|5.033003||Viu NPOSIXU_tb|5.035004||Viu NPOSIXU_tb_p8|5.033003||Viu NPOSIXU_tb_pb|5.033003||Viu NSIG|5.009003||Viu ntohi|5.003007||Viu ntohl|5.003007||Viu ntohs|5.003007||Viu nuke_stacks|5.005000||Viu Null|5.003007||Viu Nullav|5.003007|5.003007|d Nullch|5.003007|5.003007| Nullcv|5.003007|5.003007|d Nullfp|5.003007||Viu Nullgv|5.003007||Viu Nullhe|5.003007||Viu Nullhek|5.004000||Viu Nullhv|5.003007|5.003007|d Nullop|5.003007||Viu Nullsv|5.003007|5.003007| NUM2PTR|5.006000||pVu NUM_ANYOF_CODE_POINTS|5.021004||Viu NUM_CLASSES|5.029001||Viu num_overflow|5.009001||Vniu NV_BIG_ENDIAN|5.021009||Viu NV_DIG|5.006000||Viu NVef|5.006001|5.003007|poVn NV_EPSILON|5.007003||Viu NVff|5.006001|5.003007|poVn NVgf|5.006001|5.003007|poVn NV_IMPLICIT_BIT|5.021009||Viu NV_INF|5.007003||Viu NV_LITTLE_ENDIAN|5.021009||Viu NVMANTBITS|5.023000|5.023000|Vn NV_MANT_DIG|5.006001||Viu NV_MAX_10_EXP|5.007003||Viu NV_MAX|5.006001||Viu NV_MAX_EXP|5.021003||Viu NV_MIN_10_EXP|5.007003||Viu NV_MIN|5.006001||Viu NV_MIN_EXP|5.021003||Viu NV_MIX_ENDIAN|5.021009||Viu NV_NAN|5.007003||Viu NV_NAN_BITS|5.023000||Viu NV_NAN_IS_QUIET|5.023000||Viu NV_NAN_IS_SIGNALING|5.023000||Viu NV_NAN_PAYLOAD_MASK|5.023000||Viu NV_NAN_PAYLOAD_MASK_IEEE_754_128_BE|5.023000||Viu NV_NAN_PAYLOAD_MASK_IEEE_754_128_LE|5.023000||Viu NV_NAN_PAYLOAD_MASK_IEEE_754_64_BE|5.023000||Viu NV_NAN_PAYLOAD_MASK_IEEE_754_64_LE|5.023000||Viu NV_NAN_PAYLOAD_MASK_SKIP_EIGHT|5.023006||Viu NV_NAN_PAYLOAD_PERM_0_TO_7|5.023000||Viu NV_NAN_PAYLOAD_PERM|5.023000||Viu NV_NAN_PAYLOAD_PERM_7_TO_0|5.023000||Viu NV_NAN_PAYLOAD_PERM_IEEE_754_128_BE|5.023000||Viu NV_NAN_PAYLOAD_PERM_IEEE_754_128_LE|5.023000||Viu NV_NAN_PAYLOAD_PERM_IEEE_754_64_BE|5.023000||Viu NV_NAN_PAYLOAD_PERM_IEEE_754_64_LE|5.023000||Viu NV_NAN_PAYLOAD_PERM_SKIP_EIGHT|5.023006||Viu NV_NAN_QS_BIT|5.023000||Viu NV_NAN_QS_BIT_OFFSET|5.023000||Viu NV_NAN_QS_BIT_SHIFT|5.023000||Viu NV_NAN_QS_BYTE|5.023000||Viu NV_NAN_QS_BYTE_OFFSET|5.023000||Viu NV_NAN_QS_QUIET|5.023000||Viu NV_NAN_QS_SIGNALING|5.023000||Viu NV_NAN_QS_TEST|5.023000||Viu NV_NAN_QS_XOR|5.023000||Viu NV_NAN_SET_QUIET|5.023000||Viu NV_NAN_SET_SIGNALING|5.023000||Viu NV_OVERFLOWS_INTEGERS_AT|5.010001|5.010001|Vn NV_PRESERVES_UV_BITS|5.006001|5.006001|Vn NVSIZE|5.006001|5.006001|Vn NVTYPE|5.006000|5.003007|poVn NV_VAX_ENDIAN|5.025003||Viu NV_WITHIN_IV|5.006000||Viu NV_WITHIN_UV|5.006000||Viu NV_X86_80_BIT|5.025004||Viu NV_ZERO_IS_ALLBITS_ZERO|5.035009|5.035009|Vn OA_AVREF|5.003007||Viu OA_BASEOP|5.005000||Viu OA_BASEOP_OR_UNOP|5.005000||Viu OA_BINOP|5.005000||Viu OA_CLASS_MASK|5.005000||Viu OA_COP|5.005000||Viu OA_CVREF|5.003007||Viu OA_DANGEROUS|5.003007||Viu OA_DEFGV|5.003007||Viu OA_FILEREF|5.003007||Viu OA_FILESTATOP|5.005000||Viu OA_FOLDCONST|5.003007||Viu OA_HVREF|5.003007||Viu OA_LIST|5.003007||Viu OA_LISTOP|5.005000||Viu OA_LOGOP|5.005000||Viu OA_LOOP|5.005000||Viu OA_LOOPEXOP|5.005000||Viu OA_MARK|5.003007||Viu OA_METHOP|5.021005||Viu OA_OPTIONAL|5.003007||Viu OA_OTHERINT|5.003007||Viu OA_PADOP|5.006000||Viu OA_PMOP|5.005000||Viu OA_PVOP_OR_SVOP|5.006000||Viu OA_RETSCALAR|5.003007||Viu OA_SCALAR|5.003007||Viu OA_SCALARREF|5.003007||Viu OASHIFT|5.003007||Viu OA_SVOP|5.005000||Viu OA_TARGET|5.003007||Viu OA_TARGLEX|5.006000||Viu OA_UNOP|5.005000||Viu OA_UNOP_AUX|5.021007||Viu O_BINARY|5.006000||Viu O_CREAT|5.006000||Viu OCSHIFT|5.006000||Viu OCTAL_VALUE|5.019008||Viu Off_t|5.003007|5.003007|Vn Off_t_size|5.006000|5.006000|Vn OFFUNI_IS_INVARIANT|5.023003||Viu OFFUNISKIP|5.019004||Viu OFFUNISKIP_helper|5.035004||Viu ONCE_PAT_MOD|5.009005||Viu ONCE_PAT_MODS|5.009005||Viu ONE_IF_EBCDIC_ZERO_IF_NOT|5.035004||Viu oopsAV|5.003007||Viu oopsHV|5.003007||Viu OP|5.003007||Viu op_append_elem|5.013006|5.013006| op_append_list|5.013006|5.013006| opASSIGN|5.003007||Viu OP_CHECK_MUTEX_INIT|5.015008||Viu OP_CHECK_MUTEX_LOCK|5.015008||Viu OP_CHECK_MUTEX_TERM|5.015008||Viu OP_CHECK_MUTEX_UNLOCK|5.015008||Viu OP_CLASS|5.013007|5.013007| op_class|5.025010|5.025010| op_clear|5.006000||cViu OPCODE|5.003007||Viu op_contextualize|5.013006|5.013006| op_convert_list|5.021006|5.021006| OP_DESC|5.007003|5.007003| op_dump|5.006000|5.006000| OPEN|5.003007||Viu open|5.005000||Viu opendir|5.005000||Viu openn_cleanup|5.019010||Viu openn_setup|5.019010||Viu open_script|5.005000||Viu OPEN_t8|5.035004||Viu OPEN_t8_p8|5.033003||Viu OPEN_t8_pb|5.033003||Viu OPEN_tb|5.035004||Viu OPEN_tb_p8|5.033003||Viu OPEN_tb_pb|5.033003||Viu OPERAND|5.003007||Viu OPERANDl|5.031005||Viu OPERANDs|5.031005||Viu OPFAIL|5.009005||Viu OPFAIL_t8|5.035004||Viu OPFAIL_t8_p8|5.033003||Viu OPFAIL_t8_pb|5.033003||Viu OPFAIL_tb|5.035004||Viu OPFAIL_tb_p8|5.033003||Viu OPFAIL_tb_pb|5.033003||Viu OPf_FOLDED|5.021007||Viu OPf_KIDS|5.003007|5.003007| OPf_KNOW|5.003007||Viu OPf_LIST|5.003007||Viu OPf_MOD|5.003007||Viu OPf_PARENS|5.003007||Viu op_free|5.003007|5.003007| OP_FREED|5.017002||Viu OPf_REF|5.003007||Viu OPf_SPECIAL|5.003007||Viu OPf_STACKED|5.003007||Viu OPf_WANT|5.004000||Viu OPf_WANT_LIST|5.004000||Viu OPf_WANT_SCALAR|5.004000||Viu OPf_WANT_VOID|5.004000||Viu OP_GIMME|5.004000||Viu OP_GIMME_REVERSE|5.010001||Viu OpHAS_SIBLING|5.021007|5.003007|p op_integerize|5.015003||Viu OP_IS_DIRHOP|5.015003||Viu OP_IS_FILETEST|5.006001||Viu OP_IS_FILETEST_ACCESS|5.008001||Viu OP_IS_INFIX_BIT|5.021009||Viu OP_IS_NUMCOMPARE|5.015003||Viu OP_IS_SOCKET|5.006001||Viu OP_IS_STAT|5.031001||Viu OpLASTSIB_set|5.021011|5.003007|p op_linklist|5.013006|5.013006| op_lvalue|5.013007|5.013007|x op_lvalue_flags|||ciu OP_LVALUE_NO_CROAK|5.015001||Viu OpMAYBESIB_set|5.021011|5.003007|p opmethod_stash|5.021007||Viu OpMORESIB_set|5.021011|5.003007|p OP_NAME|5.007003|5.007003| op_null|5.007002|5.007002| OPpALLOW_FAKE|5.015006||Viu op_parent|5.025001|5.025001|n OPpARG1_MASK|5.021004||Viu OPpARG2_MASK|5.021004||Viu OPpARG3_MASK|5.021004||Viu OPpARG4_MASK|5.021004||Viu OPpARGELEM_AV|5.025004||Viu OPpARGELEM_HV|5.025004||Viu OPpARGELEM_MASK|5.025004||Viu OPpARGELEM_SV|5.025004||Viu OPpASSIGN_BACKWARDS|5.003007||Viu OPpASSIGN_COMMON_AGG|5.023002||Viu OPpASSIGN_COMMON_RC1|5.023002||Viu OPpASSIGN_COMMON_SCALAR|5.023002||Viu OPpASSIGN_CV_TO_GV|5.009003||Viu OPpASSIGN_TRUEBOOL|5.027003||Viu OPpAVHVSWITCH_MASK|5.025006||Viu OPpCONCAT_NESTED|5.027007||Viu OPpCONST_BARE|5.003007||Viu OPpCONST_ENTERED|5.003007||Viu OPpCONST_NOVER|5.009003||Viu OPpCONST_SHORTCIRCUIT|5.009001||Viu OPpCONST_STRICT|5.005004||Viu OPpCOREARGS_DEREF1|5.015003||Viu OPpCOREARGS_DEREF2|5.015003||Viu OPpCOREARGS_PUSHMARK|5.015003||Viu OPpCOREARGS_SCALARMOD|5.015003||Viu OPpDEFER_FINALLY|5.035008||Viu OPpDEREF|5.004000||Viu OPpDEREF_AV|5.003007||Viu OPpDEREF_HV|5.003007||Viu OPpDEREF_SV|5.004000||Viu OPpDONT_INIT_GV|5.009003||Viu OPpEARLY_CV|5.006000|5.006000| OPpENTERSUB_AMPER|5.003007|5.003007| OPpENTERSUB_DB|5.003007||Viu OPpENTERSUB_HASTARG|5.006000||Viu OPpENTERSUB_INARGS|5.006000||Viu OPpENTERSUB_LVAL_MASK|5.015001||Viu OPpENTERSUB_NOPAREN|5.005004||Viu OPpEVAL_BYTES|5.015005||Viu OPpEVAL_COPHH|5.015005||Viu OPpEVAL_HAS_HH|5.009003||Viu OPpEVAL_RE_REPARSING|5.017011||Viu OPpEVAL_UNICODE|5.015005||Viu OPpEXISTS_SUB|5.006000||Viu OPpFLIP_LINENUM|5.003007||Viu OPpFT_ACCESS|5.008001||Viu OPpFT_AFTER_t|5.015008||Viu OPpFT_STACKED|5.009001||Viu OPpFT_STACKING|5.015001||Viu OPpHINT_STRICT_REFS|5.021004||Viu OPpHUSH_VMSISH|5.007003||Viu OPpINDEX_BOOLNEG|5.027003||Viu OPpITER_DEF|5.027008||Viu OPpITER_REVERSED|5.009002||Viu OPpKVSLICE|5.027001||Viu OPpLIST_GUESSED|5.003007||Viu OPpLVAL_DEFER|5.004000||Viu OPpLVAL_INTRO|5.003007||Viu OPpLVALUE|5.019006||Viu OPpLVREF_AV|5.021005||Viu OPpLVREF_CV|5.021005||Viu OPpLVREF_ELEM|5.021005||Viu OPpLVREF_HV|5.021005||Viu OPpLVREF_ITER|5.021005||Viu OPpLVREF_SV|5.021005||Viu OPpLVREF_TYPE|5.021005||Viu OPpMAYBE_LVSUB|5.007001||Viu OPpMAYBE_TRUEBOOL|5.017004||Viu OPpMAY_RETURN_CONSTANT|5.009003||Viu OPpMULTICONCAT_APPEND|5.027006||Viu OPpMULTICONCAT_FAKE|5.027006||Viu OPpMULTICONCAT_STRINGIFY|5.027006||Viu OPpMULTIDEREF_DELETE|5.021007||Viu OPpMULTIDEREF_EXISTS|5.021007||Viu OPpOFFBYONE|5.015002||Viu OPpOPEN_IN_CRLF|5.006000||Viu OPpOPEN_IN_RAW|5.006000||Viu OPpOPEN_OUT_CRLF|5.006000||Viu OPpOPEN_OUT_RAW|5.006000||Viu OPpOUR_INTRO|5.006000||Viu OPpPADHV_ISKEYS|5.027003||Viu OPpPADRANGE_COUNTMASK|5.017006||Viu OPpPADRANGE_COUNTSHIFT|5.017006||Viu OPpPAD_STATE|5.009004||Viu OPpPV_IS_UTF8|5.016000||Viu OPpREFCOUNTED|5.006000||Viu OPpREPEAT_DOLIST|5.003007||Viu op_prepend_elem|5.013006|5.013006| OPpREVERSE_INPLACE|5.011002||Viu OPpRV2HV_ISKEYS|5.027003||Viu OPpSLICE|5.004000||Viu OPpSLICEWARNING|5.019004||Viu OPpSORT_DESCEND|5.009002||Viu OPpSORT_INPLACE|5.009001||Viu OPpSORT_INTEGER|5.006000||Viu OPpSORT_NUMERIC|5.006000||Viu OPpSORT_REVERSE|5.006000||Viu OPpSPLIT_ASSIGN|5.025006||Viu OPpSPLIT_IMPLIM|5.019002||Viu OPpSPLIT_LEX|5.025006||Viu OPpSUBSTR_REPL_FIRST|5.015006||Viu OPpTARGET_MY|5.006000||Viu OPpTRANS_ALL|5.009001||Viu OPpTRANS_CAN_FORCE_UTF8|5.031006||Viu OPpTRANS_COMPLEMENT|5.003007||Viu OPpTRANS_DELETE|5.003007||Viu OPpTRANS_FROM_UTF|5.006000||Viu OPpTRANS_GROWS|5.006000||Viu OPpTRANS_IDENTICAL|5.006000||Viu OPpTRANS_SQUASH|5.003007||Viu OPpTRANS_TO_UTF|5.006000||Viu OPpTRANS_USE_SVOP|5.031006||Viu OPpTRUEBOOL|5.017004||Viu OPpUSEINT|5.035005||Viu OpREFCNT_dec|5.006000||Viu op_refcnt_dec|||xiu OpREFCNT_inc|5.006000||Viu op_refcnt_inc|||xiu OP_REFCNT_INIT|5.006000||Viu OP_REFCNT_LOCK|5.006000||Viu op_refcnt_lock|5.009002|5.009002|u OpREFCNT_set|5.006000||Viu OP_REFCNT_TERM|5.006000||Viu OP_REFCNT_UNLOCK|5.006000||Viu op_refcnt_unlock|5.009002|5.009002|u op_relocate_sv|5.021005||Viu op_scope|5.013007|5.013007|x OP_SIBLING|5.021002||Viu OpSIBLING|5.021007|5.003007|p op_sibling_splice|5.021002|5.021002|n OpSLAB|5.017002||Viu opslab_force_free|5.017002||Viu opslab_free|5.017002||Viu opslab_free_nopad|5.017002||Viu OpslabREFCNT_dec|5.017002||Viu OpslabREFCNT_dec_padok|5.017002||Viu OpSLOT|5.017002||Viu OPSLOT_HEADER|5.017002||Viu OpSLOToff|5.033001||Viu op_std_init|5.015003||Viu OPTIMIZED|5.005000||Viu OPTIMIZED_t8|5.035004||Viu OPTIMIZED_t8_p8|5.033003||Viu OPTIMIZED_t8_pb|5.033003||Viu OPTIMIZED_tb|5.035004||Viu OPTIMIZED_tb_p8|5.033003||Viu OPTIMIZED_tb_pb|5.033003||Viu optimize_op|5.027006||Viu optimize_optree|5.027006||Vi optimize_regclass|5.035001||Viu OP_TYPE_IS|5.019007|5.019007| OP_TYPE_IS_NN|5.019010||Viu OP_TYPE_ISNT|5.019010||Viu OP_TYPE_ISNT_AND_WASNT|5.019010||Viu OP_TYPE_ISNT_AND_WASNT_NN|5.019010||Viu OP_TYPE_ISNT_NN|5.019010||Viu OP_TYPE_IS_OR_WAS|5.019010|5.019010| OP_TYPE_IS_OR_WAS_NN|5.019010||Viu op_unscope|5.017003||xViu op_wrap_finally|5.035008|5.035008|x O_RDONLY|5.006000||Viu O_RDWR|5.006000||Viu ORIGMARK|5.003007|5.003007| OSNAME|5.003007|5.003007|Vn OSVERS|5.007002|5.007002|Vn O_TEXT|5.006000||Viu OutCopFILE|5.007003||Viu output_non_portable|5.031008||Viu output_posix_warnings|5.029005||Viu O_VMS_DELETEONCLOSE|5.031002||Viu O_WRONLY|5.006000||Viu package|5.003007||Viu package_version|5.011001||Viu pack_cat|5.033002|5.033002|d packlist|5.008001|5.008001| pack_rec|5.008001||Viu packWARN2|5.007003|5.003007|p packWARN3|5.007003|5.003007|p packWARN4|5.007003|5.003007|p packWARN|5.007003|5.003007|p pad_add_anon|5.015001|5.015001| pad_add_name_pv|5.015001|5.015001| pad_add_name_pvn|5.015001|5.015001| pad_add_name_pvs|5.015001|5.015001| pad_add_name_sv|5.015001|5.015001| padadd_NO_DUP_CHECK|5.011002||Viu padadd_OUR|5.011002||Viu padadd_STALEOK|5.017003||Viu padadd_STATE|5.011002||Viu pad_add_weakref|5.021007||Viu pad_alloc|5.015001|5.015001|x pad_alloc_name|5.015001||Vi PadARRAY|5.017004|5.017004|x PAD_BASE_SV|5.008001||Vi pad_block_start|5.008001||Vi pad_check_dup|5.008001||Vi PAD_CLONE_VARS|5.008001||Vi PAD_COMPNAME|5.017004||Viu PAD_COMPNAME_FLAGS|5.008001||Vi PAD_COMPNAME_FLAGS_isOUR|5.009004||Viu PAD_COMPNAME_GEN|5.008001||Vi PAD_COMPNAME_GEN_set|5.009003||Vi PAD_COMPNAME_OURSTASH|5.008001||Vi PAD_COMPNAME_PV|5.008001||Vi PAD_COMPNAME_SV|5.009005||Viu PAD_COMPNAME_TYPE|5.008001||Vi pad_compname_type|5.033005|5.033005|d PAD_FAKELEX_ANON|5.009005||Viu PAD_FAKELEX_MULTI|5.009005||Viu pad_findlex|5.005000||Vi pad_findmy_pv|5.015001|5.015001| pad_findmy_pvn|5.015001|5.015001| pad_findmy_pvs|5.015001|5.015001| pad_findmy_sv|5.015001|5.015001| pad_fixup_inner_anons|5.008001||Vi pad_free|5.003007||Vi pad_leavemy|5.003007||Vi PadlistARRAY|5.017004|5.017004|x padlist_dup|5.013002||Vi PadlistMAX|5.017004|5.017004|x PadlistNAMES|5.017004|5.017004|x PadlistNAMESARRAY|5.017004|5.017004|x PadlistNAMESMAX|5.017004|5.017004|x PadlistREFCNT|5.017004|5.017004|x padlist_store|5.017004||Viu PadMAX|5.017004|5.017004|x padname_dup|5.021007||Vi PadnameFLAGS|5.021007||Viu padname_free|||ciu PADNAME_FROM_PV|5.021007||Viu PadnameIN_SCOPE|5.031004||Vniu PadnameIsOUR|5.017004||Vi PadnameIsSTATE|5.017004||Vi PadnameIsSTATE_on|5.021007||Viu PadnameLEN|5.017004|5.017004|x PadnamelistARRAY|5.017004|5.017004|x padnamelist_dup|5.021007||Vi padnamelist_fetch|5.021007|5.021007|xn padnamelist_free|||ciu PadnamelistMAX|5.017004|5.017004|x PadnamelistMAXNAMED|5.019003||Viu PadnamelistREFCNT|5.021007|5.021007|x PadnamelistREFCNT_dec|5.021007|5.021007|x padnamelist_store|5.021007|5.021007|x PadnameLVALUE|5.021006||Viu PadnameLVALUE_on|5.021006||Viu PadnameOURSTASH|5.017004||Vi PadnameOURSTASH_set|5.021007||Viu PadnameOUTER|5.017004||Vi PadnamePROTOCV|5.021007||Viu PadnamePV|5.017004|5.017004|x PadnameREFCNT|5.021007|5.021007|x PadnameREFCNT_dec|5.021007|5.021007|x PadnameSV|5.017004|5.017004|x PADNAMEt_LVALUE|5.021007||Viu PADNAMEt_OUR|5.021007||Viu PADNAMEt_OUTER|5.021007|5.021007| PADNAMEt_STATE|5.021007||Viu PADNAMEt_TYPED|5.021007||Viu PadnameTYPE|5.017004||Vi PadnameTYPE_set|5.021007||Viu PadnameUTF8|5.017004|5.017004|x pad_new|5.015001|5.015001| padnew_CLONE|5.008001||Viu padnew_SAVE|5.008001||Viu padnew_SAVESUB|5.008001||Viu pad_peg|5.009004||Viu pad_push|5.008001||cVi pad_reset|5.003007||Vi PAD_RESTORE_LOCAL|5.008001||Vi PAD_SAVE_LOCAL|5.008001||Vi PAD_SAVE_SETNULLPAD|5.008001||Vi PAD_SET_CUR|5.008001||Vi PAD_SET_CUR_NOSAVE|5.008002||Vi pad_setsv|5.008001||cV PAD_SETSV|5.008001||Vi pad_sv|5.003007||cV PAD_SV|5.003007||Vi PAD_SVl|5.008001||Vi pad_swipe|5.003007||Vi pad_tidy|5.015001|5.015001|x panic_write2|5.008001||Viu PARENT_FAKELEX_FLAGS|5.009005||Viu PARENT_PAD_INDEX|5.009005||Viu parse_arithexpr|5.013008|5.013008|x parse_barestmt|5.013007|5.013007|x parse_block|5.013007|5.013007|x parse_body|5.006000||Viu parse_fullexpr|5.013008|5.013008|x parse_fullstmt|5.013005|5.013005|x parse_gv_stash_name|5.019004||Viu parse_ident|5.017010||Viu parse_label|5.013007|5.013007|x parse_listexpr|5.013008|5.013008|x parse_lparen_question_flags|5.017009||Viu PARSE_OPTIONAL|5.013007|5.013007| parser_dup|5.009000|5.009000|u parser_free|5.009005||Viu parser_free_nexttoke_ops|5.017006||Viu parse_stmtseq|5.013006|5.013006|x parse_subsignature|5.031003|5.031003|x parse_termexpr|5.013008|5.013008|x parse_unicode_opts|5.008001||Viu parse_uniprop_string|5.027011||Viu PATCHLEVEL|5.003007||Viu path_is_searchable|5.019001||Vniu Pause|5.003007||Viu pause|5.005000||Viu pclose|5.003007||Viu peep|5.003007||Viu pending_ident|5.017004||Viu PERL_ABS|5.008001|5.003007|p Perl_acos|5.021004|5.021004|n perl_alloc|5.003007|5.003007|n PERL_ALLOC_CHECK|5.006000||Viu perl_alloc_using|5.006000||Vnu PERL_ANY_COW|5.017007||Viu PERL_API_REVISION|5.006000||Viu PERL_API_SUBVERSION|5.006000||Viu PERL_API_VERSION|5.006000||Viu PERL_API_VERSION_STRING|5.013004||Viu PERL_ARENA_ROOTS_SIZE|5.009004||Viu PERL_ARENA_SIZE|5.009003||Viu PERL_ARGS_ASSERT_CROAK_XS_USAGE|||ponu Perl_asin|5.021004|5.021004|n Perl_assert|5.011000||Viu perl_assert_ptr|5.027004||Viu PERL_ASYNC_CHECK|5.006000|5.006000| Perl_atan2|5.006000|5.006000|n Perl_atan|5.021004|5.021004|n Perl_atof2|5.006001||Viu Perl_atof|5.006000||Viu PERL_BCDVERSION||5.003007|onu PERL_BISON_VERSION|5.023008||Viu PERL_BITFIELD16|5.010001||Viu PERL_BITFIELD32|5.010001||Viu PERL_BITFIELD8|5.010001||Viu PERL_CALLCONV|5.005002||Viu PERL_CALLCONV_NO_RET|5.017002||Viu Perl_ceil|5.009001|5.009001|n PERL_CKDEF|5.006000||Viu perl_clone|5.006000||Vn perl_clone_using|5.006000||Vnu PERL_CLZ_32|5.035003||Viu PERL_CLZ_64|5.035003||Viu perl_construct|5.003007|5.003007|n PERL_COP_SEQMAX|5.013010||Viu PERL_COPY_ON_WRITE|5.023001||Viu Perl_cos|5.006000|5.006000|n Perl_cosh|5.021004|5.021004|n PERL_COUNT_MULTIPLIER|5.027007||Viu PERL_CTZ_32|5.035003||Viu PERL_CTZ_64|5.035003||Viu Perl_custom_op_xop|5.019006||V PERLDB_ALL|5.004002||Viu PERLDBf_GOTO|5.004005||Viu PERLDBf_INTER|5.004002||Viu PERLDBf_LINE|5.004002||Viu PERLDBf_NAMEANON|5.006000||Viu PERLDBf_NAMEEVAL|5.006000||Viu PERLDBf_NONAME|5.004005||Viu PERLDBf_NOOPT|5.004002||Viu PERLDBf_SAVESRC|5.010001||Viu PERLDBf_SAVESRC_INVALID|5.010001||Viu PERLDBf_SAVESRC_NOSUBS|5.010001||Viu PERLDBf_SINGLE|5.004002||Viu PERLDBf_SUB|5.004002||Viu PERLDBf_SUBLINE|5.004002||Viu PERLDB_GOTO|5.004005||Viu PERLDB_INTER|5.004002||Viu PERLDB_LINE|5.004002||Viu PERLDB_LINE_OR_SAVESRC|5.023002||Viu PERLDB_NAMEANON|5.006000||Viu PERLDB_NAMEEVAL|5.006000||Viu PERLDB_NOOPT|5.004002||Viu PERLDB_SAVESRC|5.010001||Viu PERLDB_SAVESRC_INVALID|5.010001||Viu PERLDB_SAVESRC_NOSUBS|5.010001||Viu PERLDB_SINGLE|5.004002||Viu PERLDB_SUB|5.004002||Viu PERLDB_SUBLINE|5.004002||Viu PERLDB_SUB_NN|5.004005||Viu PERL_DEB2|5.021007||Viu PERL_DEB|5.008001||Viu PERL_deBruijnMagic32|5.035003||Viu PERL_deBruijnMagic64|5.035003||Viu PERL_deBruijnShift32|5.035003||Viu PERL_deBruijnShift64|5.035003||Viu PERL_DEBUG|5.008001||Viu Perl_debug_log|5.003007||Viu PERL_DEBUG_PAD|5.007003||Viu PERL_DEBUG_PAD_ZERO|5.007003||Viu PERL_DECIMAL_VERSION|5.019008||Viu PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION|5.009003||Viu perl_destruct|5.007003|5.007003|n PerlDir_chdir|5.005000||Viu PerlDir_close|5.005000||Viu PerlDir_mapA|5.006000||Viu PerlDir_mapW|5.006000||Viu PerlDir_mkdir|5.005000||Viu PerlDir_open|5.005000||Viu PerlDir_read|5.005000||Viu PerlDir_rewind|5.005000||Viu PerlDir_rmdir|5.005000||Viu PerlDir_seek|5.005000||Viu PerlDir_tell|5.005000||Viu PERL_DONT_CREATE_GVSV|5.009003||Viu Perl_drand48|5.019004||Viu Perl_drand48_init|5.019004||Viu PERL_DRAND48_QUAD|5.019004||Viu PERL_DTRACE_PROBE_ENTRY|5.023009||Viu PERL_DTRACE_PROBE_FILE_LOADED|5.023009||Viu PERL_DTRACE_PROBE_FILE_LOADING|5.023009||Viu PERL_DTRACE_PROBE_OP|5.023009||Viu PERL_DTRACE_PROBE_PHASE|5.023009||Viu PERL_DTRACE_PROBE_RETURN|5.023009||Viu PERL_EBCDIC_TABLES_H|5.027001||Viu PERL_ENABLE_EXPERIMENTAL_REGEX_OPTIMISATIONS|5.009004||Viu PERL_ENABLE_EXTENDED_TRIE_OPTIMISATION|5.009004||Viu PERL_ENABLE_POSITIVE_ASSERTION_STUDY|5.009005||Viu PERL_ENABLE_TRIE_OPTIMISATION|5.009004||Viu PerlEnv_clearenv|5.006000||Viu PerlEnv_ENVgetenv|5.006000||Viu PerlEnv_ENVgetenv_len|5.006000||Viu PerlEnv_free_childdir|5.006000||Viu PerlEnv_free_childenv|5.006000||Viu PerlEnv_get_childdir|5.006000||Viu PerlEnv_get_childenv|5.006000||Viu PerlEnv_get_child_IO|5.006000||Viu PerlEnv_getenv|5.005000||Viu PerlEnv_getenv_len|5.006000||Viu PerlEnv_lib_path|5.005000||Viu PerlEnv_os_id|5.006000||Viu PerlEnv_putenv|5.005000||Viu PerlEnv_sitelib_path|5.005000||Viu PerlEnv_uname|5.005004||Viu PerlEnv_vendorlib_path|5.006000||Viu Perl_error_log|5.006000||Viu Perl_eval_pv||5.003007|onu Perl_eval_sv||5.003007|onu PERL_EXIT_ABORT|5.019003|5.019003| PERL_EXIT_DESTRUCT_END|5.007003|5.007003| PERL_EXIT_EXPECTED|5.006000|5.006000| PERL_EXIT_WARN|5.019003|5.019003| Perl_exp|5.006000|5.006000|n Perl_fabs|5.035005||Viu PERL_FEATURE_H|5.029006||Viu PERL_FILE_IS_ABSOLUTE|5.006000||Viu PERL_FILTER_EXISTS|5.009005||Viu Perl_floor|5.006000|5.006000|n PERL_FLUSHALL_FOR_CHILD|5.006000||Viu Perl_fmod|5.006000|5.006000|n Perl_fp_class|5.007003||Viu Perl_fp_class_denorm|5.007003||Viu Perl_fp_class_inf|5.007003||Viu Perl_fp_class_nan|5.007003||Viu Perl_fp_class_ndenorm|5.007003||Viu Perl_fp_class_ninf|5.007003||Viu Perl_fp_class_nnorm|5.007003||Viu Perl_fp_class_norm|5.007003||Viu Perl_fp_class_nzero|5.007003||Viu Perl_fp_class_pdenorm|5.007003||Viu Perl_fp_class_pinf|5.007003||Viu Perl_fp_class_pnorm|5.007003||Viu Perl_fp_class_pzero|5.007003||Viu Perl_fp_class_qnan|5.007003||Viu Perl_fp_class_snan|5.007003||Viu Perl_fp_class_zero|5.007003||Viu PERL_FPU_INIT|5.007002||Viu PERL_FPU_POST_EXEC|5.008001||Viu PERL_FPU_PRE_EXEC|5.008001||Viu perl_free|5.003007|5.003007|n Perl_free_c_backtrace|5.021001||Viu Perl_frexp|5.006000|5.006000|n PERL_FS_VER_FMT|5.006000||Viu PERL_FS_VERSION|5.010001||Viu PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||Viu PERL_GCC_VERSION_GE|5.035003||Viu PERL_GCC_VERSION_GT|5.035003||Viu PERL_GCC_VERSION_LE|5.035003||Viu PERL_GCC_VERSION_LT|5.035003||Viu PERL_GET_CONTEXT|5.006000||Viu PERL_GET_INTERP|5.006000||Viu PERL_GET_THX|5.006000||Viu PERL_GIT_UNPUSHED_COMMITS|5.010001||Viu PERL_GPROF_MONCONTROL|5.007002||Viu PERL_HANDY_H|5.027001||Viu PERL_HAS_FAST_GET_LSB_POS32|5.035003||Viu PERL_HAS_FAST_GET_LSB_POS64|5.035003||Viu PERL_HAS_FAST_GET_MSB_POS32|5.035003||Viu PERL_HAS_FAST_GET_MSB_POS64|5.035003||Viu PERL_HASH|5.003007|5.003007|p PERL_HASH_DEFAULT_HvMAX|5.017011||Viu PERL_HASH_FUNC|5.017006||Viu PERL_HASH_FUNC_SIPHASH13|5.033007||Viu PERL_HASH_FUNC_ZAPHOD32|5.027001||Viu PERL_HASH_INTERNAL|5.008002||Viu PERL_HASH_ITER_BUCKET|5.018000||Viu PERL_HASH_RANDOMIZE_KEYS|5.018000||Viu PERL_HASH_SEED|5.008001||Viu PERL_HASH_SEED_BYTES|5.017006||Viu PERL_HASH_SEED_STATE|5.027001||Viu PERL_HASH_SEED_WORDS|5.033007||Viu PERL_HASH_STATE_BYTES|5.027001||Viu PERL_HASH_STATE_WORDS|5.033007||Viu PERL_HASH_USE_SBOX32_ALSO|5.027001||Viu PERL_HASH_WITH_SEED|5.021001||Viu PERL_HASH_WITH_STATE|5.027001||Viu PERL_HV_ARRAY_ALLOC_BYTES|5.006000||Viu PERL___I|5.009005||Viu PERL_IMPLICIT_CONTEXT|5.006000||Viu PERL_INC_VERSION_LIST|5.035009|5.035009|Vn Perl_internal_drand48|5.027004||Viu PERL_INTERPRETER_SIZE_UPTO_MEMBER|5.010000||Viu PERL_INT_MAX|5.003007|5.003007|p PERL_INT_MIN|5.003007|5.003007|p PERL_INVLIST_INLINE_H|5.029006||Viu PerlIO|5.003007||Viu PerlIO_apply_layers|5.007001|5.007001| PerlIOArg|5.007001||Viu PerlIOBase|5.007001||Viu PerlIO_binmode|5.007001|5.007001| PERLIOBUF_DEFAULT_BUFSIZ|5.013007||Viu PerlIO_canset_cnt|5.003007|5.003007|n PerlIO_clearerr|5.007003|5.007003| PerlIO_close|5.007003|5.007003| PerlIO_context_layers|||u PerlIO_debug|5.007001|5.007001| PERLIO_DUP_CLONE|5.007003||Viu PERLIO_DUP_FD|5.007003||Viu PerlIO_eof|5.007003|5.007003| PerlIO_error|5.007003|5.007003| PerlIO_exportFILE|5.003007|5.003007|n PERLIO_F_APPEND|5.007001|5.007001| PerlIO_fast_gets|5.003007|5.003007|n PERLIO_F_CANREAD|5.007001|5.007001| PERLIO_F_CANWRITE|5.007001|5.007001| PERLIO_F_CLEARED|5.013008||Viu PERLIO_F_CRLF|5.007001|5.007001| PerlIO_fdopen|5.003007|5.003007|n PERLIO_F_EOF|5.007001|5.007001| PERLIO_F_ERROR|5.007001|5.007001| PERLIO_F_FASTGETS|5.007001|5.007001| PerlIO_fileno|5.007003|5.007003| PerlIO_fill|5.007000|5.007000|u PerlIO_findFILE|5.003007|5.003007|n PERLIO_F_LINEBUF|5.007001|5.007001| PerlIO_flush|5.007003|5.007003| PERLIO_F_NOTREG|5.008001||Viu PERLIO_F_OPEN|5.007001|5.007001| PERLIO_F_RDBUF|5.007001|5.007001| PERLIO_F_TEMP|5.007001|5.007001| PERLIO_F_TRUNCATE|5.007001|5.007001| PERLIO_F_TTY|5.007001||Viu PERLIO_F_UNBUF|5.007001|5.007001| PERLIO_FUNCS_CAST|5.009003||pVu PERLIO_FUNCS_DECL|5.009003|5.009003|pVu PERLIO_F_UTF8|5.007001|5.007001| PERLIO_F_WRBUF|5.007001|5.007001| PerlIO_get_base|5.007003|5.007003| PerlIO_get_bufsiz|5.007003|5.007003| PerlIO_getc|5.003007|5.003007|n PerlIO_get_cnt|5.007003|5.007003| PerlIO_getpos|5.003007|5.003007|n PerlIO_get_ptr|5.007003|5.007003| PERLIO_H|5.027001||Viu PerlIO_has_base|5.003007|5.003007|n PerlIO_has_cntptr|5.003007|5.003007|n PerlIO_importFILE|5.003007|5.003007|n PERLIO_INIT|5.009005||Viu PERLIO_K_BUFFERED|5.007001|5.007001| PERLIO_K_CANCRLF|5.007001|5.007001| PERLIO_K_DESTRUCT|5.007001||Viu PERLIO_K_DUMMY|5.007001||Viu PERLIO_K_FASTGETS|5.007001|5.007001| PERLIO_K_MULTIARG|5.007003|5.007003| PERLIO_K_RAW|5.007001|5.007001| PERLIO_K_UTF8|5.007001||Viu PERLIO_LAYERS|5.007001||Viu PERLIOL_H|5.027001||Viu PerlIONext|5.007001||Viu PERLIO_NOT_STDIO|5.003007||Viu PerlIO_open|5.003007|5.003007|n PerlIO_printf|5.006000|5.003007| PerlIO_putc|5.003007|5.003007|n PerlIO_puts|5.003007|5.003007|n PerlIO_read|5.007003|5.007003| PerlIO_releaseFILE|5.003007|5.003007|n PerlIO_reopen|5.003007|5.003007|n PerlIO_restore_errno|5.021006||cViu PerlIO_rewind|5.003007|5.003007|n PerlIO_save_errno|5.021006||cViu PerlIO_seek|5.007003|5.007003| PerlIOSelf|5.007001||Viu PerlIO_set_cnt|5.007003|5.007003| PerlIO_setlinebuf|5.007003|5.007003| PerlIO_setpos|5.003007|5.003007|n PerlIO_set_ptrcnt|5.007003|5.007003| PerlIO_stderr|5.007003|5.007003| PerlIO_stdin|5.007003|5.007003| PerlIO_stdout|5.007003|5.007003| PerlIO_stdoutf|5.006000|5.003007| PERLIO_STDTEXT|5.007001||Viu PerlIO_tell|5.007003|5.007003| PERLIO_TERM|5.009005||Viu PerlIO_ungetc|5.003007|5.003007|n PerlIO_unread|5.007003|5.007003|u PERLIO_USING_CRLF|5.007003||Viu PerlIOValid|5.007003||Viu PerlIO_vprintf|5.003007|5.003007|n PerlIO_write|5.007003|5.007003| Perl_isfinite|5.007003|5.007003|n Perl_isfinitel|5.021004||Viu PERL_IS_GCC|5.032001||Viu Perl_isinf|5.007003|5.007003|n Perl_isnan|5.006001|5.006001|n PERL_IS_SUBWORD_ADDR|5.027007||Viu PERL_IS_UTF8_CHAR_DFA|5.035004||Viu PERL_JNP_TO_DECIMAL|5.033001||Viu Perl_langinfo|5.027004|5.027004|n PERL_LANGINFO_H|5.027004||Viu PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu Perl_ldexp|5.021003|5.021003|n PerlLIO_access|5.005000||Viu PerlLIO_chmod|5.005000||Viu PerlLIO_chown|5.005000||Viu PerlLIO_chsize|5.005000||Viu PerlLIO_close|5.005000||Viu PerlLIO_dup2|5.005000||Viu PerlLIO_dup2_cloexec|5.027008||Viu PerlLIO_dup|5.005000||Viu PerlLIO_dup_cloexec|5.027008||Viu PerlLIO_flock|5.005000||Viu PerlLIO_fstat|5.005000||Viu PerlLIO_ioctl|5.005000||Viu PerlLIO_isatty|5.005000||Viu PerlLIO_link|5.006000||Viu PerlLIO_lseek|5.005000||Viu PerlLIO_lstat|5.005000||Viu PerlLIO_mktemp|5.005000||Viu PerlLIO_open3|5.005000||Viu PerlLIO_open3_cloexec|5.027008||Viu PerlLIO_open|5.005000||Viu PerlLIO_open_cloexec|5.027008||Viu PerlLIO_read|5.005000||Viu PerlLIO_readlink|5.033005||Viu PerlLIO_rename|5.005000||Viu PerlLIO_setmode|5.005000||Viu PerlLIO_stat|5.005000||Viu PerlLIO_symlink|5.033005||Viu PerlLIO_tmpnam|5.005000||Viu PerlLIO_umask|5.005000||Viu PerlLIO_unlink|5.005000||Viu PerlLIO_utime|5.005000||Viu PerlLIO_write|5.005000||Viu PERL_LOADMOD_DENY|5.006000|5.003007| PERL_LOADMOD_IMPORT_OPS|5.006000|5.003007| PERL_LOADMOD_NOIMPORT|5.006000|5.003007| Perl_log10|5.021004|5.021004|n Perl_log|5.006000|5.006000|n PERL_LONG_MAX|5.003007|5.003007|p PERL_LONG_MIN|5.003007|5.003007|p PERL_MAGIC_arylen|5.007002|5.003007|p PERL_MAGIC_arylen_p|5.009003|5.009003| PERL_MAGIC_backref|5.007002|5.003007|p PERL_MAGIC_bm|5.007002|5.003007|p PERL_MAGIC_checkcall|5.013006|5.013006| PERL_MAGIC_collxfrm|5.007002|5.003007|p PERL_MAGIC_dbfile|5.007002|5.003007|p PERL_MAGIC_dbline|5.007002|5.003007|p PERL_MAGIC_debugvar|5.021005|5.021005| PERL_MAGIC_defelem|5.007002|5.003007|p PERL_MAGIC_env|5.007002|5.003007|p PERL_MAGIC_envelem|5.007002|5.003007|p PERL_MAGIC_ext|5.007002|5.003007|p PERL_MAGIC_fm|5.007002|5.003007|p PERL_MAGIC_glob||5.003007|ponu PERL_MAGIC_hints|5.009004|5.009004| PERL_MAGIC_hintselem|5.009004|5.009004| PERL_MAGIC_isa|5.007002|5.003007|p PERL_MAGIC_isaelem|5.007002|5.003007|p PERL_MAGIC_lvref|5.021005|5.021005| PERL_MAGIC_mutex||5.003007|ponu PERL_MAGIC_nkeys|5.007002|5.003007|p PERL_MAGIC_nonelem|5.027009|5.027009| PERL_MAGIC_overload||5.003007|ponu PERL_MAGIC_overload_elem||5.003007|ponu PERL_MAGIC_overload_table|5.007002|5.003007|p PERL_MAGIC_pos|5.007002|5.003007|p PERL_MAGIC_qr|5.007002|5.003007|p PERL_MAGIC_READONLY_ACCEPTABLE|5.015000||Viu PERL_MAGIC_regdata|5.007002|5.003007|p PERL_MAGIC_regdatum|5.007002|5.003007|p PERL_MAGIC_regex_global|5.007002|5.003007|p PERL_MAGIC_rhash|5.009003|5.009003| PERL_MAGIC_shared|5.007003|5.003007|p PERL_MAGIC_shared_scalar|5.007003|5.003007|p PERL_MAGIC_sig|5.007002|5.003007|p PERL_MAGIC_sigelem|5.007002|5.003007|p PERL_MAGIC_substr|5.007002|5.003007|p PERL_MAGIC_sv|5.007002|5.003007|p PERL_MAGIC_symtab|5.009003|5.009003| PERL_MAGIC_taint|5.007002|5.003007|p PERL_MAGIC_tied|5.007002|5.003007|p PERL_MAGIC_tiedelem|5.007002|5.003007|p PERL_MAGIC_tiedscalar|5.007002|5.003007|p PERL_MAGIC_TYPE_IS_VALUE_MAGIC|5.015000||Viu PERL_MAGIC_TYPE_READONLY_ACCEPTABLE|5.015000||Viu PERL_MAGIC_utf8|5.008001|5.003007|p PERL_MAGIC_UTF8_CACHESIZE|5.008001||Viu PERL_MAGIC_uvar|5.007002|5.003007|p PERL_MAGIC_uvar_elem|5.007003|5.003007|p PERL_MAGIC_VALUE_MAGIC|5.015000||Viu PERL_MAGIC_vec|5.007002|5.003007|p PERL_MAGIC_vstring|5.008001|5.003007|p PERL_MAGIC_VTABLE_MASK|5.015000||Viu PERL_MALLOC_CTL_H|5.027001||Viu Perl_malloc_good_size|5.010001||Viu PERL_MALLOC_WRAP|5.009002|5.009002|Vn PerlMem_calloc|5.006000||Viu PerlMem_free|5.005000||Viu PerlMem_free_lock|5.006000||Viu PerlMem_get_lock|5.006000||Viu PerlMem_is_locked|5.006000||Viu PerlMem_malloc|5.005000||Viu PERL_MEMORY_DEBUG_HEADER_SIZE|5.019009||Viu PerlMemParse_calloc|5.006000||Viu PerlMemParse_free|5.006000||Viu PerlMemParse_free_lock|5.006000||Viu PerlMemParse_get_lock|5.006000||Viu PerlMemParse_is_locked|5.006000||Viu PerlMemParse_malloc|5.006000||Viu PerlMemParse_realloc|5.006000||Viu PerlMem_realloc|5.005000||Viu PerlMemShared_calloc|5.006000||Viu PerlMemShared_free|5.006000||Viu PerlMemShared_free_lock|5.006000||Viu PerlMemShared_get_lock|5.006000||Viu PerlMemShared_is_locked|5.006000||Viu PerlMemShared_malloc|5.006000||Viu PerlMemShared_realloc|5.006000||Viu PERL_MG_UFUNC|5.007001||Viu Perl_modf|5.006000|5.006000|n PERL_MULTICONCAT_HEADER_SIZE|5.027006||Viu PERL_MULTICONCAT_IX_LENGTHS|5.027006||Viu PERL_MULTICONCAT_IX_NARGS|5.027006||Viu PERL_MULTICONCAT_IX_PLAIN_LEN|5.027006||Viu PERL_MULTICONCAT_IX_PLAIN_PV|5.027006||Viu PERL_MULTICONCAT_IX_UTF8_LEN|5.027006||Viu PERL_MULTICONCAT_IX_UTF8_PV|5.027006||Viu PERL_MULTICONCAT_MAXARG|5.027006||Viu Perl_my_mkostemp|5.027008||Viu Perl_my_mkstemp|5.027004||Viu PERL_MY_SNPRINTF_GUARDED|5.009004||Viu PERL_MY_SNPRINTF_POST_GUARD|5.021002||Viu PERL_MY_VSNPRINTF_GUARDED|5.009004||Viu PERL_MY_VSNPRINTF_POST_GUARD|5.021002||Viu PERL_NO_DEV_RANDOM|5.009004||Viu PERL_NON_CORE_CHECK_EMPTY|5.035004||Viu PERL_OBJECT_THIS|5.005000||Viu PERL_OP_PARENT|5.025001||Viu PERL_PADNAME_MINIMAL|5.021007||Viu PERL_PADSEQ_INTRO|5.013010||Viu perl_parse|5.006000|5.006000|n PERL_PATCHLEVEL_H_IMPLICIT|5.006000||Viu PERL_PATCHNUM|5.010001||Viu PERL_POISON_EXPR|5.019006||Viu Perl_pow|5.006000|5.006000|n Perl_pp_accept|5.013009||Viu Perl_pp_aelemfast_lex|5.015000||Viu Perl_pp_andassign|5.013009||Viu Perl_pp_avalues|5.013009||Viu Perl_pp_bind|5.013009||Viu Perl_pp_bit_xor|5.013009||Viu Perl_pp_chmod|5.013009||Viu Perl_pp_chomp|5.013009||Viu Perl_pp_connect|5.013009||Viu Perl_pp_cos|5.013009||Viu Perl_pp_custom|5.013009||Viu Perl_pp_dbmclose|5.013009||Viu PERL_PPDEF|5.006000||Viu Perl_pp_dofile|5.013009||Viu Perl_pp_dor|5.013009||Viu Perl_pp_dorassign|5.013009||Viu Perl_pp_dump|5.013009||Viu Perl_pp_egrent|5.013009||Viu Perl_pp_enetent|5.013009||Viu Perl_pp_eprotoent|5.013009||Viu Perl_pp_epwent|5.013009||Viu Perl_pp_eservent|5.013009||Viu Perl_pp_exp|5.013009||Viu Perl_pp_fcntl|5.013009||Viu Perl_pp_ftatime|5.013009||Viu Perl_pp_ftbinary|5.013009||Viu Perl_pp_ftblk|5.013009||Viu Perl_pp_ftchr|5.013009||Viu Perl_pp_ftctime|5.013009||Viu Perl_pp_ftdir|5.013009||Viu Perl_pp_fteexec|5.013009||Viu Perl_pp_fteowned|5.013009||Viu Perl_pp_fteread|5.013009||Viu Perl_pp_ftewrite|5.013009||Viu Perl_pp_ftfile|5.013009||Viu Perl_pp_ftmtime|5.013009||Viu Perl_pp_ftpipe|5.013009||Viu Perl_pp_ftrexec|5.013009||Viu Perl_pp_ftrwrite|5.013009||Viu Perl_pp_ftsgid|5.013009||Viu Perl_pp_ftsize|5.013009||Viu Perl_pp_ftsock|5.013009||Viu Perl_pp_ftsuid|5.013009||Viu Perl_pp_ftsvtx|5.013009||Viu Perl_pp_ftzero|5.013009||Viu Perl_pp_getpeername|5.013009||Viu Perl_pp_getsockname|5.013009||Viu Perl_pp_ggrgid|5.013009||Viu Perl_pp_ggrnam|5.013009||Viu Perl_pp_ghbyaddr|5.013009||Viu Perl_pp_ghbyname|5.013009||Viu Perl_pp_gnbyaddr|5.013009||Viu Perl_pp_gnbyname|5.013009||Viu Perl_pp_gpbyname|5.013009||Viu Perl_pp_gpbynumber|5.013009||Viu Perl_pp_gpwnam|5.013009||Viu Perl_pp_gpwuid|5.013009||Viu Perl_pp_gsbyname|5.013009||Viu Perl_pp_gsbyport|5.013009||Viu Perl_pp_gsockopt|5.013009||Viu Perl_pp_hex|5.013009||Viu Perl_pp_i_postdec|5.006000||Viu Perl_pp_i_postinc|5.006000||Viu Perl_pp_i_predec|5.006000||Viu Perl_pp_i_preinc|5.006000||Viu Perl_pp_keys|5.013009||Viu Perl_pp_kill|5.013009||Viu Perl_pp_lcfirst|5.013009||Viu Perl_pp_lineseq|5.013009||Viu Perl_pp_listen|5.013009||Viu Perl_pp_localtime|5.013009||Viu Perl_pp_log|5.013009||Viu Perl_pp_lstat|5.013009||Viu Perl_pp_mapstart|5.013009||Viu Perl_pp_msgctl|5.013009||Viu Perl_pp_msgget|5.013009||Viu Perl_pp_msgrcv|5.013009||Viu Perl_pp_msgsnd|5.013009||Viu Perl_pp_nbit_xor|5.021009||Viu Perl_pp_orassign|5.013009||Viu Perl_pp_padany|5.013009||Viu Perl_pp_pop|5.013009||Viu Perl_pp_read|5.013009||Viu Perl_pp_recv|5.013009||Viu Perl_pp_regcmaybe|5.013009||Viu Perl_pp_rindex|5.013009||Viu Perl_pp_rv2hv|5.013009||Viu Perl_pp_say|5.013009||Viu Perl_pp_sbit_xor|5.021009||Viu Perl_pp_scalar|5.013009||Viu Perl_pp_schomp|5.013009||Viu Perl_pp_scope|5.013009||Viu Perl_pp_seek|5.013009||Viu Perl_pp_semop|5.013009||Viu Perl_pp_send|5.013009||Viu Perl_pp_sge|5.013009||Viu Perl_pp_sgrent|5.013009||Viu Perl_pp_sgt|5.013009||Viu Perl_pp_shmctl|5.013009||Viu Perl_pp_shmget|5.013009||Viu Perl_pp_shmread|5.013009||Viu Perl_pp_shutdown|5.013009||Viu Perl_pp_slt|5.013009||Viu Perl_pp_snetent|5.013009||Viu Perl_pp_socket|5.013009||Viu Perl_pp_sprotoent|5.013009||Viu Perl_pp_spwent|5.013009||Viu Perl_pp_sqrt|5.013009||Viu Perl_pp_sservent|5.013009||Viu Perl_pp_ssockopt|5.013009||Viu Perl_pp_symlink|5.013009||Viu Perl_pp_transr|5.013009||Viu Perl_pp_unlink|5.013009||Viu Perl_pp_utime|5.013009||Viu Perl_pp_values|5.013009||Viu PERL_PRESERVE_IVUV|5.007001||Viu PERL_PRIeldbl|5.006001|5.006001|Vn PERL_PRIfldbl|5.006000|5.006000|Vn PERL_PRIgldbl|5.006000|5.006000|Vn PerlProc_abort|5.005000||Viu PerlProc_crypt|5.005000||Viu PerlProc_DynaLoad|5.006000||Viu PerlProc_execl|5.005000||Viu PerlProc_execv|5.005000||Viu PerlProc_execvp|5.005000||Viu PerlProc__exit|5.005000||Viu PerlProc_exit|5.005000||Viu PerlProc_fork|5.006000||Viu PerlProc_getegid|5.005000||Viu PerlProc_geteuid|5.005000||Viu PerlProc_getgid|5.005000||Viu PerlProc_getlogin|5.005000||Viu PerlProc_GetOSError|5.006000||Viu PerlProc_getpid|5.006000||Viu PerlProc_gettimeofday|5.008000||Viu PerlProc_getuid|5.005000||Viu PerlProc_kill|5.005000||Viu PerlProc_killpg|5.005000||Viu PerlProc_lasthost|5.007001||Viu PerlProc_longjmp|5.005000||Viu PerlProc_pause|5.005000||Viu PerlProc_pclose|5.005000||Viu PerlProc_pipe|5.005000||Viu PerlProc_pipe_cloexec|5.027008||Viu PerlProc_popen|5.005000||Viu PerlProc_popen_list|5.007001||Viu PerlProc_setgid|5.005000||Viu PerlProc_setjmp|5.005000||Viu PerlProc_setuid|5.005000||Viu PerlProc_signal|5.005000||Viu PerlProc_sleep|5.005000||Viu PerlProc_spawnvp|5.008000||Viu PerlProc_times|5.005000||Viu PerlProc_wait|5.005000||Viu PerlProc_waitpid|5.005000||Viu perl_pthread_mutex_lock|5.023006||Viu perl_pthread_mutex_unlock|5.023006||Viu PERL_PV_ESCAPE_ALL|5.009004|5.003007|p PERL_PV_ESCAPE_DWIM|5.019008||Viu PERL_PV_ESCAPE_FIRSTCHAR|5.009004|5.003007|p PERL_PV_ESCAPE_NOBACKSLASH|5.009004|5.003007|p PERL_PV_ESCAPE_NOCLEAR|5.009004|5.003007|p PERL_PV_ESCAPE_NONASCII|5.013009|5.013009| PERL_PV_ESCAPE_QUOTE|5.009004|5.003007|p PERL_PV_ESCAPE_RE|5.009005|5.003007|p PERL_PV_ESCAPE_UNI|5.009004|5.003007|p PERL_PV_ESCAPE_UNI_DETECT|5.009004|5.003007|p PERL_PV_PRETTY_DUMP|5.009004||pcV PERL_PV_PRETTY_ELLIPSES|5.010000|5.003007|p PERL_PV_PRETTY_EXACTSIZE|5.021005||Viu PERL_PV_PRETTY_LTGT|5.009004|5.003007|p PERL_PV_PRETTY_NOCLEAR|5.010000||pcV PERL_PV_PRETTY_QUOTE|5.009004|5.003007|p PERL_PV_PRETTY_REGPROP|5.009004||pcV PERL_QUAD_MAX|5.003007|5.003007|p PERL_QUAD_MIN|5.003007|5.003007|p PERL_READ_LOCK|5.033005||Viu PERL_READ_UNLOCK|5.033005||Viu PERL_REENTR_API|5.009005||Viu PERL_REENTR_H|5.027001||Viu PERL_REENTR_USING_ASCTIME_R|5.031011||Viu PERL_REENTR_USING_CRYPT_R|5.031011||Viu PERL_REENTR_USING_CTERMID_R|5.031011||Viu PERL_REENTR_USING_CTIME_R|5.031011||Viu PERL_REENTR_USING_ENDGRENT_R|5.031011||Viu PERL_REENTR_USING_ENDHOSTENT_R|5.031011||Viu PERL_REENTR_USING_ENDNETENT_R|5.031011||Viu PERL_REENTR_USING_ENDPROTOENT_R|5.031011||Viu PERL_REENTR_USING_ENDPWENT_R|5.031011||Viu PERL_REENTR_USING_ENDSERVENT_R|5.031011||Viu PERL_REENTR_USING_GETGRENT_R|5.031011||Viu PERL_REENTR_USING_GETGRGID_R|5.031011||Viu PERL_REENTR_USING_GETGRNAM_R|5.031011||Viu PERL_REENTR_USING_GETHOSTBYADDR_R|5.031011||Viu PERL_REENTR_USING_GETHOSTBYNAME_R|5.031011||Viu PERL_REENTR_USING_GETHOSTENT_R|5.031011||Viu PERL_REENTR_USING_GETLOGIN_R|5.031011||Viu PERL_REENTR_USING_GETNETBYADDR_R|5.031011||Viu PERL_REENTR_USING_GETNETBYNAME_R|5.031011||Viu PERL_REENTR_USING_GETNETENT_R|5.031011||Viu PERL_REENTR_USING_GETPROTOBYNAME_R|5.031011||Viu PERL_REENTR_USING_GETPROTOBYNUMBER_R|5.031011||Viu PERL_REENTR_USING_GETPROTOENT_R|5.031011||Viu PERL_REENTR_USING_GETPWENT_R|5.031011||Viu PERL_REENTR_USING_GETPWNAM_R|5.031011||Viu PERL_REENTR_USING_GETPWUID_R|5.031011||Viu PERL_REENTR_USING_GETSERVBYNAME_R|5.031011||Viu PERL_REENTR_USING_GETSERVBYPORT_R|5.031011||Viu PERL_REENTR_USING_GETSERVENT_R|5.031011||Viu PERL_REENTR_USING_GETSPNAM_R|5.031011||Viu PERL_REENTR_USING_GMTIME_R|5.031011||Viu PERL_REENTR_USING_LOCALTIME_R|5.031011||Viu PERL_REENTR_USING_READDIR64_R|5.031011||Viu PERL_REENTR_USING_READDIR_R|5.031011||Viu PERL_REENTR_USING_SETGRENT_R|5.031011||Viu PERL_REENTR_USING_SETHOSTENT_R|5.031011||Viu PERL_REENTR_USING_SETLOCALE_R|5.031011||Viu PERL_REENTR_USING_SETNETENT_R|5.031011||Viu PERL_REENTR_USING_SETPROTOENT_R|5.031011||Viu PERL_REENTR_USING_SETPWENT_R|5.031011||Viu PERL_REENTR_USING_SETSERVENT_R|5.031011||Viu PERL_REENTR_USING_STRERROR_R|5.031011||Viu PERL_REENTR_USING_TMPNAM_R|5.031011||Viu PERL_REENTR_USING_TTYNAME_R|5.031011||Viu PERL_REGCHARCLASS_H|5.027001||Viu PERL_REGCOMP_H|5.029006||Viu PERL_REGMATCH_SLAB_SLOTS|5.009004||Viu PERL_RELOCATABLE_INC|5.017002|5.017002|Vn PERL_REVISION|5.006000|5.006000|d perl_run|5.003007|5.003007|n PERL_RW_MUTEX_DESTROY|5.033005||Viu PERL_RW_MUTEX_INIT|5.033005||Viu Perl_safesysmalloc_size|5.010001||Viu PERL_SAWAMPERSAND|5.017010||Viu PERL_SCAN_ALLOW_MEDIAL_UNDERSCORES|5.031009||Viu PERL_SCAN_ALLOW_UNDERSCORES|5.007003|5.003007|p PERL_SCAN_DISALLOW_PREFIX|5.007003|5.003007|p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003|5.003007|p PERL_SCAN_NOTIFY_ILLDIGIT|5.031008||Viu PERL_SCAN_SILENT_ILLDIGIT|5.008001|5.003007|p PERL_SCAN_SILENT_NON_PORTABLE|5.015001||Viu PERL_SCAN_SILENT_OVERFLOW|5.031009||Viu PERL_SCAN_TRAILING|5.021002|5.021002| PERL_SCNfldbl|5.006001|5.006001|Vn PERL_SCRIPT_MODE|5.004005||Viu PERL_SEEN_HV_FUNC_H|5.017010||Viu PERL_SEEN_HV_MACRO_H|5.027001||Viu PERL_SET_CONTEXT|5.006000||Viu PERL_SET_INTERP|5.006000||Viu Perl_setlocale|5.027002|5.027002|n PERL_SET_PHASE|5.015001||Viu PERL_SET_THX|5.006000||Viu Perl_sharepvn|5.006000||Viu PERL_SHORT_MAX|5.003007|5.003007|p PERL_SHORT_MIN|5.003007|5.003007|p PERLSI_DESTROY|5.005000||Viu PERLSI_DIEHOOK|5.005000||Viu PERL_SIGNALS_UNSAFE_FLAG|5.008001|5.003007|p Perl_signbit|5.009005|5.009005|xn PERLSI_MAGIC|5.005000||Viu PERLSI_MAIN|5.005000||Viu PERLSI_MULTICALL|5.023000||Viu Perl_sin|5.006000|5.006000|n Perl_sinh|5.021004|5.021004|n PerlSIO_canset_cnt|5.007001||Viu PerlSIO_clearerr|5.007001||Viu PerlSIO_fast_gets|5.007001||Viu PerlSIO_fclose|5.007001||Viu PerlSIO_fdopen|5.007001||Viu PerlSIO_fdupopen|5.007001||Viu PerlSIO_feof|5.007001||Viu PerlSIO_ferror|5.007001||Viu PerlSIO_fflush|5.007001||Viu PerlSIO_fgetc|5.007001||Viu PerlSIO_fgetpos|5.007001||Viu PerlSIO_fgets|5.007001||Viu PerlSIO_fileno|5.007001||Viu PerlSIO_fopen|5.007001||Viu PerlSIO_fputc|5.007001||Viu PerlSIO_fputs|5.007001||Viu PerlSIO_fread|5.007001||Viu PerlSIO_freopen|5.007001||Viu PerlSIO_fseek|5.007001||Viu PerlSIO_fsetpos|5.007001||Viu PerlSIO_ftell|5.007001||Viu PerlSIO_fwrite|5.007001||Viu PerlSIO_get_base|5.007001||Viu PerlSIO_get_bufsiz|5.007001||Viu PerlSIO_get_cnt|5.007001||Viu PerlSIO_get_ptr|5.007001||Viu PerlSIO_has_base|5.007001||Viu PerlSIO_has_cntptr|5.007001||Viu PerlSIO_init|5.007001||Viu PerlSIO_printf|5.007001||Viu PerlSIO_rewind|5.007001||Viu PerlSIO_setbuf|5.007001||Viu PerlSIO_set_cnt|5.007001||Viu PerlSIO_setlinebuf|5.007001||Viu PerlSIO_set_ptr|5.007001||Viu PerlSIO_setvbuf|5.007001||Viu PerlSIO_stderr|5.007001||Viu PerlSIO_stdin|5.007001||Viu PerlSIO_stdout|5.007001||Viu PerlSIO_stdoutf|5.007001||Viu PerlSIO_tmpfile|5.007001||Viu PerlSIO_ungetc|5.007001||Viu PERLSI_OVERLOAD|5.005000||Viu PerlSIO_vprintf|5.007001||Viu PERL_SIPHASH_FNC|5.025008||Viu PERLSI_REGCOMP|5.031011||Viu PERLSI_REQUIRE|5.005000||Viu PERLSI_SIGNAL|5.005000||Viu PERLSI_SORT|5.005000||Viu PERLSI_UNDEF|5.005000||Viu PERLSI_UNKNOWN|5.005000||Viu PERLSI_WARNHOOK|5.005000||Viu PERL_SNPRINTF_CHECK|5.021002||Viu PerlSock_accept|5.005000||Viu PerlSock_accept_cloexec|5.027008||Viu PerlSock_bind|5.005000||Viu PerlSock_closesocket|5.006000||Viu PerlSock_connect|5.005000||Viu PerlSock_endhostent|5.005000||Viu PerlSock_endnetent|5.005000||Viu PerlSock_endprotoent|5.005000||Viu PerlSock_endservent|5.005000||Viu PerlSock_gethostbyaddr|5.005000||Viu PerlSock_gethostbyname|5.005000||Viu PerlSock_gethostent|5.005000||Viu PerlSock_gethostname|5.005000||Viu PerlSock_getnetbyaddr|5.005000||Viu PerlSock_getnetbyname|5.005000||Viu PerlSock_getnetent|5.005000||Viu PerlSock_getpeername|5.005000||Viu PerlSock_getprotobyname|5.005000||Viu PerlSock_getprotobynumber|5.005000||Viu PerlSock_getprotoent|5.005000||Viu PerlSock_getservbyname|5.005000||Viu PerlSock_getservbyport|5.005000||Viu PerlSock_getservent|5.005000||Viu PerlSock_getsockname|5.005000||Viu PerlSock_getsockopt|5.005000||Viu PerlSock_htonl|5.005000||Viu PerlSock_htons|5.005000||Viu PerlSock_inet_addr|5.005000||Viu PerlSock_inet_ntoa|5.005000||Viu PerlSock_listen|5.005000||Viu PerlSock_ntohl|5.005000||Viu PerlSock_ntohs|5.005000||Viu PerlSock_recv|5.005000||Viu PerlSock_recvfrom|5.005000||Viu PerlSock_select|5.005000||Viu PerlSock_send|5.005000||Viu PerlSock_sendto|5.005000||Viu PerlSock_sethostent|5.005000||Viu PerlSock_setnetent|5.005000||Viu PerlSock_setprotoent|5.005000||Viu PerlSock_setservent|5.005000||Viu PerlSock_setsockopt|5.005000||Viu PerlSock_shutdown|5.005000||Viu PERL_SOCKS_NEED_PROTOTYPES|5.007001||Viu PerlSock_socket|5.005000||Viu PerlSock_socket_cloexec|5.027008||Viu PerlSock_socketpair|5.005000||Viu PerlSock_socketpair_cloexec|5.027008||Viu Perl_sqrt|5.006000|5.006000|n PERL_STACK_OVERFLOW_CHECK|5.006000||Viu PERL_STATIC_FORCE_INLINE|5.031011||Viu PERL_STATIC_FORCE_INLINE_NO_RET|5.031011||Viu PERL_STATIC_INLINE|5.013004|5.013004|poVn PERL_STATIC_INLINE_NO_RET|5.017005||Viu PERL_STATIC_NO_RET|5.017005||Viu PERL_STRLEN_EXPAND_SHIFT|5.013004||Viu PERL_STRLEN_ROUNDUP|5.009003||Viu PERL_STRLEN_ROUNDUP_QUANTUM|5.009003||Viu Perl_strtod|5.021004||Viu PERL_SUB_DEPTH_WARN|5.010001||Viu PERL_SUBVERSION|5.006000|5.003007|d PERL_SYS_FPU_INIT|5.021005||Viu PERL_SYS_INIT3|5.006000|5.006000| PERL_SYS_INIT3_BODY|5.010000||Viu PERL_SYS_INIT|5.003007|5.003007| PERL_SYS_INIT_BODY|5.010000||Viu PERL_SYS_TERM|5.003007|5.003007| PERL_SYS_TERM_BODY|5.010000||Viu Perl_tan|5.021004|5.021004|n Perl_tanh|5.021004|5.021004|n PERL_TARGETARCH|5.007002|5.007002|Vn PERL_THREAD_LOCAL|5.035004|5.035004|Vn PERL_TIME64_CONFIG_H|5.027001||Viu PERL_TIME64_H|5.027001||Viu PERL_TRACK_MEMPOOL|5.009003||Viu PERL_TSA|5.023006||Viu PERL_TSA_ACQUIRE|5.023006||Viu PERL_TSA_ACTIVE|5.023006||Viu PERL_TSA_CAPABILITY|5.023006||Viu PERL_TSA_EXCLUDES|5.023006||Viu PERL_TSA_GUARDED_BY|5.023006||Viu PERL_TSA_NO_TSA|5.023006||Viu PERL_TSA_PT_GUARDED_BY|5.023006||Viu PERL_TSA_RELEASE|5.023006||Viu PERL_TSA_REQUIRES|5.023006||Viu PERL_UCHAR_MAX|5.003007|5.003007|p PERL_UCHAR_MIN|5.003007|5.003007|p PERL_UINT_MAX|5.003007|5.003007|p PERL_UINT_MIN|5.003007|5.003007|p PERL_ULONG_MAX|5.003007|5.003007|p PERL_ULONG_MIN|5.003007|5.003007|p PERL_UNICODE_ALL_FLAGS|5.008001||Viu PERL_UNICODE_ARGV|5.008001||Viu PERL_UNICODE_ARGV_FLAG|5.008001||Viu PERL_UNICODE_CONSTANTS_H|5.027001||Viu PERL_UNICODE_DEFAULT_FLAGS|5.008001||Viu PERL_UNICODE_IN|5.008001||Viu PERL_UNICODE_IN_FLAG|5.008001||Viu PERL_UNICODE_INOUT|5.008001||Viu PERL_UNICODE_INOUT_FLAG|5.008001||Viu PERL_UNICODE_LOCALE|5.008001||Viu PERL_UNICODE_LOCALE_FLAG|5.008001||Viu PERL_UNICODE_MAX|5.007003||Viu PERL_UNICODE_OUT|5.008001||Viu PERL_UNICODE_OUT_FLAG|5.008001||Viu PERL_UNICODE_STD|5.008001||Viu PERL_UNICODE_STDERR|5.008001||Viu PERL_UNICODE_STDERR_FLAG|5.008001||Viu PERL_UNICODE_STD_FLAG|5.008001||Viu PERL_UNICODE_STDIN|5.008001||Viu PERL_UNICODE_STDIN_FLAG|5.008001||Viu PERL_UNICODE_STDOUT|5.008001||Viu PERL_UNICODE_STDOUT_FLAG|5.008001||Viu PERL_UNICODE_UTF8CACHEASSERT|5.009004||Viu PERL_UNICODE_UTF8CACHEASSERT_FLAG|5.009004||Viu PERL_UNICODE_WIDESYSCALLS|5.008001||Viu PERL_UNICODE_WIDESYSCALLS_FLAG|5.008001||Viu PERL_UNLOCK_HOOK|5.009004||Viu PERL_UNUSED_ARG|5.009003|5.003007|p PERL_UNUSED_CONTEXT|5.009004|5.003007|p PERL_UNUSED_DECL|5.007002|5.003007|p PERL_UNUSED_RESULT|5.021001|5.003007|p PERL_UNUSED_VAR|5.007002|5.003007|p PERL_UQUAD_MAX|5.003007|5.003007|p PERL_UQUAD_MIN|5.003007|5.003007|p PERL_USE_DEVEL|5.010001|5.010001|Vn PERL_USE_GCC_BRACE_GROUPS|5.009004|5.003007|pV PERL_USES_PL_PIDSTATUS|5.009003||Viu PERL_USE_THREAD_LOCAL|5.035004||Viu PERL_USHORT_MAX|5.003007|5.003007|p PERL_USHORT_MIN|5.003007|5.003007|p PERL_UTF8_H|5.027001||Viu PERL_UTIL_H|5.025012||Viu Perl_va_copy|5.007001||Viu PERLVAR|5.005000||Viu PERLVARA|5.006000||Viu PERLVARI|5.005000||Viu PERL_VARIANTS_WORD_MASK|5.027007||Viu PERLVARIC|5.005000||Viu PERL_VERSION|5.006000|5.003007|d PERL_VERSION_EQ|5.033001||p PERL_VERSION_GE|5.033001|5.003007|p PERL_VERSION_GT|5.033001|5.003007|p PERL_VERSION_LE|5.033001|5.003007|p PERL_VERSION_LT|5.033001|5.003007|p PERL_VERSION_MAJOR|5.033001||Viu PERL_VERSION_MINOR|5.033001||Viu PERL_VERSION_NE|5.033001||p PERL_VERSION_PATCH|5.033001||Viu PERL_VERSION_STRING|5.010001||Viu PERL_WAIT_FOR_CHILDREN|5.006000||Viu Perl_Warn_Bit|5.033003||Viu Perl_warner_nocontext||5.004000|ponu PERL_WARNHOOK_FATAL|5.009004||Viu Perl_Warn_Off|5.033003||Viu PERL_WORD_BOUNDARY_MASK|5.027007||Viu PERL_WORDSIZE|5.027007||Viu PERL_WRITE_LOCK|5.033005||Viu PERL_WRITE_MSG_TO_CONSOLE|5.007003||Viu PERL_WRITE_UNLOCK|5.033005||Viu PERL_XSUB_H|5.027001||Viu perly_sighandler|5.031007||cVnu phase_name|5.035007|5.035007| PHOSTNAME|5.006000|5.006000|Vn pidgone|5.003007||Viu Pid_t|5.005000|5.005000|Vn pipe|5.005000||Viu PIPE_OPEN_MODE|5.008002||Viu PIPESOCK_MODE|5.008001||Viu PL_AboveLatin1|5.015008||Viu PL_amagic_generation|5.005000||Viu PL_an|5.005000||Viu PL_argvgv|5.005000||Viu PL_argvoutgv|5.005000||Viu PL_argvout_stack|5.006000||Viu PL_Assigned_invlist|5.025009||Viu PL_basetime|5.005000||Viu PL_beginav|5.005000||Viu PL_beginav_save|5.006001||Viu PL_blockhooks|5.013003||Viu PL_body_arenas|5.009004||Viu PL_body_roots|5.009003||Viu PL_bodytarget|5.005000||Viu PL_breakable_sub_gen|5.010001||Viu PL_bufend||5.003007|ponu PL_bufptr||5.003007|ponu PL_CCC_non0_non230|5.029008||Viu PL_check|5.009003|5.006000| PL_checkav|5.006000||Viu PL_checkav_save|5.008001||Viu PL_chopset|5.005000||Viu PL_clocktick|5.008001||Viu PL_collation_ix|5.005000||Viu PL_collation_name|5.005000||Viu PL_collation_standard|5.005000||Viu PL_collxfrm_base|5.005000||Viu PL_collxfrm_mult|5.005000||Viu PL_colors|5.005000||Viu PL_colorset|5.005000||Viu PL_compcv|5.005000||Viu PL_compiling|5.005000|5.003007|poVnu PL_comppad|5.008001|5.008001|x PL_comppad_name|5.017004|5.017004|x PL_comppad_name_fill|5.005000||Viu PL_comppad_name_floor|5.005000||Viu PL_constpadix|5.021004||Viu PL_copline||5.003007|ponu PL_cop_seqmax|5.005000||Viu PL_cshlen|5.005000||Viu PL_curcop|5.004005|5.003007|p PL_curcopdb|5.005000||Viu PL_curlocales|5.027009||Viu PL_curpad|5.005000|5.005000|x PL_curpm|5.005000||Viu PL_curpm_under|5.025007||Viu PL_curstack|5.005000||Viu PL_curstackinfo|5.005000||Viu PL_curstash|5.004005|5.003007|p PL_curstname|5.005000||Viu PL_custom_op_descs|5.007003||Viu PL_custom_op_names|5.007003||Viu PL_custom_ops|5.013007||Viu PL_cv_has_eval|5.009000||Viu PL_dbargs|5.005000||Viu PL_DBcontrol|5.021005||Viu PL_DBcv|5.005000||Viu PL_DBgv|5.005000||Viu PL_DBline|5.005000||Viu PL_DBsignal|5.005000|5.003007|poVnu PL_DBsignal_iv|5.021005||Viu PL_DBsingle|5.005000||pV PL_DBsingle_iv|5.021005||Viu PL_DBsub|5.005000||pV PL_DBtrace|5.005000||pV PL_DBtrace_iv|5.021005||Viu PL_debstash|5.005000|5.003007|poVnu PL_debug|5.005000||Viu PL_debug_pad|5.007003||Viu PL_defgv|5.004005|5.003007|p PL_def_layerlist|5.007003||Viu PL_defoutgv|5.005000||Viu PL_defstash|5.005000||Viu PL_delaymagic|5.005000||Viu PL_delaymagic_egid|5.015008||Viu PL_delaymagic_euid|5.015008||Viu PL_delaymagic_gid|5.015008||Viu PL_delaymagic_uid|5.015008||Viu PL_destroyhook|5.010000||Viu PL_diehook|5.005000|5.003007|poVnu PL_Dir|5.006000||Viu PL_dirty|5.005000|5.003007|poVnu PL_doswitches|5.005000||Viu PL_dowarn|5.005000||pV PL_dumper_fd|5.009003||Viu PL_dumpindent|5.006000||Viu PL_dump_re_max_len|5.023008||Viu PL_efloatbuf|5.006000||Viu PL_efloatsize|5.006000||Viu PL_E_FORMAT_PRECISION|5.029000||Viu PL_encoding|5.007003||Viu PL_endav|5.005000||Viu PL_Env|5.006000||Viu PL_envgv|5.005000||Viu PL_errgv|5.004005|5.003007|p PL_error_count||5.003007|ponu PL_errors|5.006000||Viu PL_e_script|5.005000||Viu PL_eval_root|5.005000||Viu PL_evalseq|5.005000||Viu PL_eval_start|5.005000||Viu PL_exit_flags|5.006000|5.006000| PL_exitlist|5.005000||Viu PL_exitlistlen|5.005000||Viu PL_expect||5.003007|ponu PL_fdpid|5.005000||Viu PL_filemode|5.005000||Viu PL_firstgv|5.005000||Viu PL_forkprocess|5.005000||Viu PL_formtarget|5.005000||Viu PL_GCB_invlist|5.021009||Viu PL_generation|5.005000||Viu PL_gensym|5.005000||Viu PL_globalstash|5.005000||Viu PL_globhook|5.015005||Viu PL_hash_rand_bits|5.017010||Viu PL_HASH_RAND_BITS_ENABLED|5.018000||Viu PL_hash_rand_bits_enabled|5.018000||Viu PL_hash_seed|5.033007||Viu PL_hash_state|5.033007||Viu PL_HasMultiCharFold|5.017005||Viu PL_hexdigit||5.003007|pn PL_hintgv|5.005000||Viu PL_hints|5.005000|5.003007|poVnu PL_hv_fetch_ent_mh|5.005000||Viu PL_incgv|5.005000||Viu PL_in_clean_all|5.005000||Viu PL_in_clean_objs|5.005000||Viu PL_in_eval|5.005000||Viu PL_initav|5.005000||Viu PL_in_load_module|5.008001||Viu PL_in_my||5.003007|ponu PL_in_my_stash||5.005000|ponu PL_inplace|5.005000||Viu PL_in_some_fold|5.029007||Viu PL_internal_random_state|5.027004||Viu PL_in_utf8_COLLATE_locale|5.025002||Viu PL_in_utf8_CTYPE_locale|5.019009||Viu PL_in_utf8_turkic_locale|5.029008||Viu PL_isarev|5.009005||Viu PL_keyword_plugin|5.011002|5.011002|x PL_known_layers|5.007003||Viu PL_langinfo_buf|5.027004||Viu PL_langinfo_bufsize|5.027004||Viu PL_lastfd|5.005000||Viu PL_lastgotoprobe|5.005000||Viu PL_last_in_gv|5.005000||Vi PL_laststatval|5.005000|5.003007|poVnu PL_laststype|5.005000||Viu PL_Latin1|5.015008||Viu PL_LB_invlist|5.023007||Viu PL_lc_numeric_mutex_depth|5.027009||Viu PL_lex_state||5.003007|ponu PL_lex_stuff||5.003007|ponu PL_linestr||5.003007|ponu PL_LIO|5.006000||Viu PL_locale_utf8ness|5.027009||Viu PL_localizing|5.005000||Viu PL_localpatches|5.005000||Viu PL_lockhook|5.007003||Viu PL_main_cv|5.005000||Viu PL_main_root|5.005000||Viu PL_mainstack|5.005000||Viu PL_main_start|5.005000||Viu PL_markstack|5.005000||Viu PL_markstack_max|5.005000||Viu PL_markstack_ptr|5.005000||Viu PL_max_intro_pending|5.005000||Viu PL_maxo|5.005000||Viu PL_maxsysfd|5.005000|5.005000| PL_mbrlen_ps|5.031010||Viu PL_mbrtowc_ps|5.031010||Viu PL_Mem|5.006000||Viu PL_mem_log|5.033005||Viu PL_memory_debug_header|5.009004||Viu PL_MemParse|5.006000||Viu PL_MemShared|5.006000||Viu PL_mess_sv|5.005000|5.004000|poVnu PL_min_intro_pending|5.005000||Viu PL_minus_a|5.005000||Viu PL_minus_c|5.005000||Viu PL_minus_E|5.009003||Viu PL_minus_F|5.005000||Viu PL_minus_l|5.005000||Viu PL_minus_n|5.005000||Viu PL_minus_p|5.005000||Viu PL_modcount|5.005000||Viu PL_modglobal|5.005000|5.005000| PL_multideref_pc|5.021007||Viu PL_my_cxt_list|5.009003||Viu PL_my_cxt_size|5.009003||Viu PL_na|5.004005|5.003007|p PL_nomemok|5.005000||Viu PL_no_modify||5.003007|ponu PL_numeric_name|5.005000||Viu PL_numeric_radix_sv|5.007002||Viu PL_numeric_standard|5.005000||Viu PL_numeric_underlying|5.027006||Viu PL_numeric_underlying_is_standard|5.027009||Viu PL_ofsgv|5.011000||Vi PL_oldname|5.005000||Viu PL_op|5.005000||Viu PL_op_exec_cnt|5.019002||Viu PL_opfreehook|5.011000|5.011000| PL_op_mask|5.005000||Viu PL_origalen|5.005000||Viu PL_origargc|5.005000||Viu PL_origargv|5.005000||Viu PL_origenviron|5.005000||Viu PL_origfilename|5.005000||Viu PL_ors_sv|5.007001||Viu PL_osname|5.005000||Viu PL_padix|5.005000||Viu PL_padix_floor|5.005000||Viu PL_padlist_generation|5.021007||Viu PL_padname_const|5.021007||Viu PL_padname_undef|5.021007||Viu PL_pad_reset_pending|5.005000||Viu PL_parser|5.009005|5.003007|p PL_patchlevel|5.005000||Viu PL_peepp|5.007003|5.007003| PL_perldb|5.005000|5.003007|poVnu PL_perl_destruct_level|5.004005|5.003007|p PL_perlio|5.007003||Viu PL_phase|5.013007|5.013007| PL_pidstatus|5.005000||Viu PL_Posix_ptrs|5.029000||Viu PL_ppaddr||5.003007|ponu PL_preambleav|5.005000||Viu PL_prevailing_version|5.035009||Viu PL_Private_Use|5.029009||Viu PL_Proc|5.006000||Viu PL_profiledata|5.005000||Viu PL_psig_name|5.006000||Viu PL_psig_pend|5.007001||Viu PL_psig_ptr|5.006000||Viu PL_ptr_table|5.006000||Viu PL_random_state|5.019004||Viu PL_RANDOM_STATE_TYPE|5.019004||Viu PL_reentrant_buffer|5.007002||Viu PL_reentrant_retint|5.008001||Viu PL_reg_curpm|5.006000||Viu PL_regex_pad|5.007002||Viu PL_regex_padav|5.007002||Viu PL_registered_mros|5.010001||Viu PL_regmatch_slab|5.009004||Viu PL_regmatch_state|5.009004||Viu PL_replgv|5.005000||Viu PL_restartjmpenv|5.013001||Viu PL_restartop|5.005000|5.005000| PL_rpeepp|5.013005|5.013005| PL_rs|5.005000||Vi PL_rsfp||5.003007|ponu PL_rsfp_filters||5.003007|ponu PL_runops|5.006000|5.006000| PL_savebegin|5.007003||Viu PL_savestack|5.005000||Viu PL_savestack_ix|5.005000||Viu PL_savestack_max|5.005000||Viu PL_sawampersand|5.005000||Viu PL_SB_invlist|5.021009||Viu PL_scopestack|5.005000||Viu PL_scopestack_ix|5.005000||Viu PL_scopestack_max|5.005000||Viu PL_scopestack_name|5.011002||Viu PL_SCX_invlist|5.027008||Viu PL_secondgv|5.005000||Viu PL_setlocale_buf|5.027009||Viu PL_setlocale_bufsize|5.027009||Viu PL_sharehook|5.007003||Viu PL_sighandler1p|5.031007||Viu PL_sighandler3p|5.031007||Viu PL_sighandlerp|5.005000||Viu PL_signalhook|5.013002||Viu PL_signals|5.008001|5.003007|poVnu PL_sig_pending|5.007001||Viu PL_Sock|5.006000||Viu PL_sortcop|5.005000||Viu PL_sortstash|5.005000||Viu PL_splitstr|5.005000||Viu PL_srand_called|5.006000||Viu PL_stack_base|5.005000|5.003007|poVnu PL_stack_max|5.005000||Viu PL_stack_sp|5.005000|5.003007|poVnu PL_start_env|5.005000||Viu PL_stashcache|5.008001||Viu PL_stashpad|5.017001||Viu PL_stashpadix|5.017001||Viu PL_stashpadmax|5.017001||Viu PL_statcache|5.005000|5.003007|poVnu PL_statgv|5.005000||Viu PL_statname|5.005000||Viu PL_statusvalue|5.005000||Viu PL_statusvalue_posix|5.009003||Viu PL_statusvalue_vms|5.005000||Viu PL_stderrgv|5.006000||Viu PL_stdingv|5.005000|5.003007|poVnu PL_StdIO|5.006000||Viu PL_strtab|5.005000||Viu PL_strxfrm_is_behaved|5.025002||Viu PL_strxfrm_max_cp|5.025002||Viu PL_strxfrm_NUL_replacement|5.025008||Viu PL_sub_generation|5.005000||Viu PL_subline|5.005000||Viu PL_subname|5.005000||Viu PL_Sv|5.005000||pcV PL_sv_arenaroot|5.005000|5.003007|poVnu PL_sv_consts|5.019002||Viu PL_sv_count|5.005000||Viu PL_sv_immortals|5.027003||Viu PL_sv_no|5.004005|5.003007|p PL_sv_root|5.005000||Viu PL_sv_serial|5.010001||Viu PL_sv_undef|5.004005|5.003007|p PL_sv_yes|5.004005|5.003007|p PL_sv_zero|5.027003|5.027003| PL_sys_intern|5.005000||Viu PL_tainted|5.005000|5.003007|poVnu PL_tainting|5.005000|5.003007|poVnu PL_taint_warn|5.007003||Viu PL_threadhook|5.008000||Viu PL_tmps_floor|5.005000||Viu PL_tmps_ix|5.005000||Viu PL_tmps_max|5.005000||Viu PL_tmps_stack|5.005000||Viu PL_tokenbuf||5.003007|ponu PL_top_env|5.005000||Viu PL_toptarget|5.005000||Viu PL_TR_SPECIAL_HANDLING_UTF8|5.031006||Viu PL_underlying_numeric_obj|5.027009||Viu PL_unicode|5.008001||Viu PL_unitcheckav|5.009005||Viu PL_unitcheckav_save|5.009005||Viu PL_unlockhook|5.007003||Viu PL_unsafe|5.005000||Viu PL_UpperLatin1|5.019005||Viu PLUS|5.003007||Viu PLUS_t8|5.035004||Viu PLUS_t8_p8|5.033003||Viu PLUS_t8_pb|5.033003||Viu PLUS_tb|5.035004||Viu PLUS_tb_p8|5.033003||Viu PLUS_tb_pb|5.033003||Viu PL_utf8cache|5.009004||Viu PL_utf8_charname_begin|5.017006||Viu PL_utf8_charname_continue|5.017006||Viu PL_utf8_foldclosures|5.013007||Viu PL_utf8_idcont|5.008000||Viu PL_utf8_idstart|5.008000||Viu PL_utf8locale|5.008001||Viu PL_utf8_mark|5.006000||Viu PL_utf8_perl_idcont|5.017008||Viu PL_utf8_perl_idstart|5.015004||Viu PL_utf8_tofold|5.007003||Viu PL_utf8_tolower|5.006000||Viu PL_utf8_tosimplefold|5.027011||Viu PL_utf8_totitle|5.006000||Viu PL_utf8_toupper|5.006000||Viu PL_utf8_xidcont|5.013010||Viu PL_utf8_xidstart|5.013010||Viu PL_vtbl_arylen|5.015000||Viu PL_vtbl_arylen_p|5.015000||Viu PL_vtbl_backref|5.015000||Viu PL_vtbl_bm|5.015000||Viu PL_vtbl_checkcall|5.017000||Viu PL_vtbl_collxfrm|5.015000||Viu PL_vtbl_dbline|5.015000||Viu PL_vtbl_debugvar|5.021005||Viu PL_vtbl_defelem|5.015000||Viu PL_vtbl_env|5.015000||Viu PL_vtbl_envelem|5.015000||Viu PL_vtbl_fm|5.015000||Viu PL_vtbl_hints|5.015000||Viu PL_vtbl_hintselem|5.015000||Viu PL_vtbl_isa|5.015000||Viu PL_vtbl_isaelem|5.015000||Viu PL_vtbl_lvref|5.021005||Viu PL_vtbl_mglob|5.015000||Viu PL_vtbl_nkeys|5.015000||Viu PL_vtbl_nonelem|5.027009||Viu PL_vtbl_ovrld|5.015000||Viu PL_vtbl_pack|5.015000||Viu PL_vtbl_packelem|5.015000||Viu PL_vtbl_pos|5.015000||Viu PL_vtbl_regdata|5.015000||Viu PL_vtbl_regdatum|5.015000||Viu PL_vtbl_regexp|5.015000||Viu PL_vtbl_sig|5.035001||Viu PL_vtbl_sigelem|5.015000||Viu PL_vtbl_substr|5.015000||Viu PL_vtbl_sv|5.015000||Viu PL_vtbl_taint|5.015000||Viu PL_vtbl_utf8|5.015000||Viu PL_vtbl_uvar|5.015000||Viu PL_vtbl_vec|5.015000||Viu PL_warnhook|5.005000||Viu PL_warn_locale|5.021008||Viu PL_watchaddr|5.006000||Viu PL_watchok|5.006000||Viu PL_WB_invlist|5.021009||Viu PL_wcrtomb_ps|5.031010||Viu PL_XPosix_ptrs|5.017008||Viu PL_Xpv|5.005000|5.003007|poVnu PL_xsubfilename|5.021006||Viu pm_description|5.009004||Viu PMf_BASE_SHIFT|5.013004||Viu PMf_CHARSET|5.017011||Viu PMf_CODELIST_PRIVATE|5.017001||Viu PMf_CONST|5.003007||Viu PMf_CONTINUE|5.004000||Viu PMf_EVAL|5.003007||Viu PMf_EXTENDED|5.003007||Viu PMf_EXTENDED_MORE|5.021005||Viu PMf_FOLD|5.003007||Viu PMf_GLOBAL|5.003007||Viu PMf_HAS_CV|5.017001||Viu PMf_HAS_ERROR|5.025010||Viu PMf_IS_QR|5.017001||Viu PMf_KEEP|5.003007||Viu PMf_KEEPCOPY|5.009005||Viu PMf_MULTILINE|5.003007||Viu PMf_NOCAPTURE|5.021008||Viu PMf_NONDESTRUCT|5.013002||Viu PMf_ONCE|5.003007||Viu PMf_RETAINT|5.004005||Viu PMf_SINGLELINE|5.003007||Viu PMf_SPLIT|5.017011||Viu PMf_STRICT|5.021008||Viu PMf_USED|5.009005||Viu PMf_USE_RE_EVAL|5.017001||Viu PMf_WILDCARD|5.031010||Viu PM_GETRE|5.007002||Viu pmop_dump|5.006000|5.006000|u PmopSTASH|5.007001||Viu PmopSTASHPV|5.007001||Viu PmopSTASHPV_set|5.007001||Viu PmopSTASH_set|5.007001||Viu pmruntime|5.003007||Viu PM_SETRE|5.007002||Viu PM_STR|5.027010||Viu pmtrans|5.003007||Viu pMY_CXT|5.009000|5.009000|p _pMY_CXT||5.009000|p pMY_CXT_||5.009000|p PNf|5.021007||Viu PNfARG|5.021007||Viu Poison|5.008000|5.003007|p PoisonFree|5.009004|5.003007|p PoisonNew|5.009004|5.003007|p PoisonPADLIST|5.021006||Viu PoisonWith|5.009004|5.003007|p popen|5.003007||Viu POPi|5.003007|5.003007| POPl|5.003007|5.003007| POPMARK|5.003007||cViu POP_MULTICALL|5.009003|5.009003| POPn|5.006000|5.003007| POPp|5.003007|5.003007| POPpbytex|5.007001|5.007001| POPpconstx|5.009003||Viu POPpx|5.005003|5.005003| POPs|5.003007|5.003007| pop_scope|5.003007|5.003007|u POPSTACK|5.005000||Viu POPSTACK_TO|5.005000||Viu POPu|5.004000|5.004000| POPul|5.006000|5.006000| populate_ANYOF_from_invlist|5.019005||Viu populate_isa|||viu POSIXA|5.017003||Viu POSIXA_t8|5.035004||Viu POSIXA_t8_p8|5.033003||Viu POSIXA_t8_pb|5.033003||Viu POSIXA_tb|5.035004||Viu POSIXA_tb_p8|5.033003||Viu POSIXA_tb_pb|5.033003||Viu POSIX_CC_COUNT|5.017008||Viu POSIXD|5.017003||Viu POSIXD_t8|5.035004||Viu POSIXD_t8_p8|5.033003||Viu POSIXD_t8_pb|5.033003||Viu POSIXD_tb|5.035004||Viu POSIXD_tb_p8|5.033003||Viu POSIXD_tb_pb|5.033003||Viu POSIXL|5.017003||Viu POSIXL_CLEAR|5.029004||Viu POSIXL_SET|5.029004||Viu POSIXL_t8|5.035004||Viu POSIXL_t8_p8|5.033003||Viu POSIXL_t8_pb|5.033003||Viu POSIXL_tb|5.035004||Viu POSIXL_tb_p8|5.033003||Viu POSIXL_tb_pb|5.033003||Viu POSIXL_TEST|5.029004||Viu POSIXL_ZERO|5.029004||Viu POSIXU|5.017003||Viu POSIXU_t8|5.035004||Viu POSIXU_t8_p8|5.033003||Viu POSIXU_t8_pb|5.033003||Viu POSIXU_tb|5.035004||Viu POSIXU_tb_p8|5.033003||Viu POSIXU_tb_pb|5.033003||Viu PP|5.003007||Viu pregcomp|5.009005|5.009005| pregexec|5.003007|5.003007| PREGf_ANCH|5.019009||Viu PREGf_ANCH_GPOS|5.019009||Viu PREGf_ANCH_MBOL|5.019009||Viu PREGf_ANCH_SBOL|5.019009||Viu PREGf_CUTGROUP_SEEN|5.009005||Viu PREGf_GPOS_FLOAT|5.019009||Viu PREGf_GPOS_SEEN|5.019009||Viu PREGf_IMPLICIT|5.009005||Viu PREGf_NAUGHTY|5.009005||Viu PREGf_NOSCAN|5.019009||Viu PREGf_RECURSE_SEEN|5.023009||Viu pregfree2|5.011000||cVu pregfree|5.003007|5.003007|u PREGf_SKIP|5.009005||Viu PREGf_USE_RE_EVAL|5.017001||Viu PREGf_VERBARG_SEEN|5.009005||Viu prepare_SV_for_RV|5.010001||Viu prescan_version|5.011004|5.011004| PRESCAN_VERSION|5.019008||Viu PREVOPER|5.003007||Viu PREV_RANGE_MATCHES_INVLIST|5.023002||Viu printbuf|5.009004||Viu print_bytes_for_locale|5.027002||Viu print_collxfrm_input_and_return|5.025004||Viu printf|5.003007||Viu PRINTF_FORMAT_NULL_OK|5.009005|5.009005|Vn printf_nocontext|5.007001||vdVnu PRIVLIB|5.003007|5.003007|Vn PRIVLIB_EXP|5.003007|5.003007|Vn PRIVSHIFT|5.003007||Viu process_special_blocks|5.009005||Viu PROCSELFEXE_PATH|5.007003|5.007003|Vn PRUNE|5.009005||Viu PRUNE_t8|5.035004||Viu PRUNE_t8_p8|5.033003||Viu PRUNE_t8_pb|5.033003||Viu PRUNE_tb|5.035004||Viu PRUNE_tb_p8|5.033003||Viu PRUNE_tb_pb|5.033003||Viu PSEUDO|5.009004||Viu PSEUDO_t8|5.035004||Viu PSEUDO_t8_p8|5.033003||Viu PSEUDO_t8_pb|5.033003||Viu PSEUDO_tb|5.035004||Viu PSEUDO_tb_p8|5.033003||Viu PSEUDO_tb_pb|5.033003||Viu pthread_addr_t|5.005000||Viu PTHREAD_ATFORK|5.007002||Viu pthread_attr_init|5.006000||Viu PTHREAD_ATTR_SETDETACHSTATE|5.006000||Viu pthread_condattr_default|5.005000||Viu PTHREAD_CREATE|5.006000||Viu pthread_create|5.008001||Viu PTHREAD_CREATE_JOINABLE|5.005000||Viu PTHREAD_GETSPECIFIC|5.007002||Viu PTHREAD_GETSPECIFIC_INT|5.006000||Viu pthread_key_create|5.005000||Viu pthread_keycreate|5.008001||Viu pthread_mutexattr_default|5.005000||Viu pthread_mutexattr_init|5.005000||Viu pthread_mutexattr_settype|5.005000||Viu pTHX_12|5.019010||Viu pTHX_1|5.006000||Viu pTHX_2|5.006000||Viu pTHX_3|5.006000||Viu pTHX_4|5.006000||Viu pTHX|5.006000|5.003007|p pTHX_5|5.009003||Viu pTHX_6|5.009003||Viu pTHX_7|5.009003||Viu pTHX_8|5.009003||Viu pTHX_9|5.009003||Viu pTHX_||5.003007|p pTHX__FORMAT|5.009002||Viu pTHX_FORMAT|5.009002||Viu pTHXo|5.006000||Viu pTHX__VALUE|5.009002||Viu pTHX_VALUE|5.009002||Viu pTHXx|5.006000||Viu PTR2IV|5.006000|5.003007|p PTR2nat|5.009003|5.003007|p PTR2NV|5.006000|5.003007|p PTR2ul|5.007001|5.003007|p PTR2UV|5.006000|5.003007|p Ptrdiff_t|5.029003||Viu ptr_hash|5.017010||Vniu PTRSIZE|5.005000|5.005000|Vn ptr_table_fetch|5.009005|5.009005|u ptr_table_find|5.009004||Vniu ptr_table_free|5.009005|5.009005|u ptr_table_new|5.009005|5.009005|u ptr_table_split|5.009005|5.009005|u ptr_table_store|5.009005|5.009005|u PTRV|5.006000|5.003007|poVnu PUSHi|5.003007|5.003007| PUSHMARK|5.003007|5.003007| PUSHmortal|5.009002|5.003007|p PUSH_MULTICALL|5.011000|5.011000| PUSH_MULTICALL_FLAGS|5.018000||Viu PUSHn|5.006000|5.003007| PUSHp|5.003007|5.003007| PUSHs|5.003007|5.003007| push_scope|5.003007|5.003007|u PUSHSTACK|5.005000||Viu PUSHSTACKi|5.005000||Viu PUSHSTACK_INIT_HWM|5.027002||Viu PUSHTARG|5.003007||Viu PUSHu|5.004000|5.003007|p PUTBACK|5.003007|5.003007| putc|5.003007||Viu put_charclass_bitmap_innards|5.021004||Viu put_charclass_bitmap_innards_common|5.023008||Viu put_charclass_bitmap_innards_invlist|5.023008||Viu put_code_point|5.021004||Viu putc_unlocked|5.003007||Viu putenv|5.005000||Viu put_range|5.019009||Viu putw|5.003007||Viu pv_display|5.006000|5.003007|p pv_escape|5.009004|5.003007|p pv_pretty|5.009004|5.003007|p pv_uni_display|5.007003|5.007003| pWARN_ALL|5.006000||Viu pWARN_NONE|5.006000||Viu pWARN_STD|5.006000||Viu PWGECOS|5.004005|5.004005|Vn PWPASSWD|5.005000|5.005000|Vn qerror|5.006000||cViu QR_PAT_MODS|5.009005||Viu QUAD_IS_INT|5.006000|5.006000|Vn QUAD_IS___INT64|5.015003|5.015003|Vn QUAD_IS_INT64_T|5.006000|5.006000|Vn QUAD_IS_LONG|5.006000|5.006000|Vn QUAD_IS_LONG_LONG|5.006000|5.006000|Vn QUADKIND|5.006000|5.006000|Vn quadmath_format_needed|5.021004||Vni quadmath_format_valid|5.031007||Vni Quad_t|5.003007|5.003007|Vn QUESTION_MARK_CTRL|5.021001||Viu RADIXCHAR|5.027010||Viu RANDBITS|5.003007|5.003007|Vn RANDOM_R_PROTO|5.008000|5.008000|Vn Rand_seed_t|5.006000|5.006000|Vn RANGE_INDICATOR|5.031006||Viu rck_elide_nothing|5.032001||Viu RD_NODATA|5.003007|5.003007|Vn read|5.005000||Viu readdir|5.005000||Viu readdir64|5.009000||Viu READDIR64_R_PROTO|5.008000|5.008000|Vn READDIR_R_PROTO|5.008000|5.008000|Vn READ_XDIGIT|5.017006|5.017006| realloc|5.003007||Vn ReANY|5.017006||cVnu re_compile|5.009005|5.009005|u RE_COMPILE_RECURSION_INIT|5.029009||Viu RE_COMPILE_RECURSION_LIMIT|5.029009||Viu re_croak|||iu recv|5.006000||Viu recvfrom|5.005000||Viu RE_DEBUG_COMPILE_DUMP|5.009004||Viu RE_DEBUG_COMPILE_FLAGS|5.009005||Viu RE_DEBUG_COMPILE_MASK|5.009004||Viu RE_DEBUG_COMPILE_OPTIMISE|5.009004||Viu RE_DEBUG_COMPILE_PARSE|5.009004||Viu RE_DEBUG_COMPILE_TEST|5.021005||Viu RE_DEBUG_COMPILE_TRIE|5.009004||Viu RE_DEBUG_EXECUTE_INTUIT|5.009004||Viu RE_DEBUG_EXECUTE_MASK|5.009004||Viu RE_DEBUG_EXECUTE_MATCH|5.009004||Viu RE_DEBUG_EXECUTE_TRIE|5.009004||Viu RE_DEBUG_EXTRA_BUFFERS|5.009005||Viu RE_DEBUG_EXTRA_DUMP_PRE_OPTIMIZE|5.031004||Viu RE_DEBUG_EXTRA_GPOS|5.011000||Viu RE_DEBUG_EXTRA_MASK|5.009004||Viu RE_DEBUG_EXTRA_OPTIMISE|5.009005||Viu RE_DEBUG_EXTRA_STACK|5.009005||Viu RE_DEBUG_EXTRA_STATE|5.009004||Viu RE_DEBUG_EXTRA_TRIE|5.009004||Viu RE_DEBUG_EXTRA_WILDCARD|5.031011||Viu RE_DEBUG_FLAG|5.009004||Viu RE_DEBUG_FLAGS|5.009002||Viu re_dup_guts|5.011000|5.011000| reentrant_free|5.008000||cVu reentrant_init|5.008000||cVu REENTRANT_PROTO_B_B|5.008000||Viu REENTRANT_PROTO_B_BI|5.008000||Viu REENTRANT_PROTO_B_BW|5.008000||Viu REENTRANT_PROTO_B_CCD|5.008000||Viu REENTRANT_PROTO_B_CCS|5.008000||Viu REENTRANT_PROTO_B_IBI|5.008000||Viu REENTRANT_PROTO_B_IBW|5.008000||Viu REENTRANT_PROTO_B_SB|5.008000||Viu REENTRANT_PROTO_B_SBI|5.008000||Viu REENTRANT_PROTO_I_BI|5.008000||Viu REENTRANT_PROTO_I_BW|5.008000||Viu REENTRANT_PROTO_I_CCSBWR|5.008000||Viu REENTRANT_PROTO_I_CCSD|5.008000||Viu REENTRANT_PROTO_I_CII|5.008000||Viu REENTRANT_PROTO_I_CIISD|5.008000||Viu REENTRANT_PROTO_I_CSBI|5.008000||Viu REENTRANT_PROTO_I_CSBIR|5.008000||Viu REENTRANT_PROTO_I_CSBWR|5.008000||Viu REENTRANT_PROTO_I_CSBWRE|5.008000||Viu REENTRANT_PROTO_I_CSD|5.008000||Viu REENTRANT_PROTO_I_CWISBWRE|5.008000||Viu REENTRANT_PROTO_I_CWISD|5.008000||Viu REENTRANT_PROTO_I_D|5.008000||Viu REENTRANT_PROTO_I_H|5.008000||Viu REENTRANT_PROTO_I_IBI|5.008000||Viu REENTRANT_PROTO_I_IBW|5.008000||Viu REENTRANT_PROTO_I_ICBI|5.008000||Viu REENTRANT_PROTO_I_ICSBWR|5.008000||Viu REENTRANT_PROTO_I_ICSD|5.008000||Viu REENTRANT_PROTO_I_ID|5.008000||Viu REENTRANT_PROTO_I_IISD|5.008000||Viu REENTRANT_PROTO_I_ISBWR|5.008000||Viu REENTRANT_PROTO_I_ISD|5.008000||Viu REENTRANT_PROTO_I_LISBI|5.008000||Viu REENTRANT_PROTO_I_LISD|5.008000||Viu REENTRANT_PROTO_I_SB|5.008000||Viu REENTRANT_PROTO_I_SBI|5.008000||Viu REENTRANT_PROTO_I_SBIE|5.008000||Viu REENTRANT_PROTO_I_SBIH|5.008000||Viu REENTRANT_PROTO_I_SBIR|5.008000||Viu REENTRANT_PROTO_I_SBWR|5.008000||Viu REENTRANT_PROTO_I_SBWRE|5.008000||Viu REENTRANT_PROTO_I_SD|5.008000||Viu REENTRANT_PROTO_I_TISD|5.008000||Viu REENTRANT_PROTO_I_TS|5.008000||Viu REENTRANT_PROTO_I_TSBI|5.008000||Viu REENTRANT_PROTO_I_TSBIR|5.008000||Viu REENTRANT_PROTO_I_TSBWR|5.008000||Viu REENTRANT_PROTO_I_TsISBWRE|5.008001||Viu REENTRANT_PROTO_I_TSR|5.008000||Viu REENTRANT_PROTO_I_UISBWRE|5.008000||Viu REENTRANT_PROTO_I_uISBWRE|5.008001||Viu REENTRANT_PROTO_S_CBI|5.008000||Viu REENTRANT_PROTO_S_CCSBI|5.008000||Viu REENTRANT_PROTO_S_CIISBIE|5.008000||Viu REENTRANT_PROTO_S_CSBI|5.008000||Viu REENTRANT_PROTO_S_CSBIE|5.008000||Viu REENTRANT_PROTO_S_CWISBIE|5.008000||Viu REENTRANT_PROTO_S_CWISBWIE|5.008000||Viu REENTRANT_PROTO_S_ICSBI|5.008000||Viu REENTRANT_PROTO_S_ISBI|5.008000||Viu REENTRANT_PROTO_S_LISBI|5.008000||Viu REENTRANT_PROTO_S_SBI|5.008000||Viu REENTRANT_PROTO_S_SBIE|5.008000||Viu REENTRANT_PROTO_S_SBW|5.008000||Viu REENTRANT_PROTO_S_TISBI|5.008000||Viu REENTRANT_PROTO_S_TS|5.031011||Viu REENTRANT_PROTO_S_TSBI|5.008000||Viu REENTRANT_PROTO_S_TSBIE|5.008000||Viu REENTRANT_PROTO_S_TWISBIE|5.008000||Viu REENTRANT_PROTO_V_D|5.008000||Viu REENTRANT_PROTO_V_H|5.008000||Viu REENTRANT_PROTO_V_ID|5.008000||Viu reentrant_retry|5.008000||vcVnu reentrant_size|5.008000||cVu REENTR_MEMZERO|5.009003||Viu re_exec_indentf|5.023009||vViu REF|5.003007||Viu ref|5.009003||Viu ref_array_or_hash|5.027008||Viu refcounted_he_chain_2hv|5.013007||cVi REFCOUNTED_HE_EXISTS|5.015007||Viu refcounted_he_fetch_pv|5.013007||cVi refcounted_he_fetch_pvn|5.013007||cVi refcounted_he_fetch_pvs|5.013007||Vi refcounted_he_fetch_sv|5.013007||cVi refcounted_he_free|5.013007||cVi refcounted_he_inc|5.013007||cVi REFCOUNTED_HE_KEY_UTF8|5.013007||Viu refcounted_he_new_pv|5.013007||cVi refcounted_he_new_pvn|5.013007||cVi refcounted_he_new_pvs|5.013007||Vi refcounted_he_new_sv|5.013007||cVi refcounted_he_value|5.009004||Viu REFF|5.004001||Viu REFFA|5.013010||Viu REFFAN|5.031001||Viu REFFAN_t8|5.035004||Viu REFFAN_t8_p8|5.033003||Viu REFFAN_t8_pb|5.033003||Viu REFFAN_tb|5.035004||Viu REFFAN_tb_p8|5.033003||Viu REFFAN_tb_pb|5.033003||Viu REFFA_t8|5.035004||Viu REFFA_t8_p8|5.033003||Viu REFFA_t8_pb|5.033003||Viu REFFA_tb|5.035004||Viu REFFA_tb_p8|5.033003||Viu REFFA_tb_pb|5.033003||Viu REFFL|5.004001||Viu REFFLN|5.031001||Viu REFFLN_t8|5.035004||Viu REFFLN_t8_p8|5.033003||Viu REFFLN_t8_pb|5.033003||Viu REFFLN_tb|5.035004||Viu REFFLN_tb_p8|5.033003||Viu REFFLN_tb_pb|5.033003||Viu REFFL_t8|5.035004||Viu REFFL_t8_p8|5.033003||Viu REFFL_t8_pb|5.033003||Viu REFFL_tb|5.035004||Viu REFFL_tb_p8|5.033003||Viu REFFL_tb_pb|5.033003||Viu REFFN|5.031001||Viu REFFN_t8|5.035004||Viu REFFN_t8_p8|5.033003||Viu REFFN_t8_pb|5.033003||Viu REFFN_tb|5.035004||Viu REFFN_tb_p8|5.033003||Viu REFFN_tb_pb|5.033003||Viu REFF_t8|5.035004||Viu REFF_t8_p8|5.033003||Viu REFF_t8_pb|5.033003||Viu REFF_tb|5.035004||Viu REFF_tb_p8|5.033003||Viu REFF_tb_pb|5.033003||Viu REFFU|5.013008||Viu REFFUN|5.031001||Viu REFFUN_t8|5.035004||Viu REFFUN_t8_p8|5.033003||Viu REFFUN_t8_pb|5.033003||Viu REFFUN_tb|5.035004||Viu REFFUN_tb_p8|5.033003||Viu REFFUN_tb_pb|5.033003||Viu REFFU_t8|5.035004||Viu REFFU_t8_p8|5.033003||Viu REFFU_t8_pb|5.033003||Viu REFFU_tb|5.035004||Viu REFFU_tb_p8|5.033003||Viu REFFU_tb_pb|5.033003||Viu REF_HE_KEY|5.009005||Viu refkids|5.003007||Viu REFN|5.031001||Viu REFN_t8|5.035004||Viu REFN_t8_p8|5.033003||Viu REFN_t8_pb|5.033003||Viu REFN_tb|5.035004||Viu REFN_tb_p8|5.033003||Viu REFN_tb_pb|5.033003||Viu REF_t8|5.035004||Viu REF_t8_p8|5.033003||Viu REF_t8_pb|5.033003||Viu REF_tb|5.035004||Viu REF_tb_p8|5.033003||Viu REF_tb_pb|5.033003||Viu refto|5.005000||Viu reg2Lanode|5.021005||Viu reg|5.005000||Viu reganode|5.005000||Viu REG_ANY|5.006000||Viu REG_ANY_t8|5.035004||Viu REG_ANY_t8_p8|5.033003||Viu REG_ANY_t8_pb|5.033003||Viu REG_ANY_tb|5.035004||Viu REG_ANY_tb_p8|5.033003||Viu REG_ANY_tb_pb|5.033003||Viu regatom|5.005000||Viu regbranch|5.005000||Viu reg_check_named_buff_matched|5.009005||Vniu regclass|5.005000||Viu regcppop|5.005000||Viu regcppush|5.005000||Viu regcp_restore|5.025006||Viu regcurly|5.013010||cVniu REG_CUTGROUP_SEEN|5.019009||Viu regdump|5.005000|5.005000|u regdump_extflags|5.009005||Viu regdump_intflags|5.019002||Viu regdupe_internal|5.009005||cVu regexec_flags|5.005000||cVu REGEX_SET|5.031010||Viu regex_set_precedence|5.021010||Vniu REGEX_SET_t8|5.035004||Viu REGEX_SET_t8_p8|5.033003||Viu REGEX_SET_t8_pb|5.033003||Viu REGEX_SET_tb|5.035004||Viu REGEX_SET_tb_p8|5.033003||Viu REGEX_SET_tb_pb|5.033003||Viu REG_EXTFLAGS_NAME_SIZE|5.020000||Viu regfree_internal|5.009005||cVu REG_GPOS_SEEN|5.019009||Viu reghop3|5.007001||Vniu reghop4|5.009005||Vniu reghopmaybe3|5.007001||Vniu reginclass|5.005000||Viu REG_INFTY|5.004005||Viu reginitcolors|5.006000||cVu reginsert|5.005000||Viu REG_INTFLAGS_NAME_SIZE|5.020000||Viu register|5.003007||Viu reg_la_NOTHING|||Viu reg_la_OPFAIL|||Viu REG_LB_SEEN|||Viu REG_LOOKBEHIND_SEEN|5.019009||Viu REG_MAGIC|5.006000||Viu regmatch|5.005000||Viu REGMATCH_STATE_MAX|5.009005||Viu reg_named_buff|5.009005||cViu reg_named_buff_all|5.009005||cVu reg_named_buff_exists|5.009005||cVu reg_named_buff_fetch|5.009005||cVu reg_named_buff_firstkey|5.009005||cVu reg_named_buff_iter|5.009005||cViu reg_named_buff_nextkey|5.009005||cVu reg_named_buff_scalar|5.009005||cVu regnext|5.003007||cVu reg_node|5.005000||Viu regnode_guts|5.021005||Viu regnode_guts_debug|||Viu REGNODE_MAX|5.009004||Viu REGNODE_SIMPLE|5.013002||Viu REGNODE_VARIES|5.013002||Viu reg_numbered_buff_fetch|5.009005||cViu reg_numbered_buff_length|5.009005||cViu reg_numbered_buff_store|5.009005||cViu regpiece|5.005000||Viu regpnode|5.031010||Viu regprop|5.003007||Viu reg_qr_package|5.009005||cViu REG_RECURSE_SEEN|5.019009||Viu regrepeat|5.005000||Viu REG_RUN_ON_COMMENT_SEEN|5.019009||Viu reg_scan_name|5.009005||Viu reg_skipcomment|5.009005||Vniu regtail|5.005000||Viu regtail_study|5.009004||Viu reg_temp_copy|5.009005||cViu REG_TOP_LEVEL_BRANCHES_SEEN|5.019009||Viu regtry|5.005000||Viu REG_UNBOUNDED_QUANTIFIER_SEEN|5.019009||Viu REG_UNFOLDED_MULTI_SEEN|5.019009||Viu REG_VERBARG_SEEN|5.019009||Viu REG_ZERO_LEN_SEEN|5.019009||Viu re_indentf|5.023009||vViu re_intuit_start|5.006000||cVu re_intuit_string|5.006000||cVu rename|5.005000||Viu Renew|5.003007|5.003007| Renewc|5.003007|5.003007| RENUM|5.005000||Viu RENUM_t8|5.035004||Viu RENUM_t8_p8|5.033003||Viu RENUM_t8_pb|5.033003||Viu RENUM_tb|5.035004||Viu RENUM_tb_p8|5.033003||Viu RENUM_tb_pb|5.033003||Viu re_op_compile|5.017001||Viu repeatcpy|5.003007|5.003007|nu REPLACEMENT_CHARACTER_UTF8|5.025005|5.003007|p report_evil_fh|5.006001||Viu report_redefined_cv|5.015006||Viu report_uninit|5.006000||cVi report_wrongway_fh|5.013009||Viu re_printf|5.023009||vViu RE_PV_COLOR_DECL|5.009004||Viu RE_PV_QUOTED_DECL|5.009004||Viu require_pv|5.006000|5.006000| require_tie_mod|5.009005||Viu ReREFCNT_dec|5.005000||Viu ReREFCNT_inc|5.005000||Viu RESTORE_ERRNO|5.010001||Vi RESTORE_LC_NUMERIC|5.021010|5.021010|p restore_magic|5.009003||Viu restore_switched_locale|5.027009||Viu RE_SV_DUMPLEN|5.009004||Viu RE_SV_ESCAPE|5.009004||Viu RE_SV_TAIL|5.009004||Viu RETPUSHNO|5.003007||Viu RETPUSHUNDEF|5.003007||Viu RETPUSHYES|5.003007||Viu RE_TRIE_MAXBUF_INIT|5.009002||Viu RE_TRIE_MAXBUF_NAME|5.009002||Viu RETSETNO|5.003007||Viu RETSETTARG|5.021009||Viu RETSETUNDEF|5.003007||Viu RETSETYES|5.003007||Viu RETURN|5.003007||Viu RETURNOP|5.003007||Viu RETURNX|5.003007||Viu RETVAL|5.003007|5.003007|V rewind|5.003007||Viu rewinddir|5.005000||Viu REXEC_CHECKED|5.005000||Viu REXEC_COPY_SKIP_POST|5.017004||Viu REXEC_COPY_SKIP_PRE|5.017004||Viu REXEC_COPY_STR|5.005000||Viu REXEC_FAIL_ON_UNDERFLOW|5.019003||Viu REXEC_IGNOREPOS|5.006000||Viu REXEC_NOT_FIRST|5.006000||Viu REXEC_SCREAM|5.006000||Viu rmdir|5.005000||Viu RMS_DIR|5.008001||Viu RMS_FAC|5.008001||Viu RMS_FEX|5.008001||Viu RMS_FNF|5.008001||Viu RMS_IFI|5.008001||Viu RMS_ISI|5.008001||Viu RMS_PRV|5.008001||Viu rninstr|5.003007|5.003007|n ROTL32|5.017010||Viu ROTL64|5.017010||Viu ROTL_UV|5.017010||Viu ROTR32|5.027001||Viu ROTR64|5.027001||Viu ROTR_UV|5.027001||Viu rpeep|5.013005||Viu rsignal|5.004000|5.004000| rsignal_restore|5.004000||Viu rsignal_save|5.004000||Viu rsignal_state|5.004000|5.004000|u RsPARA|5.003007||Viu RsRECORD|5.005000||Viu RsSIMPLE|5.003007||Viu RsSNARF|5.003007||Viu run_body|5.006000||Viu runops_debug|5.005000||cVu RUNOPS_DEFAULT|5.005000||Viu runops_standard|5.005000||cVu run_user_filter|5.009003||Viu rv2cv_op_cv|5.013006|5.013006| RV2CVOPCV_FLAG_MASK|5.021004||Viu RV2CVOPCV_MARK_EARLY|5.013006|5.013006| RV2CVOPCV_MAYBE_NAME_GV|5.021004||Viu RV2CVOPCV_RETURN_NAME_GV|5.013006|5.013006| RV2CVOPCV_RETURN_STUB|5.021004||Viu rvpv_dup|5.008008|5.008008|u RX_ANCHORED_SUBSTR|5.010001||Viu RX_ANCHORED_UTF8|5.010001||Viu RXapif_ALL|5.009005||Viu RXapif_CLEAR|5.009005||Viu RXapif_DELETE|5.009005||Viu RXapif_EXISTS|5.009005||Viu RXapif_FETCH|5.009005||Viu RXapif_FIRSTKEY|5.009005||Viu RXapif_NEXTKEY|5.009005||Viu RXapif_ONE|5.009005||Viu RXapif_REGNAME|5.009005||Viu RXapif_REGNAMES|5.009005||Viu RXapif_REGNAMES_COUNT|5.009005||Viu RXapif_SCALAR|5.009005||Viu RXapif_STORE|5.009005||Viu RX_BUFF_IDX_CARET_FULLMATCH|5.017004||Viu RX_BUFF_IDX_CARET_POSTMATCH|5.017004||Viu RX_BUFF_IDX_CARET_PREMATCH|5.017004||Viu RX_BUFF_IDX_FULLMATCH|5.009005||Viu RX_BUFF_IDX_POSTMATCH|5.009005||Viu RX_BUFF_IDX_PREMATCH|5.009005||Viu RX_CHECK_SUBSTR|5.010001||Viu RX_COMPFLAGS|5.017011||Viu RX_ENGINE|5.010001||Viu RX_EXTFLAGS|5.010001||Viu RXf_BASE_SHIFT|5.013004||Viu RXf_CHECK_ALL|5.009005||Viu RXf_COPY_DONE|5.009005||Viu RXf_EVAL_SEEN|5.009005||Viu RXf_INTUIT_TAIL|5.009005||Viu RXf_IS_ANCHORED|5.019009||Viu RX_FLOAT_SUBSTR|5.010001||Viu RX_FLOAT_UTF8|5.010001||Viu RXf_MATCH_UTF8|5.009005||Viu RXf_NO_INPLACE_SUBST|5.017011||Viu RXf_NULL|5.010000||Viu RXf_PMf_CHARSET|5.013009||Viu RXf_PMf_COMPILETIME|5.009005||Viu RXf_PMf_EXTENDED|5.009005||Viu RXf_PMf_EXTENDED_MORE|5.021005||Viu RXf_PMf_FLAGCOPYMASK|5.017011||Viu RXf_PMf_FOLD|5.009005||Viu RXf_PMf_KEEPCOPY|5.009005||Viu RXf_PMf_MULTILINE|5.009005||Viu RXf_PMf_NOCAPTURE|5.021008||Viu RXf_PMf_SINGLELINE|5.009005||Viu RXf_PMf_SPLIT|5.017011||Viu RXf_PMf_STD_PMMOD|5.009005||Viu RXf_PMf_STD_PMMOD_SHIFT|5.010001||Viu RXf_PMf_STRICT|5.021008||Viu RXf_SKIPWHITE|5.009005||Viu RXf_SPLIT|5.009005||Viu RXf_START_ONLY|5.009005||Viu RXf_TAINTED|5.009005||Viu RXf_TAINTED_SEEN|5.009005||Viu RXf_UNBOUNDED_QUANTIFIER_SEEN|5.019009||Viu RXf_USE_INTUIT|5.009005||Viu RXf_USE_INTUIT_ML|5.009005||Viu RXf_USE_INTUIT_NOML|5.009005||Viu RXf_WHITE|5.009005||Viu RX_GOFS|5.010001||Viu RXi_GET|5.009005||Viu RXi_GET_DECL|5.009005||Viu RX_INTFLAGS|5.019009||Viu RXi_SET|5.009005||Viu RX_ISTAINTED|5.017006||Viu RX_LASTCLOSEPAREN|5.010001||Viu RX_LASTPAREN|5.010001||Viu RX_MATCH_COPIED|5.006000||Viu RX_MATCH_COPIED_off|5.006000||Viu RX_MATCH_COPIED_on|5.006000||Viu RX_MATCH_COPIED_set|5.006000||Viu RX_MATCH_COPY_FREE|5.009000||Viu RX_MATCH_TAINTED|5.005000||Viu RX_MATCH_TAINTED_off|5.005000||Viu RX_MATCH_TAINTED_on|5.005000||Viu RX_MATCH_TAINTED_set|5.005000||Viu RX_MATCH_UTF8|5.008001||Viu RX_MATCH_UTF8_off|5.008001||Viu RX_MATCH_UTF8_on|5.008001||Viu RX_MATCH_UTF8_set|5.008001||Viu RX_MINLEN|5.010001||Viu RX_MINLENRET|5.010001||Viu RX_NPARENS|5.010001||Viu RX_OFFS|5.010001||Viu RXp_COMPFLAGS|5.017011||Viu RXp_ENGINE|5.027003||Viu RXp_EXTFLAGS|5.010001||Viu RXp_GOFS|5.027003||Viu RXp_HAS_CUTGROUP|5.027003||Viu RXp_INTFLAGS|5.019009||Viu RXp_ISTAINTED|5.027003||Viu RXp_MATCH_COPIED|5.010001||Viu RXp_MATCH_COPIED_off|5.010001||Viu RXp_MATCH_COPIED_on|5.010001||Viu RXp_MATCH_COPY_FREE|5.027003||Viu RXp_MATCH_TAINTED|5.010001||Viu RXp_MATCH_TAINTED_off|5.027003||Viu RXp_MATCH_TAINTED_on|5.017008||Viu RXp_MATCH_UTF8|5.010001||Viu RXp_MATCH_UTF8_off|5.027003||Viu RXp_MATCH_UTF8_on|5.027003||Viu RXp_MATCH_UTF8_set|5.027003||Viu RXp_MINLEN|5.027003||Viu RXp_MINLENRET|5.027003||Viu RXp_NPARENS|5.027003||Viu RXp_OFFS|5.027003||Viu RXp_PAREN_NAMES|5.010001||Viu RX_PRECOMP|5.010001||Viu RX_PRECOMP_const|5.010001||Viu RX_PRELEN|5.010001||Viu RXp_SAVED_COPY|5.027003||Viu RXp_SUBBEG|5.027003||Viu RXp_SUBOFFSET|5.027003||Viu RXp_ZERO_LEN|5.027003||Viu RX_REFCNT|5.010001||Viu rxres_free|5.004000||Viu rxres_restore|5.004000||Viu rxres_save|5.004000||Viu RX_SAVED_COPY|5.011000||Viu RX_SUBBEG|5.010001||Viu RX_SUBCOFFSET|5.017004||Viu RX_SUBLEN|5.010001||Viu RX_SUBOFFSET|5.017004||Viu RX_TAINT_on|5.017006||Viu RX_UTF8|5.010001||Viu RX_WRAPLEN|5.010001||Viu RX_WRAPPED|5.010001||Viu RX_WRAPPED_const|5.011000||Viu RX_ZERO_LEN|5.019003||Viu safecalloc|5.003007||Viu Safefree|5.003007|5.003007| safefree|5.003007||Viu safemalloc|5.003007||Viu saferealloc|5.003007||Viu safesyscalloc|5.006000|5.006000|n safesysfree|5.006000|5.006000|n safesysmalloc|5.006000|5.006000|n safesysrealloc|5.006000|5.006000|n SAFE_TRIE_NODENUM|5.009002||Viu same_dirent|5.003007||Viu SANE_ERRSV|5.031003|5.031003| SANY|5.003007||Viu SANY_t8|5.035004||Viu SANY_t8_p8|5.033003||Viu SANY_t8_pb|5.033003||Viu SANY_tb|5.035004||Viu SANY_tb_p8|5.033003||Viu SANY_tb_pb|5.033003||Viu save_adelete|5.011000|5.011000|u SAVEADELETE|5.011000||Viu save_aelem|5.004005|5.004005|u save_aelem_flags|5.011000|5.011000|u save_alloc|5.006000|5.006000|u save_aptr|5.003007|5.003007| save_ary|5.003007|5.003007| SAVEBOOL|5.008001|5.008001| save_bool|5.008001||cVu save_clearsv|5.003007||cVu SAVECLEARSV|5.003007||Vi SAVECOMPILEWARNINGS|5.009004||Viu SAVECOMPPAD|5.006000||Vi SAVECOPFILE|5.006000||Viu SAVECOPFILE_FREE|5.006001||Viu SAVECOPLINE|5.006000||Viu SAVECOPSTASH_FREE|5.006001||Viu SAVE_DEFSV|5.004005|5.003007|p SAVEDELETE|5.003007|5.003007| save_delete|5.003007||cVu save_destructor|5.003007||cVu SAVEDESTRUCTOR|5.006000|5.006000| SAVEDESTRUCTOR_X|5.006000|5.006000| save_destructor_x|5.006000||cVu SAVE_ERRNO|5.010001||Vi SAVEFEATUREBITS|5.031006||Viu SAVEf_KEEPOLDELEM|5.011000||Viu SAVEFREECOPHH|5.013007||Viu SAVEFREEOP|5.010001|5.010001| save_freeop|5.010001||cVu SAVEFREEPADNAME|5.021007||Viu SAVEFREEPV|5.003007|5.003007| save_freepv|5.010001||cVu SAVEFREESV|5.003007|5.003007| save_freesv|5.010001||cVu SAVEf_SETMAGIC|5.011000||Viu SAVEGENERICPV|5.006001||Viu save_generic_pvref|5.006001|5.006001|u SAVEGENERICSV|5.005003||Viu save_generic_svref|5.005003|5.005003|u save_gp|5.004000|5.004000| save_hash|5.003007|5.003007| save_hdelete|5.011000|5.011000|u SAVEHDELETE|5.011000||Viu save_hek_flags|5.008000||Vniu save_helem|5.004005|5.004005|u save_helem_flags|5.011000|5.011000|u SAVEHINTS|5.005000||Viu save_hints|5.013005|5.013005|u save_hptr|5.003007|5.003007| SAVEI16|5.004000|5.004000| save_I16|5.004000||cVu SAVEI32|5.003007|5.003007| save_I32|5.003007||cVu SAVEI8|5.006000|5.006000| save_I8|5.006000||cVu SAVEINT|5.003007|5.003007| save_int|5.003007||cVu save_item|5.003007|5.003007| SAVEIV|5.003007|5.003007| save_iv|5.004000||cVu save_lines|5.005000||Viu save_list|5.003007|5.003007|d SAVELONG|5.003007|5.003007| save_long|5.003007||dcVu save_magic_flags|5.019002||Viu SAVE_MASK|5.013001||Viu SAVEMORTALIZESV|5.007001|5.007001| save_mortalizesv|5.010001||cVu save_nogv|5.003007|5.003007|du SAVEOP|5.005000||Viu save_op|5.010001|5.010001|u save_padsv_and_mortalize|5.010001|5.010001|u SAVEPADSVANDMORTALIZE|5.010001||Viu SAVEPADSV|||i SAVEPARSER|5.009005||Viu SAVEPPTR|5.003007|5.003007| save_pptr|5.003007||cVu save_pushi32ptr|5.013006|5.013006|u save_pushptr|5.010001|5.010001|u save_pushptri32ptr|5.010001||Viu save_pushptrptr|5.013006|5.013006|u savepv|5.003007|5.003007| savepvn|5.003007|5.003007| savepvs|5.009003|5.009003| save_re_context|5.006000||cVu save_scalar|5.003007|5.003007| save_scalar_at|5.005000||Viu save_set_svflags|5.009000|5.009000|u SAVESETSVFLAGS|5.009000||Viu savesharedpv|5.007003|5.007003| SAVESHAREDPV|5.007003||Viu savesharedpvn|5.009005|5.009005| save_shared_pvref|5.007003|5.007003|u savesharedpvs|5.013006|5.013006| savesharedsvpv|5.013006|5.013006| SAVESPTR|5.003007|5.003007| save_sptr|5.003007||cVu savestack_grow|5.003007|5.003007|u savestack_grow_cnt|5.008001|5.008001|u SAVESTACK_POS|5.004000|5.004000| save_strlen|5.019004||cViu SAVESTRLEN|5.035005|5.035005| savesvpv|5.009002|5.009002| save_svref|5.003007|5.003007| SAVESWITCHSTACK|5.009002||Viu SAVEt_ADELETE|5.011000||Viu SAVEt_AELEM|5.004005||Viu SAVEt_ALLOC|5.006000||Viu SAVEt_APTR|5.003007||Viu SAVEt_AV|5.003007||Viu SAVEt_BOOL|5.008001||Viu SAVEt_CLEARPADRANGE|5.017006||Viu SAVEt_CLEARSV|5.003007||Viu SAVEt_COMPILE_WARNINGS|5.009004||Viu SAVEt_COMPPAD|5.006000||Viu SAVEt_DELETE|5.003007||Viu SAVEt_DESTRUCTOR|5.003007||Viu SAVEt_DESTRUCTOR_X|5.006000||Viu SAVEt_FREECOPHH|5.013007||Viu SAVEt_FREEOP|5.003007||Viu SAVEt_FREEPADNAME|5.021007||Viu SAVEt_FREEPV|5.003007||Viu SAVEt_FREESV|5.003007||Viu SAVEt_GENERIC_PVREF|5.006001||Viu SAVEt_GENERIC_SVREF|5.005003||Viu SAVEt_GP|5.003007||Viu SAVEt_GVSLOT|5.017007||Viu SAVEt_GVSV|5.013005||Viu SAVEt_HELEM|5.004005||Viu SAVEt_HINTS|5.005000||Viu SAVEt_HINTS_HH|5.033001||Viu SAVEt_HPTR|5.003007||Viu SAVEt_HV|5.003007||Viu SAVEt_I16|5.004000||Viu SAVEt_I32|5.003007||Viu SAVEt_I32_SMALL|5.013001||Viu SAVEt_I8|5.006000||Viu SAVE_TIGHT_SHIFT|5.013001||Viu SAVEt_INT|5.003007||Viu SAVEt_INT_SMALL|5.013001||Viu SAVEt_ITEM|5.003007||Viu SAVEt_IV|5.003007||Viu SAVEt_LONG|5.003007||Viu SAVEt_MORTALIZESV|5.007001||Viu SAVETMPS|5.003007|5.003007| savetmps|||xu SAVEt_NSTAB|5.003007||Viu save_to_buffer|5.027004||Vniu SAVEt_OP|5.005000||Viu SAVEt_PADSV_AND_MORTALIZE|5.010001||Viu SAVEt_PARSER|5.009005||Viu SAVEt_PPTR|5.003007||Viu SAVEt_READONLY_OFF|5.019002||Viu SAVEt_REGCONTEXT|5.003007||Viu SAVEt_SAVESWITCHSTACK|5.009002||Viu SAVEt_SET_SVFLAGS|5.009000||Viu SAVEt_SHARED_PVREF|5.007003||Viu SAVEt_SPTR|5.003007||Viu SAVEt_STACK_POS|5.004000||Viu SAVEt_STRLEN|5.019004||Viu SAVEt_STRLEN_SMALL|5.033005||Viu SAVEt_SV|5.003007||Viu SAVEt_SVREF|5.003007||Viu SAVEt_TMPSFLOOR|5.023008||Viu SAVEt_VPTR|5.006000||Viu save_vptr|5.006000|5.006000|u SAVEVPTR|5.006000||Viu SAWAMPERSAND_LEFT|5.017004||Viu SAWAMPERSAND_MIDDLE|5.017004||Viu SAWAMPERSAND_RIGHT|5.017004||Viu sawparens|5.003007||Viu sb_dstr|5.003007||Viu sb_iters|5.003007||Viu sb_m|5.003007||Viu sb_maxiters|5.003007||Viu SBOL|5.003007||Viu SBOL_t8|5.035004||Viu SBOL_t8_p8|5.033003||Viu SBOL_t8_pb|5.033003||Viu SBOL_tb|5.035004||Viu SBOL_tb_p8|5.033003||Viu SBOL_tb_pb|5.033003||Viu sb_orig|5.003007||Viu SBOX32_CHURN_ROUNDS|5.027001||Viu SBOX32_MAX_LEN|5.027001||Viu SBOX32_MIX3|5.027001||Viu SBOX32_MIX4|5.027001||Viu SBOX32_SCRAMBLE32|5.027001||Viu SBOX32_SKIP_MASK|5.027001||Viu SBOX32_STATE_BITS|5.027001||Viu SBOX32_STATE_BYTES|5.027001||Viu SBOX32_STATE_WORDS|5.027001||Viu SBOX32_STATIC_INLINE|5.027001||Viu SBOX32_WARN2|5.027001||Viu SBOX32_WARN3|5.027001||Viu SBOX32_WARN4|5.027001||Viu SBOX32_WARN5|5.027001||Viu SBOX32_WARN6|5.027001||Viu sb_rflags|5.006000||Viu sb_rx|5.003007||Viu sb_rxres|5.004000||Viu sb_rxtainted|5.004000||Viu sb_s|5.003007||Viu sb_strend|5.003007||Viu sb_targ|5.003007||Viu scalar|5.003007||Viu scalarboolean|5.005000||Viu scalarkids|5.003007||Viu scalar_mod_type|5.006000||Vniu scalarvoid|5.003007||Viu scan_bin|5.006000|5.006000| scan_commit|5.005000||Viu scan_const|5.003007||Viu SCAN_DEF|5.003007||Viu scan_formline|5.003007||Viu scan_heredoc|5.003007||Viu scan_hex|5.006000|5.003007| scan_ident|5.003007||Viu scan_inputsymbol|5.003007||Viu scan_num|5.003007||cVu scan_oct|5.006000|5.003007| scan_pat|5.003007||Viu SCAN_REPL|5.003007||Viu scan_str|5.003007||xcViu scan_subst|5.003007||Viu SCAN_TR|5.003007||Viu scan_trans|5.003007||Viu scan_version|5.009001|5.009001| SCAN_VERSION|5.019008||Viu scan_vstring|5.009005|5.009005|u scan_word|5.003007||xcViu SCHED_YIELD|5.006000|5.006000|Vn SCOPE_SAVES_SIGNAL_MASK|5.007001||Viu search_const|5.010001||Viu seed|5.009003|5.009003|u seedDrand01|5.006000|5.006000| SEEK_CUR|5.003007||Viu seekdir|5.005000||Viu SEEK_END|5.003007||Viu SEEK_SET|5.003007||Viu select|5.005000||Viu Select_fd_set_t|5.003007|5.003007|Vn SELECT_MIN_BITS|5.005003|5.005003|Vn Semctl|5.004005||Viu semun|5.006000||Viu send|5.005000||Viu sendto|5.005000||Viu SEOL|5.003007||Viu SEOL_t8|5.035004||Viu SEOL_t8_p8|5.033003||Viu SEOL_t8_pb|5.033003||Viu SEOL_tb|5.035004||Viu SEOL_tb_p8|5.033003||Viu SEOL_tb_pb|5.033003||Viu sequence_num|5.009003||Viu set_ANYOF_arg|5.019005||Viu set_ANYOF_SYNTHETIC|5.019009||Viu setbuf|5.003007||Viu set_caret_X|5.019006||Viu set_context|5.006000|5.006000|nu setdefout|5.011000|5.011000| SETERRNO|5.003007||Vi setfd_cloexec|5.027008||Vniu setfd_cloexec_for_nonsysfd|5.027008||Viu setfd_cloexec_or_inhexec_by_sysfdness|5.027008||Viu setfd_inhexec|5.027008||Vniu setfd_inhexec_for_sysfd|5.027008||Viu setgid|5.005000||Viu setgrent|5.009000||Viu SETGRENT_R_HAS_FPTR|5.008000||Viu SETGRENT_R_PROTO|5.008000|5.008000|Vn sethostent|5.005000||Viu SETHOSTENT_R_PROTO|5.008000|5.008000|Vn SETi|5.003007||Viu setjmp|5.005000||Viu setlinebuf|5.005000||Viu setlocale|5.009000||Viu setlocale_debug_string|5.027002||Vniu SETLOCALE_LOCK|5.033005||Viu SETLOCALE_R_PROTO|5.008000|5.008000|Vn SETLOCALE_UNLOCK|5.033005||Viu SET_MARK_OFFSET|5.006000||Viu setmode|5.005000||Viu SETn|5.003007||Viu setnetent|5.005000||Viu SETNETENT_R_PROTO|5.008000|5.008000|Vn set_numeric_radix|5.006000||Viu SET_NUMERIC_STANDARD|5.004000||Viu set_numeric_standard|5.006000||cViu SET_NUMERIC_UNDERLYING|5.021010||Viu set_numeric_underlying|5.027006||cViu SETp|5.003007||Viu set_padlist|5.021006||cVniu setprotoent|5.005000||Viu SETPROTOENT_R_PROTO|5.008000|5.008000|Vn setpwent|5.009000||Viu SETPWENT_R_HAS_FPTR|5.008000||Viu SETPWENT_R_PROTO|5.008000|5.008000|Vn set_regex_pv|5.029004||Viu setregid|5.003007||Viu setreuid|5.003007||Viu SETs|5.003007||Viu setservent|5.005000||Viu SETSERVENT_R_PROTO|5.008000|5.008000|Vn setsockopt|5.005000||Viu setSTR_LEN|5.031005||Viu SET_SVANY_FOR_BODYLESS_IV|5.023008||Viu SET_SVANY_FOR_BODYLESS_NV|5.023008||Viu SETTARG|5.003007||Viu SET_THR|5.005000||Viu SET_THREAD_SELF|5.005003||Viu SETu|5.004000||Viu setuid|5.005000||Viu _setup_canned_invlist|5.019008||cViu setvbuf|5.003007||Viu share_hek|5.009003|5.009003|u share_hek_flags|5.008000||Viu share_hek_hek|5.009003||Viu sharepvn|5.005000||Viu SHARP_S_SKIP|5.007003||Viu Shmat_t|5.003007|5.003007|Vn SHORTSIZE|5.004000|5.004000|Vn should_warn_nl|5.021001||Vniu should_we_output_Debug_r|5.031011||Viu SH_PATH|5.003007|5.003007|Vn shutdown|5.005000||Viu si_dup|5.007003|5.007003|u S_IEXEC|5.006000||Viu S_IFIFO|5.011000||Viu S_IFMT|5.003007||Viu SIGABRT|5.003007||Viu sighandler1|5.031007||Vniu sighandler3|5.031007||Vniu sighandler|5.003007||Vniu SIGILL|5.003007||Viu Sigjmp_buf|5.003007|5.003007|Vn Siglongjmp|5.003007|5.003007| signal|5.005000||Viu Signal_t|5.003007|5.003007|Vn SIG_NAME|5.003007|5.003007|Vn SIG_NUM|5.003007|5.003007|Vn Sigsetjmp|5.003007|5.003007| SIG_SIZE|5.007001|5.007001|Vn simplify_sort|5.006000||Viu single_1bit_pos32|5.035003||cVnu single_1bit_pos64|5.035003||cVnu SINGLE_PAT_MOD|5.009005||Viu SIPHASH_SEED_STATE|5.027001||Viu SIPROUND|5.017006||Viu S_IREAD|5.006000||Viu S_IRGRP|5.003007||Viu S_IROTH|5.003007||Viu S_IRUSR|5.003007||Viu S_IRWXG|5.006000||Viu S_IRWXO|5.006000||Viu S_IRWXU|5.006000||Viu S_ISBLK|5.003007||Viu S_ISCHR|5.003007||Viu S_ISDIR|5.003007||Viu S_ISFIFO|5.003007||Viu S_ISGID|5.003007||Viu S_ISLNK|5.003007||Viu S_ISREG|5.003007||Viu S_ISSOCK|5.003007||Viu S_ISUID|5.003007||Viu SITEARCH|5.003007|5.003007|Vn SITEARCH_EXP|5.003007|5.003007|Vn SITELIB|5.003007|5.003007|Vn SITELIB_EXP|5.003007|5.003007|Vn SITELIB_STEM|5.006000|5.006000|Vn S_IWGRP|5.003007||Viu S_IWOTH|5.003007||Viu S_IWRITE|5.006000||Viu S_IWUSR|5.003007||Viu S_IXGRP|5.003007||Viu S_IXOTH|5.003007||Viu S_IXUSR|5.003007||Viu SIZE_ALIGN|5.005000||Viu Size_t|5.003007|5.003007|Vn Size_t_MAX|5.021003||Viu Size_t_size|5.006000|5.006000|Vn SKIP|5.009005||Viu SKIP_next|5.009005||Viu SKIP_next_fail|5.009005||Viu SKIP_next_fail_t8|5.035004||Viu SKIP_next_fail_t8_p8|5.033003||Viu SKIP_next_fail_t8_pb|5.033003||Viu SKIP_next_fail_tb|5.035004||Viu SKIP_next_fail_tb_p8|5.033003||Viu SKIP_next_fail_tb_pb|5.033003||Viu SKIP_next_t8|5.035004||Viu SKIP_next_t8_p8|5.033003||Viu SKIP_next_t8_pb|5.033003||Viu SKIP_next_tb|5.035004||Viu SKIP_next_tb_p8|5.033003||Viu SKIP_next_tb_pb|5.033003||Viu skipspace_flags|5.019002||xcViu SKIP_t8|5.035004||Viu SKIP_t8_p8|5.033003||Viu SKIP_t8_pb|5.033003||Viu SKIP_tb|5.035004||Viu SKIP_tb_p8|5.033003||Viu SKIP_tb_pb|5.033003||Viu skip_to_be_ignored_text|5.023004||Viu Slab_Alloc|5.006000||cViu Slab_Free|5.007003||cViu Slab_to_ro|5.017002||Viu Slab_to_rw|5.009005||Viu sleep|5.005000||Viu SLOPPYDIVIDE|5.003007||Viu socket|5.005000||Viu SOCKET_OPEN_MODE|5.008002||Viu socketpair|5.005000||Viu Sock_size_t|5.006000|5.006000|Vn softref2xv|||iu sortcv|5.009003||Viu sortcv_stacked|5.009003||Viu sortcv_xsub|5.009003||Viu sortsv|5.007003|5.007003| sortsv_flags|5.009003|5.009003| sortsv_flags_impl|5.031011||Viu SP|5.003007|5.003007| space_join_names_mortal|5.009004||Viu SPAGAIN|5.003007|5.003007| S_PAT_MODS|5.009005||Viu specialWARN|5.006000||Viu SRAND48_R_PROTO|5.008000|5.008000|Vn SRANDOM_R_PROTO|5.008000|5.008000|Vn SRCLOSE|5.027008||Viu SRCLOSE_t8|5.035004||Viu SRCLOSE_t8_p8|5.033003||Viu SRCLOSE_t8_pb|5.033003||Viu SRCLOSE_tb|5.035004||Viu SRCLOSE_tb_p8|5.033003||Viu SRCLOSE_tb_pb|5.033003||Viu SROPEN|5.027008||Viu SROPEN_t8|5.035004||Viu SROPEN_t8_p8|5.033003||Viu SROPEN_t8_pb|5.033003||Viu SROPEN_tb|5.035004||Viu SROPEN_tb_p8|5.033003||Viu SROPEN_tb_pb|5.033003||Viu SS_ACCVIO|5.008001||Viu SS_ADD_BOOL|5.017007||Viu SS_ADD_DPTR|5.017007||Viu SS_ADD_DXPTR|5.017007||Viu SS_ADD_END|5.017007||Viu SS_ADD_INT|5.017007||Viu SS_ADD_IV|5.017007||Viu SS_ADD_LONG|5.017007||Viu SS_ADD_PTR|5.017007||Viu SS_ADD_UV|5.017007||Viu SS_BUFFEROVF|5.021009||Viu ssc_add_range|5.019005||Viu ssc_and|5.019005||Viu ssc_anything|5.019005||Viu ssc_clear_locale|5.019005||Vniu ssc_cp_and|5.019005||Viu ssc_finalize|5.019005||Viu SSCHECK|5.003007||Viu ssc_init|5.019005||Viu ssc_intersection|5.019005||Viu ssc_is_anything|5.019005||Vniu ssc_is_cp_posixl_init|5.019005||Vniu SSC_MATCHES_EMPTY_STRING|5.021004||Viu ssc_or|5.019005||Viu ssc_union|5.019005||Viu SS_DEVOFFLINE|5.008001||Viu ss_dup|5.007003|5.007003|u SSGROW|5.008001||Viu SS_IVCHAN|5.008001||Viu SSize_t|5.003007|5.003007|Vn SSize_t_MAX|5.019004||Viu SS_MAXPUSH|5.017007||Viu SSNEW|5.006000||Viu SSNEWa|5.006000||Viu SSNEWat|5.007001||Viu SSNEWt|5.007001||Viu SS_NOPRIV|5.021001||Viu SS_NORMAL|5.008001||Viu SSPOPBOOL|5.008001||Viu SSPOPDPTR|5.003007||Viu SSPOPDXPTR|5.006000||Viu SSPOPINT|5.003007||Viu SSPOPIV|5.003007||Viu SSPOPLONG|5.003007||Viu SSPOPPTR|5.003007||Viu SSPOPUV|5.013001||Viu SSPTR|5.006000||Viu SSPTRt|5.007001||Viu SSPUSHBOOL|5.008001||Viu SSPUSHDPTR|5.003007||Viu SSPUSHDXPTR|5.006000||Viu SSPUSHINT|5.003007||Viu SSPUSHIV|5.003007||Viu SSPUSHLONG|5.003007||Viu SSPUSHPTR|5.003007||Viu SSPUSHUV|5.013001||Viu ST|5.003007|5.003007| stack_grow|5.003007||cVu STANDARD_C|5.003007||Viu STAR|5.003007||Viu STAR_t8|5.035004||Viu STAR_t8_p8|5.033003||Viu STAR_t8_pb|5.033003||Viu STAR_tb|5.035004||Viu STAR_tb_p8|5.033003||Viu STAR_tb_pb|5.033003||Viu START_EXTERN_C|5.005000|5.003007|pV start_glob|||xi START_MY_CXT|5.010000|5.010000|p STARTPERL|5.003007|5.003007|Vn start_subparse|5.004000|5.003007|pu StashHANDLER|5.007001||Viu Stat|5.003007||Viu stat|5.005000||Viu STATIC|5.005000||Viu STATIC_ASSERT_1|5.021007||Viu STATIC_ASSERT_2|5.021007||Viu STATIC_ASSERT_DECL|5.027001||Viu STATIC_ASSERT_STMT|5.021007||Viu Stat_t|5.004005||Viu STATUS_ALL_FAILURE|5.004000||Viu STATUS_ALL_SUCCESS|5.004000||Viu STATUS_CURRENT|5.004000||Viu STATUS_EXIT|5.009003||Viu STATUS_EXIT_SET|5.009003||Viu STATUS_NATIVE|5.004000||Viu STATUS_NATIVE_CHILD_SET|5.009003||Viu STATUS_UNIX|5.009003||Viu STATUS_UNIX_EXIT_SET|5.009003||Viu STATUS_UNIX_SET|5.009003||Viu STDCHAR|5.003007|5.003007|Vn stderr|5.003007||Viu ST_DEV_SIGN|5.035004|5.035004|Vn ST_DEV_SIZE|5.035004|5.035004|Vn stdin|5.003007||Viu STDIO_PTR_LVAL_SETS_CNT|5.007001|5.007001|Vn STDIO_PTR_LVALUE|5.006000|5.006000|Vn STDIO_STREAM_ARRAY|5.006000|5.006000|Vn stdize_locale|5.007001||Viu stdout|5.003007||Viu stdoutf|5.005000||Viu STD_PAT_MODS|5.009005||Viu STD_PMMOD_FLAGS_CLEAR|5.013006||Viu ST_INO_SIGN|5.015002|5.015002|Vn ST_INO_SIZE|5.015002|5.015002|Vn STMT_END|5.003007|5.003007|pV STMT_START|5.003007|5.003007|pV STOREFEATUREBITSHH|5.031006||Viu STORE_LC_NUMERIC_FORCE_TO_UNDERLYING|5.021010|5.021010| STORE_LC_NUMERIC_SET_STANDARD|5.027009||pVu STORE_LC_NUMERIC_SET_TO_NEEDED|5.021010|5.021010| STORE_LC_NUMERIC_SET_TO_NEEDED_IN|5.031003|5.031003| STORE_NUMERIC_SET_STANDARD|||piu strBEGINs|5.027006||Viu strEQ|5.003007|5.003007| Strerror|5.003007||Viu strerror|5.009000||Viu STRERROR_R_PROTO|5.008000|5.008000|Vn strGE|5.003007|5.003007| strGT|5.003007|5.003007| STRING|5.006000||Viu STRINGIFY|5.003007|5.003007|Vn STRINGl|5.031005||Viu STRINGs|5.031005||Viu strip_return|5.009003||Viu strLE|5.003007|5.003007| STR_LEN|5.006000||Viu STRLEN|5.027001||Viu STR_LENl|5.031005||Viu STR_LENs|5.031005||Viu strLT|5.003007|5.003007| strNE|5.003007|5.003007| strnEQ|5.003007|5.003007| strnNE|5.003007|5.003007| STR_SZ|5.006000||Viu Strtod|5.029010|5.029010|n Strtol|5.006000|5.006000|n strtoll|5.006000||Viu Strtoul|5.006000|5.006000|n strtoull|5.006000||Viu str_to_version|5.006000||cVu StructCopy|5.003007|5.003007|V STRUCT_OFFSET|5.004000||Viu STRUCT_SV|5.007001||Viu STR_WITH_LEN|5.009003|5.003007|pV study_chunk|5.005000||Viu sub_crush_depth|5.004000||Viu sublex_done|5.005000||Viu sublex_push|5.005000||Viu sublex_start|5.005000||Viu SUBST_TAINT_BOOLRET|5.013010||Viu SUBST_TAINT_PAT|5.013010||Viu SUBST_TAINT_REPL|5.013010||Viu SUBST_TAINT_RETAINT|5.013010||Viu SUBST_TAINT_STR|5.013010||Viu SUBVERSION|5.003007||Viu SUCCEED|5.003007||Viu SUCCEED_t8|5.035004||Viu SUCCEED_t8_p8|5.033003||Viu SUCCEED_t8_pb|5.033003||Viu SUCCEED_tb|5.035004||Viu SUCCEED_tb_p8|5.033003||Viu SUCCEED_tb_pb|5.033003||Viu SUSPEND|5.005000||Viu SUSPEND_t8|5.035004||Viu SUSPEND_t8_p8|5.033003||Viu SUSPEND_t8_pb|5.033003||Viu SUSPEND_tb|5.035004||Viu SUSPEND_tb_p8|5.033003||Viu SUSPEND_tb_pb|5.033003||Viu sv_2bool|5.013006||cV sv_2bool_flags|5.013006||cV sv_2bool_nomg|5.017002||Viu sv_2cv|5.003007|5.003007| sv_2io|5.003007|5.003007| sv_2iuv_common|5.009004||Viu sv_2iuv_non_preserve|5.007001||Viu sv_2iv|5.009001||cVu sv_2iv_flags|5.009001|5.009001| sv_2mortal|5.003007|5.003007| sv_2num|5.010000||xVi sv_2nv|5.013001||Viu sv_2nv_flags|5.013001|5.013001| sv_2pv|5.005000||cVu sv_2pvbyte|5.006000|5.003007|p sv_2pvbyte_flags|5.031004|5.031004|u sv_2pvbyte_nolen|5.009003||pcV sv_2pv_flags|5.007002||pcV sv_2pv_nolen|5.009003||pcV sv_2pv_nomg|5.007002||Viu sv_2pvutf8|5.006000|5.006000| sv_2pvutf8_flags|5.031004|5.031004|u sv_2pvutf8_nolen|5.009003||cV sv_2uv|5.009001||pcVu sv_2uv_flags|5.009001|5.009001| sv_add_arena|5.003007||Vi sv_add_backref|||iu SvAMAGIC|5.003007||Viu SvAMAGIC_off|5.003007|5.003007|nu SvAMAGIC_on|5.003007|5.003007|nu SvANY|5.003007||Viu sv_backoff|5.003007|5.003007|n sv_bless|5.003007|5.003007| sv_buf_to_ro|5.019008||Viu sv_buf_to_rw|5.019008||Viu SvCANCOW|5.017007||Viu SvCANEXISTDELETE|5.011000||Viu SV_CATBYTES|5.021005|5.021005| sv_cat_decode|5.008001|5.008001| sv_cathek|5.021004||Viu sv_catpv|5.003007|5.003007| sv_catpvf|5.004000||vV sv_catpv_flags|5.013006|5.013006| sv_catpvf_mg|5.004005||pvV sv_catpvf_mg_nocontext|5.006000||pvVn sv_catpvf_nocontext|5.006000||vVn sv_catpv_mg|5.004005|5.003007|p sv_catpvn|5.003007|5.003007| sv_catpvn_flags|5.007002|5.007002| sv_catpvn_mg|5.004005|5.003007|p sv_catpvn_nomg|5.007002|5.003007|p sv_catpvn_nomg_maybeutf8|5.017005||Viu sv_catpvn_nomg_utf8_upgrade|5.017002||Viu sv_catpv_nomg|5.013006|5.013006| sv_catpvs|5.009003|5.003007|p sv_catpvs_flags|5.013006|5.013006| sv_catpvs_mg|5.013006|5.013006| sv_catpvs_nomg|5.013006|5.013006| sv_catsv|5.003007|5.003007| sv_catsv_flags|5.007002|5.007002| sv_catsv_mg|5.004005|5.003007|p sv_catsv_nomg|5.007002|5.003007|p SV_CATUTF8|5.021005|5.021005| sv_catxmlpvs|5.013006||Viu SV_CHECK_THINKFIRST|5.008001||Viu SV_CHECK_THINKFIRST_COW_DROP|5.009000||Viu sv_chop|5.003007|5.003007| sv_clean_all|5.003007||Vi sv_clean_objs|5.003007||Vi sv_clear|5.003007|5.003007| sv_cmp|5.003007|5.003007| sv_cmp_flags|5.013006|5.013006| sv_cmp_locale|5.004000|5.004000| sv_cmp_locale_flags|5.013006|5.013006| sv_collxfrm|5.013006||V sv_collxfrm_flags|5.013006|5.013006| SvCOMPILED|5.003007||Viu SvCOMPILED_off|5.003007||Viu SvCOMPILED_on|5.003007||Viu SV_CONST|5.019002||Viu SV_CONST_BINMODE|5.019002||Viu SV_CONST_CLEAR|5.019002||Viu SV_CONST_CLOSE|5.019002||Viu SV_CONST_DELETE|5.019002||Viu SV_CONST_DESTROY|5.019002||Viu SV_CONST_EOF|5.019002||Viu SV_CONST_EXISTS|5.019002||Viu SV_CONST_EXTEND|5.019002||Viu SV_CONST_FETCH|5.019002||Viu SV_CONST_FETCHSIZE|5.019002||Viu SV_CONST_FILENO|5.019002||Viu SV_CONST_FIRSTKEY|5.019002||Viu SV_CONST_GETC|5.019002||Viu SV_CONST_NEXTKEY|5.019002||Viu SV_CONST_OPEN|5.019002||Viu SV_CONST_POP|5.019002||Viu SV_CONST_PRINT|5.019002||Viu SV_CONST_PRINTF|5.019002||Viu SV_CONST_PUSH|5.019002||Viu SV_CONST_READ|5.019002||Viu SV_CONST_READLINE|5.019002||Viu SV_CONST_RETURN|5.009003|5.003007|poVnu SV_CONST_SCALAR|5.019002||Viu SV_CONSTS_COUNT|5.019002||Viu SV_CONST_SEEK|5.019002||Viu SV_CONST_SHIFT|5.019002||Viu SV_CONST_SPLICE|5.019002||Viu SV_CONST_STORE|5.019002||Viu SV_CONST_STORESIZE|5.019002||Viu SV_CONST_TELL|5.019002||Viu SV_CONST_TIEARRAY|5.019002||Viu SV_CONST_TIEHANDLE|5.019002||Viu SV_CONST_TIEHASH|5.019002||Viu SV_CONST_TIESCALAR|5.019002||Viu SV_CONST_UNSHIFT|5.019002||Viu SV_CONST_UNTIE|5.019002||Viu SV_CONST_WRITE|5.019002||Viu sv_copypv|5.007003|5.007003| sv_copypv_flags|5.017002|5.017002| sv_copypv_nomg|5.017002|5.017002| SV_COW_DROP_PV|5.008001|5.003007|p SV_COW_OTHER_PVS|5.009005||Viu SV_COW_REFCNT_MAX|5.017007||Viu SV_COW_SHARED_HASH_KEYS|5.009005|5.003007|poVnu SvCUR|5.003007|5.003007| SvCUR_set|5.003007|5.003007| sv_dec|5.003007|5.003007| sv_dec_nomg|5.013002|5.013002| sv_del_backref|5.006000||cViu sv_derived_from|5.004000|5.004000| sv_derived_from_pv|5.015004|5.015004| sv_derived_from_pvn|5.015004|5.015004| sv_derived_from_sv|5.015004|5.015004| sv_derived_from_svpvn|5.031006||Viu sv_destroyable|5.010000|5.010000| SvDESTROYABLE|5.010000||Viu sv_display|5.021002||Viu SV_DO_COW_SVSETSV|5.009005||Viu sv_does|5.009004|5.009004| sv_does_pv|5.015004|5.015004| sv_does_pvn|5.015004|5.015004| sv_does_sv|5.015004|5.015004| sv_dump|5.003007|5.003007| sv_dup|5.007003|5.007003|u sv_dup_common|5.013002||Viu sv_dup_inc|5.013002|5.013002|u sv_dup_inc_multiple|5.011000||Viu SvEND|5.003007|5.003007| SvEND_set|5.003007||Viu SvENDx|5.003007||Viu sv_eq|5.003007|5.003007| sv_eq_flags|5.013006|5.013006| sv_exp_grow|5.009003||Viu SVf256|5.008001||Viu SVf32|5.009002||Viu SVf|5.006000|5.003007|p SvFAKE|5.003007||Viu SvFAKE_off|5.003007||Viu SvFAKE_on|5.003007||Viu SVf_AMAGIC|5.003007||Viu SVfARG|5.009005|5.003007|p SVf_BREAK|5.003007||Viu SVf_FAKE|5.003007||Viu SVf_IOK|5.003007||Viu SVf_IsCOW|5.017006||Viu SVf_IVisUV|5.006000||Viu SvFLAGS|5.003007||Viu SVf_NOK|5.003007||Viu SVf_OK|5.003007||Viu SVf_OOK|5.003007||Viu sv_force_normal|5.006000|5.006000| sv_force_normal_flags|5.007001|5.007001| SV_FORCE_UTF8_UPGRADE|5.011000|5.011000| SVf_POK|5.003007||Viu SVf_PROTECT|5.021005||Viu SVf_READONLY|5.003007||Viu sv_free2|||xciu sv_free|5.003007|5.003007| sv_free_arenas|5.003007||Vi SVf_ROK|5.003007||Viu SVf_THINKFIRST|5.003007||Viu SVf_UTF8|5.006000|5.003007|p SvGAMAGIC|5.006001|5.006001| sv_get_backrefs|5.021008|5.021008|xn SvGETMAGIC|5.004005|5.003007|p sv_gets|5.003007|5.003007| SvGID|5.019001||Viu SV_GMAGIC|5.007002|5.003007|p SvGMAGICAL|5.003007||Viu SvGMAGICAL_off|5.003007||Viu SvGMAGICAL_on|5.003007||Viu SvGROW|5.003007|5.003007| sv_grow|5.003007||cV Sv_Grow|5.003007||Viu sv_grow_fresh|5.035006||cV SvGROW_mutable|5.009003||Viu SV_HAS_TRAILING_NUL|5.009004|5.003007|p SV_IMMEDIATE_UNREF|5.007001|5.003007|p SvIMMORTAL|5.004000||Viu SvIMMORTAL_INTERP|5.027003||Viu SvIMMORTAL_TRUE|5.027003||Viu sv_inc|5.003007|5.003007| sv_i_ncmp|5.009003||Viu sv_i_ncmp_desc|5.031011||Viu sv_inc_nomg|5.013002|5.013002| sv_insert|5.003007|5.003007| sv_insert_flags|5.010001|5.010001| SvIOK|5.003007|5.003007| SvIOK_nog|5.017002||Viu SvIOK_nogthink|5.017002||Viu SvIOK_notUV|5.006000|5.006000| SvIOK_off|5.003007|5.003007| SvIOK_on|5.003007|5.003007| SvIOK_only|5.003007|5.003007| SvIOK_only_UV|5.006000|5.006000| SvIOKp|5.003007|5.003007| SvIOKp_on|5.003007||Viu SvIOK_UV|5.006000|5.006000| sv_isa|5.003007|5.003007| sv_isa_sv|5.031007|5.031007|x SvIsBOOL|5.035004|5.035004| SvIsCOW|5.008003|5.008003| SvIsCOW_shared_hash|5.008003|5.008003| SvIS_FREED|5.009003||Viu sv_isobject|5.003007|5.003007| SvIV|5.003007|5.003007| sv_iv|5.005000||dcV SvIV_nomg|5.009001|5.003007|p SvIV_please|5.007001||Viu SvIV_please_nomg|5.013002||Viu SvIV_set|5.003007|5.003007| SvIVX|5.003007|5.003007| SvIVx|5.003007|5.003007| SvIVXx|5.003007||Viu sv_kill_backrefs|||xiu sv_len|5.003007|5.003007| SvLEN|5.003007|5.003007| SvLEN_set|5.003007|5.003007| sv_len_utf8|5.006000|5.006000|p sv_len_utf8_nomg||5.006000|p SvLENx|5.003007||Viu SvLOCK|5.007003|5.007003| sv_magic|5.003007|5.003007| SvMAGIC|5.003007||Viu SvMAGICAL|5.003007||Viu SvMAGICAL_off|5.003007||Viu SvMAGICAL_on|5.003007||Viu sv_magicext|5.007003|5.007003| sv_magicext_mglob|5.019002||cViu sv_magic_portable||5.004000|pou SvMAGIC_set|5.009003|5.003007|p sv_mortalcopy|5.003007|5.003007| sv_mortalcopy_flags|5.031001|5.003007|p SV_MUTABLE_RETURN|5.009003|5.003007|poVnu sv_ncmp|5.009003||Viu sv_ncmp_desc|5.031011||Viu sv_newmortal|5.003007|5.003007| sv_newref|5.003007||cV SvNIOK|5.003007|5.003007| SvNIOK_nog|5.017002||Viu SvNIOK_nogthink|5.017002||Viu SvNIOK_off|5.003007|5.003007| SvNIOKp|5.003007|5.003007| SvNOK|5.003007|5.003007| SvNOK_nog|5.017002||Viu SvNOK_nogthink|5.017002||Viu SvNOK_off|5.003007|5.003007| SvNOK_on|5.003007|5.003007| SvNOK_only|5.003007|5.003007| SvNOKp|5.003007|5.003007| SvNOKp_on|5.003007||Viu sv_nolocking|5.031004|5.031004|d sv_nosharing|5.007003|5.007003| SV_NOSTEAL|5.009002|5.003007|p sv_nounlocking|5.009004|5.009004|d sv_numeq|5.035009|5.035009| sv_numeq_flags|5.035009|5.035009| sv_nv|5.005000||dcV SvNV|5.006000|5.003007| SvNV_nomg|5.013002|5.003007|p SvNV_set|5.006000|5.003007| SvNVX|5.006000|5.003007| SvNVx|5.006000|5.003007| SvNVXx|5.003007||Viu SvOBJECT|5.003007||Viu SvOBJECT_off|5.003007||Viu SvOBJECT_on|5.003007||Viu SvOK|5.003007|5.003007| SvOK_off|5.003007||Viu SvOK_off_exc_UV|5.006000||Viu SvOKp|5.003007||Viu sv_only_taint_gmagic|5.021010||Vniu SvOOK|5.003007|5.003007| SvOOK_off|5.003007|5.003007| SvOOK_offset|5.011000|5.011000| SvOOK_on|5.003007||Viu sv_or_pv_len_utf8|5.017005||Viu sv_or_pv_pos_u2b|5.019004||Viu SvOURSTASH|5.009005||Viu SvOURSTASH_set|5.009005||Viu SvPADMY|5.003007||Viu SvPADMY_on|5.003007||Viu SVpad_OUR|5.006000||Viu SvPAD_OUR|5.009004||Viu SvPAD_OUR_on|5.009004||Viu SvPADSTALE|5.009000||Viu SvPADSTALE_off|5.009000||Viu SvPADSTALE_on|5.009000||Viu SVpad_STATE|5.009004||Viu SvPAD_STATE|5.009004||Viu SvPAD_STATE_on|5.009004||Viu SvPADTMP|5.003007||Viu SvPADTMP_off|5.003007||Viu SvPADTMP_on|5.003007||Viu SVpad_TYPED|5.007002||Viu SvPAD_TYPED|5.009004||Viu SvPAD_TYPED_on|5.009004||Viu SVpav_REAL|5.009003||Viu SVpav_REIFY|5.009003||Viu SvPCS_IMPORTED|5.009005||Viu SvPCS_IMPORTED_off|5.009005||Viu SvPCS_IMPORTED_on|5.009005||Viu SvPEEK|5.003007||Viu sv_peek|5.005000|5.005000|u SVpgv_GP|5.009005||Viu SVphv_CLONEABLE|5.009003||Viu SVphv_HASKFLAGS|5.008000||Viu SVphv_LAZYDEL|5.003007||Viu SVphv_SHAREKEYS|5.003007||Viu SVp_IOK|5.003007||Viu SVp_NOK|5.003007||Viu SvPOK|5.003007|5.003007| SvPOK_byte_nog|5.017002||Viu SvPOK_byte_nogthink|5.017002||Viu SvPOK_byte_pure_nogthink|5.017003||Viu SvPOK_nog|5.017002||Viu SvPOK_nogthink|5.017002||Viu SvPOK_off|5.003007|5.003007| SvPOK_on|5.003007|5.003007| SvPOK_only|5.003007|5.003007| SvPOK_only_UTF8|5.006000|5.006000| SvPOK_or_cached_IV|||Viu SvPOKp|5.003007|5.003007| SvPOKp_on|5.003007||Viu SvPOK_pure_nogthink|5.017003||Viu SvPOK_utf8_nog|5.017002||Viu SvPOK_utf8_nogthink|5.017002||Viu SvPOK_utf8_pure_nogthink|5.017003||Viu sv_pos_b2u|5.006000|5.006000| sv_pos_b2u_flags|5.019003|5.019003| sv_pos_b2u_midway|5.009004||Viu sv_pos_u2b|5.006000|5.006000| sv_pos_u2b_cached|5.009004||Viu sv_pos_u2b_flags|5.011005|5.011005| sv_pos_u2b_forwards|5.009004||Vniu sv_pos_u2b_midway|5.009004||Vniu SVp_POK|5.003007||Viu SVppv_STATIC|5.035004||Viu SVprv_PCS_IMPORTED|5.009005||Viu SVprv_WEAKREF|5.006000||Viu SVp_SCREAM|5.003007||Viu SvPV|5.003007|5.003007| sv_pv|5.008000||cV SvPVbyte|5.006000|5.003007|p sv_pvbyte|5.008000||cV SvPVbyte_force|5.009002|5.009002| sv_pvbyten|5.006000||dcV sv_pvbyten_force|5.006000||cV SvPVbyte_nolen|5.006000|5.006000| SvPVbyte_nomg|5.031004|5.031004| SvPVbyte_or_null|5.031004|5.031004| SvPVbyte_or_null_nomg|5.031004|5.031004| SvPVbytex|5.006000|5.006000| SvPVbytex_force|5.006000|5.006000| SvPVbytex_nolen|5.009003|5.009003| SvPVCLEAR|5.025006|5.025006|p SvPV_const|5.009003|5.003007|p SvPV_flags|5.007002|5.003007|p SvPV_flags_const|5.009003|5.003007|p SvPV_flags_const_nolen|5.009003||pVu SvPV_flags_mutable|5.009003|5.003007|p SvPV_force|5.003007|5.003007|p SvPV_force_flags|5.007002|5.003007|p SvPV_force_flags_mutable|5.009003|5.003007|p SvPV_force_flags_nolen|5.009003|5.003007|p SvPV_force_mutable|5.009003|5.003007|p SvPV_force_nolen|5.009003|5.003007|p SvPV_force_nomg|5.007002|5.003007|p SvPV_force_nomg_nolen|5.009003|5.003007|p SvPV_free|5.009003|5.009003| SvPV_mutable|5.009003|5.003007|p sv_pvn|5.004000||dcV sv_pvn_force|5.005000||cV sv_pvn_force_flags|5.007002|5.003007|p sv_pvn_force_nomg|5.007002||Viu sv_pvn_nomg|5.007003|5.005000|pdu SvPV_nolen|5.006000|5.003007|p SvPV_nolen_const|5.009003|5.003007|p SvPV_nomg|5.007002|5.003007|p SvPV_nomg_const|5.009003|5.003007|p SvPV_nomg_const_nolen|5.009003|5.003007|p SvPV_nomg_nolen|5.013007|5.003007|p SvPV_renew|5.009003|5.003007|p SvPV_set|5.003007|5.003007| SvPV_shrink_to_cur|5.009003||Viu SvPVutf8|5.006000|5.006000| sv_pvutf8|5.008000||cV SvPVutf8_force|5.006000|5.006000| sv_pvutf8n|5.006000||dcV sv_pvutf8n_force|5.006000||cV SvPVutf8_nolen|5.006000|5.006000| SvPVutf8_nomg|5.031004|5.031004| SvPVutf8_or_null|5.031004|5.031004| SvPVutf8_or_null_nomg|5.031004|5.031004| SvPVutf8x|5.006000|5.006000| SvPVutf8x_force|5.006000|5.006000| SvPVX|5.003007|5.003007| SvPVx|5.003007|5.003007| SvPVX_const|5.009003|5.003007|p SvPVx_const|5.009003|5.009003| SvPVx_force|5.005000|5.005000| SvPVX_mutable|5.009003|5.003007|p SvPVx_nolen|5.009003|5.009003| SvPVx_nolen_const|5.009003|5.003007|p SvPVXtrue|5.017002||Viu SvPVXx|5.003007|5.003007| SvREADONLY|5.003007|5.003007| SvREADONLY_off|5.003007|5.003007| SvREADONLY_on|5.003007|5.003007| sv_recode_to_utf8|5.007003|5.007003| sv_ref|5.023005|5.023005| SvREFCNT|5.003007|5.003007| SvREFCNT_dec|5.003007|5.003007| SvREFCNT_dec_NN|5.017007|5.017007| SvREFCNT_IMMORTAL|5.017008||Viu SvREFCNT_inc|5.003007|5.003007|pn SvREFCNT_inc_NN|5.009004|5.003007|pn SvREFCNT_inc_simple|5.009004|5.003007|pn SvREFCNT_inc_simple_NN|5.009004|5.003007|pn SvREFCNT_inc_simple_void|5.009004|5.003007|pn SvREFCNT_inc_simple_void_NN|5.009004|5.003007|pn SvREFCNT_inc_void|5.009004|5.003007|pn SvREFCNT_inc_void_NN|5.009004|5.003007|pn sv_reftype|5.003007|5.003007| sv_replace|5.003007|5.003007| sv_report_used|5.003007|5.003007| sv_reset|5.003007|5.003007| sv_resetpvn|5.017005||Viu SvRMAGICAL|5.003007||Viu SvRMAGICAL_off|5.003007||Viu SvRMAGICAL_on|5.003007||Viu SvROK|5.003007|5.003007| SvROK_off|5.003007|5.003007| SvROK_on|5.003007|5.003007| SvRV|5.003007|5.003007| SvRV_const|5.010001||Viu SvRV_set|5.009003|5.003007|p sv_rvunweaken|5.027004|5.027004| sv_rvweaken|5.006000|5.006000| SvRVx|5.003007||Viu SvRX|5.009005|5.003007|p SvRXOK|5.009005|5.003007|p SV_SAVED_COPY|5.009005||Viu SvSCREAM|5.003007||Viu SvSCREAM_off|5.003007||Viu SvSCREAM_on|5.003007||Viu sv_setbool|5.035004|5.035004| sv_setbool_mg|5.035004|5.035004| sv_setgid|5.019001||Viu sv_sethek|5.015004||cViu sv_setiv|5.003007|5.003007| sv_setiv_mg|5.004005|5.003007|p SvSETMAGIC|5.003007|5.003007| SvSetMagicSV|5.004000|5.004000| SvSetMagicSV_nosteal|5.004000|5.004000| sv_setnv|5.006000|5.003007| sv_setnv_mg|5.006000|5.003007|p sv_setpv|5.003007|5.003007| sv_setpv_bufsize|5.025006|5.025006| sv_setpvf|5.004000||vV sv_setpvf_mg|5.004005||pvV sv_setpvf_mg_nocontext|5.006000||pvVn sv_setpvf_nocontext|5.006000||vVn sv_setpviv|5.008001|5.008001|d sv_setpviv_mg|5.008001|5.008001|d sv_setpv_mg|5.004005|5.003007|p sv_setpvn|5.003007|5.003007| sv_setpvn_fresh|5.035006|5.035006| sv_setpvn_mg|5.004005|5.003007|p sv_setpvs|5.009004|5.003007|p sv_setpvs_mg|5.013006|5.013006| sv_setref_iv|5.003007|5.003007| sv_setref_nv|5.006000|5.003007| sv_setref_pv|5.003007|5.003007| sv_setref_pvn|5.003007|5.003007| sv_setref_pvs|5.013006|5.013006| sv_setref_uv|5.007001|5.007001| sv_setrv_inc|5.035004|5.035004| sv_setrv_inc_mg|5.035004|5.035004| sv_setrv_noinc|5.035004|5.035004| sv_setrv_noinc_mg|5.035004|5.035004| sv_setsv|5.003007|5.003007| SvSetSV|5.003007|5.003007| sv_setsv_cow|5.009000||xcViu sv_setsv_flags|5.007002|5.003007|p sv_setsv_mg|5.004005|5.003007|p sv_setsv_nomg|5.007002|5.003007|p SvSetSV_nosteal|5.004000|5.004000| sv_setuid|5.019001||Viu sv_set_undef|5.025008|5.025008| sv_setuv|5.004000|5.003007|p sv_setuv_mg|5.004005|5.003007|p SVs_GMG|5.003007||Viu SvSHARE|5.007003|5.007003| SvSHARED_HASH|5.009003|5.003007|p SvSHARED_HEK_FROM_PV|5.009003||Viu SV_SKIP_OVERLOAD|5.013001||Viu SV_SMAGIC|5.009003|5.003007|p SvSMAGICAL|5.003007||Viu SvSMAGICAL_off|5.003007||Viu SvSMAGICAL_on|5.003007||Viu SVs_OBJECT|5.003007||Viu SVs_PADMY|5.003007||Viu SVs_PADSTALE|5.009000|5.009000| SVs_PADTMP|5.003007||Viu SVs_RMG|5.003007||Viu SVs_SMG|5.003007||Viu SvSTASH|5.003007|5.003007| SvSTASH_set|5.009003|5.003007|p SVs_TEMP|5.003007|5.003007| sv_streq|5.035009|5.035009| sv_streq_flags|5.035009|5.035009| sv_string_from_errnum|5.027003|5.027003| SvTAIL|5.003007||Viu SvTAINT|5.003007|5.003007| sv_taint|5.009003||cV SvTAINTED|5.004000|5.004000| sv_tainted|5.004000||cV SvTAINTED_off|5.004000|5.004000| SvTAINTED_on|5.004000|5.004000| SvTEMP|5.003007||Viu SvTEMP_off|5.003007||Viu SvTEMP_on|5.003007||Viu SVt_FIRST|5.021005||Viu SvTHINKFIRST|5.003007||Vi SvTIED_mg|5.005003||Viu SvTIED_obj|5.005003|5.005003| SVt_INVLIST|||c SVt_IV|5.003007|5.003007| SVt_MASK|5.015001||Viu SVt_NULL|5.003007|5.003007| SVt_NV|5.003007|5.003007| SVt_PV|5.003007|5.003007| SVt_PVAV|5.003007|5.003007| SVt_PVBM|5.009005||Viu SVt_PVCV|5.003007|5.003007| SVt_PVFM|5.003007|5.003007| SVt_PVGV|5.003007|5.003007| SVt_PVHV|5.003007|5.003007| SVt_PVIO|5.003007|5.003007| SVt_PVIV|5.003007|5.003007| SVt_PVLV|5.003007|5.003007| SVt_PVMG|5.003007|5.003007| SVt_PVNV|5.003007|5.003007| SVt_REGEXP|5.011000|5.011000| SvTRUE|5.003007|5.003007| sv_true|5.005000||cV SvTRUE_common|5.033005||cVu SvTRUE_NN|5.017007|5.017007| SvTRUE_nomg|5.013006|5.003007|p SvTRUE_nomg_NN|5.017007|5.017007| SvTRUEx|5.003007|5.003007| SvTRUEx_nomg|5.017002||Viu SVt_RV|5.011000||Viu SvTYPE|5.003007|5.003007| SVTYPEMASK|5.003007||Viu SvUID|5.019001||Viu SV_UNDEF_RETURNS_NULL|5.011000||Viu sv_unglob|5.005000||Viu sv_uni_display|5.007003|5.007003| SvUNLOCK|5.007003|5.007003| sv_unmagic|5.003007|5.003007| sv_unmagicext|5.013008|5.003007|p sv_unref|5.003007|5.003007| sv_unref_flags|5.007001|5.007001| sv_untaint|5.004000||cV SvUOK|5.007001|5.006000|p SvUOK_nog|5.017002||Viu SvUOK_nogthink|5.017002||Viu sv_upgrade|5.003007|5.003007| SvUPGRADE|5.003007|5.003007| sv_usepvn|5.003007|5.003007| sv_usepvn_flags|5.009004|5.009004| sv_usepvn_mg|5.004005|5.003007|p SvUTF8|5.006000|5.003007|p sv_utf8_decode|5.006000|5.006000| sv_utf8_downgrade|5.006000|5.006000| sv_utf8_downgrade_flags|5.031004|5.031004| sv_utf8_downgrade_nomg|5.031004|5.031004| sv_utf8_encode|5.006000|5.006000| SV_UTF8_NO_ENCODING|5.008001|5.003007|pd SvUTF8_off|5.006000|5.006000| SvUTF8_on|5.006000|5.006000| sv_utf8_upgrade|5.007001|5.007001| sv_utf8_upgrade_flags|5.007002|5.007002| sv_utf8_upgrade_flags_grow|5.011000|5.011000| sv_utf8_upgrade_nomg|5.007002|5.007002| SvUV|5.004000|5.003007|p sv_uv|5.005000||pdcV SvUV_nomg|5.009001|5.003007|p SvUV_set|5.009003|5.003007|p SvUVX|5.004000|5.003007|p SvUVx|5.004000|5.003007|p SvUVXx|5.004000|5.003007|pd SvVALID|5.003007||Viu sv_vcatpvf|5.006000|5.004000|p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn|5.004000|5.004000| sv_vcatpvfn_flags|5.017002|5.017002| SvVOK|5.008001|5.008001| sv_vsetpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn|5.004000|5.004000| SvVSTRING_mg|5.009004|5.003007|p SvWEAKREF|5.006000||Viu SvWEAKREF_off|5.006000||Viu SvWEAKREF_on|5.006000||Viu swallow_bom|5.006001||Viu switch_category_locale_to_template|5.027009||Viu SWITCHSTACK|5.003007||Viu switch_to_global_locale|5.027009|5.003007|pn sync_locale|5.027009|5.003007|pn sys_init3|||cnu sys_init|||cnu sys_intern_clear|5.006001||Vu sys_intern_dup|5.006000||Vu sys_intern_init|5.006001||Vu SYSTEM_GMTIME_MAX|5.011000||Viu SYSTEM_GMTIME_MIN|5.011000||Viu SYSTEM_LOCALTIME_MAX|5.011000||Viu SYSTEM_LOCALTIME_MIN|5.011000||Viu sys_term|||cnu TAIL|5.005000||Viu TAIL_t8|5.035004||Viu TAIL_t8_p8|5.033003||Viu TAIL_t8_pb|5.033003||Viu TAIL_tb|5.035004||Viu TAIL_tb_p8|5.033003||Viu TAIL_tb_pb|5.033003||Viu TAINT|5.004000||Viu taint_env|5.003007|5.003007|u TAINT_ENV|5.003007||Viu TAINT_get|5.017006||Viu TAINT_IF|5.003007||Viu TAINTING_get|5.017006||Viu TAINTING_set|5.017006||Viu TAINT_NOT|5.003007||Viu taint_proper|5.003007|5.003007|u TAINT_PROPER|5.003007||Viu TAINT_set|5.017006||Viu TAINT_WARN_get|5.017006||Viu TAINT_WARN_set|5.017006||Viu TARG|5.003007|5.003007| TARGi|5.023005||Viu TARGn|5.023005||Viu TARGu|5.023005||Viu telldir|5.005000||Viu T_FMT|5.027010||Viu T_FMT_AMPM|5.027010||Viu THIS|5.003007|5.003007|V THOUSEP|5.027010||Viu THR|5.005000||Viu THREAD_CREATE_NEEDS_STACK|5.007002||Viu thread_locale_init|5.027009|5.027009|xnu thread_locale_term|5.027009|5.027009|xnu THREAD_RET_TYPE|5.005000||Viu tied_method|5.013009||vViu TIED_METHOD_ARGUMENTS_ON_STACK|5.013009||Viu TIED_METHOD_MORTALIZE_NOT_NEEDED|5.013009||Viu TIED_METHOD_SAY|5.013009||Viu times|5.005000||Viu Time_t|5.003007|5.003007|Vn Timeval|5.004000|5.004000|Vn TM|5.011000||Viu tmpfile|5.003007||Viu tmpnam|5.005000||Viu TMPNAM_R_PROTO|5.008000|5.008000|Vn tmps_grow_p|5.021005||cViu to_byte_substr|5.008000||Viu to_case_cp_list|5.035004||Viu toCTRL|5.004000||Viu toFOLD|5.019001|5.019001| toFOLD_A|5.019001|5.019001| _to_fold_latin1|5.015005||cVniu toFOLD_LC|5.019001||Viu toFOLD_uni|5.007003||Viu toFOLD_utf8|5.031005|5.031005| toFOLD_utf8_safe|5.025009|5.006000|p toFOLD_uvchr|5.023009|5.006000|p TO_INTERNAL_SIZE|5.023002||Viu tokenize_use|5.009003||Viu tokeq|5.005000||Viu tokereport|5.007001||Viu toLOWER|5.003007|5.003007| toLOWER_A|5.019001|5.019001| toLOWER_L1|5.019001|5.019001| toLOWER_LATIN1|5.013006|5.011002| to_lower_latin1|5.015005||Vniu toLOWER_LC|5.004000|5.004000| toLOWER_uni|5.006000||Viu toLOWER_utf8|5.031005|5.031005| toLOWER_utf8_safe|5.025009|5.006000|p toLOWER_uvchr|5.023009|5.006000|p too_few_arguments_pv|5.016000||Viu TOO_LATE_FOR|5.008001||Viu too_many_arguments_pv|5.016000||Viu TOPi|5.003007||Viu TOPl|5.003007||Viu TOPm1s|5.007001||Viu TOPMARK|5.003007||cViu TOPn|5.003007||Viu TOPp1s|5.007001||Viu TOPp|5.003007||Viu TOPpx|5.005003||Viu TOPs|5.003007||Viu TOPu|5.004000||Viu TOPul|5.006000||Viu toTITLE|5.019001|5.019001| toTITLE_A|5.019001|5.019001| toTITLE_uni|5.006000||Viu toTITLE_utf8|5.031005|5.031005| toTITLE_utf8_safe|5.025009|5.006000|p toTITLE_uvchr|5.023009|5.006000|p to_uni_fold|5.014000||cVu _to_uni_fold_flags|5.014000||cVu to_uni_lower|5.006000||cVu to_uni_title|5.006000||cVu to_uni_upper|5.006000||cVu toUPPER|5.003007|5.003007| toUPPER_A|5.019001|5.019001| toUPPER_LATIN1_MOD|5.011002||Viu toUPPER_LC|5.004000||Viu _to_upper_title_latin1|5.015005||Viu toUPPER_uni|5.006000||Viu toUPPER_utf8|5.031005|5.031005| toUPPER_utf8_safe|5.025009|5.006000|p toUPPER_uvchr|5.023009|5.006000|p _to_utf8_case|5.023006||Viu _to_utf8_fold_flags|5.014000||cVu _to_utf8_lower_flags|5.015006||cVu to_utf8_substr|5.008000||Viu _to_utf8_title_flags|5.015006||cVu _to_utf8_upper_flags|5.015006||cVu translate_substr_offsets|5.015006||Vniu traverse_op_tree|5.029008||Vi TR_DELETE|5.031006||Viu TRIE|5.009002||Viu TRIE_BITMAP|5.009004||Viu TRIE_BITMAP_BYTE|5.009004||Viu TRIE_BITMAP_CLEAR|5.009004||Viu TRIE_BITMAP_SET|5.009004||Viu TRIE_BITMAP_TEST|5.009004||Viu TRIEC|5.009004||Viu TRIE_CHARCOUNT|5.009004||Viu TRIEC_t8|5.035004||Viu TRIEC_t8_p8|5.033003||Viu TRIEC_t8_pb|5.033003||Viu TRIEC_tb|5.035004||Viu TRIEC_tb_p8|5.033003||Viu TRIEC_tb_pb|5.033003||Viu TRIE_next|5.009005||Viu TRIE_next_fail|5.009005||Viu TRIE_next_fail_t8|5.035004||Viu TRIE_next_fail_t8_p8|5.033003||Viu TRIE_next_fail_t8_pb|5.033003||Viu TRIE_next_fail_tb|5.035004||Viu TRIE_next_fail_tb_p8|5.033003||Viu TRIE_next_fail_tb_pb|5.033003||Viu TRIE_next_t8|5.035004||Viu TRIE_next_t8_p8|5.033003||Viu TRIE_next_t8_pb|5.033003||Viu TRIE_next_tb|5.035004||Viu TRIE_next_tb_p8|5.033003||Viu TRIE_next_tb_pb|5.033003||Viu TRIE_NODEIDX|5.009002||Viu TRIE_NODENUM|5.009002||Viu TRIE_t8|5.035004||Viu TRIE_t8_p8|5.033003||Viu TRIE_t8_pb|5.033003||Viu TRIE_tb|5.035004||Viu TRIE_tb_p8|5.033003||Viu TRIE_tb_pb|5.033003||Viu TRIE_WORDS_OFFSET|5.009005||Viu TR_OOB|5.031006||Viu TR_R_EMPTY|5.031006||Viu TR_SPECIAL_HANDLING|5.031006||Viu TRUE|5.003007||Viu truncate|5.006000||Viu TR_UNLISTED|5.031006||Viu TR_UNMAPPED|5.031006||Viu try_amagic_bin|||ciu tryAMAGICbin_MG|5.013002||Viu try_amagic_un|||ciu tryAMAGICunDEREF|5.006000||Viu tryAMAGICun_MG|5.013002||Viu tryAMAGICunTARGETlist|5.017002||Viu TS_W32_BROKEN_LOCALECONV|5.027010||Viu tTHX|5.009003||Viu ttyname|5.009000||Viu TTYNAME_R_PROTO|5.008000|5.008000|Vn turkic_fc|5.029008||Viu turkic_lc|5.029008||Viu turkic_uc|5.029008||Viu TWO_BYTE_UTF8_TO_NATIVE|5.019004||Viu TWO_BYTE_UTF8_TO_UNI|5.013008||Viu TYPE_CHARS|5.004000||Viu TYPE_DIGITS|5.004000||Viu U16|5.027001||Viu U16_MAX|5.003007||Viu U16_MIN|5.003007||Viu U16SIZE|5.006000|5.006000|Vn U16TYPE|5.006000|5.006000|Vn U_32|5.007002|5.007002| U32|5.027001||Viu U32_ALIGNMENT_REQUIRED|5.007001|5.007001|Vn U32_MAX|5.003007||Viu U32_MAX_P1|5.007002||Viu U32_MAX_P1_HALF|5.007002||Viu U32_MIN|5.003007||Viu U32SIZE|5.006000|5.006000|Vn U32TYPE|5.006000|5.006000|Vn U64|5.023002||Viu U64SIZE|5.006000|5.006000|Vn U64TYPE|5.006000|5.006000|Vn U8|5.027001||Viu U8_MAX|5.003007||Viu U8_MIN|5.003007||Viu U8SIZE|5.006000|5.006000|Vn U8TO16_LE|5.017010||Viu U8TO32_LE|5.017010||Viu U8TO64_LE|5.017006||Viu U8TYPE|5.006000|5.006000|Vn UCHARAT|5.003007||Viu U_I|5.003007||Viu Uid_t|5.003007|5.003007|Vn Uid_t_f|5.006000|5.006000|Vn Uid_t_sign|5.006000|5.006000|Vn Uid_t_size|5.006000|5.006000|Vn UINT16_C|5.003007|5.003007| UINT32_C|5.003007|5.003007| UINT32_MIN|5.006000||Viu UINT64_C|5.023002|5.023002| UINT64_MIN|5.006000||Viu UINTMAX_C|5.003007|5.003007| uiv_2buf|5.009003||Vniu U_L|5.003007||Viu umask|5.005000||Viu uname|5.005004||Viu UNDERBAR|5.009002|5.003007|p unexpected_non_continuation_text|5.025006||Viu ungetc|5.003007||Viu UNI_age_values_index|5.029009||Viu UNI_AHEX|5.029002||Viu UNI_ahex_values_index|5.029009||Viu UNI_ALNUM|5.029002||Viu UNI_ALPHA|5.029002||Viu UNI_ALPHABETIC|5.029002||Viu UNI_alpha_values_index|5.029009||Viu UNI_ASCIIHEXDIGIT|5.029002||Viu UNI_BASICLATIN|5.029002||Viu UNI_bc_values_index|5.029009||Viu UNI_bidic_values_index|5.029009||Viu UNI_bidim_values_index|5.029009||Viu UNI_BLANK|5.029002||Viu UNI_blk_values_index|5.029009||Viu UNI_bpt_values_index|5.029009||Viu UNI_cased_values_index|5.029009||Viu UNI_CC|5.029002||Viu UNI_ccc_values_index|5.029009||Viu UNI_ce_values_index|5.029009||Viu UNI_ci_values_index|5.029009||Viu UNI_CNTRL|5.029002||Viu UNICODE_ALLOW_ABOVE_IV_MAX|5.031006||Viu UNICODE_ALLOW_ANY|5.007003||Viu UNICODE_ALLOW_SUPER|5.007003||Viu UNICODE_ALLOW_SURROGATE|5.007003||Viu UNICODE_BYTE_ORDER_MARK|5.008000||Viu UNICODE_DISALLOW_ABOVE_31_BIT|5.023006|5.023006| UNICODE_DISALLOW_ILLEGAL_C9_INTERCHANGE|5.025005|5.025005| UNICODE_DISALLOW_ILLEGAL_INTERCHANGE|5.013009|5.013009| UNICODE_DISALLOW_NONCHAR|5.013009|5.013009| UNICODE_DISALLOW_PERL_EXTENDED|5.027002|5.027002| UNICODE_DISALLOW_SUPER|5.013009|5.013009| UNICODE_DISALLOW_SURROGATE|5.013009|5.013009| UNICODE_DOT_DOT_VERSION|5.023002||Viu UNICODE_DOT_VERSION|5.023002||Viu UNICODE_GOT_NONCHAR|5.027009||Viu UNICODE_GOT_PERL_EXTENDED|5.027009||Viu UNICODE_GOT_SUPER|5.027009||Viu UNICODE_GOT_SURROGATE|5.027009||Viu UNICODE_GREEK_CAPITAL_LETTER_SIGMA|5.007003||Viu UNICODE_GREEK_SMALL_LETTER_FINAL_SIGMA|5.007003||Viu UNICODE_GREEK_SMALL_LETTER_SIGMA|5.007003||Viu UNICODE_IS_32_CONTIGUOUS_NONCHARS|5.023006||Viu UNICODE_IS_BYTE_ORDER_MARK|5.007001||Viu UNICODE_IS_END_PLANE_NONCHAR_GIVEN_NOT_SUPER|5.023006||Viu UNICODE_IS_NONCHAR|5.013009|5.013009| UNICODE_IS_PERL_EXTENDED|5.027002||Viu UNICODE_IS_REPLACEMENT|5.007002|5.007002| UNICODE_IS_SUPER|5.013009|5.013009| UNICODE_IS_SURROGATE|5.007001|5.007001| UNICODE_MAJOR_VERSION|5.023002||Viu UNICODE_PAT_MOD|5.013006||Viu UNICODE_PAT_MODS|5.013006||Viu UNICODE_REPLACEMENT|5.007001|5.003007|p UNICODE_SURROGATE_FIRST|5.007001||Viu UNICODE_SURROGATE_LAST|5.007001||Viu UNICODE_WARN_ABOVE_31_BIT|5.023006|5.023006| UNICODE_WARN_ILLEGAL_C9_INTERCHANGE|5.025005|5.025005| UNICODE_WARN_ILLEGAL_INTERCHANGE|5.013009|5.013009| UNICODE_WARN_NONCHAR|5.013009|5.013009| UNICODE_WARN_PERL_EXTENDED|5.027002|5.027002| UNICODE_WARN_SUPER|5.013009|5.013009| UNICODE_WARN_SURROGATE|5.013009|5.013009| UNI_compex_values_index|5.029009||Viu UNI_CONTROL|5.029002||Viu UNI_cwcf_values_index|5.029009||Viu UNI_cwcm_values_index|5.029009||Viu UNI_cwkcf_values_index|5.029009||Viu UNI_cwl_values_index|5.029009||Viu UNI_cwt_values_index|5.029009||Viu UNI_cwu_values_index|5.029009||Viu UNI_dash_values_index|5.029009||Viu UNI_DECIMALNUMBER|5.029002||Viu UNI_dep_values_index|5.029009||Viu UNI_dia_values_index|5.029009||Viu UNI_DIGIT|5.029002||Viu UNI_DISPLAY_BACKSLASH|5.007003|5.007003| UNI_DISPLAY_BACKSPACE|5.031009|5.031009| UNI_DISPLAY_ISPRINT|5.007003|5.007003| UNI_DISPLAY_QQ|5.007003|5.007003| UNI_DISPLAY_REGEX|5.007003|5.007003| UNI_di_values_index|5.029009||Viu UNI_dt_values_index|5.029009||Viu UNI_ea_values_index|5.029009||Viu UNI_ebase_values_index|5.031010||Viu UNI_ecomp_values_index|5.031010||Viu UNI_emod_values_index|5.031010||Viu UNI_emoji_values_index|5.031010||Viu UNI_epres_values_index|5.031010||Viu UNI_extpict_values_index|5.031010||Viu UNI_ext_values_index|5.029009||Viu UNI_gcb_values_index|5.029009||Viu UNI_gc_values_index|5.029009||Viu UNI_GRAPH|5.029002||Viu UNI_grbase_values_index|5.029009||Viu UNI_grext_values_index|5.029009||Viu UNI_HEX|5.029002||Viu UNI_HEXDIGIT|5.029002||Viu UNI_hex_values_index|5.029009||Viu UNI_HORIZSPACE|5.029002||Viu UNI_hst_values_index|5.029009||Viu UNI_HYPHEN|5.029002||Viu UNI_hyphen_values_index|5.029009||Viu UNI_idc_values_index|5.029009||Viu UNI_identifierstatus_values_index|5.031010||Viu UNI_identifiertype_values_index|5.031010||Viu UNI_ideo_values_index|5.029009||Viu UNI_idsb_values_index|5.029009||Viu UNI_idst_values_index|5.029009||Viu UNI_ids_values_index|5.029009||Viu UNI_inpc_values_index|5.029009||Viu UNI_insc_values_index|5.029009||Viu UNI_in_values_index|5.029009||Viu UNI_IS_INVARIANT|5.007001||Viu UNI_jg_values_index|5.029009||Viu UNI_joinc_values_index|5.029009||Viu UNI_jt_values_index|5.029009||Viu UNI_L|5.029002||Viu UNI_L_AMP|5.029002||Viu UNI_LB__SG|5.029002||Viu UNI_lb_values_index|5.029009||Viu UNI_LC|5.029002||Viu UNI_LL|5.029002||Viu UNI_loe_values_index|5.029009||Viu UNI_LOWER|5.029002||Viu UNI_LOWERCASE|5.029002||Viu UNI_lower_values_index|5.029009||Viu UNI_LT|5.029002||Viu UNI_LU|5.029002||Viu UNI_math_values_index|5.029009||Viu UNI_nchar_values_index|5.029009||Viu UNI_ND|5.029002||Viu UNI_nfcqc_values_index|5.029009||Viu UNI_nfdqc_values_index|5.029009||Viu UNI_nfkcqc_values_index|5.029009||Viu UNI_nfkdqc_values_index|5.029009||Viu UNI_nt_values_index|5.029009||Viu UNI_nv_values_index|5.029009||Viu UNI_patsyn_values_index|5.029009||Viu UNI_patws_values_index|5.029009||Viu UNI_pcm_values_index|5.029009||Viu UNI_PERLSPACE|5.029002||Viu UNI_PERLWORD|5.029002||Viu UNI_PRINT|5.029002||Viu UNI_qmark_values_index|5.029009||Viu UNI_radical_values_index|5.029009||Viu UNI_ri_values_index|5.029009||Viu UNI_sb_values_index|5.029009||Viu UNI_sc_values_index|5.029009||Viu UNI_scx_values_index|5.029009||Viu UNI_sd_values_index|5.029009||Viu UNISKIP|5.007001||Viu UNISKIP_BY_MSB|5.035004||Viu UNI_SPACE|5.029002||Viu UNI_SPACEPERL|5.029002||Viu UNI_sterm_values_index|5.029009||Viu UNI_term_values_index|5.029009||Viu UNI_TITLECASE|5.029002||Viu UNI_TITLECASELETTER|5.029002||Viu UNI_TO_NATIVE|5.007001|5.003007|p UNI_uideo_values_index|5.029009||Viu UNI_UPPER|5.029002||Viu UNI_UPPERCASE|5.029002||Viu UNI_upper_values_index|5.029009||Viu UNI_vo_values_index|5.029009||Viu UNI_vs_values_index|5.029009||Viu UNI_wb_values_index|5.029009||Viu UNI_WHITESPACE|5.029002||Viu UNI_WORD|5.029002||Viu UNI_WSPACE|5.029002||Viu UNI_wspace_values_index|5.029009||Viu UNI_XDIGIT|5.029002||Viu UNI_xidc_values_index|5.029009||Viu UNI_xids_values_index|5.029009||Viu UNI_XPERLSPACE|5.029002||Viu UNKNOWN_ERRNO_MSG|5.019007||Viu UNLESSM|5.003007||Viu UNLESSM_t8|5.035004||Viu UNLESSM_t8_p8|5.033003||Viu UNLESSM_t8_pb|5.033003||Viu UNLESSM_tb|5.035004||Viu UNLESSM_tb_p8|5.033003||Viu UNLESSM_tb_pb|5.033003||Viu UNLIKELY|5.009004|5.003007|p UNLINK|5.003007||Viu unlink|5.005000||Viu unlnk|5.003007||cVu UNLOCK_DOLLARZERO_MUTEX|5.008001||Viu UNLOCK_LC_NUMERIC_STANDARD|5.021010||poVnu UNLOCK_NUMERIC_STANDARD|||piu UNOP_AUX_item_sv|5.021007||Viu unpack_rec|5.008001||Viu unpack_str|5.007003|5.007003|d unpackstring|5.008001|5.008001| unpackWARN1|5.007003||Viu unpackWARN2|5.007003||Viu unpackWARN3|5.007003||Viu unpackWARN4|5.007003||Viu unreferenced_to_tmp_stack|5.013002||Viu unshare_hek|5.004000||Viu unshare_hek_or_pvn|5.008000||Viu unsharepvn|5.003007|5.003007|u unwind_handler_stack|5.009003||Viu update_debugger_info|5.009005||Viu upg_version|5.009005|5.009005| UPG_VERSION|5.019008||Viu Uquad_t|5.006000|5.006000|Vn U_S|5.003007||Viu usage|5.005000||Viu USE_64_BIT_ALL|5.006000|5.006000|Vn USE_64_BIT_INT|5.006000|5.006000|Vn USE_64_BIT_RAWIO|5.006000||Viu USE_64_BIT_STDIO|5.006000||Viu USE_BSDPGRP|5.003007||Viu USE_C_BACKTRACE|5.035009|5.035009|Vn USE_DYNAMIC_LOADING|5.003007|5.003007|Vn USE_ENVIRON_ARRAY|5.007001||Viu USE_GRENT_BUFFER|5.008000||Viu USE_GRENT_FPTR|5.008000||Viu USE_GRENT_PTR|5.008000||Viu USE_HASH_SEED|5.008001||Viu USE_HOSTENT_BUFFER|5.008000||Viu USE_HOSTENT_ERRNO|5.008000||Viu USE_HOSTENT_PTR|5.008000||Viu USE_ITHREADS|5.010000|5.010000|Vn USE_LARGE_FILES|5.006000|5.006000|Vn USE_LEFT|5.004000||Viu USE_LOCALE|5.004000||Viu USE_LOCALE_ADDRESS|5.027009||Viu USE_LOCALE_COLLATE|5.004000||Viu USE_LOCALE_CTYPE|5.004000||Viu USE_LOCALE_IDENTIFICATION|5.027009||Viu USE_LOCALE_MEASUREMENT|5.027009||Viu USE_LOCALE_MESSAGES|5.019002||Viu USE_LOCALE_MONETARY|5.019002||Viu USE_LOCALE_NUMERIC|5.004000||Viu USE_LOCALE_PAPER|5.027009||Viu USE_LOCALE_SYNTAX|5.033001||Viu USE_LOCALE_TELEPHONE|5.027009||Viu USE_LOCALE_TIME|5.021002||Viu USE_LOCALE_TOD|5.033001||Viu USEMYBINMODE|5.006000||Viu USE_NETENT_BUFFER|5.008000||Viu USE_NETENT_ERRNO|5.008000||Viu USE_NETENT_PTR|5.008000||Viu USE_PERL_ATOF|5.008000||Viu USE_PERLIO|5.007001|5.007001|Vn USE_PERL_PERTURB_KEYS|5.018000||Viu USE_POSIX_2008_LOCALE|5.027003||Viu USE_PROTOENT_BUFFER|5.008000||Viu USE_PROTOENT_PTR|5.008000||Viu USE_PWENT_BUFFER|5.008000||Viu USE_PWENT_FPTR|5.008000||Viu USE_PWENT_PTR|5.008000||Viu USE_REENTRANT_API|5.007003||Viu USER_PROP_MUTEX_INIT|5.029008||Viu USER_PROP_MUTEX_LOCK|5.029008||Viu USER_PROP_MUTEX_TERM|5.029008||Viu USER_PROP_MUTEX_UNLOCK|5.029008||Viu USE_SEMCTL_SEMID_DS|5.004005|5.004005|Vn USE_SEMCTL_SEMUN|5.004005|5.004005|Vn USE_SERVENT_BUFFER|5.008000||Viu USE_SERVENT_PTR|5.008000||Viu USE_SPENT_BUFFER|5.031011||Viu USE_SPENT_PTR|5.008000||Viu USE_STAT_BLOCKS|5.005003|5.005003|Vn USE_STAT_RDEV|5.003007||Viu USE_STDIO|5.003007||Viu USE_STDIO_BASE|5.006000|5.006000|Vn USE_STDIO_PTR|5.006000|5.006000|Vn USE_SYSTEM_GMTIME|5.011000||Viu USE_SYSTEM_LOCALTIME|5.011000||Viu USE_THREADS|5.006000|5.006000|Vn USE_THREAD_SAFE_LOCALE|5.025004||Viu USE_TM64|5.011000||Viu USE_UTF8_IN_NAMES|5.007003||Viu utf16_textfilter|5.011001||Viu utf16_to_utf8|5.035004||cViu utf16_to_utf8_base|5.035004||cViu utf16_to_utf8_reversed|5.035004||cViu UTF8_ACCUMULATE|5.007001||Viu UTF8_ALLOW_ANY|5.007001||Viu UTF8_ALLOW_ANYUV|5.007001||Viu UTF8_ALLOW_CONTINUATION|5.007001||Viu UTF8_ALLOW_DEFAULT|5.009004||Viu UTF8_ALLOW_EMPTY|5.007001||Viu UTF8_ALLOW_FE_FF|5.027009||Viu UTF8_ALLOW_FFFF|5.007001||Viu UTF8_ALLOW_LONG|5.007001||Viu UTF8_ALLOW_LONG_AND_ITS_VALUE|5.025009||Viu UTF8_ALLOW_NON_CONTINUATION|5.007001||Viu UTF8_ALLOW_OVERFLOW|5.025009||Viu UTF8_ALLOW_SHORT|5.007001||Viu UTF8_ALLOW_SURROGATE|5.007001||Viu UTF8_CHECK_ONLY|5.007001|5.007001| UTF8_CHK_SKIP|5.031006|5.006000|p UTF8_DISALLOW_ABOVE_31_BIT|5.023006||Viu UTF8_DISALLOW_FE_FF|5.013009||Viu UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE|5.025005|5.025005| UTF8_DISALLOW_ILLEGAL_INTERCHANGE|5.013009|5.013009| UTF8_DISALLOW_NONCHAR|5.013009|5.013009| UTF8_DISALLOW_PERL_EXTENDED|5.027002|5.027002| UTF8_DISALLOW_SUPER|5.013009|5.013009| UTF8_DISALLOW_SURROGATE|5.013009|5.013009| utf8_distance|5.006000|5.006000| UTF8_EIGHT_BIT_HI|5.007001||Viu UTF8_EIGHT_BIT_LO|5.007001||Viu UTF8f|5.019001|5.003007|p UTF8fARG|5.019002|5.003007|p UTF8_GOT_ABOVE_31_BIT|5.025006||Viu UTF8_GOT_CONTINUATION|5.025006|5.025006| UTF8_GOT_EMPTY|5.025006|5.025006| UTF8_GOT_LONG|5.025006|5.025006| UTF8_GOT_NONCHAR|5.025006|5.025006| UTF8_GOT_NON_CONTINUATION|5.025006|5.025006| UTF8_GOT_OVERFLOW|5.025006|5.025006| UTF8_GOT_PERL_EXTENDED|5.027002|5.027002| UTF8_GOT_SHORT|5.025006|5.025006| UTF8_GOT_SUPER|5.025006|5.025006| UTF8_GOT_SURROGATE|5.025006|5.025006| utf8_hop|5.006000|5.006000|n utf8_hop_back|5.025007|5.025007|n utf8_hop_forward|5.025007|5.025007|n utf8_hop_safe|5.025007|5.025007|n UTF8_IS_ABOVE_LATIN1|5.017004||Viu UTF8_IS_ABOVE_LATIN1_START|5.023003||Viu UTF8_IS_CONTINUATION|5.007001||Viu UTF8_IS_CONTINUED|5.007001||Viu UTF8_IS_DOWNGRADEABLE_START|5.007001||Viu UTF8_IS_INVARIANT|5.007001|5.003007|p UTF8_IS_NEXT_CHAR_DOWNGRADEABLE|5.017006||Viu UTF8_IS_NONCHAR|5.023002|5.023002| UTF8_IS_NONCHAR_GIVEN_THAT_NON_SUPER_AND_GE_PROBLEMATIC|5.013009||Viu UTF8_IS_PERL_EXTENDED|5.035004||Viu UTF8_IS_REPLACEMENT||| UTF8_IS_START|5.007001||Viu UTF8_IS_START_base|5.031007||Viu UTF8_IS_SUPER|5.023002|5.023002| UTF8_IS_SURROGATE|5.023002|5.023002| utf8_length|5.007001|5.007001| UTF8_MAXBYTES|5.009002|5.006000|p UTF8_MAXBYTES_CASE|5.009002|5.003007|p UTF8_MAX_FOLD_CHAR_EXPAND|5.013009||Viu UTF8_MAXLEN|5.006000||Viu utf8_mg_len_cache_update|5.013003||Viu utf8_mg_pos_cache_update|5.009004||Viu utf8n_to_uvchr|5.007001|5.007001|n utf8n_to_uvchr_error|5.025006|5.025006|n utf8n_to_uvchr_msgs|5.027009|5.027009|n _utf8n_to_uvchr_msgs_helper|5.029001||cVnu utf8n_to_uvuni|5.007001||dcV UTF8_SAFE_SKIP|5.029009|5.006000|p UTF8SKIP|5.006000|5.006000| UTF8_SKIP|5.023002|5.006000|p utf8_to_bytes|5.006001|5.006001|x utf8_to_utf16|5.035004||Viu utf8_to_utf16_base|5.035004||xcViu utf8_to_utf16_reversed|5.035004||Viu utf8_to_uvchr|5.007001|5.006001|pd utf8_to_uvchr_buf|5.015009|5.006001|p utf8_to_uvchr_buf_helper|5.031004||cVu utf8_to_uvuni|5.007001||dcV utf8_to_uvuni_buf|5.015009||dcV UTF8_TWO_BYTE_HI|5.011002||Viu UTF8_TWO_BYTE_HI_nocast|5.011002||Viu UTF8_TWO_BYTE_LO|5.011002||Viu UTF8_TWO_BYTE_LO_nocast|5.011002||Viu UTF8_WARN_ABOVE_31_BIT|5.023006||Viu UTF8_WARN_FE_FF|5.013009||Viu UTF8_WARN_ILLEGAL_C9_INTERCHANGE|5.025005|5.025005| UTF8_WARN_ILLEGAL_INTERCHANGE|5.013009|5.013009| UTF8_WARN_NONCHAR|5.013009|5.013009| UTF8_WARN_PERL_EXTENDED|5.027002|5.027002| UTF8_WARN_SUPER|5.013009|5.013009| UTF8_WARN_SURROGATE|5.013009|5.013009| UTF_ACCUMULATION_SHIFT|5.007001||Viu UTF_CONTINUATION_BYTE_INFO_BITS|5.035004||Viu UTF_CONTINUATION_MARK|5.007001||Viu UTF_CONTINUATION_MASK|5.007001||Viu UTF_EBCDIC_CONTINUATION_BYTE_INFO_BITS|5.035004||Viu UTF_FIRST_CONT_BYTE_110000|5.035004||Viu UTF_FIRST_CONT_BYTE|5.035004||Viu UTF_IS_CONTINUATION_MASK|5.023006||Viu UTF_MIN_ABOVE_LATIN1_BYTE|5.031006||Viu UTF_MIN_CONTINUATION_BYTE|5.035004||Viu UTF_MIN_START_BYTE|5.031006||Viu UTF_START_BYTE_110000|5.035004||Viu UTF_START_BYTE|5.035004||Viu UTF_START_MARK|5.007001||Viu UTF_START_MASK|5.007001||Viu UTF_TO_NATIVE|5.007001||Viu utilize|5.003007||Viu utime|5.005000||Viu U_V|5.006000|5.003007| UVCHR_IS_INVARIANT|5.019004|5.003007|p UVCHR_SKIP|5.022000|5.003007|p uvchr_to_utf8|5.007001|5.007001| uvchr_to_utf8_flags|5.007003|5.007003| uvchr_to_utf8_flags_msgs|5.027009|5.027009| UV_DIG|5.006000||Viu UVf|5.010000|5.010000|d UV_IS_QUAD|5.006000||Viu UV_MAX|5.003007|5.003007| UV_MAX_P1|5.007002||Viu UV_MAX_P1_HALF|5.007002||Viu UV_MIN|5.003007|5.003007| UVof|5.006000|5.003007|poVn uvoffuni_to_utf8_flags|5.027009||cV uvoffuni_to_utf8_flags_msgs|5.027009||cVu UVSIZE|5.006000|5.003007|poVn UVTYPE|5.006000|5.003007|poVn UVuf|5.006000|5.003007|poVn uvuni_to_utf8|5.019004||cVu uvuni_to_utf8_flags|5.007003||dcV UVxf|5.006000|5.003007|poVn UVXf|5.007001|5.007001|poVn VAL_EAGAIN|5.003007|5.003007|Vn validate_proto|5.019002||xcVi validate_suid|||iu valid_utf8_to_uvchr|5.015009||cVn valid_utf8_to_uvuni|5.015009||dcVu VAL_O_NONBLOCK|5.003007|5.003007|Vn variant_byte_number|5.031004||cVnu variant_under_utf8_count|5.027007||Vni varname|5.009003||Viu vcmp|5.009000|5.009000| VCMP|5.019008||Viu vcroak|5.006000|5.006000| vdeb|5.007003|5.007003|u VERB|5.009005||Viu VERB_t8|5.035004||Viu VERB_t8_p8|5.033003||Viu VERB_t8_pb|5.033003||Viu VERB_tb|5.035004||Viu VERB_tb_p8|5.033003||Viu VERB_tb_pb|5.033003||Viu vform|5.006000|5.006000| vfprintf|5.003007||Viu visit|5.005000||Viu vivify_defelem|5.004000||cViu vivify_ref|5.004000||Viu vload_module|5.006000|5.003007|p vmess|5.006000|5.004000|p vnewSVpvf|5.006000|5.004000|p vnormal|5.009002|5.009002| VNORMAL|5.019008||Viu vnumify|5.009000|5.009000| VNUMIFY|5.019008||Viu voidnonfinal|5.035002||Viu VOL|5.003007||Viu vstringify|5.009000|5.009000| VSTRINGIFY|5.019008||Viu VTBL_amagic|5.005003||Viu VTBL_amagicelem|5.005003||Viu VTBL_arylen|5.005003||Viu VTBL_bm|5.005003||Viu VTBL_collxfrm|5.005003||Viu VTBL_dbline|5.005003||Viu VTBL_defelem|5.005003||Viu VTBL_env|5.005003||Viu VTBL_envelem|5.005003||Viu VTBL_fm|5.005003||Viu VTBL_glob|5.005003||Viu VTBL_isa|5.005003||Viu VTBL_isaelem|5.005003||Viu VTBL_mglob|5.005003||Viu VTBL_nkeys|5.005003||Viu VTBL_pack|5.005003||Viu VTBL_packelem|5.005003||Viu VTBL_pos|5.005003||Viu VTBL_regdata|5.006000||Viu VTBL_regdatum|5.006000||Viu VTBL_regexp|5.005003||Viu VTBL_sigelem|5.005003||Viu VTBL_substr|5.005003||Viu VTBL_sv|5.005003||Viu VTBL_taint|5.005003||Viu VTBL_uvar|5.005003||Viu VTBL_vec|5.005003||Viu vTHX|5.006000||Viu VT_NATIVE|5.021004||Viu vtohl|5.003007||Viu vtohs|5.003007||Viu VUTIL_REPLACE_CORE|5.019008||Viu vverify|5.009003|5.009003| VVERIFY|5.019008||Viu vwarn|5.006000|5.003007| vwarner|5.006000|5.004000|p wait4pid|5.003007||Viu wait|5.005000||Viu want_vtbl_bm|5.015000||Viu want_vtbl_fm|5.015000||Viu warn|5.003007||vV WARN_ALL|5.006000|5.003007|p WARN_ALLstring|5.006000||Viu WARN_AMBIGUOUS|5.006000|5.003007|p WARN_ASSERTIONS||5.003007|ponu WARN_BAREWORD|5.006000|5.003007|p WARN_CLOSED|5.006000|5.003007|p WARN_CLOSURE|5.006000|5.003007|p WARN_DEBUGGING|5.006000|5.003007|p WARN_DEPRECATED|5.006000|5.003007|p WARN_DIGIT|5.006000|5.003007|p warner|5.006000||pvV warner_nocontext|5.006000||vVn WARN_EXEC|5.006000|5.003007|p WARN_EXITING|5.006000|5.003007|p WARN_EXPERIMENTAL|5.017004|5.017004| WARN_EXPERIMENTAL__ALPHA_ASSERTIONS|5.027009|5.027009| WARN_EXPERIMENTAL__ARGS_ARRAY_WITH_SIGNATURES|5.035009|5.035009| WARN_EXPERIMENTAL__BITWISE|5.021009|5.021009| WARN_EXPERIMENTAL__BUILTIN|5.035009|5.035009| WARN_EXPERIMENTAL__CONST_ATTR|5.021008|5.021008| WARN_EXPERIMENTAL__DECLARED_REFS|5.025003|5.025003| WARN_EXPERIMENTAL__DEFER|5.035004|5.035004| WARN_EXPERIMENTAL__FOR_LIST|5.035005|5.035005| WARN_EXPERIMENTAL__ISA|5.031007|5.031007| WARN_EXPERIMENTAL__LEXICAL_SUBS|5.017005|5.017005| WARN_EXPERIMENTAL__POSTDEREF|5.019005|5.019005| WARN_EXPERIMENTAL__PRIVATE_USE|5.029009|5.029009| WARN_EXPERIMENTAL__REFALIASING|5.021005|5.021005| WARN_EXPERIMENTAL__REGEX_SETS|5.017008|5.017008| WARN_EXPERIMENTAL__RE_STRICT|5.021008|5.021008| WARN_EXPERIMENTAL__SCRIPT_RUN|5.027008|5.027008| WARN_EXPERIMENTAL__SIGNATURES|5.019009|5.019009| WARN_EXPERIMENTAL__SMARTMATCH|5.017011|5.017011| WARN_EXPERIMENTAL__TRY|5.033007|5.033007| WARN_EXPERIMENTAL__UNIPROP_WILDCARDS|5.029009|5.029009| WARN_EXPERIMENTAL__VLB|5.029009|5.029009| WARN_GLOB|5.006000|5.003007|p WARN_ILLEGALPROTO|5.011004|5.011004| WARN_IMPRECISION|5.011000|5.011000| WARN_INPLACE|5.006000|5.003007|p WARN_INTERNAL|5.006000|5.003007|p WARN_IO|5.006000|5.003007|p WARN_LAYER|5.008000|5.003007|p WARN_LOCALE|5.021006|5.021006| WARN_MALLOC|5.006000|5.003007|p WARN_MISC|5.006000|5.003007|p WARN_MISSING|5.021002|5.021002| WARN_NEWLINE|5.006000|5.003007|p warn_nocontext|5.006000||pvVn WARN_NONCHAR|5.013010|5.013010| WARN_NONEstring|5.006000||Viu WARN_NON_UNICODE|5.013010|5.013010| WARN_NUMERIC|5.006000|5.003007|p WARN_ONCE|5.006000|5.003007|p warn_on_first_deprecated_use|5.025009||Viu WARN_OVERFLOW|5.006000|5.003007|p WARN_PACK|5.006000|5.003007|p WARN_PARENTHESIS|5.006000|5.003007|p WARN_PIPE|5.006000|5.003007|p WARN_PORTABLE|5.006000|5.003007|p WARN_PRECEDENCE|5.006000|5.003007|p WARN_PRINTF|5.006000|5.003007|p _warn_problematic_locale|5.021008||cVniu WARN_PROTOTYPE|5.006000|5.003007|p WARN_QW|5.006000|5.003007|p WARN_RECURSION|5.006000|5.003007|p WARN_REDEFINE|5.006000|5.003007|p WARN_REDUNDANT|5.021002|5.021002| WARN_REGEXP|5.006000|5.003007|p WARN_RESERVED|5.006000|5.003007|p WARN_SEMICOLON|5.006000|5.003007|p WARN_SEVERE|5.006000|5.003007|p WARN_SHADOW|5.027007|5.027007| WARNshift|5.011001||Viu WARN_SIGNAL|5.006000|5.003007|p WARNsize|5.006000||Viu WARN_SUBSTR|5.006000|5.003007|p WARN_SURROGATE|5.013010|5.013010| warn_sv|5.013001|5.003007|p WARN_SYNTAX|5.006000|5.003007|p WARN_SYSCALLS|5.019004|5.019004| WARN_TAINT|5.006000|5.003007|p WARN_THREADS|5.008000|5.003007|p WARN_UNINITIALIZED|5.006000|5.003007|p WARN_UNOPENED|5.006000|5.003007|p WARN_UNPACK|5.006000|5.003007|p WARN_UNTIE|5.006000|5.003007|p WARN_UTF8|5.006000|5.003007|p WARN_VOID|5.006000|5.003007|p was_lvalue_sub|||ciu watch|5.003007||Viu WB_BREAKABLE|5.023008||Viu WB_DQ_then_HL|5.023008||Viu WB_Ex_or_FO_or_ZWJ_then_foo|5.025003||Viu WB_HL_then_DQ|5.023008||Viu WB_hs_then_hs|5.023008||Viu WB_LE_or_HL_then_MB_or_ML_or_SQ|5.023008||Viu WB_MB_or_ML_or_SQ_then_LE_or_HL|5.023008||Viu WB_MB_or_MN_or_SQ_then_NU|5.023008||Viu WB_NOBREAK|5.023008||Viu WB_NU_then_MB_or_MN_or_SQ|5.023008||Viu WB_RI_then_RI|5.025003||Viu WCTOMB_LOCK|5.033005||Viu WCTOMB_UNLOCK|5.033005||Viu what_MULTI_CHAR_FOLD_latin1_safe|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part0|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part1|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part2|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part3|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part4|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part5|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part6|5.033005||Viu what_MULTI_CHAR_FOLD_utf8_safe_part7|5.033005||Viu whichsig|5.003007|5.003007| whichsig_pv|5.015004|5.015004| whichsig_pvn|5.015004|5.015004| whichsig_sv|5.015004|5.015004| WHILEM|5.003007||Viu WHILEM_A_max|5.009005||Viu WHILEM_A_max_fail|5.009005||Viu WHILEM_A_max_fail_t8|5.035004||Viu WHILEM_A_max_fail_t8_p8|5.033003||Viu WHILEM_A_max_fail_t8_pb|5.033003||Viu WHILEM_A_max_fail_tb|5.035004||Viu WHILEM_A_max_fail_tb_p8|5.033003||Viu WHILEM_A_max_fail_tb_pb|5.033003||Viu WHILEM_A_max_t8|5.035004||Viu WHILEM_A_max_t8_p8|5.033003||Viu WHILEM_A_max_t8_pb|5.033003||Viu WHILEM_A_max_tb|5.035004||Viu WHILEM_A_max_tb_p8|5.033003||Viu WHILEM_A_max_tb_pb|5.033003||Viu WHILEM_A_min|5.009005||Viu WHILEM_A_min_fail|5.009005||Viu WHILEM_A_min_fail_t8|5.035004||Viu WHILEM_A_min_fail_t8_p8|5.033003||Viu WHILEM_A_min_fail_t8_pb|5.033003||Viu WHILEM_A_min_fail_tb|5.035004||Viu WHILEM_A_min_fail_tb_p8|5.033003||Viu WHILEM_A_min_fail_tb_pb|5.033003||Viu WHILEM_A_min_t8|5.035004||Viu WHILEM_A_min_t8_p8|5.033003||Viu WHILEM_A_min_t8_pb|5.033003||Viu WHILEM_A_min_tb|5.035004||Viu WHILEM_A_min_tb_p8|5.033003||Viu WHILEM_A_min_tb_pb|5.033003||Viu WHILEM_A_pre|5.009005||Viu WHILEM_A_pre_fail|5.009005||Viu WHILEM_A_pre_fail_t8|5.035004||Viu WHILEM_A_pre_fail_t8_p8|5.033003||Viu WHILEM_A_pre_fail_t8_pb|5.033003||Viu WHILEM_A_pre_fail_tb|5.035004||Viu WHILEM_A_pre_fail_tb_p8|5.033003||Viu WHILEM_A_pre_fail_tb_pb|5.033003||Viu WHILEM_A_pre_t8|5.035004||Viu WHILEM_A_pre_t8_p8|5.033003||Viu WHILEM_A_pre_t8_pb|5.033003||Viu WHILEM_A_pre_tb|5.035004||Viu WHILEM_A_pre_tb_p8|5.033003||Viu WHILEM_A_pre_tb_pb|5.033003||Viu WHILEM_B_max|5.009005||Viu WHILEM_B_max_fail|5.009005||Viu WHILEM_B_max_fail_t8|5.035004||Viu WHILEM_B_max_fail_t8_p8|5.033003||Viu WHILEM_B_max_fail_t8_pb|5.033003||Viu WHILEM_B_max_fail_tb|5.035004||Viu WHILEM_B_max_fail_tb_p8|5.033003||Viu WHILEM_B_max_fail_tb_pb|5.033003||Viu WHILEM_B_max_t8|5.035004||Viu WHILEM_B_max_t8_p8|5.033003||Viu WHILEM_B_max_t8_pb|5.033003||Viu WHILEM_B_max_tb|5.035004||Viu WHILEM_B_max_tb_p8|5.033003||Viu WHILEM_B_max_tb_pb|5.033003||Viu WHILEM_B_min|5.009005||Viu WHILEM_B_min_fail|5.009005||Viu WHILEM_B_min_fail_t8|5.035004||Viu WHILEM_B_min_fail_t8_p8|5.033003||Viu WHILEM_B_min_fail_t8_pb|5.033003||Viu WHILEM_B_min_fail_tb|5.035004||Viu WHILEM_B_min_fail_tb_p8|5.033003||Viu WHILEM_B_min_fail_tb_pb|5.033003||Viu WHILEM_B_min_t8|5.035004||Viu WHILEM_B_min_t8_p8|5.033003||Viu WHILEM_B_min_t8_pb|5.033003||Viu WHILEM_B_min_tb|5.035004||Viu WHILEM_B_min_tb_p8|5.033003||Viu WHILEM_B_min_tb_pb|5.033003||Viu WHILEM_t8|5.035004||Viu WHILEM_t8_p8|5.033003||Viu WHILEM_t8_pb|5.033003||Viu WHILEM_tb|5.035004||Viu WHILEM_tb_p8|5.033003||Viu WHILEM_tb_pb|5.033003||Viu WIDEST_UTYPE|5.015004|5.003007|poVnu win32_croak_not_implemented|5.017006||Vniu WIN32SCK_IS_STDSCK|5.007001||Viu win32_setlocale|5.027006||Viu withinCOUNT|5.031004||Viu withinCOUNT_KNOWN_VALID|5.033005||Viu WITH_LC_NUMERIC_SET_TO_NEEDED|5.031003|5.031003| WITH_LC_NUMERIC_SET_TO_NEEDED_IN|5.031003|5.031003| with_queued_errors|5.013001||Viu with_tp_UTF8ness|5.033003||Viu with_t_UTF8ness|5.035004||Viu wrap_keyword_plugin|5.027006|5.027006|x wrap_op_checker|5.015008|5.015008| write|5.005000||Viu write_to_stderr|5.008001||Viu XCPT_CATCH|5.009002|5.003007|p XCPT_RETHROW|5.009002|5.003007|p XCPT_TRY_END|5.009002|5.003007|p XCPT_TRY_START|5.009002|5.003007|p XDIGIT_VALUE|5.019008||Viu xio_any|5.006001||Viu xio_dirp|5.006001||Viu xiv_iv|5.009003||Viu xlv_targoff|5.019004||Viu XopDISABLE|5.013007|5.013007|V XOPd_xop_class|5.013007||Viu XOPd_xop_desc|5.013007||Viu XOPd_xop_name|5.013007||Viu XOPd_xop_peep|5.013007||Viu XopENABLE|5.013007|5.013007|V XopENTRY|5.013007|5.013007|V XopENTRYCUSTOM|5.019006|5.013007|V XopENTRY_set|5.013007|5.013007|V XopFLAGS|5.013007|5.013007| XOPf_xop_class|5.013007||Viu XOPf_xop_desc|5.013007||Viu XOPf_xop_name|5.013007||Viu XOPf_xop_peep|5.013007||Viu XORSHIFT128_set|5.027001||Viu XORSHIFT96_set|5.027001||Viu XPUSHi|5.003007|5.003007| XPUSHmortal|5.009002|5.003007|p XPUSHn|5.006000|5.003007| XPUSHp|5.003007|5.003007| XPUSHs|5.003007|5.003007| XPUSHTARG|5.003007||Viu XPUSHu|5.004000|5.003007|p XPUSHundef|5.006000||Viu xpv_len|5.017006||Viu XS|5.003007|5.003007|Vu XSANY|5.003007||Viu XS_APIVERSION_BOOTCHECK|5.013004|5.013004| XS_APIVERSION_POPMARK_BOOTCHECK|5.021006||Viu XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK|5.021006||Viu xs_boot_epilog|5.021006||cViu XS_BOTHVERSION_BOOTCHECK|5.021006||Viu XS_BOTHVERSION_POPMARK_BOOTCHECK|5.021006||Viu XS_BOTHVERSION_SETXSUBFN_POPMARK_BOOTCHECK|5.021006||Viu XS_DYNAMIC_FILENAME|5.009004||Viu XS_EXTERNAL|5.015002|5.015002|Vu xs_handshake|||vcniu XSINTERFACE_CVT|5.005000||Viu XSINTERFACE_CVT_ANON|5.010000||Viu XSINTERFACE_FUNC|5.005000||Viu XSINTERFACE_FUNC_SET|5.005000||Viu XS_INTERNAL|5.015002|5.015002|Vu XSprePUSH|5.006000|5.003007|poVnu XSPROTO|5.010000|5.003007|pVu XSRETURN|5.003007|5.003007|p XSRETURN_EMPTY|5.003007|5.003007| XSRETURN_IV|5.003007|5.003007| XSRETURN_NO|5.003007|5.003007| XSRETURN_NV|5.006000|5.003007| XSRETURN_PV|5.003007|5.003007| XSRETURN_PVN|5.006000||Viu XSRETURN_UNDEF|5.003007|5.003007| XSRETURN_UV|5.008001|5.003007|p XSRETURN_YES|5.003007|5.003007| XS_SETXSUBFN_POPMARK|5.021006||Viu XST_mIV|5.003007|5.003007| XST_mNO|5.003007|5.003007| XST_mNV|5.006000|5.003007| XST_mPV|5.003007|5.003007| XST_mPVN|5.006000||Viu XST_mUNDEF|5.003007|5.003007| XST_mUV|5.008001|5.003007|p XST_mYES|5.003007|5.003007| XS_VERSION|5.003007|5.003007| XS_VERSION_BOOTCHECK|5.003007|5.003007| xs_version_bootcheck|||iu XTENDED_PAT_MOD|5.009005||Viu xuv_uv|5.009003||Viu YESEXPR|5.027010||Viu YESSTR|5.027010||Viu YIELD|5.005000||Viu YYDEBUG|5.025006||Viu YYEMPTY|5.009005||Viu yyerror|5.003007||Viu yyerror_pv|5.016000||Viu yyerror_pvn|5.016000||Viu yylex|5.003007||cViu yyparse|5.003007||Viu yyquit|5.025010||Viu YYSTYPE_IS_DECLARED|5.009001||Viu YYSTYPE_IS_TRIVIAL|5.009001||Viu YYTOKENTYPE|5.009001||Viu yyunlex|5.013005||Viu yywarn|5.003007||Viu ZAPHOD32_FINALIZE|5.027001||Viu ZAPHOD32_MIX|5.027001||Viu ZAPHOD32_SCRAMBLE32|5.027001||Viu ZAPHOD32_STATIC_INLINE|5.027001||Viu ZAPHOD32_WARN2|5.027001||Viu ZAPHOD32_WARN3|5.027001||Viu ZAPHOD32_WARN4|5.027001||Viu ZAPHOD32_WARN5|5.027001||Viu ZAPHOD32_WARN6|5.027001||Viu Zero|5.003007|5.003007| ZeroD|5.009002|5.003007|p ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort dictionary_order keys %API) { next if $API{$f}{core_only}; next if $API{$f}{beyond_depr}; next if $API{$f}{inaccessible}; next if $API{$f}{experimental}; next unless $API{$f}{todo}; next if int_parse_version($API{$f}{todo}) <= $int_min_perl; my $repeat = 40 - length($f); $repeat = 0 if $repeat < 0; print "$f ", '.'x $repeat, " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for hints, possible replacement candidates, etc. my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { BEGIN { 'warnings'->unimport('uninitialized') if "$]" > '5.006' } my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { # Here, we are in the middle of accumulating a hint or warning. my $end_of_hint = 0; # A line containing a comment end marker closes the hint. Remove that # marker for processing below. if (s/\s*$rcce(.*?)\s*$//) { die "Nothing can follow the end of comment in '$_'\n" if length $1 > 0; $end_of_hint = 1; } # Set $h to the hash of which type. my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; # Ignore any leading and trailing white space, and an optional star comment # continuation marker, then place the meat of the line into $1 m/^\s*(?:\*\s*)?(.*?)\s*$/; # Add the meat of this line to the hash value of each API element it # applies to for (@{$hint->[1]}) { $h->{$_} ||= ''; # avoid the warning older perls generate $h->{$_} .= "$1\n"; } # If the line had a comment close, we are through with this hint undef $hint if $end_of_hint; next; } # Set up $hint if this is the beginning of a Hint: or Warning: # These are from a multi-line C comment in the file, with the first line # looking like (a space has been inserted because this file can't have C # comment markers in it): # / * Warning: PL_expect, PL_copline, PL_rsfp # # $hint becomes # [ # 'Warning', # [ # 'PL_expect', # 'PL_copline', # 'PL_rsfp', # ], # ] if (m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}) { $hint = [$1, [split /,?\s+/, $2]]; next; } if ($define) { # If in the middle of a definition... # append a continuation line ending with backslash. if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { # Otherwise this line ends the definition, make foo depend on bar # (and what bar depends on) if its not one of ppp's own constructs if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } # For '#define foo bar' or '#define foo(a,b,c) bar', $define becomes a # reference to [ foo, bar ] $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; # Set $replace to the number given for lines that look like # / * Replace: \d+ * / # Thus setting it to 1 starts a region where replacements are automatically # done, and setting it to 0 ends that region. $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; # Add bar => foo to %replace for lines like '#define foo bar in a region # where $replace is non-zero $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; # Add bar => foo to %replace for lines like '#define foo bar / * Replace * / $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; # Add foo => bar to %replace for lines like / * Replace foo with bar * / $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+.*?)\s+$rcce\s*$}; # For lines like / * foo, bar depends on baz, bat * / # create a list of the elements on the rhs, and make that list apply to each # element in the lhs, which becomes a key in \%depends. if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %seen; $_ = [sort dictionary_order grep !$seen{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; # Sort the names, and split into two classes; one for things that are part of # the API; a second for things that aren't. my @ok_to_use; my @shouldnt_use; for $f (sort dictionary_order keys %API) { next unless $f =~ /$match/; my $base = int_parse_version($API{$f}{base}) if $API{$f}{base}; if ($base && ! $API{$f}{inaccessible} && ! $API{$f}{core_only}) { push @ok_to_use, $f; } else { push @shouldnt_use, $f; } } # We normally suppress non-API items. But if the search matched no API # items, output the non-ones. This allows someone to get the info for an # item if they ask for it specifically enough, but doesn't normally clutter # the output with irrelevant results. @ok_to_use = @shouldnt_use unless @ok_to_use; for $f (@ok_to_use) { print "\n=== $f ===\n"; my $info = 0; my $base; $base = int_parse_version($API{$f}{base}) if $API{$f}{base}; my $todo; $todo = int_parse_version($API{$f}{todo}) if $API{$f}{todo}; # Output information if ($base) { my $with_or= ""; if ( $base <= $int_min_perl || ( (! $API{$f}{provided} && ! $todo) || ($todo && $todo >= $base))) { $with_or= " with or"; } my $Supported = ($API{$f}{undocumented}) ? 'Available' : 'Supported'; print "\n$Supported at least since perl-", format_version($base), ",$with_or without $ppport."; if ($API{$f}{unverified}) { print "\nThis information is based on inspection of the source code", " and has not been\n", "verified by successful compilation."; } print "\n"; $info++; } if ($API{$f}{provided} || $todo) { print "\nThis is only supported by $ppport, and NOT by perl versions going forward.\n" unless $base; if ($todo) { if (! $base || $todo < $base) { my $additionally = ""; $additionally .= " additionally" if $base; print "$ppport$additionally provides support at least back to perl-", format_version($todo), ".\n"; } } elsif (! $base || $base > $int_min_perl) { if (exists $depends{$f}) { my $max = 0; for (@{$depends{$f}}) { $max = int_parse_version($API{$_}{todo}) if $API{$_}{todo} && $API{$_}{todo} > $max; # XXX What to assume unspecified values are? This effectively makes them MIN_PERL } $todo = $max if $max; } print "\n$ppport provides support for this, but ironically, does not", " currently know,\n", "for this report, the minimum version it supports for this"; if ($API{$f}{undocumented}) { print " and many things\n", "it provides that are implemented as macros and aren't", " documented. You can\n", "help by submitting a documentation patch"; } print ".\n"; if ($todo) { if ($todo <= $int_min_perl) { print "It may very well be supported all the way back to ", format_version(5.003_07), ".\n"; } else { print "But given the things $f depends on, it's a good", " guess that it isn't\n", "supported prior to ", format_version($todo), ".\n"; } } } } if ($API{$f}{provided}) { print "Support needs to be explicitly requested by #define NEED_$f\n", "(or #define NEED_${f}_GLOBAL).\n" if exists $need{$f}; $info++; } if ($base || ! $API{$f}{ppport_fnc}) { my $email = "Send email to perl5-porters\@perl.org if you need to have this functionality.\n"; if ($API{$f}{inaccessible}) { print "\nThis is not part of the public API, and may not even be accessible to XS code.\n"; $info++; } elsif ($API{$f}{core_only}) { print "\nThis is not part of the public API, and should not be used by XS code.\n"; $info++; } elsif ($API{$f}{deprecated}) { print "\nThis is deprecated and should not be used. Convert existing uses.\n"; $info++; } elsif ($API{$f}{experimental}) { print "\nThe API for this is unstable and should not be used by XS code.\n", $email; $info++; } elsif ($API{$f}{undocumented}) { print "\nSince this is undocumented, the API should be considered unstable.\n"; if ($API{$f}{provided}) { print "Consider bringing this up on the list: perl5-porters\@perl.org.\n"; } else { print "It may be that this is not intended for XS use, or it may just be\n", "that no one has gotten around to documenting it.\n", $email; } $info++; } unless ($info) { print "No portability information available. Check your spelling; or", " this could be\na bug in Devel::PPPort. To report an issue:\n", "https://github.com/Dual-Life/Devel-PPPort/issues/new\n"; } } print "\nDepends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; if (exists $hints{$f} || exists $warnings{$f}) { print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } $count++; } $count or print "\nFound no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort dictionary_order keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if ( ! exists $API{$func}{base} || int_parse_version($API{$func}{base}) > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if ( exists $API{$func}{todo} && int_parse_version($API{$func}{todo}) > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort dictionary_order keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{noTHXarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort dictionary_order keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort dictionary_order keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += (hint($func) || 0); } unless ($opt{quiet}) { for $func (sort dictionary_order keys %{$file{uses_todo}}) { next if int_parse_version($API{$func}{todo}) <= $int_min_perl; print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort dictionary_order keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort dictionary_order keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort dictionary_order keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv || 0; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #define D_PPP_RELEASE_DATE 1646179200 /* 2022-03-02 */ #if ! defined(PERL_REVISION) && ! defined(PERL_VERSION_MAJOR) # if ! defined(__PATCHLEVEL_H_INCLUDED__) \ && ! ( defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if ! defined(PERL_VERSION) \ && ! defined(PERL_VERSION_MAJOR) \ && ( ! defined(SUBVERSION) || ! defined(PATCHLEVEL) ) # include # endif #endif #ifdef PERL_VERSION_MAJOR # define D_PPP_MAJOR PERL_VERSION_MAJOR #elif defined(PERL_REVISION) # define D_PPP_MAJOR PERL_REVISION #else # define D_PPP_MAJOR 5 #endif #ifdef PERL_VERSION_MINOR # define D_PPP_MINOR PERL_VERSION_MINOR #elif defined(PERL_VERSION) # define D_PPP_MINOR PERL_VERSION #elif defined(PATCHLEVEL) # define D_PPP_MINOR PATCHLEVEL # define PERL_VERSION PATCHLEVEL /* back-compat */ #else # error Could not find a source for PERL_VERSION_MINOR #endif #ifdef PERL_VERSION_PATCH # define D_PPP_PATCH PERL_VERSION_PATCH #elif defined(PERL_SUBVERSION) # define D_PPP_PATCH PERL_SUBVERSION #elif defined(SUBVERSION) # define D_PPP_PATCH SUBVERSION # define PERL_SUBVERSION SUBVERSION /* back-compat */ #else # error Could not find a source for PERL_VERSION_PATCH #endif #if D_PPP_MAJOR < 5 || D_PPP_MAJOR == 6 # error Devel::PPPort works only on Perl 5, Perl 7, ... #elif D_PPP_MAJOR != 5 /* Perl 7 and above: the old forms are deprecated, set up so that they * assume Perl 5, and will make this look like 5.201.201. * * 201 is used so will be well above anything that would come from a 5 * series if we unexpectedly have to continue it, but still gives plenty of * room, up to 255, of numbers that will fit into a byte in case there is * something else unforeseen */ # undef PERL_REVISION # undef PERL_VERSION # undef PERL_SUBVERSION # define D_PPP_REVISION 5 # define D_PPP_VERSION 201 # define D_PPP_SUBVERSION 201 # if (defined(__clang__) /* _Pragma here doesn't work with gcc */ \ && ( (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ || defined(_STDC_C99) \ || defined(__c99))) # define D_PPP_STRINGIFY(x) #x # define D_PPP_deprecate(xyz) _Pragma(D_PPP_STRINGIFY(GCC warning(D_PPP_STRINGIFY(xyz) " is deprecated"))) # define PERL_REVISION (D_PPP_REVISION D_PPP_deprecate(PERL_REVISION)) # define PERL_VERSION (D_PPP_REVISION D_PPP_deprecate(PERL_VERSION)) # define PERL_SUBVERSION (D_PPP_SUBVERSION D_PPP_deprecate(PERL_SUBVERSION)) # else # define PERL_REVISION D_PPP_REVISION # define PERL_VERSION D_PPP_REVISION # define PERL_SUBVERSION D_PPP_SUBVERSION # endif #endif /* Warning: PERL_PATCHLEVEL PATCHLEVEL SUBVERSION PERL_REVISION PERL_VERSION * PERL_SUBVERSION PERL_BCDVERSION * * You should be using PERL_VERSION_xy(maj,min,ptch) instead of this, where xy * is one of EQ, NE, LE, GT, LT, GE */ /* Replace PERL_PATCHLEVEL with PERL_VERSION_xy(5,a,b) (where xy is EQ,LT,GT...) */ /* Replace PATCHLEVEL with PERL_VERSION_xy(5,a,b) (where xy is EQ,LT,GT...) */ /* Replace SUBVERSION with PERL_VERSION_xy(5,a,b) (where xy is EQ,LT,GT...) */ /* Replace PERL_REVISION with PERL_VERSION_xy(a,b,c) (where xy is EQ,LT,GT...) */ /* Replace PERL_VERSION with PERL_VERSION_xy(5,a,b) (where xy is EQ,LT,GT...) */ /* Replace PERL_SUBVERSION with PERL_VERSION_xy(5,a,b) (where xy is EQ,LT,GT...) */ /* Replace PERL_BCDVERSION with PERL_VERSION_xy(5,a,b) (where xy is EQ,LT,GT...) */ #define D_PPP_DEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define D_PPP_JNP_TO_BCD(j,n,p) ((D_PPP_DEC2BCD(j)<<24)|(D_PPP_DEC2BCD(n)<<12)|D_PPP_DEC2BCD(p)) #define PERL_BCDVERSION D_PPP_JNP_TO_BCD(D_PPP_MAJOR, \ D_PPP_MINOR, \ D_PPP_PATCH) /* These differ from the versions outside D:P in using PERL_BCDVERSION instead * of PERL_DECIMAL_VERSION. The formats printing in this module assume BCD, so * always use it */ #undef PERL_VERSION_EQ #undef PERL_VERSION_NE #undef PERL_VERSION_LT #undef PERL_VERSION_GE #undef PERL_VERSION_LE #undef PERL_VERSION_GT /* N.B. These don't work if the patch number is 42 or 92, as those are what '*' * is in ASCII and EBCDIC respectively */ #ifndef PERL_VERSION_EQ # define PERL_VERSION_EQ(j,n,p) \ (((p) == '*') ? ( (j) == D_PPP_VERSION_MAJOR \ && (n) == D_PPP_VERSION_MINOR) \ : (PERL_BCDVERSION == D_PPP_JNP_TO_BCD(j,n,p))) #endif #ifndef PERL_VERSION_NE # define PERL_VERSION_NE(j,n,p) (! PERL_VERSION_EQ(j,n,p)) #endif #ifndef PERL_VERSION_LT # define PERL_VERSION_LT(j,n,p) /* p=='*' means _LT(j,n,0) */ \ (PERL_BCDVERSION < D_PPP_JNP_TO_BCD( (j), \ (n), \ (((p) == '*') ? 0 : (p)))) #endif #ifndef PERL_VERSION_GE # define PERL_VERSION_GE(j,n,p) (! PERL_VERSION_LT(j,n,p)) #endif #ifndef PERL_VERSION_LE # define PERL_VERSION_LE(j,n,p) /* p=='*' means _LT(j,n+1,0) */ \ (PERL_BCDVERSION < D_PPP_JNP_TO_BCD( (j), \ (((p) == '*') ? ((n)+1) : (n)), \ (((p) == '*') ? 0 : (p)))) #endif #ifndef PERL_VERSION_GT # define PERL_VERSION_GT(j,n,p) (! PERL_VERSION_LE(j,n,p)) #endif #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif /* Hint: dTHX For pre-5.6.0 thread compatibility, instead use dTHXR, available only through ppport.h */ #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif /* Hint: aTHX For pre-5.6.0 thread compatibility, instead use aTHXR, available only through ppport.h */ #ifndef aTHX_ # define aTHX_ #endif /* Hint: aTHX_ For pre-5.6.0 thread compatibility, instead use aTHXR_, available only through ppport.h */ #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef LONGSIZE # define LONGSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef LONGSIZE # define LONGSIZE 4 #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_Xpv Xpv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf # define PL_mess_sv mess_sv /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid it, and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doing. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #if (PERL_BCDVERSION <= 0x5003022) # undef start_subparse # if (PERL_BCDVERSION < 0x5003022) #ifndef start_subparse # define start_subparse(a, b) Perl_start_subparse() #endif # else #ifndef start_subparse # define start_subparse(a, b) Perl_start_subparse(b) #endif # endif #if (PERL_BCDVERSION < 0x5003007) foo #endif #endif /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) /* And before that, we need to make sure this gets compiled for the functions * that rely on it */ #define NEED_newCONSTSUB #if defined(NEED_newCONSTSUB) static CV * DPPP_(my_newCONSTSUB)(HV * stash, const char * name, SV * sv); static #else extern CV * DPPP_(my_newCONSTSUB)(HV * stash, const char * name, SV * sv); #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline CV * DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { CV *cv; U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; cv = newSUB( start_subparse(FALSE, 0), newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; return cv; } #endif #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #ifndef PERL_STATIC_INLINE # define PERL_STATIC_INLINE static inline #endif #else #ifndef PERL_STATIC_INLINE # define PERL_STATIC_INLINE static #endif #endif #ifndef cBOOL # define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0) #endif #ifndef OpHAS_SIBLING # define OpHAS_SIBLING(o) (cBOOL((o)->op_sibling)) #endif #ifndef OpSIBLING # define OpSIBLING(o) (0 + (o)->op_sibling) #endif #ifndef OpMORESIB_set # define OpMORESIB_set(o, sib) ((o)->op_sibling = (sib)) #endif #ifndef OpLASTSIB_set # define OpLASTSIB_set(o, parent) ((o)->op_sibling = NULL) #endif #ifndef OpMAYBESIB_set # define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib)) #endif #ifndef HEf_SVKEY # define HEf_SVKEY -2 #endif #if defined(DEBUGGING) && !defined(__COVERITY__) #ifndef __ASSERT_ # define __ASSERT_(statement) assert(statement), #endif #else #ifndef __ASSERT_ # define __ASSERT_(statement) #endif #endif #ifndef __has_builtin # define __has_builtin(x) 0 #endif #if __has_builtin(__builtin_unreachable) # define D_PPP_HAS_BUILTIN_UNREACHABLE #elif (defined(__GNUC__) && ( __GNUC__ > 4 \ || __GNUC__ == 4 && __GNUC_MINOR__ >= 5)) # define D_PPP_HAS_BUILTIN_UNREACHABLE #endif #ifndef ASSUME # ifdef DEBUGGING # define ASSUME(x) assert(x) # elif defined(_MSC_VER) # define ASSUME(x) __assume(x) # elif defined(__ARMCC_VERSION) # define ASSUME(x) __promise(x) # elif defined(D_PPP_HAS_BUILTIN_UNREACHABLE) # define ASSUME(x) ((x) ? (void) 0 : __builtin_unreachable()) # else # define ASSUME(x) assert(x) # endif #endif #ifndef NOT_REACHED # ifdef D_PPP_HAS_BUILTIN_UNREACHABLE # define NOT_REACHED \ STMT_START { \ ASSUME(!"UNREACHABLE"); __builtin_unreachable(); \ } STMT_END # elif ! defined(__GNUC__) && (defined(__sun) || defined(__hpux)) # define NOT_REACHED # else # define NOT_REACHED ASSUME(!"UNREACHABLE") # endif #endif #ifndef WIDEST_UTYPE # ifdef QUADKIND # ifdef U64TYPE # define WIDEST_UTYPE U64TYPE # else # define WIDEST_UTYPE unsigned Quad_t # endif # else # define WIDEST_UTYPE U32 # endif #endif /* These could become provided if/when they become part of the public API */ #ifndef withinCOUNT # define withinCOUNT(c, l, n) \ (((WIDEST_UTYPE) (((c)) - ((l) | 0))) <= (((WIDEST_UTYPE) ((n) | 0)))) #endif #ifndef inRANGE # define inRANGE(c, l, u) \ ( (sizeof(c) == sizeof(U8)) ? withinCOUNT(((U8) (c)), (l), ((u) - (l))) \ : (sizeof(c) == sizeof(U32)) ? withinCOUNT(((U32) (c)), (l), ((u) - (l))) \ : (withinCOUNT(((WIDEST_UTYPE) (c)), (l), ((u) - (l))))) #endif /* The '| 0' part ensures a compiler error if c is not integer (like e.g., a * pointer) */ #undef FITS_IN_8_BITS /* handy.h version uses a core-only constant */ #ifndef FITS_IN_8_BITS # define FITS_IN_8_BITS(c) ( (sizeof(c) == 1) \ || !(((WIDEST_UTYPE)((c) | 0)) & ~0xFF)) #endif /* Create the macro for "is'macro'_utf8_safe(s, e)". For code points below * 256, it calls the equivalent _L1 macro by converting the UTF-8 to code * point. That is so that it can automatically get the bug fixes done in this * file. */ #define D_PPP_IS_GENERIC_UTF8_SAFE(s, e, macro) \ (((e) - (s)) <= 0 \ ? 0 \ : UTF8_IS_INVARIANT((s)[0]) \ ? is ## macro ## _L1((s)[0]) \ : (((e) - (s)) < UTF8SKIP(s)) \ ? 0 \ : UTF8_IS_DOWNGRADEABLE_START((s)[0]) \ /* The cast in the line below is only to silence warnings */ \ ? is ## macro ## _L1((WIDEST_UTYPE) LATIN1_TO_NATIVE( \ UTF8_ACCUMULATE(NATIVE_UTF8_TO_I8((s)[0]) \ & UTF_START_MASK(2), \ (s)[1]))) \ : is ## macro ## _utf8(s)) /* Create the macro for "is'macro'_LC_utf8_safe(s, e)". For code points below * 256, it calls the equivalent _L1 macro by converting the UTF-8 to code * point. That is so that it can automatically get the bug fixes done in this * file. */ #define D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, macro) \ (((e) - (s)) <= 0 \ ? 0 \ : UTF8_IS_INVARIANT((s)[0]) \ ? is ## macro ## _LC((s)[0]) \ : (((e) - (s)) < UTF8SKIP(s)) \ ? 0 \ : UTF8_IS_DOWNGRADEABLE_START((s)[0]) \ /* The cast in the line below is only to silence warnings */ \ ? is ## macro ## _LC((WIDEST_UTYPE) LATIN1_TO_NATIVE( \ UTF8_ACCUMULATE(NATIVE_UTF8_TO_I8((s)[0]) \ & UTF_START_MASK(2), \ (s)[1]))) \ : is ## macro ## _utf8(s)) /* A few of the early functions are broken. For these and the non-LC case, * machine generated code is substituted. But that code doesn't work for * locales. This is just like the above macro, but at the end, we call the * macro we've generated for the above 255 case, which is correct since locale * isn't involved. This will generate extra code to handle the 0-255 inputs, * but hopefully it will be optimized out by the C compiler. But just in case * it isn't, this macro is only used on the few versions that are broken */ #define D_PPP_IS_GENERIC_LC_UTF8_SAFE_BROKEN(s, e, macro) \ (((e) - (s)) <= 0 \ ? 0 \ : UTF8_IS_INVARIANT((s)[0]) \ ? is ## macro ## _LC((s)[0]) \ : (((e) - (s)) < UTF8SKIP(s)) \ ? 0 \ : UTF8_IS_DOWNGRADEABLE_START((s)[0]) \ /* The cast in the line below is only to silence warnings */ \ ? is ## macro ## _LC((WIDEST_UTYPE) LATIN1_TO_NATIVE( \ UTF8_ACCUMULATE(NATIVE_UTF8_TO_I8((s)[0]) \ & UTF_START_MASK(2), \ (s)[1]))) \ : is ## macro ## _utf8_safe(s, e)) #ifndef SvRX # define SvRX(rv) (SvROK((rv)) ? (SvMAGICAL(SvRV((rv))) ? (mg_find(SvRV((rv)), PERL_MAGIC_qr) ? mg_find(SvRV((rv)), PERL_MAGIC_qr)->mg_obj : NULL) : NULL) : NULL) #endif #ifndef SvRXOK # define SvRXOK(sv) (!!SvRX(sv)) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef PERL_UNUSED_RESULT # if defined(__GNUC__) && defined(HASATTRIBUTE_WARN_UNUSED_RESULT) # define PERL_UNUSED_RESULT(v) STMT_START { __typeof__(v) z = (v); (void)sizeof(z); } STMT_END # else # define PERL_UNUSED_RESULT(v) ((void)(v)) # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if (PERL_BCDVERSION < 0x5004000) || defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN #ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN #endif # endif #endif #if ! defined(__GNUC__) || defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) || defined(__cplusplus) # undef PERL_USE_GCC_BRACE_GROUPS #else # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #if defined(VOIDFLAGS) && defined(PERL_USE_GCC_BRACE_GROUPS) # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef av_tindex # define av_tindex AvFILL #endif #ifndef av_top_index # define av_top_index AvFILL #endif #ifndef av_count # define av_count(av) (AvFILL(av)+1) #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif /* On versions without NATIVE_TO_ASCII, only ASCII is supported */ #if defined(EBCDIC) && defined(NATIVE_TO_ASCI) #ifndef NATIVE_TO_LATIN1 # define NATIVE_TO_LATIN1(c) NATIVE_TO_ASCII(c) #endif #ifndef LATIN1_TO_NATIVE # define LATIN1_TO_NATIVE(c) ASCII_TO_NATIVE(c) #endif #ifndef NATIVE_TO_UNI # define NATIVE_TO_UNI(c) ((c) > 255 ? (c) : NATIVE_TO_LATIN1(c)) #endif #ifndef UNI_TO_NATIVE # define UNI_TO_NATIVE(c) ((c) > 255 ? (c) : LATIN1_TO_NATIVE(c)) #endif #else #ifndef NATIVE_TO_LATIN1 # define NATIVE_TO_LATIN1(c) (c) #endif #ifndef LATIN1_TO_NATIVE # define LATIN1_TO_NATIVE(c) (c) #endif #ifndef NATIVE_TO_UNI # define NATIVE_TO_UNI(c) (c) #endif #ifndef UNI_TO_NATIVE # define UNI_TO_NATIVE(c) (c) #endif #endif /* Warning: LATIN1_TO_NATIVE, NATIVE_TO_LATIN1 NATIVE_TO_UNI UNI_TO_NATIVE EBCDIC is not supported on versions earlier than 5.7.1 */ /* The meaning of this changed; use the modern version */ #undef isPSXSPC #undef isPSXSPC_A #undef isPSXSPC_L1 /* Hint: isPSXSPC, isPSXSPC_A, isPSXSPC_L1, isPSXSPC_utf8_safe This is equivalent to the corresponding isSPACE-type macro. On perls before 5.18, this matched a vertical tab and SPACE didn't. But the ppport.h SPACE version does match VT in all perl releases. Since VT's are extremely rarely found in real-life files, this difference effectively doesn't matter */ /* Hint: isSPACE, isSPACE_A, isSPACE_L1, isSPACE_utf8_safe Until Perl 5.18, this did not match the vertical tab (VT). The ppport.h version does match it in all perl releases. Since VT's are extremely rarely found in real-life files, this difference effectively doesn't matter */ #ifdef EBCDIC /* This is the first version where these macros are fully correct on EBCDIC * platforms. Relying on the C library functions, as earlier releases did, * causes problems with locales */ # if (PERL_BCDVERSION < 0x5022000) # undef isALNUM # undef isALNUM_A # undef isALNUM_L1 # undef isALNUMC # undef isALNUMC_A # undef isALNUMC_L1 # undef isALPHA # undef isALPHA_A # undef isALPHA_L1 # undef isALPHANUMERIC # undef isALPHANUMERIC_A # undef isALPHANUMERIC_L1 # undef isASCII # undef isASCII_A # undef isASCII_L1 # undef isBLANK # undef isBLANK_A # undef isBLANK_L1 # undef isCNTRL # undef isCNTRL_A # undef isCNTRL_L1 # undef isDIGIT # undef isDIGIT_A # undef isDIGIT_L1 # undef isGRAPH # undef isGRAPH_A # undef isGRAPH_L1 # undef isIDCONT # undef isIDCONT_A # undef isIDCONT_L1 # undef isIDFIRST # undef isIDFIRST_A # undef isIDFIRST_L1 # undef isLOWER # undef isLOWER_A # undef isLOWER_L1 # undef isOCTAL # undef isOCTAL_A # undef isOCTAL_L1 # undef isPRINT # undef isPRINT_A # undef isPRINT_L1 # undef isPUNCT # undef isPUNCT_A # undef isPUNCT_L1 # undef isSPACE # undef isSPACE_A # undef isSPACE_L1 # undef isUPPER # undef isUPPER_A # undef isUPPER_L1 # undef isWORDCHAR # undef isWORDCHAR_A # undef isWORDCHAR_L1 # undef isXDIGIT # undef isXDIGIT_A # undef isXDIGIT_L1 # endif #ifndef isASCII # define isASCII(c) (isCNTRL(c) || isPRINT(c)) #endif /* The below is accurate for all EBCDIC code pages supported by * all the versions of Perl overridden by this */ #ifndef isCNTRL # define isCNTRL(c) ( (c) == '\0' || (c) == '\a' || (c) == '\b' \ || (c) == '\f' || (c) == '\n' || (c) == '\r' \ || (c) == '\t' || (c) == '\v' \ || ((c) <= 3 && (c) >= 1) /* SOH, STX, ETX */ \ || (c) == 7 /* U+7F DEL */ \ || ((c) <= 0x13 && (c) >= 0x0E) /* SO, SI */ \ /* DLE, DC[1-3] */ \ || (c) == 0x18 /* U+18 CAN */ \ || (c) == 0x19 /* U+19 EOM */ \ || ((c) <= 0x1F && (c) >= 0x1C) /* [FGRU]S */ \ || (c) == 0x26 /* U+17 ETB */ \ || (c) == 0x27 /* U+1B ESC */ \ || (c) == 0x2D /* U+05 ENQ */ \ || (c) == 0x2E /* U+06 ACK */ \ || (c) == 0x32 /* U+16 SYN */ \ || (c) == 0x37 /* U+04 EOT */ \ || (c) == 0x3C /* U+14 DC4 */ \ || (c) == 0x3D /* U+15 NAK */ \ || (c) == 0x3F /* U+1A SUB */ \ ) #endif #if '^' == 106 /* EBCDIC POSIX-BC */ # define D_PPP_OUTLIER_CONTROL 0x5F #else /* EBCDIC 1047 037 */ # define D_PPP_OUTLIER_CONTROL 0xFF #endif /* The controls are everything below blank, plus one outlier */ #ifndef isCNTRL_L1 # define isCNTRL_L1(c) ((WIDEST_UTYPE) (c) < ' ' \ || (WIDEST_UTYPE) (c) == D_PPP_OUTLIER_CONTROL) #endif /* The ordering of the tests in this and isUPPER are to exclude most characters * early */ #ifndef isLOWER # define isLOWER(c) ( (c) >= 'a' && (c) <= 'z' \ && ( (c) <= 'i' \ || ((c) >= 'j' && (c) <= 'r') \ || (c) >= 's')) #endif #ifndef isUPPER # define isUPPER(c) ( (c) >= 'A' && (c) <= 'Z' \ && ( (c) <= 'I' \ || ((c) >= 'J' && (c) <= 'R') \ || (c) >= 'S')) #endif #else /* Above is EBCDIC; below is ASCII */ # if (PERL_BCDVERSION < 0x5004000) /* The implementation of these in older perl versions can give wrong results if * the C program locale is set to other than the C locale */ # undef isALNUM # undef isALNUM_A # undef isALPHA # undef isALPHA_A # undef isDIGIT # undef isDIGIT_A # undef isIDFIRST # undef isIDFIRST_A # undef isLOWER # undef isLOWER_A # undef isUPPER # undef isUPPER_A # endif # if (PERL_BCDVERSION == 0x5007000) /* this perl made space GRAPH */ # undef isGRAPH # endif # if (PERL_BCDVERSION < 0x5008000) /* earlier perls omitted DEL */ # undef isCNTRL # endif # if (PERL_BCDVERSION < 0x5010000) /* earlier perls included all of the isSPACE() characters, which is wrong. The * version provided by Devel::PPPort always overrides an existing buggy * version. */ # undef isPRINT # undef isPRINT_A # endif # if (PERL_BCDVERSION < 0x5014000) /* earlier perls always returned true if the parameter was a signed char */ # undef isASCII # undef isASCII_A # endif # if (PERL_BCDVERSION < 0x5017008) /* earlier perls didn't include PILCROW, SECTION SIGN */ # undef isPUNCT_L1 # endif # if (PERL_BCDVERSION < 0x5013007) /* khw didn't investigate why this failed */ # undef isALNUMC_L1 #endif # if (PERL_BCDVERSION < 0x5020000) /* earlier perls didn't include \v */ # undef isSPACE # undef isSPACE_A # undef isSPACE_L1 # endif #ifndef isASCII # define isASCII(c) ((WIDEST_UTYPE) (c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((WIDEST_UTYPE) (c) < ' ' || (c) == 127) #endif #ifndef isCNTRL_L1 # define isCNTRL_L1(c) ( (WIDEST_UTYPE) (c) < ' ' \ || inRANGE((c), 0x7F, 0x9F)) #endif #ifndef isLOWER # define isLOWER(c) inRANGE((c), 'a', 'z') #endif #ifndef isUPPER # define isUPPER(c) inRANGE((c), 'A', 'Z') #endif #endif /* Below are definitions common to EBCDIC and ASCII */ #ifndef isASCII_L1 # define isASCII_L1(c) isASCII(c) #endif #ifndef isASCII_LC # define isASCII_LC(c) isASCII(c) #endif #ifndef isALNUM # define isALNUM(c) isWORDCHAR(c) #endif #ifndef isALNUMC # define isALNUMC(c) isALPHANUMERIC(c) #endif #ifndef isALNUMC_L1 # define isALNUMC_L1(c) isALPHANUMERIC_L1(c) #endif #ifndef isALPHA # define isALPHA(c) (isUPPER(c) || isLOWER(c)) #endif #ifndef isALPHA_L1 # define isALPHA_L1(c) (isUPPER_L1(c) || isLOWER_L1(c)) #endif #ifndef isALPHANUMERIC # define isALPHANUMERIC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isALPHANUMERIC_L1 # define isALPHANUMERIC_L1(c) (isALPHA_L1(c) || isDIGIT(c)) #endif #ifndef isALPHANUMERIC_LC # define isALPHANUMERIC_LC(c) (isALPHA_LC(c) || isDIGIT_LC(c)) #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifndef isBLANK_L1 # define isBLANK_L1(c) ( isBLANK(c) \ || ( FITS_IN_8_BITS(c) \ && NATIVE_TO_LATIN1((U8) c) == 0xA0)) #endif #ifndef isBLANK_LC # define isBLANK_LC(c) isBLANK(c) #endif #ifndef isDIGIT # define isDIGIT(c) inRANGE(c, '0', '9') #endif #ifndef isDIGIT_L1 # define isDIGIT_L1(c) isDIGIT(c) #endif #ifndef isGRAPH # define isGRAPH(c) (isWORDCHAR(c) || isPUNCT(c)) #endif #ifndef isGRAPH_L1 # define isGRAPH_L1(c) ( isPRINT_L1(c) \ && (c) != ' ' \ && NATIVE_TO_LATIN1((U8) c) != 0xA0) #endif #ifndef isIDCONT # define isIDCONT(c) isWORDCHAR(c) #endif #ifndef isIDCONT_L1 # define isIDCONT_L1(c) isWORDCHAR_L1(c) #endif #ifndef isIDCONT_LC # define isIDCONT_LC(c) isWORDCHAR_LC(c) #endif #ifndef isIDFIRST # define isIDFIRST(c) (isALPHA(c) || (c) == '_') #endif #ifndef isIDFIRST_L1 # define isIDFIRST_L1(c) (isALPHA_L1(c) || (U8) (c) == '_') #endif #ifndef isIDFIRST_LC # define isIDFIRST_LC(c) (isALPHA_LC(c) || (U8) (c) == '_') #endif #ifndef isLOWER_L1 # define isLOWER_L1(c) ( isLOWER(c) \ || ( FITS_IN_8_BITS(c) \ && ( ( NATIVE_TO_LATIN1((U8) c) >= 0xDF \ && NATIVE_TO_LATIN1((U8) c) != 0xF7) \ || NATIVE_TO_LATIN1((U8) c) == 0xAA \ || NATIVE_TO_LATIN1((U8) c) == 0xBA \ || NATIVE_TO_LATIN1((U8) c) == 0xB5))) #endif #ifndef isOCTAL # define isOCTAL(c) (((WIDEST_UTYPE)((c)) & ~7) == '0') #endif #ifndef isOCTAL_L1 # define isOCTAL_L1(c) isOCTAL(c) #endif #ifndef isPRINT # define isPRINT(c) (isGRAPH(c) || (c) == ' ') #endif #ifndef isPRINT_L1 # define isPRINT_L1(c) (FITS_IN_8_BITS(c) && ! isCNTRL_L1(c)) #endif #ifndef isPSXSPC # define isPSXSPC(c) isSPACE(c) #endif #ifndef isPSXSPC_L1 # define isPSXSPC_L1(c) isSPACE_L1(c) #endif #ifndef isPUNCT # define isPUNCT(c) ( (c) == '-' || (c) == '!' || (c) == '"' \ || (c) == '#' || (c) == '$' || (c) == '%' \ || (c) == '&' || (c) == '\'' || (c) == '(' \ || (c) == ')' || (c) == '*' || (c) == '+' \ || (c) == ',' || (c) == '.' || (c) == '/' \ || (c) == ':' || (c) == ';' || (c) == '<' \ || (c) == '=' || (c) == '>' || (c) == '?' \ || (c) == '@' || (c) == '[' || (c) == '\\' \ || (c) == ']' || (c) == '^' || (c) == '_' \ || (c) == '`' || (c) == '{' || (c) == '|' \ || (c) == '}' || (c) == '~') #endif #ifndef isPUNCT_L1 # define isPUNCT_L1(c) ( isPUNCT(c) \ || ( FITS_IN_8_BITS(c) \ && ( NATIVE_TO_LATIN1((U8) c) == 0xA1 \ || NATIVE_TO_LATIN1((U8) c) == 0xA7 \ || NATIVE_TO_LATIN1((U8) c) == 0xAB \ || NATIVE_TO_LATIN1((U8) c) == 0xB6 \ || NATIVE_TO_LATIN1((U8) c) == 0xB7 \ || NATIVE_TO_LATIN1((U8) c) == 0xBB \ || NATIVE_TO_LATIN1((U8) c) == 0xBF))) #endif #ifndef isSPACE # define isSPACE(c) ( isBLANK(c) || (c) == '\n' || (c) == '\r' \ || (c) == '\v' || (c) == '\f') #endif #ifndef isSPACE_L1 # define isSPACE_L1(c) ( isSPACE(c) \ || (FITS_IN_8_BITS(c) \ && ( NATIVE_TO_LATIN1((U8) c) == 0x85 \ || NATIVE_TO_LATIN1((U8) c) == 0xA0))) #endif #ifndef isUPPER_L1 # define isUPPER_L1(c) ( isUPPER(c) \ || (FITS_IN_8_BITS(c) \ && ( NATIVE_TO_LATIN1((U8) c) >= 0xC0 \ && NATIVE_TO_LATIN1((U8) c) <= 0xDE \ && NATIVE_TO_LATIN1((U8) c) != 0xD7))) #endif #ifndef isWORDCHAR # define isWORDCHAR(c) (isALPHANUMERIC(c) || (c) == '_') #endif #ifndef isWORDCHAR_L1 # define isWORDCHAR_L1(c) (isIDFIRST_L1(c) || isDIGIT(c)) #endif #ifndef isWORDCHAR_LC # define isWORDCHAR_LC(c) (isIDFIRST_LC(c) || isDIGIT_LC(c)) #endif #ifndef isXDIGIT # define isXDIGIT(c) ( isDIGIT(c) \ || inRANGE((c), 'a', 'f') \ || inRANGE((c), 'A', 'F')) #endif #ifndef isXDIGIT_L1 # define isXDIGIT_L1(c) isXDIGIT(c) #endif #ifndef isXDIGIT_LC # define isXDIGIT_LC(c) isxdigit(c) #endif #ifndef isALNUM_A # define isALNUM_A(c) isALNUM(c) #endif #ifndef isALNUMC_A # define isALNUMC_A(c) isALNUMC(c) #endif #ifndef isALPHA_A # define isALPHA_A(c) isALPHA(c) #endif #ifndef isALPHANUMERIC_A # define isALPHANUMERIC_A(c) isALPHANUMERIC(c) #endif #ifndef isASCII_A # define isASCII_A(c) isASCII(c) #endif #ifndef isBLANK_A # define isBLANK_A(c) isBLANK(c) #endif #ifndef isCNTRL_A # define isCNTRL_A(c) isCNTRL(c) #endif #ifndef isDIGIT_A # define isDIGIT_A(c) isDIGIT(c) #endif #ifndef isGRAPH_A # define isGRAPH_A(c) isGRAPH(c) #endif #ifndef isIDCONT_A # define isIDCONT_A(c) isIDCONT(c) #endif #ifndef isIDFIRST_A # define isIDFIRST_A(c) isIDFIRST(c) #endif #ifndef isLOWER_A # define isLOWER_A(c) isLOWER(c) #endif #ifndef isOCTAL_A # define isOCTAL_A(c) isOCTAL(c) #endif #ifndef isPRINT_A # define isPRINT_A(c) isPRINT(c) #endif #ifndef isPSXSPC_A # define isPSXSPC_A(c) isPSXSPC(c) #endif #ifndef isPUNCT_A # define isPUNCT_A(c) isPUNCT(c) #endif #ifndef isSPACE_A # define isSPACE_A(c) isSPACE(c) #endif #ifndef isUPPER_A # define isUPPER_A(c) isUPPER(c) #endif #ifndef isWORDCHAR_A # define isWORDCHAR_A(c) isWORDCHAR(c) #endif #ifndef isXDIGIT_A # define isXDIGIT_A(c) isXDIGIT(c) #endif #ifndef isASCII_utf8_safe # define isASCII_utf8_safe(s,e) (((e) - (s)) <= 0 ? 0 : isASCII(*(s))) #endif #ifndef isASCII_uvchr # define isASCII_uvchr(c) (FITS_IN_8_BITS(c) ? isASCII_L1(c) : 0) #endif #if (PERL_BCDVERSION >= 0x5006000) # ifdef isALPHA_uni /* If one defined, all are; this is just an exemplar */ # define D_PPP_is_ctype(upper, lower, c) \ (FITS_IN_8_BITS(c) \ ? is ## upper ## _L1(c) \ : is ## upper ## _uni((UV) (c))) /* _uni is old synonym */ # else # define D_PPP_is_ctype(upper, lower, c) \ (FITS_IN_8_BITS(c) \ ? is ## upper ## _L1(c) \ : is_uni_ ## lower((UV) (c))) /* is_uni_ is even older */ # endif #ifndef isALPHA_uvchr # define isALPHA_uvchr(c) D_PPP_is_ctype(ALPHA, alpha, c) #endif #ifndef isALPHANUMERIC_uvchr # define isALPHANUMERIC_uvchr(c) (isALPHA_uvchr(c) || isDIGIT_uvchr(c)) #endif # ifdef is_uni_blank #ifndef isBLANK_uvchr # define isBLANK_uvchr(c) D_PPP_is_ctype(BLANK, blank, c) #endif # else #ifndef isBLANK_uvchr # define isBLANK_uvchr(c) (FITS_IN_8_BITS(c) \ ? isBLANK_L1(c) \ : ( (UV) (c) == 0x1680 /* Unicode 3.0 */ \ || inRANGE((UV) (c), 0x2000, 0x200A) \ || (UV) (c) == 0x202F /* Unicode 3.0 */\ || (UV) (c) == 0x205F /* Unicode 3.2 */\ || (UV) (c) == 0x3000)) #endif # endif #ifndef isCNTRL_uvchr # define isCNTRL_uvchr(c) D_PPP_is_ctype(CNTRL, cntrl, c) #endif #ifndef isDIGIT_uvchr # define isDIGIT_uvchr(c) D_PPP_is_ctype(DIGIT, digit, c) #endif #ifndef isGRAPH_uvchr # define isGRAPH_uvchr(c) D_PPP_is_ctype(GRAPH, graph, c) #endif #ifndef isIDCONT_uvchr # define isIDCONT_uvchr(c) isWORDCHAR_uvchr(c) #endif #ifndef isIDFIRST_uvchr # define isIDFIRST_uvchr(c) D_PPP_is_ctype(IDFIRST, idfirst, c) #endif #ifndef isLOWER_uvchr # define isLOWER_uvchr(c) D_PPP_is_ctype(LOWER, lower, c) #endif #ifndef isPRINT_uvchr # define isPRINT_uvchr(c) D_PPP_is_ctype(PRINT, print, c) #endif #ifndef isPSXSPC_uvchr # define isPSXSPC_uvchr(c) isSPACE_uvchr(c) #endif #ifndef isPUNCT_uvchr # define isPUNCT_uvchr(c) D_PPP_is_ctype(PUNCT, punct, c) #endif #ifndef isSPACE_uvchr # define isSPACE_uvchr(c) D_PPP_is_ctype(SPACE, space, c) #endif #ifndef isUPPER_uvchr # define isUPPER_uvchr(c) D_PPP_is_ctype(UPPER, upper, c) #endif #ifndef isXDIGIT_uvchr # define isXDIGIT_uvchr(c) D_PPP_is_ctype(XDIGIT, xdigit, c) #endif #ifndef isWORDCHAR_uvchr # define isWORDCHAR_uvchr(c) (FITS_IN_8_BITS(c) \ ? isWORDCHAR_L1(c) : isALPHANUMERIC_uvchr(c)) #endif #ifndef isALPHA_utf8_safe # define isALPHA_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, ALPHA) #endif # ifdef isALPHANUMERIC_utf8 #ifndef isALPHANUMERIC_utf8_safe # define isALPHANUMERIC_utf8_safe(s,e) \ D_PPP_IS_GENERIC_UTF8_SAFE(s, e, ALPHANUMERIC) #endif # else #ifndef isALPHANUMERIC_utf8_safe # define isALPHANUMERIC_utf8_safe(s,e) \ (isALPHA_utf8_safe(s,e) || isDIGIT_utf8_safe(s,e)) #endif # endif /* This was broken before 5.18, and just use this instead of worrying about * which releases the official works on */ # if 'A' == 65 #ifndef isBLANK_utf8_safe # define isBLANK_utf8_safe(s,e) \ ( ( LIKELY((e) > (s)) ) ? /* Machine generated */ \ ( ( 0x09 == ((const U8*)s)[0] || 0x20 == ((const U8*)s)[0] ) ? 1 \ : ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) ? \ ( ( 0xC2 == ((const U8*)s)[0] ) ? \ ( ( 0xA0 == ((const U8*)s)[1] ) ? 2 : 0 ) \ : ( 0xE1 == ((const U8*)s)[0] ) ? \ ( ( ( 0x9A == ((const U8*)s)[1] ) && ( 0x80 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : ( 0xE2 == ((const U8*)s)[0] ) ? \ ( ( 0x80 == ((const U8*)s)[1] ) ? \ ( ( inRANGE(((const U8*)s)[2], 0x80, 0x8A ) || 0xAF == ((const U8*)s)[2] ) ? 3 : 0 )\ : ( ( 0x81 == ((const U8*)s)[1] ) && ( 0x9F == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : ( ( ( 0xE3 == ((const U8*)s)[0] ) && ( 0x80 == ((const U8*)s)[1] ) ) && ( 0x80 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : 0 ) \ : 0 ) #endif # elif 'A' == 193 && '^' == 95 /* EBCDIC 1047 */ #ifndef isBLANK_utf8_safe # define isBLANK_utf8_safe(s,e) \ ( ( LIKELY((e) > (s)) ) ? \ ( ( 0x05 == ((const U8*)s)[0] || 0x40 == ((const U8*)s)[0] ) ? 1 \ : ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) ? \ ( ( 0x80 == ((const U8*)s)[0] ) ? \ ( ( 0x41 == ((const U8*)s)[1] ) ? 2 : 0 ) \ : ( 0xBC == ((const U8*)s)[0] ) ? \ ( ( ( 0x63 == ((const U8*)s)[1] ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : ( 0xCA == ((const U8*)s)[0] ) ? \ ( ( 0x41 == ((const U8*)s)[1] ) ? \ ( ( inRANGE(((const U8*)s)[2], 0x41, 0x4A ) || 0x51 == ((const U8*)s)[2] ) ? 3 : 0 )\ : ( 0x42 == ((const U8*)s)[1] ) ? \ ( ( 0x56 == ((const U8*)s)[2] ) ? 3 : 0 ) \ : ( ( 0x43 == ((const U8*)s)[1] ) && ( 0x73 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : ( ( ( 0xCE == ((const U8*)s)[0] ) && ( 0x41 == ((const U8*)s)[1] ) ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : 0 ) \ : 0 ) #endif # elif 'A' == 193 && '^' == 176 /* EBCDIC 037 */ #ifndef isBLANK_utf8_safe # define isBLANK_utf8_safe(s,e) \ ( ( LIKELY((e) > (s)) ) ? \ ( ( 0x05 == ((const U8*)s)[0] || 0x40 == ((const U8*)s)[0] ) ? 1 \ : ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) ? \ ( ( 0x78 == ((const U8*)s)[0] ) ? \ ( ( 0x41 == ((const U8*)s)[1] ) ? 2 : 0 ) \ : ( 0xBD == ((const U8*)s)[0] ) ? \ ( ( ( 0x62 == ((const U8*)s)[1] ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : ( 0xCA == ((const U8*)s)[0] ) ? \ ( ( 0x41 == ((const U8*)s)[1] ) ? \ ( ( inRANGE(((const U8*)s)[2], 0x41, 0x4A ) || 0x51 == ((const U8*)s)[2] ) ? 3 : 0 )\ : ( 0x42 == ((const U8*)s)[1] ) ? \ ( ( 0x56 == ((const U8*)s)[2] ) ? 3 : 0 ) \ : ( ( 0x43 == ((const U8*)s)[1] ) && ( 0x72 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : ( ( ( 0xCE == ((const U8*)s)[0] ) && ( 0x41 == ((const U8*)s)[1] ) ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\ : 0 ) \ : 0 ) #endif # else # error Unknown character set # endif #ifndef isCNTRL_utf8_safe # define isCNTRL_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, CNTRL) #endif #ifndef isDIGIT_utf8_safe # define isDIGIT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, DIGIT) #endif #ifndef isGRAPH_utf8_safe # define isGRAPH_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, GRAPH) #endif # ifdef isIDCONT_utf8 #ifndef isIDCONT_utf8_safe # define isIDCONT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, IDCONT) #endif # else #ifndef isIDCONT_utf8_safe # define isIDCONT_utf8_safe(s,e) isWORDCHAR_utf8_safe(s,e) #endif # endif #ifndef isIDFIRST_utf8_safe # define isIDFIRST_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, IDFIRST) #endif #ifndef isLOWER_utf8_safe # define isLOWER_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, LOWER) #endif #ifndef isPRINT_utf8_safe # define isPRINT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, PRINT) #endif # undef isPSXSPC_utf8_safe /* Use the modern definition */ #ifndef isPSXSPC_utf8_safe # define isPSXSPC_utf8_safe(s,e) isSPACE_utf8_safe(s,e) #endif #ifndef isPUNCT_utf8_safe # define isPUNCT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, PUNCT) #endif #ifndef isSPACE_utf8_safe # define isSPACE_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, SPACE) #endif #ifndef isUPPER_utf8_safe # define isUPPER_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, UPPER) #endif # ifdef isWORDCHAR_utf8 #ifndef isWORDCHAR_utf8_safe # define isWORDCHAR_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, WORDCHAR) #endif # else #ifndef isWORDCHAR_utf8_safe # define isWORDCHAR_utf8_safe(s,e) \ (isALPHANUMERIC_utf8_safe(s,e) || (*(s)) == '_') #endif # endif /* This was broken before 5.12, and just use this instead of worrying about * which releases the official works on */ # if 'A' == 65 #ifndef isXDIGIT_utf8_safe # define isXDIGIT_utf8_safe(s,e) \ ( ( LIKELY((e) > (s)) ) ? \ ( ( inRANGE(((const U8*)s)[0], 0x30, 0x39 ) || inRANGE(((const U8*)s)[0], 0x41, 0x46 ) || inRANGE(((const U8*)s)[0], 0x61, 0x66 ) ) ? 1\ : ( ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) && ( 0xEF == ((const U8*)s)[0] ) ) ? ( ( 0xBC == ((const U8*)s)[1] ) ?\ ( ( inRANGE(((const U8*)s)[2], 0x90, 0x99 ) || inRANGE(((const U8*)s)[2], 0xA1, 0xA6 ) ) ? 3 : 0 )\ : ( ( 0xBD == ((const U8*)s)[1] ) && ( inRANGE(((const U8*)s)[2], 0x81, 0x86 ) ) ) ? 3 : 0 ) : 0 )\ : 0 ) #endif # elif 'A' == 193 && '^' == 95 /* EBCDIC 1047 */ #ifndef isXDIGIT_utf8_safe # define isXDIGIT_utf8_safe(s,e) \ ( ( LIKELY((e) > (s)) ) ? \ ( ( inRANGE(((const U8*)s)[0], 0x81, 0x86 ) || inRANGE(((const U8*)s)[0], 0xC1, 0xC6 ) || inRANGE(((const U8*)s)[0], 0xF0, 0xF9 ) ) ? 1\ : ( ( ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) && ( 0xDD == ((const U8*)s)[0] ) ) && ( 0x73 == ((const U8*)s)[1] ) ) ? ( ( 0x67 == ((const U8*)s)[2] ) ?\ ( ( inRANGE(((const U8*)s)[3], 0x57, 0x59 ) || inRANGE(((const U8*)s)[3], 0x62, 0x68 ) ) ? 4 : 0 )\ : ( ( inRANGE(((const U8*)s)[2], 0x68, 0x69 ) ) && ( inRANGE(((const U8*)s)[3], 0x42, 0x47 ) ) ) ? 4 : 0 ) : 0 )\ : 0 ) #endif # elif 'A' == 193 && '^' == 176 /* EBCDIC 037 */ #ifndef isXDIGIT_utf8_safe # define isXDIGIT_utf8_safe(s,e) \ ( ( LIKELY((e) > (s)) ) ? \ ( ( inRANGE(((const U8*)s)[0], 0x81, 0x86 ) || inRANGE(((const U8*)s)[0], 0xC1, 0xC6 ) || inRANGE(((const U8*)s)[0], 0xF0, 0xF9 ) ) ? 1\ : ( ( ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) && ( 0xDD == ((const U8*)s)[0] ) ) && ( 0x72 == ((const U8*)s)[1] ) ) ? ( ( 0x66 == ((const U8*)s)[2] ) ?\ ( ( inRANGE(((const U8*)s)[3], 0x57, 0x59 ) || 0x5F == ((const U8*)s)[3] || inRANGE(((const U8*)s)[3], 0x62, 0x67 ) ) ? 4 : 0 )\ : ( ( inRANGE(((const U8*)s)[2], 0x67, 0x68 ) ) && ( inRANGE(((const U8*)s)[3], 0x42, 0x47 ) ) ) ? 4 : 0 ) : 0 )\ : 0 ) #endif # else # error Unknown character set # endif #ifndef isALPHA_LC_utf8_safe # define isALPHA_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, ALPHA) #endif # ifdef isALPHANUMERIC_utf8 #ifndef isALPHANUMERIC_LC_utf8_safe # define isALPHANUMERIC_LC_utf8_safe(s,e) \ D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, ALPHANUMERIC) #endif # else #ifndef isALPHANUMERIC_LC_utf8_safe # define isALPHANUMERIC_LC_utf8_safe(s,e) \ (isALPHA_LC_utf8_safe(s,e) || isDIGIT_LC_utf8_safe(s,e)) #endif # endif #ifndef isBLANK_LC_utf8_safe # define isBLANK_LC_utf8_safe(s,e) \ D_PPP_IS_GENERIC_LC_UTF8_SAFE_BROKEN(s, e, BLANK) #endif #ifndef isCNTRL_LC_utf8_safe # define isCNTRL_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, CNTRL) #endif #ifndef isDIGIT_LC_utf8_safe # define isDIGIT_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, DIGIT) #endif #ifndef isGRAPH_LC_utf8_safe # define isGRAPH_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, GRAPH) #endif # ifdef isIDCONT_utf8 #ifndef isIDCONT_LC_utf8_safe # define isIDCONT_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, IDCONT) #endif # else #ifndef isIDCONT_LC_utf8_safe # define isIDCONT_LC_utf8_safe(s,e) isWORDCHAR_LC_utf8_safe(s,e) #endif # endif #ifndef isIDFIRST_LC_utf8_safe # define isIDFIRST_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, IDFIRST) #endif #ifndef isLOWER_LC_utf8_safe # define isLOWER_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, LOWER) #endif #ifndef isPRINT_LC_utf8_safe # define isPRINT_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, PRINT) #endif # undef isPSXSPC_LC_utf8_safe /* Use the modern definition */ #ifndef isPSXSPC_LC_utf8_safe # define isPSXSPC_LC_utf8_safe(s,e) isSPACE_LC_utf8_safe(s,e) #endif #ifndef isPUNCT_LC_utf8_safe # define isPUNCT_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, PUNCT) #endif #ifndef isSPACE_LC_utf8_safe # define isSPACE_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, SPACE) #endif #ifndef isUPPER_LC_utf8_safe # define isUPPER_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, UPPER) #endif # ifdef isWORDCHAR_utf8 #ifndef isWORDCHAR_LC_utf8_safe # define isWORDCHAR_LC_utf8_safe(s,e) D_PPP_IS_GENERIC_LC_UTF8_SAFE(s, e, WORDCHAR) #endif # else #ifndef isWORDCHAR_LC_utf8_safe # define isWORDCHAR_LC_utf8_safe(s,e) \ (isALPHANUMERIC_LC_utf8_safe(s,e) || (*(s)) == '_') #endif # endif #ifndef isXDIGIT_LC_utf8_safe # define isXDIGIT_LC_utf8_safe(s,e) \ D_PPP_IS_GENERIC_LC_UTF8_SAFE_BROKEN(s, e, XDIGIT) #endif /* Warning: isALPHANUMERIC_utf8_safe, isALPHA_utf8_safe, isASCII_utf8_safe, * isBLANK_utf8_safe, isCNTRL_utf8_safe, isDIGIT_utf8_safe, isGRAPH_utf8_safe, * isIDCONT_utf8_safe, isIDFIRST_utf8_safe, isLOWER_utf8_safe, * isPRINT_utf8_safe, isPSXSPC_utf8_safe, isPUNCT_utf8_safe, isSPACE_utf8_safe, * isUPPER_utf8_safe, isWORDCHAR_utf8_safe, isWORDCHAR_utf8_safe, * isXDIGIT_utf8_safe, * isALPHANUMERIC_LC_utf8_safe, isALPHA_LC_utf8_safe, isASCII_LC_utf8_safe, * isBLANK_LC_utf8_safe, isCNTRL_LC_utf8_safe, isDIGIT_LC_utf8_safe, * isGRAPH_LC_utf8_safe, isIDCONT_LC_utf8_safe, isIDFIRST_LC_utf8_safe, * isLOWER_LC_utf8_safe, isPRINT_LC_utf8_safe, isPSXSPC_LC_utf8_safe, * isPUNCT_LC_utf8_safe, isSPACE_LC_utf8_safe, isUPPER_LC_utf8_safe, * isWORDCHAR_LC_utf8_safe, isWORDCHAR_LC_utf8_safe, isXDIGIT_LC_utf8_safe, * isALPHANUMERIC_uvchr, isALPHA_uvchr, isASCII_uvchr, isBLANK_uvchr, * isCNTRL_uvchr, isDIGIT_uvchr, isGRAPH_uvchr, isIDCONT_uvchr, * isIDFIRST_uvchr, isLOWER_uvchr, isPRINT_uvchr, isPSXSPC_uvchr, * isPUNCT_uvchr, isSPACE_uvchr, isUPPER_uvchr, isWORDCHAR_uvchr, * isWORDCHAR_uvchr, isXDIGIT_uvchr * * The UTF-8 handling is buggy in early Perls, and this can give inaccurate * results for code points above 0xFF, until the implementation started * settling down in 5.12 and 5.14 */ #endif #define D_PPP_TOO_SHORT_MSG "Malformed UTF-8 character starting with:" \ " \\x%02x (too short; %d bytes available, need" \ " %d)\n" /* Perls starting here had a new API which handled multi-character results */ #if (PERL_BCDVERSION >= 0x5007003) #ifndef toLOWER_uvchr # define toLOWER_uvchr(c, s, l) UNI_TO_NATIVE(to_uni_lower(NATIVE_TO_UNI(c), s, l)) #endif #ifndef toUPPER_uvchr # define toUPPER_uvchr(c, s, l) UNI_TO_NATIVE(to_uni_upper(NATIVE_TO_UNI(c), s, l)) #endif #ifndef toTITLE_uvchr # define toTITLE_uvchr(c, s, l) UNI_TO_NATIVE(to_uni_title(NATIVE_TO_UNI(c), s, l)) #endif #ifndef toFOLD_uvchr # define toFOLD_uvchr(c, s, l) UNI_TO_NATIVE(to_uni_fold( NATIVE_TO_UNI(c), s, l)) #endif # if (PERL_BCDVERSION != 0x5015006) /* Just this version is broken */ /* Prefer the macro to the function */ # if defined toLOWER_utf8 # define D_PPP_TO_LOWER_CALLEE(s,r,l) toLOWER_utf8(s,r,l) # else # define D_PPP_TO_LOWER_CALLEE(s,r,l) to_utf8_lower(s,r,l) # endif # if defined toTITLE_utf8 # define D_PPP_TO_TITLE_CALLEE(s,r,l) toTITLE_utf8(s,r,l) # else # define D_PPP_TO_TITLE_CALLEE(s,r,l) to_utf8_title(s,r,l) # endif # if defined toUPPER_utf8 # define D_PPP_TO_UPPER_CALLEE(s,r,l) toUPPER_utf8(s,r,l) # else # define D_PPP_TO_UPPER_CALLEE(s,r,l) to_utf8_upper(s,r,l) # endif # if defined toFOLD_utf8 # define D_PPP_TO_FOLD_CALLEE(s,r,l) toFOLD_utf8(s,r,l) # else # define D_PPP_TO_FOLD_CALLEE(s,r,l) to_utf8_fold(s,r,l) # endif # else /* Below is 5.15.6, which failed to make the macros available # outside of core, so we have to use the 'Perl_' form. khw # decided it was easier to just handle this case than have to # document the exception, and make an exception in the tests below # */ # define D_PPP_TO_LOWER_CALLEE(s,r,l) \ Perl__to_utf8_lower_flags(aTHX_ s, r, l, 0, NULL) # define D_PPP_TO_TITLE_CALLEE(s,r,l) \ Perl__to_utf8_title_flags(aTHX_ s, r, l, 0, NULL) # define D_PPP_TO_UPPER_CALLEE(s,r,l) \ Perl__to_utf8_upper_flags(aTHX_ s, r, l, 0, NULL) # define D_PPP_TO_FOLD_CALLEE(s,r,l) \ Perl__to_utf8_fold_flags(aTHX_ s, r, l, FOLD_FLAGS_FULL, NULL) # endif /* The actual implementation of the backported macros. If too short, croak, * otherwise call the original that doesn't have an upper limit parameter */ # define D_PPP_GENERIC_MULTI_ARG_TO(name, s, e,r,l) \ (((((e) - (s)) <= 0) \ /* We could just do nothing, but modern perls croak */ \ ? (croak("Attempting case change on zero length string"), \ 0) /* So looks like it returns something, and will compile */ \ : ((e) - (s)) < UTF8SKIP(s)) \ ? (croak(D_PPP_TOO_SHORT_MSG, \ s[0], (int) ((e) - (s)), (int) UTF8SKIP(s)), \ 0) \ : D_PPP_TO_ ## name ## _CALLEE(s,r,l)) #ifndef toUPPER_utf8_safe # define toUPPER_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_MULTI_ARG_TO(UPPER,s,e,r,l) #endif #ifndef toLOWER_utf8_safe # define toLOWER_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_MULTI_ARG_TO(LOWER,s,e,r,l) #endif #ifndef toTITLE_utf8_safe # define toTITLE_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_MULTI_ARG_TO(TITLE,s,e,r,l) #endif #ifndef toFOLD_utf8_safe # define toFOLD_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_MULTI_ARG_TO(FOLD,s,e,r,l) #endif #elif (PERL_BCDVERSION >= 0x5006000) /* Here we have UTF-8 support, but using the original API where the case * changing functions merely returned the changed code point; hence they * couldn't handle multi-character results. */ # ifdef uvchr_to_utf8 # define D_PPP_UV_TO_UTF8 uvchr_to_utf8 # else # define D_PPP_UV_TO_UTF8 uv_to_utf8 # endif /* Get the utf8 of the case changed value, and store its length; then have * to re-calculate the changed case value in order to return it */ # define D_PPP_GENERIC_SINGLE_ARG_TO_UVCHR(name, c, s, l) \ (*(l) = (D_PPP_UV_TO_UTF8(s, \ UNI_TO_NATIVE(to_uni_ ## name(NATIVE_TO_UNI(c)))) - (s)), \ UNI_TO_NATIVE(to_uni_ ## name(NATIVE_TO_UNI(c)))) #ifndef toLOWER_uvchr # define toLOWER_uvchr(c, s, l) \ D_PPP_GENERIC_SINGLE_ARG_TO_UVCHR(lower, c, s, l) #endif #ifndef toUPPER_uvchr # define toUPPER_uvchr(c, s, l) \ D_PPP_GENERIC_SINGLE_ARG_TO_UVCHR(upper, c, s, l) #endif #ifndef toTITLE_uvchr # define toTITLE_uvchr(c, s, l) \ D_PPP_GENERIC_SINGLE_ARG_TO_UVCHR(title, c, s, l) #endif #ifndef toFOLD_uvchr # define toFOLD_uvchr(c, s, l) toLOWER_uvchr(c, s, l) #endif # define D_PPP_GENERIC_SINGLE_ARG_TO_UTF8(name, s, e, r, l) \ (((((e) - (s)) <= 0) \ ? (croak("Attempting case change on zero length string"), \ 0) /* So looks like it returns something, and will compile */ \ : ((e) - (s)) < UTF8SKIP(s)) \ ? (croak(D_PPP_TOO_SHORT_MSG, \ s[0], (int) ((e) - (s)), (int) UTF8SKIP(s)), \ 0) \ /* Get the changed code point and store its UTF-8 */ \ : D_PPP_UV_TO_UTF8(r, to_utf8_ ## name(s)), \ /* Then store its length, and re-get code point for return */ \ *(l) = UTF8SKIP(r), to_utf8_ ## name(r)) /* Warning: toUPPER_utf8_safe, toLOWER_utf8_safe, toTITLE_utf8_safe, * toUPPER_uvchr, toLOWER_uvchr, toTITLE_uvchr The UTF-8 case changing operations had bugs before around 5.12 or 5.14; this backport does not correct them. In perls before 7.3, multi-character case changing is not implemented; this backport uses the simple case changes available in those perls. */ #ifndef toUPPER_utf8_safe # define toUPPER_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_SINGLE_ARG_TO_UTF8(upper, s, e, r, l) #endif #ifndef toLOWER_utf8_safe # define toLOWER_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_SINGLE_ARG_TO_UTF8(lower, s, e, r, l) #endif #ifndef toTITLE_utf8_safe # define toTITLE_utf8_safe(s,e,r,l) \ D_PPP_GENERIC_SINGLE_ARG_TO_UTF8(title, s, e, r, l) #endif /* Warning: toFOLD_utf8_safe, toFOLD_uvchr The UTF-8 case changing operations had bugs before around 5.12 or 5.14; this backport does not correct them. In perls before 7.3, case folding is not implemented; instead, this backport substitutes simple (not multi-character, which isn't available) lowercasing. This gives the correct result in most, but not all, instances */ #ifndef toFOLD_utf8_safe # define toFOLD_utf8_safe(s,e,r,l) toLOWER_utf8_safe(s,e,r,l) #endif #endif /* Until we figure out how to support this in older perls... */ #if (PERL_BCDVERSION >= 0x5008000) #ifndef HeUTF8 # define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \ SvUTF8(HeKEY_sv(he)) : \ (U32)HeKUTF8(he)) #endif #endif #ifndef C_ARRAY_LENGTH # define C_ARRAY_LENGTH(a) (sizeof(a)/sizeof((a)[0])) #endif #ifndef C_ARRAY_END # define C_ARRAY_END(a) ((a) + C_ARRAY_LENGTH(a)) #endif #ifndef LIKELY # define LIKELY(x) (x) #endif #ifndef UNLIKELY # define UNLIKELY(x) (x) #endif #ifndef MUTABLE_PTR #if defined(PERL_USE_GCC_BRACE_GROUPS) # define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) #else # define MUTABLE_PTR(p) ((void *) (p)) #endif #endif #ifndef MUTABLE_AV # define MUTABLE_AV(p) ((AV *)MUTABLE_PTR(p)) #endif #ifndef MUTABLE_CV # define MUTABLE_CV(p) ((CV *)MUTABLE_PTR(p)) #endif #ifndef MUTABLE_GV # define MUTABLE_GV(p) ((GV *)MUTABLE_PTR(p)) #endif #ifndef MUTABLE_HV # define MUTABLE_HV(p) ((HV *)MUTABLE_PTR(p)) #endif #ifndef MUTABLE_IO # define MUTABLE_IO(p) ((IO *)MUTABLE_PTR(p)) #endif #ifndef MUTABLE_SV # define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(PERL_USE_GCC_BRACE_GROUPS) # define vnewSVpvf(pat, args) ({ SV *_sv = newSV(0); sv_vsetpvfn(_sv, (pat), strlen((pat)), (args), Null(SV**), 0, Null(bool*)); _sv; }) #else # define vnewSVpvf(pat, args) ((PL_Sv = newSV(0)), sv_vsetpvfn(PL_Sv, (pat), strlen((pat)), (args), Null(SV**), 0, Null(bool*)), PL_Sv) #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * const sv, const char * const pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * const sv, const char * const pat, ...); #endif #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * const sv, const char * const pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * const sv, const char * const pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * const sv, const char * const pat, ...); #endif #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) void DPPP_(my_sv_catpvf_mg_nocontext)(SV * const sv, const char * const pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * const sv, const char * const pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * const sv, const char * const pat, ...); #endif #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * const sv, const char * const pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * const sv, const char * const pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * const sv, const char * const pat, ...); #endif #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) void DPPP_(my_sv_setpvf_mg_nocontext)(SV * const sv, const char * const pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #ifndef sv_2pvbyte # define sv_2pvbyte(sv, lp) (sv_utf8_downgrade((sv), 0), SvPV((sv), *(lp))) #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ /* Replace sv_2pvbyte with SvPVbyte */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Replace sv_pvn with SvPV */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* Replace sv_pvn_force with SvPV_force */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if defined(PERL_USE_GCC_BRACE_GROUPS) #ifndef sv_2pv_flags # define sv_2pv_flags(sv, lp, flags) ({ SV *_sv = (sv); const I32 _flags = (flags); STRLEN *_lp = lp; _lp = _lp ? : &PL_na; (!(_flags & SV_GMAGIC) && SvGMAGICAL(_sv)) ? ({ char *_pv; SvGMAGICAL_off(_sv); _pv = sv_2pv(_sv, _lp); SvGMAGICAL_on(_sv); _pv; }) : sv_2pv(_sv, _lp); }) #endif #ifndef sv_pvn_force_flags # define sv_pvn_force_flags(sv, lp, flags) ({ SV *_sv = (sv); const I32 _flags = (flags); STRLEN *_lp = lp; _lp = _lp ? : &PL_na; (!(_flags & SV_GMAGIC) && SvGMAGICAL(_sv)) ? ({ char *_pv; SvGMAGICAL_off(_sv); _pv = sv_pvn_force(_sv, _lp); SvGMAGICAL_on(_sv); _pv; }) : sv_pvn_force(_sv, _lp); }) #endif #else #ifndef sv_2pv_flags # define sv_2pv_flags(sv, lp, flags) ((PL_Sv = (sv)), (!((flags) & SV_GMAGIC) && SvGMAGICAL(PL_Sv)) ? (SvGMAGICAL_off(PL_Sv), (PL_Xpv = (XPV *)sv_2pv(PL_Sv, (lp) ? (lp) : &PL_na)), SvGMAGICAL_on(PL_Sv), (char *)PL_Xpv) : sv_2pv(PL_Sv, (lp) ? (lp) : &PL_na)) #endif #ifndef sv_pvn_force_flags # define sv_pvn_force_flags(sv, lp, flags) ((PL_Sv = (sv)), (!((flags) & SV_GMAGIC) && SvGMAGICAL(PL_Sv)) ? (SvGMAGICAL_off(PL_Sv), (PL_Xpv = (XPV *)sv_pvn_force(PL_Sv, (lp) ? (lp) : &PL_na)), SvGMAGICAL_on(PL_Sv), (char *)PL_Xpv) : sv_pvn_force(PL_Sv, (lp) ? (lp) : &PL_na)) #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define D_PPP_SVPV_NOLEN_LP_ARG &PL_na #else # define D_PPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif # if defined(PERL_USE_GCC_BRACE_GROUPS) #ifndef SvPVx_nolen_const # define SvPVx_nolen_const(sv) ({SV *sV_ = (sv); SvPV_nolen_const(sV_); }) #endif # else #ifndef SvPVx_nolen_const # define SvPVx_nolen_const(sv) (PL_Sv = sv, SvPV_nolen_const(PL_Sv)) #endif # endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_nomg_nolen # define SvPV_nomg_nolen(sv) ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, 0)) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvPVCLEAR # define SvPVCLEAR(sv) sv_setpvs((sv), "") #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef packWARN2 # define packWARN2(a,b) (packWARN(a) << 8 | (b)) #endif #ifndef packWARN3 # define packWARN3(a,b,c) (packWARN2(a,b) << 8 | (c)) #endif #ifndef packWARN4 # define packWARN4(a,b,c,d) (packWARN3(a,b,c) << 8 | (d)) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #ifndef ckWARN2 # define ckWARN2(a,b) (ckWARN(a) || ckWARN(b)) #endif #ifndef ckWARN3 # define ckWARN3(a,b,c) (ckWARN(c) || ckWARN2(a,b)) #endif #ifndef ckWARN4 # define ckWARN4(a,b,c,d) (ckWARN(d) || ckWARN3(a,b,c)) #endif #ifndef ckWARN_d # ifdef isLEXWARN_off # define ckWARN_d(a) (isLEXWARN_off || ckWARN(a)) # else # define ckWARN_d(a) 1 # endif #endif #ifndef ckWARN2_d # define ckWARN2_d(a,b) (ckWARN_d(a) || ckWARN_d(b)) #endif #ifndef ckWARN3_d # define ckWARN3_d(a,b,c) (ckWARN_d(c) || ckWARN2_d(a,b)) #endif #ifndef ckWARN4_d # define ckWARN4_d(a,b,c,d) (ckWARN_d(d) || ckWARN3_d(a,b,c)) #endif #ifndef vwarner # define vwarner(err, pat, argsp) \ STMT_START { SV *sv; \ PERL_UNUSED_ARG(err); \ sv = vnewSVpvf(pat, argsp); \ sv_2mortal(sv); \ warn("%s", SvPV_nolen(sv)); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) # if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char * pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char * pat, ...); #endif #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) #define Perl_warner DPPP_(my_warner) void DPPP_(my_warner)(U32 err, const char *pat, ...) { va_list args; va_start(args, pat); vwarner(err, pat, &args); va_end(args); } # define warner Perl_warner # define Perl_warner_nocontext Perl_warner # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(ck_warner) # if defined(NEED_ck_warner) static void DPPP_(my_ck_warner)(pTHX_ U32 err, const char * pat, ...); static #else extern void DPPP_(my_ck_warner)(pTHX_ U32 err, const char * pat, ...); #endif #if defined(NEED_ck_warner) || defined(NEED_ck_warner_GLOBAL) #define Perl_ck_warner DPPP_(my_ck_warner) void DPPP_(my_ck_warner)(pTHX_ U32 err, const char *pat, ...) { va_list args; if ( ! ckWARN((err ) & 0xFF) && ! ckWARN((err >> 8) & 0xFF) && ! ckWARN((err >> 16) & 0xFF) && ! ckWARN((err >> 24) & 0xFF)) { return; } va_start(args, pat); vwarner(err, pat, &args); va_end(args); } # define ck_warner Perl_ck_warner # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(ck_warner_d) # if defined(NEED_ck_warner_d) static void DPPP_(my_ck_warner_d)(pTHX_ U32 err, const char * pat, ...); static #else extern void DPPP_(my_ck_warner_d)(pTHX_ U32 err, const char * pat, ...); #endif #if defined(NEED_ck_warner_d) || defined(NEED_ck_warner_d_GLOBAL) #define Perl_ck_warner_d DPPP_(my_ck_warner_d) void DPPP_(my_ck_warner_d)(pTHX_ U32 err, const char *pat, ...) { va_list args; if ( ! ckWARN_d((err ) & 0xFF) && ! ckWARN_d((err >> 8) & 0xFF) && ! ckWARN_d((err >> 16) & 0xFF) && ! ckWARN_d((err >> 24) & 0xFF)) { return; } va_start(args, pat); vwarner(err, pat, &args); va_end(args); } # define ck_warner_d Perl_ck_warner_d # endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # elif IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # else # error "cannot define IV/UV formats" # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #if defined(PERL_USE_GCC_BRACE_GROUPS) #ifndef sv_2uv # define sv_2uv(sv) ({ SV *_sv = (sv); (UV) (SvNOK(_sv) ? SvNV(_sv) : sv_2nv(_sv)); }) #endif #else #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #if defined(PERL_USE_GCC_BRACE_GROUPS) #ifndef SvUVx # define SvUVx(sv) ({ SV *_sv = (sv)); SvUV(_sv); }) #endif #else #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ /* Replace sv_uv with SvUVx */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #if !defined(my_strnlen) #if defined(NEED_my_strnlen) static Size_t DPPP_(my_my_strnlen)(const char * str, Size_t maxlen); static #else extern Size_t DPPP_(my_my_strnlen)(const char * str, Size_t maxlen); #endif #if defined(NEED_my_strnlen) || defined(NEED_my_strnlen_GLOBAL) #define my_strnlen DPPP_(my_my_strnlen) #define Perl_my_strnlen DPPP_(my_my_strnlen) Size_t DPPP_(my_my_strnlen)(const char *str, Size_t maxlen) { const char *p = str; while(maxlen-- && *p) p++; return p - str; } #endif #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef memEQs # define memEQs(s1, l, s2) \ (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) #endif #ifndef memNEs # define memNEs(s1, l, s2) !memEQs(s1, l, s2) #endif #ifndef memCHRs # define memCHRs(s, c) ((const char *) memchr("" s "" , c, sizeof(s)-1)) #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifdef NEED_mess_sv #define NEED_mess #endif #ifdef NEED_mess #define NEED_mess_nocontext #define NEED_vmess #endif #ifndef croak_sv #if (PERL_BCDVERSION >= 0x5007003) || ( (PERL_BCDVERSION >= 0x5006001) && (PERL_BCDVERSION < 0x5007000) ) # if ( (PERL_BCDVERSION >= 0x5008000) && (PERL_BCDVERSION < 0x5008009) ) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5010001) ) # define D_PPP_FIX_UTF8_ERRSV_FOR_SV(sv) \ STMT_START { \ SV *_errsv = ERRSV; \ SvFLAGS(_errsv) = (SvFLAGS(_errsv) & ~SVf_UTF8) | \ (SvFLAGS(sv) & SVf_UTF8); \ } STMT_END # else # define D_PPP_FIX_UTF8_ERRSV_FOR_SV(sv) STMT_START {} STMT_END # endif # define croak_sv(sv) \ STMT_START { \ SV *_sv = (sv); \ if (SvROK(_sv)) { \ sv_setsv(ERRSV, _sv); \ croak(NULL); \ } else { \ D_PPP_FIX_UTF8_ERRSV_FOR_SV(_sv); \ croak("%" SVf, SVfARG(_sv)); \ } \ } STMT_END #elif (PERL_BCDVERSION >= 0x5004000) # define croak_sv(sv) croak("%" SVf, SVfARG(sv)) #else # define croak_sv(sv) croak("%s", SvPV_nolen(sv)) #endif #endif #ifndef die_sv #if defined(NEED_die_sv) static OP * DPPP_(my_die_sv)(pTHX_ SV * baseex); static #else extern OP * DPPP_(my_die_sv)(pTHX_ SV * baseex); #endif #if defined(NEED_die_sv) || defined(NEED_die_sv_GLOBAL) #ifdef die_sv # undef die_sv #endif #define die_sv(a) DPPP_(my_die_sv)(aTHX_ a) #define Perl_die_sv DPPP_(my_die_sv) OP * DPPP_(my_die_sv)(pTHX_ SV *baseex) { croak_sv(baseex); return (OP *)NULL; } #endif #endif #ifndef warn_sv #if (PERL_BCDVERSION >= 0x5004000) # define warn_sv(sv) warn("%" SVf, SVfARG(sv)) #else # define warn_sv(sv) warn("%s", SvPV_nolen(sv)) #endif #endif #if ! defined vmess && (PERL_BCDVERSION >= 0x5004000) # if defined(NEED_vmess) static SV * DPPP_(my_vmess)(pTHX_ const char * pat, va_list * args); static #else extern SV * DPPP_(my_vmess)(pTHX_ const char * pat, va_list * args); #endif #if defined(NEED_vmess) || defined(NEED_vmess_GLOBAL) #ifdef vmess # undef vmess #endif #define vmess(a,b) DPPP_(my_vmess)(aTHX_ a,b) #define Perl_vmess DPPP_(my_vmess) SV* DPPP_(my_vmess)(pTHX_ const char* pat, va_list* args) { mess(pat, args); return PL_mess_sv; } # endif #endif #if (PERL_BCDVERSION < 0x5006000) && (PERL_BCDVERSION >= 0x5004000) #undef mess #endif #if !defined(mess_nocontext) && !defined(Perl_mess_nocontext) && (PERL_BCDVERSION >= 0x5004000) #if defined(NEED_mess_nocontext) static SV * DPPP_(my_mess_nocontext)(const char * pat, ...); static #else extern SV * DPPP_(my_mess_nocontext)(const char * pat, ...); #endif #if defined(NEED_mess_nocontext) || defined(NEED_mess_nocontext_GLOBAL) #define mess_nocontext DPPP_(my_mess_nocontext) #define Perl_mess_nocontext DPPP_(my_mess_nocontext) SV* DPPP_(my_mess_nocontext)(const char* pat, ...) { dTHX; SV *sv; va_list args; va_start(args, pat); sv = vmess(pat, &args); va_end(args); return sv; } #endif #endif #ifndef mess #if defined(NEED_mess) static SV * DPPP_(my_mess)(pTHX_ const char * pat, ...); static #else extern SV * DPPP_(my_mess)(pTHX_ const char * pat, ...); #endif #if defined(NEED_mess) || defined(NEED_mess_GLOBAL) #define Perl_mess DPPP_(my_mess) SV* DPPP_(my_mess)(pTHX_ const char* pat, ...) { SV *sv; va_list args; va_start(args, pat); sv = vmess(pat, &args); va_end(args); return sv; } #ifdef mess_nocontext #define mess mess_nocontext #else #define mess Perl_mess_nocontext #endif #endif #endif #if ! defined mess_sv && (PERL_BCDVERSION >= 0x5004000) #if defined(NEED_mess_sv) static SV * DPPP_(my_mess_sv)(pTHX_ SV * basemsg, bool consume); static #else extern SV * DPPP_(my_mess_sv)(pTHX_ SV * basemsg, bool consume); #endif #if defined(NEED_mess_sv) || defined(NEED_mess_sv_GLOBAL) #ifdef mess_sv # undef mess_sv #endif #define mess_sv(a,b) DPPP_(my_mess_sv)(aTHX_ a,b) #define Perl_mess_sv DPPP_(my_mess_sv) SV * DPPP_(my_mess_sv)(pTHX_ SV *basemsg, bool consume) { SV *tmp; SV *ret; if (SvPOK(basemsg) && SvCUR(basemsg) && *(SvEND(basemsg)-1) == '\n') { if (consume) return basemsg; ret = mess(""); SvSetSV_nosteal(ret, basemsg); return ret; } if (consume) { sv_catsv(basemsg, mess("")); return basemsg; } ret = mess(""); tmp = newSVsv(ret); SvSetSV_nosteal(ret, basemsg); sv_catsv(ret, tmp); sv_dec(tmp); return ret; } #endif #endif #ifndef warn_nocontext #define warn_nocontext warn #endif #ifndef croak_nocontext #define croak_nocontext croak #endif #ifndef croak_no_modify #define croak_no_modify() croak_nocontext("%s", PL_no_modify) #define Perl_croak_no_modify() croak_no_modify() #endif #ifndef croak_memory_wrap #if (PERL_BCDVERSION >= 0x5009002) || ( (PERL_BCDVERSION >= 0x5008006) && (PERL_BCDVERSION < 0x5009000) ) # define croak_memory_wrap() croak_nocontext("%s", PL_memory_wrap) #else # define croak_memory_wrap() croak_nocontext("panic: memory wrap") #endif #endif #ifndef croak_xs_usage #if defined(NEED_croak_xs_usage) static void DPPP_(my_croak_xs_usage)(const CV * const cv, const char * const params); static #else extern void DPPP_(my_croak_xs_usage)(const CV * const cv, const char * const params); #endif #if defined(NEED_croak_xs_usage) || defined(NEED_croak_xs_usage_GLOBAL) #define croak_xs_usage DPPP_(my_croak_xs_usage) #define Perl_croak_xs_usage DPPP_(my_croak_xs_usage) #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) void DPPP_(my_croak_xs_usage)(const CV *const cv, const char *const params) { dTHX; const GV *const gv = CvGV(cv); PERL_ARGS_ASSERT_CROAK_XS_USAGE; if (gv) { const char *const gvname = GvNAME(gv); const HV *const stash = GvSTASH(gv); const char *const hvname = stash ? HvNAME(stash) : NULL; if (hvname) croak("Usage: %s::%s(%s)", hvname, gvname, params); else croak("Usage: %s(%s)", gvname, params); } else { /* Pants. I don't think that it should be possible to get here. */ croak("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); } } #endif #endif #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif #if (PERL_BCDVERSION >= 0x5003098) && (PERL_BCDVERSION < 0x5006000) #ifndef eval_pv # define eval_pv perl_eval_pv #endif #endif /* Replace: 0 */ #if (PERL_BCDVERSION < 0x5006000) #ifndef Perl_eval_sv # define Perl_eval_sv perl_eval_sv #endif #if (PERL_BCDVERSION >= 0x5003098) #ifndef Perl_eval_pv # define Perl_eval_pv perl_eval_pv #endif #endif #endif #ifndef G_LIST # define G_LIST G_ARRAY /* Replace */ #endif #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #if defined(PERL_USE_GCC_BRACE_GROUPS) # define D_PPP_CROAK_IF_ERROR(cond) ({ \ SV *_errsv; \ ( (cond) \ && (_errsv = ERRSV) \ && (SvROK(_errsv) || SvTRUE(_errsv)) \ && (croak_sv(_errsv), 1)); \ }) #else PERL_STATIC_INLINE void D_PPP_CROAK_IF_ERROR(int cond) { dTHX; SV *errsv; if (!cond) return; errsv = ERRSV; if (SvROK(errsv) || SvTRUE(errsv)) croak_sv(errsv); } # define D_PPP_CROAK_IF_ERROR(cond) D_PPP_CROAK_IF_ERROR(cond) #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif #ifndef G_RETHROW # define G_RETHROW 8192 # ifdef eval_sv # undef eval_sv # endif # if defined(PERL_USE_GCC_BRACE_GROUPS) # define eval_sv(sv, flags) ({ I32 _flags = (flags); I32 _ret = Perl_eval_sv(aTHX_ sv, (_flags & ~G_RETHROW)); D_PPP_CROAK_IF_ERROR(_flags & G_RETHROW); _ret; }) # else # define eval_sv(sv, flags) ((PL_na = Perl_eval_sv(aTHX_ sv, ((flags) & ~G_RETHROW))), D_PPP_CROAK_IF_ERROR((flags) & G_RETHROW), (I32)PL_na) # endif #endif /* Older Perl versions have broken croak_on_error=1 */ #if (PERL_BCDVERSION < 0x5031002) # ifdef eval_pv # undef eval_pv # if defined(PERL_USE_GCC_BRACE_GROUPS) # define eval_pv(p, croak_on_error) ({ SV *_sv = Perl_eval_pv(aTHX_ p, 0); D_PPP_CROAK_IF_ERROR(croak_on_error); _sv; }) # else # define eval_pv(p, croak_on_error) ((PL_Sv = Perl_eval_pv(aTHX_ p, 0)), D_PPP_CROAK_IF_ERROR(croak_on_error), PL_Sv) # endif # endif #endif /* This is backport for Perl 5.3.97d and older which do not provide perl_eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV * DPPP_(my_eval_pv)(const char * p, I32 croak_on_error); static #else extern SV * DPPP_(my_eval_pv)(const char * p, I32 croak_on_error); #endif #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) SV* DPPP_(my_eval_pv)(const char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; D_PPP_CROAK_IF_ERROR(croak_on_error); return sv; } #endif #endif #if ! defined(vload_module) && defined(start_subparse) #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV * name, SV * ver, va_list * args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV * name, SV * ver, va_list * args); #endif #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compiling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compiling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), #if (PERL_BCDVERSION > 0x5003000) veop, #endif modname, imop); PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV * name, SV * ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV * name, SV * ver, ...); #endif #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(PERL_USE_GCC_BRACE_GROUPS) # define newRV_noinc(sv) ({ SV *_sv = (SV *)newRV((sv)); SvREFCNT_dec((sv)); _sv; }) #else # define newRV_noinc(sv) ((PL_Sv = (SV *)newRV((sv))), SvREFCNT_dec((sv)), PL_Sv) #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(PERL_USE_GCC_BRACE_GROUPS) # define newSV_type(t) ({ SV *_sv = newSV(0); sv_upgrade(_sv, (t)); _sv; }) #else # define newSV_type(t) ((PL_Sv = newSV(0)), sv_upgrade(PL_Sv, (t)), PL_Sv) #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags # if defined(PERL_USE_GCC_BRACE_GROUPS) # define newSVpvn_flags(s, len, flags) \ ({ \ SV * sv = newSVpvn(D_PPP_CONSTPV_ARG(s), (len)); \ SvFLAGS(sv) |= ((flags) & SVf_UTF8); \ if ((flags) & SVs_TEMP) sv = sv_2mortal(sv); \ sv; \ }) # else PERL_STATIC_INLINE SV* D_PPP_newSVpvn_flags(const char *const s, const STRLEN len, const U32 flags) { dTHX; SV * sv = newSVpvn(s, len)); SvFLAGS(sv) |= (flags & SVf_UTF8); if (flags & SVs_TEMP) return sv_2mortal(sv); return sv; } # define newSVpvn_flags(s, len, flags) D_PPP_newSVpvn_flags((s), (len), (flags)); # endif #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 16 #endif #if ( (PERL_BCDVERSION >= 0x5007003) && (PERL_BCDVERSION < 0x5008007) ) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009002) ) #undef sv_setsv_flags #if defined(PERL_USE_GCC_BRACE_GROUPS) #define sv_setsv_flags(dstr, sstr, flags) \ STMT_START { \ if (((flags) & SV_NOSTEAL) && (sstr) && (SvFLAGS((SV *)(sstr)) & SVs_TEMP)) { \ SvTEMP_off((SV *)(sstr)); \ Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL); \ SvTEMP_on((SV *)(sstr)); \ } else { \ Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL); \ } \ } STMT_END #else #define sv_setsv_flags(dstr, sstr, flags) \ ( \ (((flags) & SV_NOSTEAL) && (sstr) && (SvFLAGS((SV *)(sstr)) & SVs_TEMP)) ? ( \ SvTEMP_off((SV *)(sstr)), \ Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL), \ SvTEMP_on((SV *)(sstr)), \ 1 \ ) : ( \ Perl_sv_setsv_flags(aTHX_ (dstr), (sstr), (flags) & ~SV_NOSTEAL), \ 1 \ ) \ ) #endif #endif #if defined(PERL_USE_GCC_BRACE_GROUPS) #ifndef sv_setsv_flags # define sv_setsv_flags(dstr, sstr, flags) \ STMT_START { \ if (((flags) & SV_NOSTEAL) && (sstr) && (SvFLAGS((SV *)(sstr)) & SVs_TEMP)) { \ SvTEMP_off((SV *)(sstr)); \ if (!((flags) & SV_GMAGIC) && (sstr) && SvGMAGICAL((SV *)(sstr))) { \ SvGMAGICAL_off((SV *)(sstr)); \ sv_setsv((dstr), (sstr)); \ SvGMAGICAL_on((SV *)(sstr)); \ } else { \ sv_setsv((dstr), (sstr)); \ } \ SvTEMP_on((SV *)(sstr)); \ } else { \ if (!((flags) & SV_GMAGIC) && (sstr) && SvGMAGICAL((SV *)(sstr))) { \ SvGMAGICAL_off((SV *)(sstr)); \ sv_setsv((dstr), (sstr)); \ SvGMAGICAL_on((SV *)(sstr)); \ } else { \ sv_setsv((dstr), (sstr)); \ } \ } \ } STMT_END #endif #else #ifndef sv_setsv_flags # define sv_setsv_flags(dstr, sstr, flags) \ ( \ (((flags) & SV_NOSTEAL) && (sstr) && (SvFLAGS((SV *)(sstr)) & SVs_TEMP)) ? ( \ SvTEMP_off((SV *)(sstr)), \ (!((flags) & SV_GMAGIC) && (sstr) && SvGMAGICAL((SV *)(sstr))) ? ( \ SvGMAGICAL_off((SV *)(sstr)), \ sv_setsv((dstr), (sstr)), \ SvGMAGICAL_on((SV *)(sstr)), \ 1 \ ) : ( \ sv_setsv((dstr), (sstr)), \ 1 \ ), \ SvTEMP_on((SV *)(sstr)), \ 1 \ ) : ( \ (!((flags) & SV_GMAGIC) && (sstr) && SvGMAGICAL((SV *)(sstr))) ? ( \ SvGMAGICAL_off((SV *)(sstr)), \ sv_setsv((dstr), (sstr)), \ SvGMAGICAL_on((SV *)(sstr)), \ 1 \ ) : ( \ sv_setsv((dstr), (sstr)), \ 1 \ ) \ ) \ ) #endif #endif #ifndef newSVsv_flags # if defined(PERL_USE_GCC_BRACE_GROUPS) # define newSVsv_flags(sv, flags) \ ({ \ SV *new = newSV(0); \ sv_setsv_flags(new, (sv), (flags)); \ new; \ }) # else PERL_STATIC_INLINE SV* D_PPP_newSVsv_flags(SV *const old, I32 flags) { dTHX; SV *new = newSV(0); sv_setsv_flags(new, old, flags); return new; } # define newSVsv_flags(sv, flags) D_PPP_newSVsv_flags(sv, flags) # endif #endif #ifndef newSVsv_nomg # define newSVsv_nomg(sv) newSVsv_flags((sv), SV_NOSTEAL) #endif #if (PERL_BCDVERSION >= 0x5017005) #ifndef sv_mortalcopy_flags # define sv_mortalcopy_flags(sv, flags) Perl_sv_mortalcopy_flags(aTHX_ (sv), (flags)) #endif #else #ifndef sv_mortalcopy_flags # define sv_mortalcopy_flags(sv, flags) sv_2mortal(newSVsv_flags((sv), (flags))) #endif #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif /* Hint: newSVpvn_share * The SVs created by this function only mimic the behaviour of * shared PVs without really being shared. Only use if you know * what you're doing. */ #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char * s, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char * s, I32 len, U32 hash); #endif #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *s, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) s, len); sv = newSVpvn((char *) s, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #if (PERL_BCDVERSION >= 0x5009002) && (PERL_BCDVERSION <= 0x5009003) /* 5.9.2 and 5.9.3 ignore the length param */ #undef gv_fetchpvn_flags #endif #ifdef GV_NOADD_MASK # define D_PPP_GV_NOADD_MASK GV_NOADD_MASK #else # define D_PPP_GV_NOADD_MASK 0xE0 #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, sv_type) gv_fetchpv(SvPVX(sv_2mortal(newSVpvn((name), (len)))), ((flags) & D_PPP_GV_NOADD_MASK) ? FALSE : TRUE, (I32)(sv_type)) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef gv_fetchsv # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt) #endif #ifndef get_cvn_flags # define get_cvn_flags(name, namelen, flags) get_cv(name, flags) #endif #ifndef gv_init_pvn # define gv_init_pvn(gv, stash, ptr, len, flags) gv_init(gv, stash, ptr, len, flags & GV_ADDMULTI ? TRUE : FALSE) #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef newSVpvs_share # define newSVpvs_share(str) newSVpvn_share(str "", sizeof(str) - 1, 0) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef get_cvs # define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags) #endif #undef SvGETMAGIC #ifndef SvGETMAGIC # define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x))) #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifdef SVf_IVisUV #if defined(PERL_USE_GCC_BRACE_GROUPS) #ifndef SvIV_nomg # define SvIV_nomg(sv) (!SvGMAGICAL((sv)) ? SvIV((sv)) : ({ SV *_sviv = sv_mortalcopy_flags((sv), SV_NOSTEAL); IV _iv = SvIV(_sviv); SvFLAGS((sv)) = (SvFLAGS((sv)) & ~SVf_IVisUV) | (SvFLAGS(_sviv) & SVf_IVisUV); _iv; })) #endif #ifndef SvUV_nomg # define SvUV_nomg(sv) (!SvGMAGICAL((sv)) ? SvUV((sv)) : ({ SV *_svuv = sv_mortalcopy_flags((sv), SV_NOSTEAL); UV _uv = SvUV(_svuv); SvFLAGS((sv)) = (SvFLAGS((sv)) & ~SVf_IVisUV) | (SvFLAGS(_svuv) & SVf_IVisUV); _uv; })) #endif #else #ifndef SvIV_nomg # define SvIV_nomg(sv) (!SvGMAGICAL((sv)) ? SvIV((sv)) : ((PL_Sv = sv_mortalcopy_flags((sv), SV_NOSTEAL)), sv_upgrade(PL_Sv, SVt_PVIV), (SvIVX(PL_Sv) = SvIV(PL_Sv)), (SvFLAGS((sv)) = (SvFLAGS((sv)) & ~SVf_IVisUV) | (SvFLAGS(PL_Sv) & SVf_IVisUV)), SvIVX(PL_Sv))) #endif #ifndef SvUV_nomg # define SvUV_nomg(sv) (!SvGMAGICAL((sv)) ? SvIV((sv)) : ((PL_Sv = sv_mortalcopy_flags((sv), SV_NOSTEAL)), sv_upgrade(PL_Sv, SVt_PVIV), (SvUVX(PL_Sv) = SvUV(PL_Sv)), (SvFLAGS((sv)) = (SvFLAGS((sv)) & ~SVf_IVisUV) | (SvFLAGS(PL_Sv) & SVf_IVisUV)), SvUVX(PL_Sv))) #endif #endif #else #ifndef SvIV_nomg # define SvIV_nomg(sv) (!SvGMAGICAL((sv)) ? SvIV((sv)) : SvIVx(sv_mortalcopy_flags((sv), SV_NOSTEAL))) #endif #ifndef SvUV_nomg # define SvUV_nomg(sv) (!SvGMAGICAL((sv)) ? SvUV((sv)) : SvUVx(sv_mortalcopy_flags((sv), SV_NOSTEAL))) #endif #endif #ifndef SvNV_nomg # define SvNV_nomg(sv) (!SvGMAGICAL((sv)) ? SvNV((sv)) : SvNVx(sv_mortalcopy_flags((sv), SV_NOSTEAL))) #endif #ifndef SvTRUE_nomg # define SvTRUE_nomg(sv) (!SvGMAGICAL((sv)) ? SvTRUE((sv)) : SvTRUEx(sv_mortalcopy_flags((sv), SV_NOSTEAL))) #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #if !defined(mg_findext) #if defined(NEED_mg_findext) static MAGIC * DPPP_(my_mg_findext)(const SV * sv, int type, const MGVTBL * vtbl); static #else extern MAGIC * DPPP_(my_mg_findext)(const SV * sv, int type, const MGVTBL * vtbl); #endif #if defined(NEED_mg_findext) || defined(NEED_mg_findext_GLOBAL) #define mg_findext DPPP_(my_mg_findext) #define Perl_mg_findext DPPP_(my_mg_findext) MAGIC * DPPP_(my_mg_findext)(const SV * sv, int type, const MGVTBL *vtbl) { if (sv) { MAGIC *mg; #ifdef AvPAD_NAMELIST assert(!(SvTYPE(sv) == SVt_PVAV && AvPAD_NAMELIST(sv))); #endif for (mg = SvMAGIC (sv); mg; mg = mg->mg_moremagic) { if (mg->mg_type == type && mg->mg_virtual == vtbl) return mg; } } return NULL; } #endif #endif #if !defined(sv_unmagicext) #if defined(NEED_sv_unmagicext) static int DPPP_(my_sv_unmagicext)(pTHX_ SV * const sv, const int type, MGVTBL * vtbl); static #else extern int DPPP_(my_sv_unmagicext)(pTHX_ SV * const sv, const int type, MGVTBL * vtbl); #endif #if defined(NEED_sv_unmagicext) || defined(NEED_sv_unmagicext_GLOBAL) #ifdef sv_unmagicext # undef sv_unmagicext #endif #define sv_unmagicext(a,b,c) DPPP_(my_sv_unmagicext)(aTHX_ a,b,c) #define Perl_sv_unmagicext DPPP_(my_sv_unmagicext) int DPPP_(my_sv_unmagicext)(pTHX_ SV *const sv, const int type, MGVTBL *vtbl) { MAGIC* mg; MAGIC** mgp; if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv)) return 0; mgp = &(SvMAGIC(sv)); for (mg = *mgp; mg; mg = *mgp) { const MGVTBL* const virt = mg->mg_virtual; if (mg->mg_type == type && virt == vtbl) { *mgp = mg->mg_moremagic; if (virt && virt->svt_free) virt->svt_free(aTHX_ sv, mg); if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) { if (mg->mg_len > 0) Safefree(mg->mg_ptr); else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */ SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr)); else if (mg->mg_type == PERL_MAGIC_utf8) Safefree(mg->mg_ptr); } if (mg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(mg->mg_obj); Safefree(mg); } else mgp = &mg->mg_moremagic; } if (SvMAGIC(sv)) { if (SvMAGICAL(sv)) /* if we're under save_magic, wait for restore_magic; */ mg_magical(sv); /* else fix the flags now */ } else { SvMAGICAL_off(sv); SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; } return 0; } #endif #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #if (PERL_BCDVERSION >= 0x5006000) #ifndef caller_cx # if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) static I32 DPPP_dopoptosub_at(const PERL_CONTEXT *cxstk, I32 startingblock) { I32 i; for (i = startingblock; i >= 0; i--) { const PERL_CONTEXT * const cx = &cxstk[i]; switch (CxTYPE(cx)) { default: continue; case CXt_EVAL: case CXt_SUB: case CXt_FORMAT: return i; } } return i; } # endif # if defined(NEED_caller_cx) static const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 level, const PERL_CONTEXT * * dbcxp); static #else extern const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 level, const PERL_CONTEXT * * dbcxp); #endif #if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) #ifdef caller_cx # undef caller_cx #endif #define caller_cx(a,b) DPPP_(my_caller_cx)(aTHX_ a,b) #define Perl_caller_cx DPPP_(my_caller_cx) const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 level, const PERL_CONTEXT **dbcxp) { I32 cxix = DPPP_dopoptosub_at(cxstack, cxstack_ix); const PERL_CONTEXT *cx; const PERL_CONTEXT *ccstack = cxstack; const PERL_SI *top_si = PL_curstackinfo; for (;;) { /* we may be in a higher stacklevel, so dig down deeper */ while (cxix < 0 && top_si->si_type != PERLSI_MAIN) { top_si = top_si->si_prev; ccstack = top_si->si_cxstack; cxix = DPPP_dopoptosub_at(ccstack, top_si->si_cxix); } if (cxix < 0) return NULL; /* caller() should not report the automatic calls to &DB::sub */ if (PL_DBsub && GvCV(PL_DBsub) && cxix >= 0 && ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) level++; if (!level--) break; cxix = DPPP_dopoptosub_at(ccstack, cxix - 1); } cx = &ccstack[cxix]; if (dbcxp) *dbcxp = cx; if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) { const I32 dbcxix = DPPP_dopoptosub_at(ccstack, cxix - 1); /* We expect that ccstack[dbcxix] is CXt_SUB, anyway, the field below is defined for any cx. */ /* caller() should not report the automatic calls to &DB::sub */ if (PL_DBsub && GvCV(PL_DBsub) && dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub)) cx = &ccstack[dbcxix]; } return cx; } # endif #endif /* caller_cx */ #endif /* 5.6.0 */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char * * sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char * * sp, const char * send); #endif #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) #define my_sprintf DPPP_(my_my_sprintf) /* Warning: my_sprintf It's safer to use my_snprintf instead */ /* Replace my_sprintf with my_snprintf */ int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifdef SVf_UTF8 #ifndef SvUTF8 # define SvUTF8(sv) (SvFLAGS(sv) & SVf_UTF8) #endif #endif #if (PERL_BCDVERSION == 0x5019001) /* 5.19.1 does not have UTF8fARG, only broken UTF8f */ #undef UTF8f #endif #ifdef SVf_UTF8 #ifndef UTF8f # define UTF8f SVf #endif #ifndef UTF8fARG # define UTF8fARG(u,l,p) newSVpvn_flags((p), (l), ((u) ? SVf_UTF8 : 0) | SVs_TEMP) #endif #endif #define D_PPP_MIN(a,b) (((a) <= (b)) ? (a) : (b)) #ifndef UNICODE_REPLACEMENT # define UNICODE_REPLACEMENT 0xFFFD #endif #ifdef UTF8_MAXLEN #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #endif #ifndef UTF_START_MARK # define UTF_START_MARK(len) \ (((len) > 7) ? 0xFF : (0xFF & (0xFE << (7-(len))))) #endif /* On non-EBCDIC was valid for some releases earlier than this, but easier to * just do one check */ #if (PERL_BCDVERSION < 0x5018000) # undef UTF8_MAXBYTES_CASE #endif #if 'A' == 65 # define D_PPP_BYTE_INFO_BITS 6 /* 6 bits meaningful in continuation bytes */ #ifndef UTF8_MAXBYTES_CASE # define UTF8_MAXBYTES_CASE 13 #endif #else # define D_PPP_BYTE_INFO_BITS 5 /* 5 bits meaningful in continuation bytes */ #ifndef UTF8_MAXBYTES_CASE # define UTF8_MAXBYTES_CASE 15 #endif #endif #ifndef UTF_ACCUMULATION_SHIFT # define UTF_ACCUMULATION_SHIFT D_PPP_BYTE_INFO_BITS #endif #ifdef NATIVE_TO_UTF #ifndef NATIVE_UTF8_TO_I8 # define NATIVE_UTF8_TO_I8(c) NATIVE_TO_UTF(c) #endif #else /* System doesn't support EBCDIC */ #ifndef NATIVE_UTF8_TO_I8 # define NATIVE_UTF8_TO_I8(c) (c) #endif #endif #ifdef UTF_TO_NATIVE #ifndef I8_TO_NATIVE_UTF8 # define I8_TO_NATIVE_UTF8(c) UTF_TO_NATIVE(c) #endif #else /* System doesn't support EBCDIC */ #ifndef I8_TO_NATIVE_UTF8 # define I8_TO_NATIVE_UTF8(c) (c) #endif #endif #ifndef UTF_START_MASK # define UTF_START_MASK(len) \ (((len) >= 7) ? 0x00 : (0x1F >> ((len)-2))) #endif #ifndef UTF_IS_CONTINUATION_MASK # define UTF_IS_CONTINUATION_MASK \ ((U8) (0xFF << UTF_ACCUMULATION_SHIFT)) #endif #ifndef UTF_CONTINUATION_MARK # define UTF_CONTINUATION_MARK \ (UTF_IS_CONTINUATION_MASK & 0xB0) #endif #ifndef UTF_MIN_START_BYTE # define UTF_MIN_START_BYTE \ ((UTF_CONTINUATION_MARK >> UTF_ACCUMULATION_SHIFT) | UTF_START_MARK(2)) #endif #ifndef UTF_MIN_ABOVE_LATIN1_BYTE # define UTF_MIN_ABOVE_LATIN1_BYTE \ ((0x100 >> UTF_ACCUMULATION_SHIFT) | UTF_START_MARK(2)) #endif #if (PERL_BCDVERSION < 0x5007000) /* Was the complement of what should have been */ # undef UTF8_IS_DOWNGRADEABLE_START #endif #ifndef UTF8_IS_DOWNGRADEABLE_START # define UTF8_IS_DOWNGRADEABLE_START(c) \ inRANGE(NATIVE_UTF8_TO_I8(c), \ UTF_MIN_START_BYTE, UTF_MIN_ABOVE_LATIN1_BYTE - 1) #endif #ifndef UTF_CONTINUATION_MASK # define UTF_CONTINUATION_MASK \ ((U8) ((1U << UTF_ACCUMULATION_SHIFT) - 1)) #endif #ifndef UTF8_ACCUMULATE # define UTF8_ACCUMULATE(base, added) \ (((base) << UTF_ACCUMULATION_SHIFT) \ | ((NATIVE_UTF8_TO_I8(added)) \ & UTF_CONTINUATION_MASK)) #endif #ifndef UTF8_ALLOW_ANYUV # define UTF8_ALLOW_ANYUV 0 #endif #ifndef UTF8_ALLOW_EMPTY # define UTF8_ALLOW_EMPTY 0x0001 #endif #ifndef UTF8_ALLOW_CONTINUATION # define UTF8_ALLOW_CONTINUATION 0x0002 #endif #ifndef UTF8_ALLOW_NON_CONTINUATION # define UTF8_ALLOW_NON_CONTINUATION 0x0004 #endif #ifndef UTF8_ALLOW_SHORT # define UTF8_ALLOW_SHORT 0x0008 #endif #ifndef UTF8_ALLOW_LONG # define UTF8_ALLOW_LONG 0x0010 #endif #ifndef UTF8_ALLOW_OVERFLOW # define UTF8_ALLOW_OVERFLOW 0x0080 #endif #ifndef UTF8_ALLOW_ANY # define UTF8_ALLOW_ANY ( UTF8_ALLOW_CONTINUATION \ |UTF8_ALLOW_NON_CONTINUATION \ |UTF8_ALLOW_SHORT \ |UTF8_ALLOW_LONG \ |UTF8_ALLOW_OVERFLOW) #endif #if defined UTF8SKIP /* Don't use official versions because they use MIN, which may not be available */ #undef UTF8_SAFE_SKIP #undef UTF8_CHK_SKIP #ifndef UTF8_SAFE_SKIP # define UTF8_SAFE_SKIP(s, e) ( \ ((((e) - (s)) <= 0) \ ? 0 \ : D_PPP_MIN(((e) - (s)), UTF8SKIP(s)))) #endif #ifndef UTF8_CHK_SKIP # define UTF8_CHK_SKIP(s) \ (s[0] == '\0' ? 1 : ((U8) D_PPP_MIN(my_strnlen((char *) (s), UTF8SKIP(s)), \ UTF8SKIP(s)))) #endif /* UTF8_CHK_SKIP depends on my_strnlen */ #ifndef UTF8_SKIP # define UTF8_SKIP(s) UTF8SKIP(s) #endif #endif #if 'A' == 65 #ifndef UTF8_IS_INVARIANT # define UTF8_IS_INVARIANT(c) isASCII(c) #endif #else #ifndef UTF8_IS_INVARIANT # define UTF8_IS_INVARIANT(c) (isASCII(c) || isCNTRL_L1(c)) #endif #endif #ifndef UVCHR_IS_INVARIANT # define UVCHR_IS_INVARIANT(c) UTF8_IS_INVARIANT(c) #endif #ifdef UVCHR_IS_INVARIANT # if 'A' != 65 || UVSIZE < 8 /* 32 bit platform, which includes UTF-EBCDIC on the releases this is * backported to */ # define D_PPP_UVCHR_SKIP_UPPER(c) 7 # else # define D_PPP_UVCHR_SKIP_UPPER(c) \ (((WIDEST_UTYPE) (c)) < \ (((WIDEST_UTYPE) 1) << (6 * D_PPP_BYTE_INFO_BITS)) ? 7 : 13) # endif #ifndef UVCHR_SKIP # define UVCHR_SKIP(c) \ UVCHR_IS_INVARIANT(c) ? 1 : \ (WIDEST_UTYPE) (c) < (32 * (1U << ( D_PPP_BYTE_INFO_BITS))) ? 2 : \ (WIDEST_UTYPE) (c) < (16 * (1U << (2 * D_PPP_BYTE_INFO_BITS))) ? 3 : \ (WIDEST_UTYPE) (c) < ( 8 * (1U << (3 * D_PPP_BYTE_INFO_BITS))) ? 4 : \ (WIDEST_UTYPE) (c) < ( 4 * (1U << (4 * D_PPP_BYTE_INFO_BITS))) ? 5 : \ (WIDEST_UTYPE) (c) < ( 2 * (1U << (5 * D_PPP_BYTE_INFO_BITS))) ? 6 : \ D_PPP_UVCHR_SKIP_UPPER(c) #endif #endif #ifdef is_ascii_string #ifndef is_invariant_string # define is_invariant_string(s,l) is_ascii_string(s,l) #endif #ifndef is_utf8_invariant_string # define is_utf8_invariant_string(s,l) is_ascii_string(s,l) #endif /* Hint: is_ascii_string, is_invariant_string is_utf8_invariant_string() does the same thing and is preferred because its name is more accurate as to what it does */ #endif #ifdef ibcmp_utf8 #ifndef foldEQ_utf8 # define foldEQ_utf8(s1,pe1,l1,u1,s2,pe2,l2,u2) \ cBOOL(! ibcmp_utf8(s1,pe1,l1,u1,s2,pe2,l2,u2)) #endif #endif #if defined(is_utf8_string) && defined(UTF8SKIP) #ifndef isUTF8_CHAR # define isUTF8_CHAR(s, e) ( \ (e) <= (s) || ! is_utf8_string(s, UTF8_SAFE_SKIP(s, e)) \ ? 0 \ : UTF8SKIP(s)) #endif #endif #if 'A' == 65 #ifndef BOM_UTF8 # define BOM_UTF8 "\xEF\xBB\xBF" #endif #ifndef REPLACEMENT_CHARACTER_UTF8 # define REPLACEMENT_CHARACTER_UTF8 "\xEF\xBF\xBD" #endif #elif '^' == 95 #ifndef BOM_UTF8 # define BOM_UTF8 "\xDD\x73\x66\x73" #endif #ifndef REPLACEMENT_CHARACTER_UTF8 # define REPLACEMENT_CHARACTER_UTF8 "\xDD\x73\x73\x71" #endif #elif '^' == 176 #ifndef BOM_UTF8 # define BOM_UTF8 "\xDD\x72\x65\x72" #endif #ifndef REPLACEMENT_CHARACTER_UTF8 # define REPLACEMENT_CHARACTER_UTF8 "\xDD\x72\x72\x70" #endif #else # error Unknown character set #endif #if (PERL_BCDVERSION < 0x5031004) /* Versions prior to this accepted things that are now considered * malformations, and didn't return -1 on error with warnings enabled * */ # undef utf8_to_uvchr_buf #endif /* This implementation brings modern, generally more restricted standards to * utf8_to_uvchr_buf. Some of these are security related, and clearly must * be done. But its arguable that the others need not, and hence should not. * The reason they're here is that a module that intends to play with the * latest perls should be able to work the same in all releases. An example is * that perl no longer accepts any UV for a code point, but limits them to * IV_MAX or below. This is for future internal use of the larger code points. * If it turns out that some of these changes are breaking code that isn't * intended to work with modern perls, the tighter restrictions could be * relaxed. khw thinks this is unlikely, but has been wrong in the past. */ /* 5.6.0 is the first release with UTF-8, and we don't implement this function * there due to its likely lack of still being in use, and the underlying * implementation is very different from later ones, without the later * safeguards, so would require extra work to deal with */ #if (PERL_BCDVERSION >= 0x5006001) && ! defined(utf8_to_uvchr_buf) /* Choose which underlying implementation to use. At least one must be * present or the perl is too early to handle this function */ # if defined(utf8n_to_uvchr) || defined(utf8_to_uvchr) || defined(utf8_to_uv) # if defined(utf8n_to_uvchr) /* This is the preferred implementation */ # define D_PPP_utf8_to_uvchr_buf_callee utf8n_to_uvchr # elif /* Must be at least 5.6.1 from #if above; \ If have both regular and _simple, regular has all args */ \ defined(utf8_to_uv) && defined(utf8_to_uv_simple) # define D_PPP_utf8_to_uvchr_buf_callee utf8_to_uv # elif defined(utf8_to_uvchr) /* The below won't work well on error input */ # define D_PPP_utf8_to_uvchr_buf_callee(s, curlen, retlen, flags) \ utf8_to_uvchr((U8 *)(s), (retlen)) # else # define D_PPP_utf8_to_uvchr_buf_callee(s, curlen, retlen, flags) \ utf8_to_uv((U8 *)(s), (retlen)) # endif # endif # if defined(NEED_utf8_to_uvchr_buf) static UV DPPP_(my_utf8_to_uvchr_buf)(pTHX_ const U8 * s, const U8 * send, STRLEN * retlen); static #else extern UV DPPP_(my_utf8_to_uvchr_buf)(pTHX_ const U8 * s, const U8 * send, STRLEN * retlen); #endif #if defined(NEED_utf8_to_uvchr_buf) || defined(NEED_utf8_to_uvchr_buf_GLOBAL) #ifdef utf8_to_uvchr_buf # undef utf8_to_uvchr_buf #endif #define utf8_to_uvchr_buf(a,b,c) DPPP_(my_utf8_to_uvchr_buf)(aTHX_ a,b,c) #define Perl_utf8_to_uvchr_buf DPPP_(my_utf8_to_uvchr_buf) UV DPPP_(my_utf8_to_uvchr_buf)(pTHX_ const U8 *s, const U8 *send, STRLEN *retlen) { UV ret; STRLEN curlen; bool overflows = 0; const U8 *cur_s = s; const bool do_warnings = ckWARN_d(WARN_UTF8); # if (PERL_BCDVERSION < 0x5026000) && ! defined(EBCDIC) STRLEN overflow_length = 0; # endif if (send > s) { curlen = send - s; } else { assert(0); /* Modern perls die under this circumstance */ curlen = 0; if (! do_warnings) { /* Handle empty here if no warnings needed */ if (retlen) *retlen = 0; return UNICODE_REPLACEMENT; } } # if (PERL_BCDVERSION < 0x5026000) && ! defined(EBCDIC) /* Perl did not properly detect overflow for much of its history on * non-EBCDIC platforms, often returning an overlong value which may or may * not have been tolerated in the call. Also, earlier versions, when they * did detect overflow, may have disallowed it completely. Modern ones can * replace it with the REPLACEMENT CHARACTER, depending on calling * parameters. Therefore detect it ourselves in releases it was * problematic in. */ if (curlen > 0 && UNLIKELY(*s >= 0xFE)) { /* First, on a 32-bit machine the first byte being at least \xFE * automatically is overflow, as it indicates something requiring more * than 31 bits */ if (sizeof(ret) < 8) { overflows = 1; overflow_length = (*s == 0xFE) ? 7 : 13; } else { const U8 highest[] = /* 2*63-1 */ "\xFF\x80\x87\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF"; const U8 *cur_h = highest; for (cur_s = s; cur_s < send; cur_s++, cur_h++) { if (UNLIKELY(*cur_s == *cur_h)) { continue; } /* If this byte is larger than the corresponding highest UTF-8 * byte, the sequence overflows; otherwise the byte is less * than (as we handled the equality case above), and so the * sequence doesn't overflow */ overflows = *cur_s > *cur_h; break; } /* Here, either we set the bool and broke out of the loop, or got * to the end and all bytes are the same which indicates it doesn't * overflow. If it did overflow, it would be this number of bytes * */ overflow_length = 13; } } if (UNLIKELY(overflows)) { ret = 0; if (! do_warnings && retlen) { *retlen = overflow_length; } } else # endif /* < 5.26 */ /* Here, we are either in a release that properly detects overflow, or * we have checked for overflow and the next statement is executing as * part of the above conditional where we know we don't have overflow. * * The modern versions allow anything that evaluates to a legal UV, but * not overlongs nor an empty input */ ret = D_PPP_utf8_to_uvchr_buf_callee( (U8 *) /* Early perls: no const */ s, curlen, retlen, (UTF8_ALLOW_ANYUV & ~(UTF8_ALLOW_LONG|UTF8_ALLOW_EMPTY))); # if (PERL_BCDVERSION >= 0x5026000) && (PERL_BCDVERSION < 0x5028000) /* But actually, more modern versions restrict the UV to being no more than * what an IV can hold, so it could still have gotten it wrong about * overflowing. */ if (UNLIKELY(ret > IV_MAX)) { overflows = 1; } # endif if (UNLIKELY(overflows)) { if (! do_warnings) { if (retlen) { *retlen = D_PPP_MIN(*retlen, UTF8SKIP(s)); *retlen = D_PPP_MIN(*retlen, curlen); } return UNICODE_REPLACEMENT; } else { /* We use the error message in use from 5.8-5.26 */ Perl_warner(aTHX_ packWARN(WARN_UTF8), "Malformed UTF-8 character (overflow at 0x%" UVxf ", byte 0x%02x, after start byte 0x%02x)", ret, *cur_s, *s); if (retlen) { *retlen = (STRLEN) -1; } return 0; } } /* Here, did not overflow, but if it failed for some other reason, and * warnings are off, to emulate the behavior of the real utf8_to_uvchr(), * try again, allowing anything. (Note a return of 0 is ok if the input * was '\0') */ if (UNLIKELY(ret == 0 && (curlen == 0 || *s != '\0'))) { /* If curlen is 0, we already handled the case where warnings are * disabled, so this 'if' will be true, and so later on, we know that * 's' is dereferencible */ if (do_warnings) { if (retlen) { *retlen = (STRLEN) -1; } } else { ret = D_PPP_utf8_to_uvchr_buf_callee( (U8 *) /* Early perls: no const */ s, curlen, retlen, UTF8_ALLOW_ANY); /* Override with the REPLACEMENT character, as that is what the * modern version of this function returns */ ret = UNICODE_REPLACEMENT; # if (PERL_BCDVERSION < 0x5016000) /* Versions earlier than this don't necessarily return the proper * length. It should not extend past the end of string, nor past * what the first byte indicates the length is, nor past the * continuation characters */ if (retlen && (IV) *retlen >= 0) { unsigned int i = 1; *retlen = D_PPP_MIN(*retlen, curlen); *retlen = D_PPP_MIN(*retlen, UTF8SKIP(s)); do { # ifdef UTF8_IS_CONTINUATION if (! UTF8_IS_CONTINUATION(s[i])) # else /* Versions without the above don't support EBCDIC anyway */ if (s[i] < 0x80 || s[i] > 0xBF) # endif { *retlen = i; break; } } while (++i < *retlen); } # endif } } return ret; } # endif #endif #if defined(UTF8SKIP) && defined(utf8_to_uvchr_buf) #undef utf8_to_uvchr /* Always redefine this unsafe function so that it refuses to read past a NUL, making it much less likely to read off the end of the buffer. A NUL indicates the start of the next character anyway. If the input isn't NUL-terminated, the function remains unsafe, as it always has been. */ #ifndef utf8_to_uvchr # define utf8_to_uvchr(s, lp) \ ((*(s) == '\0') \ ? utf8_to_uvchr_buf(s,((s)+1), lp) /* Handle single NUL specially */ \ : utf8_to_uvchr_buf(s, (s) + UTF8_CHK_SKIP(s), (lp))) #endif #endif /* Hint: utf8_to_uvchr Use utf8_to_uvchr_buf() instead. But ONLY if you KNOW the upper bound of the input string (not resorting to using UTF8SKIP, etc., to infer it). The backported utf8_to_uvchr() will do a better job to prevent most cases of trying to read beyond the end of the buffer */ /* Replace utf8_to_uvchr with utf8_to_uvchr_buf */ #ifdef sv_len_utf8 # if (PERL_BCDVERSION >= 0x5017005) # ifndef sv_len_utf8_nomg # if defined(PERL_USE_GCC_BRACE_GROUPS) # define sv_len_utf8_nomg(sv) \ ({ \ SV *sv_ = (sv); \ sv_len_utf8(!SvGMAGICAL(sv_) \ ? sv_ \ : sv_mortalcopy_flags(sv_, SV_NOSTEAL)); \ }) # else PERL_STATIC_INLINE STRLEN D_PPP_sv_len_utf8_nomg(SV * sv) { dTHX; if (SvGMAGICAL(sv)) return sv_len_utf8(sv_mortalcopy_flags(sv, SV_NOSTEAL)); else return sv_len_utf8(sv); } # define sv_len_utf8_nomg(sv) D_PPP_sv_len_utf8_nomg(sv) # endif # endif # else /* < 5.17.5 */ /* Older Perl versions have broken sv_len_utf8() when passed sv does not * have SVf_UTF8 flag set */ /* Also note that SvGETMAGIC() may change presence of SVf_UTF8 flag */ # undef sv_len_utf8 # if defined(PERL_USE_GCC_BRACE_GROUPS) # define sv_len_utf8_nomg(sv) \ ({ \ SV *sv2 = (sv); \ STRLEN len; \ if (SvUTF8(sv2)) { \ if (SvGMAGICAL(sv2)) \ len = Perl_sv_len_utf8(aTHX_ \ sv_mortalcopy_flags(sv2, \ SV_NOSTEAL));\ else \ len = Perl_sv_len_utf8(aTHX_ sv2); \ } \ else SvPV_nomg(sv2, len); \ len; \ }) # define sv_len_utf8(sv) ({ SV *_sv1 = (sv); \ SvGETMAGIC(_sv1); \ sv_len_utf8_nomg(_sv1); \ }) # else /* Below is no brace groups */ PERL_STATIC_INLINE STRLEN D_PPP_sv_len_utf8_nomg(SV * sv) { dTHX; STRLEN len; if (SvUTF8(sv)) { if (SvGMAGICAL(sv)) len = Perl_sv_len_utf8(aTHX_ sv_mortalcopy_flags(sv, SV_NOSTEAL)); else len = Perl_sv_len_utf8(aTHX_ sv); } else SvPV_nomg(sv, len); return len; } # define sv_len_utf8_nomg(sv) D_PPP_sv_len_utf8_nomg(sv) PERL_STATIC_INLINE STRLEN D_PPP_sv_len_utf8(SV * sv) { dTHX; SvGETMAGIC(sv); return sv_len_utf8_nomg(sv); } # define sv_len_utf8(sv) D_PPP_sv_len_utf8(sv) # endif # endif /* End of < 5.17.5 */ #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr_buf) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr_buf) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr_buf) isuni ? utf8_to_uvchr_buf((U8*)pv, end, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%" UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%" UVxf "}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #if PERL_VERSION_LT(5,27,9) #ifndef LC_NUMERIC_LOCK # define LC_NUMERIC_LOCK #endif #ifndef LC_NUMERIC_UNLOCK # define LC_NUMERIC_UNLOCK #endif # if PERL_VERSION_LT(5,19,0) # undef STORE_LC_NUMERIC_SET_STANDARD # undef RESTORE_LC_NUMERIC # undef DECLARATION_FOR_LC_NUMERIC_MANIPULATION # ifdef USE_LOCALE #ifndef DECLARATION_FOR_LC_NUMERIC_MANIPULATION # define DECLARATION_FOR_LC_NUMERIC_MANIPULATION char *LoC_ #endif #ifndef STORE_NUMERIC_SET_STANDARD # define STORE_NUMERIC_SET_STANDARD() \ LoC_ = savepv(setlocale(LC_NUMERIC, NULL)); \ SAVEFREEPV(LoC_); \ setlocale(LC_NUMERIC, "C"); #endif #ifndef RESTORE_LC_NUMERIC # define RESTORE_LC_NUMERIC() \ setlocale(LC_NUMERIC, LoC_); #endif # else #ifndef DECLARATION_FOR_LC_NUMERIC_MANIPULATION # define DECLARATION_FOR_LC_NUMERIC_MANIPULATION #endif #ifndef STORE_LC_NUMERIC_SET_STANDARD # define STORE_LC_NUMERIC_SET_STANDARD() #endif #ifndef RESTORE_LC_NUMERIC # define RESTORE_LC_NUMERIC() #endif # endif # endif #endif #ifndef LOCK_NUMERIC_STANDARD # define LOCK_NUMERIC_STANDARD() #endif #ifndef UNLOCK_NUMERIC_STANDARD # define UNLOCK_NUMERIC_STANDARD() #endif /* The names of these changed in 5.28 */ #ifndef LOCK_LC_NUMERIC_STANDARD # define LOCK_LC_NUMERIC_STANDARD LOCK_NUMERIC_STANDARD #endif #ifndef UNLOCK_LC_NUMERIC_STANDARD # define UNLOCK_LC_NUMERIC_STANDARD UNLOCK_NUMERIC_STANDARD #endif /* If this doesn't exist, it's not needed, so is void noop */ #ifndef switch_to_global_locale # define switch_to_global_locale() #endif /* Originally, this didn't return a value, but in perls like that, the value * should always be TRUE. Add a return to Perl_sync_locale() when it's * available. And actually do a sync when its not, if locales are available on * this system. */ #ifdef sync_locale # if (PERL_BCDVERSION < 0x5027009) # if (PERL_BCDVERSION >= 0x5021003) # undef sync_locale # define sync_locale() (Perl_sync_locale(aTHX), 1) # elif defined(sync_locale) /* These should only be the 5.20 maints*/ # undef sync_locale /* Just copy their defn and return 1 */ # define sync_locale() (new_ctype(setlocale(LC_CTYPE, NULL)), \ new_collate(setlocale(LC_COLLATE, NULL)), \ set_numeric_local(), \ new_numeric(setlocale(LC_NUMERIC, NULL)), \ 1) # elif defined(new_ctype) && defined(LC_CTYPE) # define sync_locale() (new_ctype(setlocale(LC_CTYPE, NULL)), 1) # endif # endif #endif #ifndef sync_locale # define sync_locale() 1 #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ JavaScript-QuickJS-0.21/easyxs/easyxs_scalar.h000644 000766 000024 00000001407 14355430321 021751 0ustar00felipestaff000000 000000 #ifndef EASYXS_SCALAR_H #define EASYXS_SCALAR_H 1 #include "init.h" /* EXPERIMENTAL! */ enum exs_sv_type_e { EXS_SVTYPE_UNKNOWN, EXS_SVTYPE_UNDEF, EXS_SVTYPE_REFERENCE, EXS_SVTYPE_BOOLEAN, EXS_SVTYPE_STRING, EXS_SVTYPE_UV, EXS_SVTYPE_IV, EXS_SVTYPE_NV, }; typedef enum exs_sv_type_e exs_sv_type_e; #ifndef SvIsBOOL #define SvIsBOOL(sv) FALSE #endif #define exs_sv_type(sv) ( \ !SvOK(sv) ? EXS_SVTYPE_UNDEF \ : SvROK(sv) ? EXS_SVTYPE_REFERENCE \ : SvIsBOOL(sv) ? EXS_SVTYPE_BOOLEAN \ : SvPOK(sv) ? EXS_SVTYPE_STRING \ : SvUOK(sv) ? EXS_SVTYPE_UV \ : SvIOK(sv) ? EXS_SVTYPE_IV \ : SvNOK(sv) ? EXS_SVTYPE_NV \ : EXS_SVTYPE_UNKNOWN \ ) #endif JavaScript-QuickJS-0.21/easyxs/README.md000644 000766 000024 00000014401 14531654173 020225 0ustar00felipestaff000000 000000 # EasyXS This library is a toolbox that assists with creation & maintenance of [Perl XS](https://perldoc.perl.org/perlxs) code. # Usage 1. Make this repository a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) of your own XS module. 2. Replace the standard XS includes (`EXTERN.h`, `perl.h`, and `XSUB.h`) with just `#include "easyxs/easyxs.h"`. … and that’s it! You now have a suite of tools that’ll make writing XS easier and safer. # Rationale Perl’s C API makes lots of things _possible_ without making them _easy_ (or _safe_). This library attempts to provide shims around that API that make it easy and safe (or, at least, safe-_er_!) to write XS code … maybe even *fun!* :-) # Library Components ## Initialization `init.h` includes the standard boilerplate code you normally stick at the top of a `*.xs` file. It also includes a fix for the [torrent of warnings that clang 12 throws](https://github.com/Perl/perl5/issues/18780) in pre-5.36 perls. `easyxs.h` brings this in, but you can also `#include "easyxs/init.h"` on its own. `init.h` also includes a fairly up-to-date (as of this writing!) `ppport.h`. ## Calling Perl ### `void exs_call_sv_void(SV* callback, SV** args)` Like the Perl API’s `call_sv()` but simplifies argument-passing. `args` points to a NULL-terminated array of `SV*`s. (It may itself also be NULL.) The callback is called in void context, so nothing is returned. **IMPORTANT CAVEATS:** - This does _not_ trap exceptions. Ensure either that the callback won’t throw, or that no corruption will happen in the event of an exception. - This **mortalizes** each `args` member. That means Perl will reduce each of those SVs’ reference counts at some point “soon” after. This is often desirable, but not always; to counteract it, do `SvREFCNT_inc()` around whichever arguments you want to be unaffected by the mortalization. (They’ll still be mortalized, but the eventual reference-count reduction will just have zero net effect.) ### `SV* exs_call_sv_scalar(SV* callback, SV** args)` Like `exs_call_sv_void()` but calls the callback in scalar context. The result is returned. ### `SV* exs_call_sv_scalar_trapped(SV* callback, SV** args, SV** error_svp)` Like `exs_call_sv_scalar()` but traps exceptions. If one happens, NULL is returned, and `*error_svp` will contain the error SV. (This SV is a **copy** of Perl’s `$@` and so **must be freed**.) ### `void exs_call_sv_void_trapped(SV* callback, SV** args, SV** error_svp)` Like `exs_call_sv_scalar_trapped()` but calls the Perl callback in void context and doesn’t return anything. ### `void exs_call_method_void(SV* object, const char* methname, SV** args)` Like `exs_call_sv_void()` but for calling object methods. See the Perl API’s `call_method()` for more details. ### `SV* exs_call_method_scalar(SV* object, const char* methname, SV** args)` Like `exs_call_method_void()` but calls the method in scalar context. The result is returned. ### `SV** exs_call_sv_list(SV* callback, SV** args)` Like `exs_call_sv_scalar` but calls the callback in list context. The return is a pointer to a NUL-terminated array of `SV*`s. The pointer will be freed automatically, but the SVs are non-mortals with reference count 1, so you’ll need to dispose of those however is best for you. ### `SV** exs_call_sv_list_trapped(SV* callback, SV** args, SV** error_svp)` Like both `exs_call_sv_list` and `exs_call_sv_scalar_trapped`. If the callback throws, this behaves as `exs_call_sv_scalar_trapped` does; otherwise, this behaves as `exs_call_sv_list` does. ## SV “Typing” Perl scalars are supposed to be “untyped”, at least insofar as strings/numbers. When conversing with other languages, though, or serializing it’s usually helpful to break things down in greater detail. EasyXS defines an `exs_sv_type` macro that takes an SV as argument and returns a member of `enum exs_sv_type_e` (typedef’d as just `exs_sv_type_e`; see `easyxs_scalar.h` for values). The logic is compatible with the serialization logic formulated during Perl 5.36’s development cycle. ## SV/Number Conversion ### `UV* exs_SvUV(SV* sv)` Like `SvUV`, but if the SV’s content can’t be a UV (e.g., the IV is negative, or the string has non-numeric characters) an exception is thrown. ## SV/String Conversion ### `char* exs_SvPVbyte_nolen(SV* sv)` Like the Perl API’s `SvPVbyte_nolen`, but if there are any NULs in the string then an exception is thrown. ### `char* exs_SvPVutf8_nolen(SV* sv)` Like `exs_SvPVbyte_nolen()` but returns the code points as UTF-8 rather than Latin-1/bytes. ## Struct References It’s common in XS code to need to persist a C struct via a Perl variable, then free that struct once the Perl variable is garbage-collected. Perl’s `sv_setref_pv` and similar APIs present one way to do this: store a pointer to the struct in an SV, then pass around a blessed (Perl) reference to that SV, freeing the struct when the referent SV gets DESTROYed. EasyXS’s “struct references” are a slight simplification of this workflow: use the referent SV’s PV to store the struct itself. Thus, Perl cleans up the struct for you, and there’s no need for a DESTROY to free your struct. (You may, of course, still need a DESTROY to free blocks to which your struct refers.) ### `exs_new_structref(type, classname)` Creates a new structref for the given (C) `type` and (Perl) `classname`. ### `exs_structref_ptr(svrv)` Returns a pointer to `svrv`’s contained struct. ## Debugging ### `exs_debug_sv_summary(SV* sv)` Writes a visual representation of the SV’s contents to `Perl_debug_log`. **NO** trailing newline is written. ### `exs_debug_showstack(const char *pattern, ...)` Writes a visual representation of Perl’s argument stack to `Perl_debug_log`. # Usage Notes If you use GitHub Actions or similar, ensure that you grab the submodule as part of your workflow’s checkout. If you use GitHub’s own [checkout](https://github.com/actions/checkout) workflow, that’s: - with: submodules: true # (or `recursive`) Alternatively, run `git submodule init && git submodule update` during the workflow’s repository setup. # License & Copyright Copyright 2022 by Gasper Software Consulting. All rights reserved. This library is released under the terms of the [MIT License](https://mitlicense.org/). JavaScript-QuickJS-0.21/easyxs/easyxs_perlcall.h000644 000766 000024 00000010750 14531654173 022314 0ustar00felipestaff000000 000000 #ifndef EASYXS_PERLCALL_H #define EASYXS_PERLCALL_H 1 #include "init.h" static inline void _EASYXS_SET_ARGS (pTHX_ SV* object, SV** args) { dSP; unsigned argscount = 0; if (args) { while (args[argscount] != NULL) argscount++; } ENTER; SAVETMPS; PUSHMARK(SP); if (object || argscount) { EXTEND(SP, (object ? 1 : 0) + argscount); if (object) PUSHs( sv_mortalcopy(object) ); unsigned a=0; while (a < argscount) mPUSHs( args[a++] ); PUTBACK; } } #define exs_call_sv_void(sv, args) STMT_START { \ _EASYXS_SET_ARGS(aTHX_ NULL, args); \ call_sv(sv, G_DISCARD | G_VOID); \ FREETMPS; \ LEAVE; \ } STMT_END #define exs_call_method_void(object, methname, args) STMT_START { \ _EASYXS_SET_ARGS(aTHX_ object, args); \ \ call_method( methname, G_DISCARD | G_VOID ); \ \ FREETMPS; \ LEAVE; \ } STMT_END static inline SV* _easyxs_fetch_scalar_return (pTHX_ int count) { dSP; SPAGAIN; SV* ret; if (count == 0) { ret = &PL_sv_undef; } else { ret = SvREFCNT_inc(POPs); while (count-- > 1) PERL_UNUSED_VAR(POPs); } PUTBACK; FREETMPS; LEAVE; return ret; } static inline SV** _easyxs_fetch_list_return (pTHX_ int count) { dSP; SPAGAIN; SV** ret; Newx(ret, 1 + count, SV*); ret[count] = NULL; while (count-- > 0) { ret[count] = SvREFCNT_inc(POPs); } PUTBACK; FREETMPS; LEAVE; SAVEFREEPV(ret); return ret; } static inline SV* _easyxs_call_method_scalar (pTHX_ SV* object, const char* methname, SV** args) { _EASYXS_SET_ARGS(aTHX_ object, args); int count = call_method(methname, G_SCALAR); return _easyxs_fetch_scalar_return(aTHX_ count); } #define exs_call_method_scalar(object, methname, args) \ _easyxs_call_method_scalar(aTHX_ object, methname, args) static inline SV* _easyxs_call_sv_scalar (pTHX_ SV* cb, SV** args) { _EASYXS_SET_ARGS(aTHX_ NULL, args); int count = call_sv(cb, G_SCALAR); return _easyxs_fetch_scalar_return(aTHX_ count); } #define exs_call_sv_scalar(sv, args) \ _easyxs_call_sv_scalar(aTHX_ sv, args) static inline SV** _easyxs_call_sv_list (pTHX_ SV* cb, SV** args) { _EASYXS_SET_ARGS(aTHX_ NULL, args); int count = call_sv(cb, G_ARRAY); return _easyxs_fetch_list_return(aTHX_ count); } #define exs_call_sv_list(sv, args) \ _easyxs_call_sv_list(aTHX_ sv, args) #define _handle_trapped_error(count, err_p) STMT_START { \ dSP; \ SV* err_tmp = ERRSV; \ if (SvTRUE(err_tmp)) { \ while (count--) PERL_UNUSED_VAR(POPs); \ \ *err_p = newSVsv(err_tmp); \ \ PUTBACK; \ FREETMPS; \ LEAVE; \ } \ } STMT_END static inline void _easyxs_call_sv_void_trapped (pTHX_ SV* cb, SV** args, SV** error) { _EASYXS_SET_ARGS(aTHX_ NULL, args); int count = call_sv(cb, G_VOID | G_EVAL); _handle_trapped_error(count, error); } #define exs_call_sv_void_trapped(sv, args, err_p) \ _easyxs_call_sv_void_trapped(aTHX_ sv, args, err_p) static inline SV* _easyxs_call_sv_scalar_trapped (pTHX_ SV* cb, SV** args, SV** error) { _EASYXS_SET_ARGS(aTHX_ NULL, args); int count = call_sv(cb, G_SCALAR | G_EVAL); _handle_trapped_error(count, error); if (SvTRUE(ERRSV)) return NULL; return _easyxs_fetch_scalar_return(aTHX_ count); } #define exs_call_sv_scalar_trapped(sv, args, err_p) \ _easyxs_call_sv_scalar_trapped(aTHX_ sv, args, err_p) static inline SV** _easyxs_call_sv_list_trapped (pTHX_ SV* cb, SV** args, SV** error) { _EASYXS_SET_ARGS(aTHX_ NULL, args); int count = call_sv(cb, G_ARRAY | G_EVAL); _handle_trapped_error(count, error); if (SvTRUE(ERRSV)) return NULL; return _easyxs_fetch_list_return(aTHX_ count); } #define exs_call_sv_list_trapped(sv, args, err_p) \ _easyxs_call_sv_list_trapped(aTHX_ sv, args, err_p) #endif JavaScript-QuickJS-0.21/easyxs/easyxs.h000644 000766 000024 00000000650 14355430321 020423 0ustar00felipestaff000000 000000 #ifndef EASYXS_H #define EASYXS_H 1 #include "init.h" #define _EASYXS_CROAK_UNDEF(expected) \ croak("undef given; " expected " expected") #define _EASYXS_CROAK_STRINGIFY_REFERENCE(sv) \ croak("%" SVf " given where string expected!", sv) #include "easyxs_perlcall.h" #include "easyxs_numeric.h" #include "easyxs_scalar.h" #include "easyxs_string.h" #include "easyxs_structref.h" #include "easyxs_debug.h" #endif JavaScript-QuickJS-0.21/easyxs/init.h000644 000766 000024 00000000756 14356541451 020071 0ustar00felipestaff000000 000000 #ifndef EASYXS_INIT #define EASYXS_INIT 1 #ifdef __cplusplus extern "C" { #endif #define PERL_NO_GET_CONTEXT #include "EXTERN.h" /* Implement perl5 7169efc77525df for older perls (part 1): */ #define STMT_START do #define STMT_END while (0) #include "perl.h" #include "XSUB.h" #include "ppport.h" #ifdef __cplusplus } #endif /* Implement perl5 7169efc77525df for older perls (part 2): */ #undef STMT_START #undef STMT_END #define STMT_START do #define STMT_END while (0) #endif JavaScript-QuickJS-0.21/lib/JavaScript/000755 000766 000024 00000000000 14563206245 020244 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/lib/JavaScript/QuickJS/000755 000766 000024 00000000000 14563206245 021555 5ustar00felipestaff000000 000000 JavaScript-QuickJS-0.21/lib/JavaScript/QuickJS.pm000644 000766 000024 00000026225 14563206143 022117 0ustar00felipestaff000000 000000 package JavaScript::QuickJS; use strict; use warnings; =encoding utf-8 =head1 NAME JavaScript::QuickJS - Run JavaScript via L in Perl =head1 SYNOPSIS Quick and dirty … my $val = JavaScript::QuickJS->new()->eval( q< let foo = "bar"; [ "The", "last", "value", "is", "returned." ]; > ); … or load ES6 modules: my $js = JavaScript::QuickJS->new()->helpers(); $js->eval_module( q/ import * as coolStuff from 'cool/stuff'; for (const [key, value] of Object.entries(coolStuff)) { console.log(key, value); } / ); =head1 DESCRIPTION This library embeds Fabrice Bellard’s L engine into a Perl XS module. You can thus run JavaScript (L specification) directly in your Perl programs. This distribution includes all needed C code; unlike with most XS modules that interface with C libraries, you don’t need QuickJS pre-installed on your system. =cut # ---------------------------------------------------------------------- use XSLoader; our $VERSION = '0.21'; XSLoader::load( __PACKAGE__, $VERSION ); # ---------------------------------------------------------------------- =head1 METHODS =head2 $obj = I->new( %CONFIG_OPTS ) Instantiates I. %CONFIG_OPTS have the same effect as in C below. =cut sub new { my ($class, %opts) = @_; my $self = $class->_new(); return %opts ? $self->configure(%opts) : $self; } =head2 $obj = I->configure( %OPTS ) Tunes the QuickJS interpreter. Returns I. %OPTS are any of: =over =item * C =item * C =item * C =back For more information on these, see QuickJS itself. =cut sub configure { my ($self, %opts) = @_; my ($stack, $memlimit, $gc_threshold) = delete @opts{'max_stack_size', 'memory_limit', 'gc_threshold'}; if (my @extra = sort keys %opts) { Carp::croak("Unknown: @extra"); } return $self->_configure($stack, $memlimit, $gc_threshold); } #---------------------------------------------------------------------- =head2 $obj = I->set_globals( NAME1 => VALUE1, .. ) Sets 1 or more globals in I. See below for details on type conversions from Perl to JavaScript. Returns I. =head2 $obj = I->helpers() Defines QuickJS’s “helpers”, e.g., C. Returns I. =head2 $obj = I->std() Enables QuickJS’s C module and creates a global of the same name that’s usable from both script and module modes. This resembles C’s C<--std> flag except that it I enables C, not C. Returns I. =head2 $obj = I->os() Like C but enables QuickJS’s C module instead of C. =head2 $VALUE = I->eval( $JS_CODE ) Like running C. Returns $JS_CODE’s last value; see below for details on type conversions from JavaScript to Perl. Untrapped exceptions in JavaScript will be rethrown as Perl exceptions. $JS_CODE is a I string. =head2 $promise = I->eval_module( $JS_CODE ) Runs $JS_CODE as a module, which enables ES6 module syntax. Note that no values can be returned directly in this mode of execution. Returns a promise that resolves once the module is loaded. =head2 $obj = I->await() Blocks until all of I’s pending work (if any) is complete. For example, if you C some code that creates a promise, call this to wait for that promise to complete. Returns I. =head2 $obj = I->set_module_base( $PATH ) Sets a base path (a byte string) for ES6 module imports. Returns I. =head2 $obj = I->unset_module_base() Restores QuickJS’s default directory for ES6 module imports (as of this writing, it’s the process’s current directory). Returns I. =cut # ---------------------------------------------------------------------- =head1 TYPE CONVERSION: JAVASCRIPT → PERL This module converts returned values from JavaScript thus: =over =item * JS string primitives become I strings in Perl. =item * JS number & boolean primitives become corresponding Perl values. =item * JS null & undefined become Perl undef. =item * JS objects … =over =item * Arrays become Perl array references. =item * “Plain” objects become Perl hash references. =item * Function, RegExp, and Date objects become Perl L, L, and L objects, respectively. =item * Behaviour is B for other object types. =back =back =head1 TYPE CONVERSION: PERL → JAVASCRIPT Generally speaking, it’s the inverse of JS → Perl: =over =item * Perl strings, numbers, & booleans become corresponding JavaScript primitives. B Perl versions before 5.36 don’t reliably distinguish “numeric strings” from “numbers”. If your perl predates 5.36, typecast accordingly to prevent your Perl “number” from becoming a JavaScript string. (Even in 5.36 and later it’s still a good idea.) =item * Perl undef becomes JS null. =item * Unblessed array & hash references become JavaScript arrays and “plain” objects. =item * L booleans become JavaScript booleans. =item * Perl code references become JavaScript functions. =item * Perl L, L, and L objects become their original JavaScript objects. =item * Anything else triggers an exception. =back =head1 MEMORY HANDLING NOTES If any instance of a class of this distribution is DESTROY()ed at Perl’s global destruction, we assume that this is a memory leak, and a warning is thrown. To prevent this, avoid circular references, and clean up all global instances. Callbacks make that tricky. When you give a JavaScript function to Perl, that Perl object holds a reference to the QuickJS context. Only once that object is Ced do we release that QuickJS context reference. Consider the following: my $return; $js->set_globals( __return => sub { $return = shift; () } ); $js->eval('__return( a => a )'); This sets $return to be a L instance. That object holds a reference to $js. $js also stores C<__return()>, which is a Perl code reference that closes around $return. Thus, we have a reference cycle: $return refers to $js, and $js refers to $return. Those two values will thus leak, and you’ll see a warning about it at Perl’s global destruction time. To break the reference cycle, just do: undef $return; … once you’re done with that variable. You I have thought you could instead do: $js->set_globals( __return => undef ) … but that doesn’t work because $js holds a reference to all Perl code references it B receives. This is because QuickJS, unlike Perl, doesn’t expose object destructors (C in Perl), so there’s no good way to release that reference to the code reference. =head1 CHARACTER ENCODING NOTES QuickJS (like all JS engines) assumes its strings are text. Since Perl can’t distinguish text from bytes, though, it’s possible to convert Perl byte strings to JavaScript strings. It often yields a reasonable result, but not always. One place where this falls over, though, is ES6 modules. QuickJS, when it loads an ES6 module, decodes that module’s string literals to characters. Thus, if you pass in byte strings from Perl, QuickJS will treat your Perl byte strings’ code points as character code points, and when you combine those code points with those from your ES6 module you may get mangled output. Another place that may create trouble is if your argument to C or C (above) contains JSON. Perl’s popular JSON encoders output byte strings by default, but as noted above, C and C need I strings. So either configure your JSON encoder to output characters, or decode JSON bytes to characters before calling C/C. For best results, I interact with QuickJS via I strings, and double-check that you’re doing it that way consistently. =head1 NUMERIC PRECISION Note the following if you expect to deal with “large” numbers: =over =item * JavaScript’s numeric-precision limits apply. (cf. L.) =item * Perl’s stringification of numbers may be I precise than JavaScript’s storage of those numbers, or even than Perl’s own storage. For example, in Perl 5.34 C prints C<1e+15>. To counteract this loss of precision, add 0 to Perl’s numeric scalars (e.g., C); this will encourage Perl to store numbers as integers when possible, which fixes this precision problem. =item * Long-double and quad-math perls may lose precision when converting numbers to/from JavaScript. To see if this affects your perl—which, if you’re unsure, it probably doesn’t—run C, and see if that perl’s compile-time options mention long doubles or quad math. =back =head1 OS SUPPORT QuickJS supports Linux, macOS, and Windows natively, so these work without issue. FreeBSD, OpenBSD, & Cygwin work after a few patches that we apply when building this library. (Hopefully these will eventually merge into QuickJS.) =head1 LIBATOMIC QuickJS uses C11 atomics. Most platforms implement that functionality in hardware, but others (e.g., arm32) don’t. To fill that void, we need to link to libatomic. This library’s build logic detects whether libatomic is necessary and will only link to it if needed. If, for some reason, you need manual control over that linking, set C in the environment to 1 or a falsy value. If you don’t know what any of that means, you can probably ignore it. =head1 SEE ALSO Other JavaScript modules on CPAN include: =over =item * L and L make the L library available to Perl. They’re similar to this library, but Duktape itself (as of this writing) lacks support for several JavaScript constructs that QuickJS supports. (It’s also slower.) =item * L and L expose Google’s L library to Perl. Neither seems to support current V8 versions. =item * L is a pure-Perl (!) JavaScript engine. =item * L and L expose Mozilla’s L engine to Perl. =back =head1 LICENSE & COPYRIGHT This library is copyright 2023 Gasper Software Consulting. This library is licensed under the same terms as Perl itself. See L. QuickJS is copyright Fabrice Bellard and Charlie Gordon. It is released under the L. =cut #---------------------------------------------------------------------- package JavaScript::QuickJS::JSObject; package JavaScript::QuickJS::RegExp; our @ISA; BEGIN { @ISA = 'JavaScript::QuickJS::JSObject' }; package JavaScript::QuickJS::Function; our @ISA; BEGIN { @ISA = 'JavaScript::QuickJS::JSObject' }; 1; JavaScript-QuickJS-0.21/lib/JavaScript/QuickJS/Promise.pm000644 000766 000024 00000001335 14563205733 023534 0ustar00felipestaff000000 000000 package JavaScript::QuickJS::Promise; use strict; use warnings; =encoding utf-8 =head1 NAME JavaScript::QuickJS::Promise - JavaScript `Promise` in Perl =head1 SYNOPSIS my $js = JavaScript::QuickJS->new(); $js->eval("Promise.resolve(123)")->then( sub { CORE::say "resolved: @_" } ); CORE::say "before await"; $js->await(); CORE::say "after await"; =head1 DESCRIPTION This class represents a JavaScript L instance in Perl. This class is not instantiated directly. =head1 METHODS This exposes C, C, and C methods that wrap the JavaScript methods of the same names. =cut 1; JavaScript-QuickJS-0.21/lib/JavaScript/QuickJS/RegExp.pm000644 000766 000024 00000001743 14563205741 023312 0ustar00felipestaff000000 000000 package JavaScript::QuickJS::RegExp; use strict; use warnings; =encoding utf-8 =head1 NAME JavaScript::QuickJS::RegExp - JavaScript `RegExp` in Perl =head1 SYNOPSIS my $regexp = JavaScript::QuickJS->new()->eval("/foo/"); if ($regexp->test('fo')) { # This won’t run because test() will return falsy. } =head1 DESCRIPTION This class represents a JavaScript L instance in Perl. This class is not instantiated directly. =head1 METHODS The following methods correspond to their JS equivalents: =over =item * C =item * C =back In addition, the following methods return their corresponding JS property: =over =item * C =item * C =item * C =item * C =item * C =item * C =item * C =item * C =item * C =item * C =back =cut 1; JavaScript-QuickJS-0.21/lib/JavaScript/QuickJS/Function.pm000644 000766 000024 00000002400 14563205724 023675 0ustar00felipestaff000000 000000 package JavaScript::QuickJS::Function; use strict; use warnings; =encoding utf-8 =head1 NAME JavaScript::QuickJS::Function - JavaScript `Function` in Perl =head1 SYNOPSIS my $func = JavaScript::QuickJS->new()->eval("() => 123"); print $func->(); # prints “123”; note overloading :) =head1 DESCRIPTION This class represents a JavaScript L instance in Perl. This class is not instantiated directly. =head1 OVERLOADING For convenience, instances of this class are callable as Perl code references. This is equivalent to a C with $this_sv (see below) set to undef. See the L above for an example. =head1 INVOCATION METHODS =head2 $ret = I->call( $this_sv, @arguments ) Like JavaScript’s method of the same name. =head1 ACCESSOR METHODS The following methods return their corresponding JS property: =over =item * C =item * C =back =cut #---------------------------------------------------------------------- sub _as_coderef; use overload ( '&{}' => \&_as_coderef, nomethod => \&_give_self, # xsub ); sub _as_coderef { my ($self) = @_; return sub { $self->call(undef, @_) }; } 1; JavaScript-QuickJS-0.21/lib/JavaScript/QuickJS/Date.pm000644 000766 000024 00000003117 14563205717 022775 0ustar00felipestaff000000 000000 package JavaScript::QuickJS::Date; use strict; use warnings; =encoding utf-8 =head1 NAME JavaScript::QuickJS::Date - JavaScript `Date` in Perl =head1 SYNOPSIS my $date = JavaScript::QuickJS->new()->eval("new Date()"); binmode \*STDOUT, ':encoding(utf-8)'; print $date->toISOString(); =head1 DESCRIPTION This class represents a JavaScript L instance in Perl. This class is not instantiated directly. =head1 METHODS All correspond to their JavaScript equivalents: =over =item * Getters: =over =item * C, C, C, C, C, C, C, C =item * UTC variants of the above: C, C, C, C, C, C, C, C =item * Stringification: C, C, C, C, C, C, C, C, C, C =item * C, C =back =item * Setters: =over =item * C, C, C, C, C, C, C =item * UTC variants of the above: C, C, C, C, C, C, C =back =back NB: C and C are omitted by design. =cut 1; JavaScript-QuickJS-0.21/t/date_invalid_input.t000644 000766 000024 00000000462 14562330717 021725 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use Test::Fatal; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $date = $js->eval('new Date()'); my $err = exception { $date->toLocaleString(\*STDOUT); }; like($err, qr); done_testing; JavaScript-QuickJS-0.21/t/callback_invalid_sv.t000644 000766 000024 00000000502 14355430271 022024 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $cb = $js->eval( 'a => a' ); eval { $cb->( bless [], 'FooFoo' ) }; my $err = $@; like $err, qr, 'invalid SV given to JS callback coderef'; done_testing; JavaScript-QuickJS-0.21/t/import_std.t000644 000766 000024 00000001344 14357264715 020255 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new()->std(); my $environ; $js->set_globals( env2perl => sub { $environ = shift }, ); my @env_kv = ( "on\xe9" => "tw\xf6", ); my @env_kv_utf8 = @env_kv; utf8::encode($_) for @env_kv_utf8; { local %ENV = @env_kv_utf8; $js->eval( q/ import('std').then(std => env2perl(std.getenviron())); / ); $js->await(); } TODO: { local $TODO = 'Seems not to work on Windows' if $^O eq 'MSWin32'; is_deeply( $environ, { @env_kv }, 'imported `std` and called getenviron() as expected', ) or diag explain $environ; } done_testing; 1; JavaScript-QuickJS-0.21/t/script_std.t000644 000766 000024 00000001312 14532531112 020221 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new()->std(); my $environ; $js->set_globals( env2perl => sub { $environ = shift }, ); my @env_kv = ( "on\xe9" => "tw\xf6", ); my @env_kv_utf8 = @env_kv; utf8::encode($_) for @env_kv_utf8; { local %ENV = @env_kv_utf8; $js->eval( q/ env2perl(std.getenviron()); / ); $js->await(); } TODO: { local $TODO = 'Seems not to work on Windows' if $^O eq 'MSWin32'; is_deeply( $environ, { @env_kv }, 'imported `std` and called getenviron() as expected', ) or diag explain $environ; } done_testing; 1; JavaScript-QuickJS-0.21/t/date.t000644 000766 000024 00000004335 14562424533 017003 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use Test::Fatal; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $date = $js->eval('let mydate = new Date(); mydate'); isa_ok($date, 'JavaScript::QuickJS::Date', 'JS Date() object'); my @settables = qw( Milliseconds Seconds Minutes Hours Date Month FullYear ); my @getters = ( ( map { "get$_" } ( map { $_, "UTC$_" } @settables, 'Day', ), 'TimezoneOffset', 'Time', ), ( map { "to$_" } 'String', 'JSON', ( map { "${_}String" } qw( UTC GMT ISO Date Time Locale LocaleDate LocaleTime ), ), ), ); for my $getter (@getters) { my $perl_got = $date->$getter(); my $js_got = $js->eval("mydate.$getter()"); is($perl_got, $js_got, "$getter() is the same in Perl and JS"); } my $time_num = (time - 100) * 1000; my $time_str = $time_num; $time_str .= ''; for my $time ($time_num, $time_str) { my $settime_return = $date->setTime($time); is( $settime_return, $date->getTime(), "setTime() returns as expected", ); is( $js->eval("mydate.getTime()"), $time, "setTime() has the intended effect", ); } for my $settable (@settables) { my $value_to_set = '' . (($settable eq 'FullYear') ? 1976 : 11); for my $settable2 ( $settable, "UTC$settable" ) { my $setter = "set$settable2"; my $getter = "get$settable2"; # print "calling $setter($value_to_set)\n"; my $setter_return = $date->$setter($value_to_set); is( $setter_return, $date->getTime(), "$setter() returns as expected", ); is( $js->eval("mydate.get$settable2()"), $value_to_set, "$setter($value_to_set)", ); # Avoid this bug: https://github.com/bellard/quickjs/issues/238 if ($^O ne 'MSWin32' || $settable ne 'FullYear') { $date->$setter(-$value_to_set); is( $js->eval("mydate.get$settable2()"), $date->$getter(), "$setter(-$value_to_set)", ); } } } done_testing; 1; JavaScript-QuickJS-0.21/t/set_globals.t000644 000766 000024 00000005602 14355430271 020356 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use Data::Dumper; use Config; use Types::Serialiser; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new()->set_globals( add1 => sub { $_[0] + 1 }, ); is( $js->eval("add1(23)"), 24, 'JS calls Perl' ); my $is_64bit = $Config{'use64bitint'}; my @roundtrip = ( "hello", "\xe9", "\x{100}", "\x{101234}", -1, -1.234, 0, 1.234, 0xffff_ffff, -0x8000_0000, $js->eval('Number.MAX_SAFE_INTEGER'), $js->eval('Number.MIN_SAFE_INTEGER'), ($is_64bit ? (map { $_, -$_ } 0xffff_ffff << 17) : () ), [1, 2, 3], [], {}, { foo => 'bar' }, { "\x{100}" => [] }, # Test magic: \%Config, ); for my $rtval (@roundtrip) { my $key = 'rtval'; $js->set_globals( $key => $rtval ); my $got = $js->eval($key); # Perl’s NV stringification loses precision once we exceed # 10^15. To minimize the chance that that will cause a problem, # we add 0 to encourage Perl to convert to an IV if possible. # if ($got =~ m<\A-?[0-9]+(?:\.[0-9]+)\z>) { $got += 0; } local $Data::Dumper::Useqq =1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; my $str = Dumper($rtval); my $alt_double_yn = $Config{'uselongdouble'} || $Config{'usequadmath'}; my $allow_approx = $alt_double_yn ? ($rtval !~ tr<0-9.-><>c) : ($rtval =~ tr<.><>); if ($allow_approx) { cmp_deeply($got, num($rtval, 0.01), "gave & received: $str" ); } else { is_deeply($got, $rtval, "gave & received: $str" ); } } eval { $js->set_globals( regexp => qr/abc/ ) }; my $err = $@; like($err, qr, 'error mentions what can’t be converted'); like($err, qri, 'error mentions JS'); $js->set_globals( mytrue => Types::Serialiser::true(), myfalse => Types::Serialiser::false(), ); my $got = $js->eval(< IV_MAX', unpack('Q', $ivmax) ], [ '<= IV_MAX', unpack('Q', $ivmax_plus1) ], [ 'negative 64-bit', unpack('q', $ivmin) ], ); for my $tt (@t) { my ($label, $expect) = @$tt; $js->set_globals( bignum => $expect, ); my $got = $js->eval('bignum'); cmp_deeply( $got, num($expect, 100), $label, ); } } done_testing; JavaScript-QuickJS-0.21/t/jsfunc_memory_handling.t000644 000766 000024 00000001065 14355430271 022603 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use JavaScript::QuickJS; { my $return; my $js = JavaScript::QuickJS->new(); $js->set_globals( __return => sub { $return = shift } ); my $ret = $js->eval('__return( a => a );'); isa_ok( $return, 'JavaScript::QuickJS::Function', 'eval() of an arrow function', ); like( "$return", qr, 'stringification', ); undef $return; } done_testing; JavaScript-QuickJS-0.21/t/import_std2.t000644 000766 000024 00000001256 14532531112 020320 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new()->std(); my $environ; $js->set_globals( env2perl => sub { $environ = shift }, ); my @env_kv = ( "on\xe9" => "tw\xf6", ); my @env_kv_utf8 = @env_kv; utf8::encode($_) for @env_kv_utf8; { local %ENV = @env_kv_utf8; $js->eval_module( q/env2perl(std.getenviron())/ ); } TODO: { local $TODO = 'Seems not to work on Windows' if $^O eq 'MSWin32'; is_deeply( $environ, { @env_kv }, 'imported `std` and called getenviron() as expected', ) or diag explain $environ; } done_testing; 1; JavaScript-QuickJS-0.21/t/basic.t000644 000766 000024 00000001716 14355430271 017143 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $result = $js->eval( q< [ true, false, 0, -1, 999, 99.9999, [ "abc", "ünicøde" ], { foo: "bar", baz: undefined, undefined: null }, ]; > ); cmp_deeply( $result, [ !!1, !!0, 0, -1, 999, num(99.9999, 0.01), [ "abc", "ünicøde" ], { foo => "bar", baz => undef, undefined => undef }, ], 'expected output', ) or diag explain $result; eval { $js->eval('[].foo.bar.baz = 234') }; my $err = $@; like($err, qr, 'error type is given'); like($err, qr, 'error detail (key) is given'); like($err, qr, 'error detail (bad value) is given'); ok( $js->eval("'Promise' in this"), 'Promise object exists', ); done_testing; 1; JavaScript-QuickJS-0.21/t/js2perl.t000644 000766 000024 00000000607 14355430271 017441 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); eval { $js->eval('[BigInt(123)]') }; my $err = $@; like($err, qri, 'BigInt in array'); eval { $js->eval('let foo = { foo: BigInt(123) }; foo') }; $err = $@; like($err, qri, 'BigInt in plain object'); done_testing; JavaScript-QuickJS-0.21/t/promise.t000644 000766 000024 00000001641 14562330717 017541 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use Test::Deep; use JavaScript::QuickJS; my @out; sub faux_print { push @out, [@_]; } my $js = JavaScript::QuickJS->new(); faux_print('start'); my $p1 = $js->eval('Promise.resolve(123)'); faux_print('created promise'); my $p2 = $p1->then( sub { faux_print("first then", @_); return 234; } ); faux_print('called then'); my $p3 = $p2->then( sub { faux_print("second then", @_); die 345; } ); $p3->catch( sub { faux_print("catch", @_); return 456; } )->finally( sub { faux_print("finally", @_); } ); faux_print('before await'); $js->await(); cmp_deeply( \@out, [ ['start'], ['created promise'], ['called then'], ['before await'], ['first then', 123], ['second then', 234], ['catch', re(345)], ['finally'], ], ); done_testing; JavaScript-QuickJS-0.21/t/export_ref.t000644 000766 000024 00000003172 14355430271 020235 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use Data::Dumper; use Config; use Types::Serialiser; use JavaScript::QuickJS; { my $js = JavaScript::QuickJS->new(); $js->set_globals( foo => sub { } ); } { my $ret; { my $js = JavaScript::QuickJS->new()->set_globals( __return => sub { $ret = shift; () }, ); $js->eval('__return( function add1(a) { return 1 + a } )'); $js->set_globals( __return => undef ); } is( $ret->(1), 2, 'add1 called without QuickJS instance', ); undef $ret; } { my $js = JavaScript::QuickJS->new(); my $struct = $js->eval('[[[]]]'); is_deeply($struct, [[[]]], 'nested arrays'); my $gives_deep = $js->eval('a => [[[a]]]'); my $got = $gives_deep->([]); is_deeply($got, [[[[]]]], 'nested arrays from funcref') or diag explain $got; } { my $ret; JavaScript::QuickJS->new()->set_globals( __return => sub { $ret = shift; () }, )->eval(qq/ __return( { add1: a => 1 + a, deepen: a => [a], } ); /); my @to_deepen = ( 123, [], [123], {}, { foo => 234 }, ); for my $specimen (@to_deepen) { my $out = $ret->{'deepen'}->($specimen); my $render = do { local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; Data::Dumper::Dumper($specimen); }; cmp_deeply( $out, [$specimen], "deepen: $render" ) or diag explain $out; } undef $ret; } done_testing; JavaScript-QuickJS-0.21/t/strict.t000644 000766 000024 00000000442 14355430271 017365 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); eval { $js->eval('foo = 123') }; my $err = $@; like $err, qr, 'reference error on undeclared variable'; done_testing; JavaScript-QuickJS-0.21/t/memory.t000644 000766 000024 00000002036 14355430271 017366 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use Test::Fatal; use JavaScript::QuickJS; my %legit = ( max_stack_size => 123456, memory_limit => 567887, gc_threshold => 1234, ); my $err = exception { JavaScript::QuickJS->new(%legit) }; ok( !$err, 'new(): no error' ); $err = exception { JavaScript::QuickJS->new()->configure(%legit) }; ok( !$err, 'configure(): no error' ); $err = exception { JavaScript::QuickJS->new( haha => 2, zaza => 7 ) }; like($err, qr, 'new() reports unknowns'); $err = exception { JavaScript::QuickJS->new()->configure( haha => 2, zaza => 7 ) }; like($err, qr, 'configure() reports unknowns'); for my $key (sort keys %legit) { my $err = exception { JavaScript::QuickJS->new( $key => -$legit{$key} ); }; ok($err, "new($key): error on negative"); $err = exception { JavaScript::QuickJS->new()->configure( $key => -$legit{$key} ); }; ok($err, "configure($key): error on negative"); } done_testing; 1; JavaScript-QuickJS-0.21/t/func_call_invalid_input.t000644 000766 000024 00000000450 14562330717 022733 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use Test::Fatal; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $func = $js->eval('() => 123'); my $err = exception { $func->call(\*STDOUT); }; like($err, qr); done_testing; JavaScript-QuickJS-0.21/t/module.t000644 000766 000024 00000004012 14562330717 017343 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use Data::Dumper; use Config; use Cwd; use File::Temp; use File::Slurper; use JavaScript::QuickJS; my $dir = File::Temp::tempdir( CLEANUP => 1 ); mkdir "$dir/my"; File::Slurper::write_binary( "$dir/my/module.js", "export const life = 42;\n", ); my $cwd = Cwd::getcwd(); my $retval; my $js = JavaScript::QuickJS->new()->set_globals( _return => sub { $retval = shift }, ); #---------------------------------------------------------------------- eval { _test_module('(should fail)'); fail 'nonono' }; my $err = $@; like($err, qr, 'module load should fail without default dir'); chdir $dir; _test_module('before set_module_base()'); chdir $cwd; is( q<> . $js->set_module_base($dir), "$js", 'set_module_base() returns object', ); _test_module('after set_module_base()'); #---------------------------------------------------------------------- is( q<> . $js->unset_module_base(), "$js", 'unset_module_base() returns object', ); eval { _test_module('(should fail)') }; $err = $@; like($err, qr, 'module load should fail without default dir'); chdir $dir; _test_module('after unset_module_base()'); sub _test_module { my ($label) = @_; my $ret = $js->eval_module(<then( sub { @from_then = @_ }, sub { @from_catch = @_ }, ); $js->await(); is_deeply(\@from_then, [undef], 'module promise resolution'); is_deeply(\@from_catch, [], 'module promise catch'); is( $retval, 42, "$label: module imported and used" ); $js = JavaScript::QuickJS->new()->set_globals( _return => sub { $retval = shift }, ); } undef $js; chdir $cwd; done_testing; JavaScript-QuickJS-0.21/t/regexp.t000644 000766 000024 00000002717 14355430271 017356 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use JavaScript::QuickJS; use Scalar::Util; my $regexp = JavaScript::QuickJS->new()->eval('/foo/g'); my @props = ( [ flags => 'g' ], [ global => bool(1) ], [ hasIndices => bool(0) ], [ multiline => bool(0) ], [ source => 'foo' ], [ sticky => bool(0) ], [ unicode => bool(0) ], [ lastIndex => 0 ], ); for my $p_ar (@props) { my ($propname, $value) = @$p_ar; cmp_deeply( $regexp->$propname(), $value, "$propname()" ); } cmp_deeply( $regexp->test('fo'), bool(0), 'test() w/ non-match' ); cmp_deeply( $regexp->test('fooo'), bool(1), 'test() w/ match' ); is( $regexp->exec('fo'), undef, 'exec() w/ non-match', ); is_deeply( $regexp->exec('foooo'), ['foo'], 'exec() w/ match', ); #---------------------------------------------------------------------- { my $js = JavaScript::QuickJS->new(); my $regexp = $js->eval('/foo/g'); $js->set_globals( re_from_perl => $regexp, ); my $match = $js->eval('re_from_perl.exec("foooo")'); cmp_deeply($match, ['foo'], 'RegExp to Perl, back to JS'); eval { JavaScript::QuickJS->new()->set_globals( bad => $regexp ) }; my $err = $@; my $re_class = ref $regexp; cmp_deeply( $err, all( re( qr<\Q$re_class\E> ), ), 'error when mismatched Perl RegExp object given', ); } done_testing; JavaScript-QuickJS-0.21/t/import_os.t000644 000766 000024 00000002033 14532531112 020057 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use Test::Deep; use Test::Fatal; use JavaScript::QuickJS; for my $mod (qw(os std)) { my $js = JavaScript::QuickJS->new()->$mod(); # ensure that this doesn't crash is( exception { $js->eval_module( qq ) }, undef, "JS with $mod(): module can import $mod", ); my $keys = $js->eval( qq ); cmp_deeply( $keys, superbagof( ignore() ), "JS with $mod(): global “$mod” exists in script mode", ) or diag explain $keys; my $js2 = JavaScript::QuickJS->new(); cmp_deeply( exception { $js2->eval_module( qq ) }, re(qr/ReferenceError/), "JS without $mod(): module fails to import $mod", ); cmp_deeply( exception { $js2->eval( qq ) }, re(qr/ReferenceError/), "JS without $mod(): script lacks global $mod", ); } done_testing; JavaScript-QuickJS-0.21/t/callback_err.t000644 000766 000024 00000002525 14355430271 020465 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); $js->set_globals( trouble => sub { die( bless [], 'Trouble' ) }, nada => sub {}, bad_perl => sub { bless [], 'WhatWhat' }, bad_perl_in_array => sub { [ bless [], 'WhatWhat' ] }, bad_perl_in_hash => sub { { foo => \*STDOUT } }, ); { my @w; $SIG{__WARN__} = sub { push @w, @_ }; eval { $js->eval("trouble()") }; my $err = $@; is(0 + @w, 1, '1 warning'); like($w[0], qr<\ATrouble=ARRAY>, 'expected warning text'); like($err, qr, 'expected error'); like($err, qri, 'error mentions JS'); } { eval { $js->eval("nada(BigInt(123123))") }; my $err = $@; like($err, qri, 'BigInt to Perl triggers error'); eval { $js->eval("nada(123, Symbol(123123))") }; $err = $@; like($err, qri, 'Symbol to Perl triggers error'); eval { $js->eval("bad_perl()") }; $err = $@; like($err, qri, 'blessed ref from callback triggers error'); eval { $js->eval("bad_perl_in_array()") }; $err = $@; like($err, qri, 'blessed ref is in array'); eval { $js->eval("bad_perl_in_hash()") }; $err = $@; like($err, qri, 'filehandle ref is in hash'); } done_testing; JavaScript-QuickJS-0.21/t/await.t000644 000766 000024 00000001302 14355430271 017156 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Deep; use Test::FailWarnings; use File::Temp; use Cwd; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $cwd = Cwd::getcwd(); my $dir = File::Temp::tempdir( CLEANUP => 1 ); chdir $dir or die "chdir($dir): $!"; { open my $jfh, '>', "module.js"; print {$jfh} "export let foo = 'BAR';"; } my $got; $js->set_globals( __ret => sub { $got = shift }, )->eval(< __ret(exp.foo)); END is($got, undef, 'pre-await(): no returned value'); $js->await(); is($got, 'BAR', 'await() waited until the jobs are done'); chdir $cwd or warn "chdir($cwd): $!"; done_testing; JavaScript-QuickJS-0.21/t/js_func_to_perl.t000644 000766 000024 00000001532 14355430271 021231 0ustar00felipestaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::FailWarnings; use JavaScript::QuickJS; my $js = JavaScript::QuickJS->new(); my $cb = $js->helpers->eval("(val) => val + 1"); isa_ok($cb, 'JavaScript::QuickJS::Function', 'JS callback'); is($cb->length(), 1, 'length() gives arity'); is($cb->name(), q<>, 'name()'); is( $cb->(2), 3, 'JS function called from Perl', ); undef $cb; pass 'Still alive (callback reaped)'; undef $js; pass 'Still alive (JS reaped)'; #---------------------------------------------------------------------- $js = JavaScript::QuickJS->new(); my $cb2 = $js->eval("let f = function myFunc(foo, bar) {}; f"); isa_ok($cb2, 'JavaScript::QuickJS::Function', 'JS callback (declaration)'); is($cb2->length(), 2, 'length() gives arity'); is($cb2->name(), q, 'name()'); done_testing(); JavaScript-QuickJS-0.21/quickjs/libregexp.c000644 000766 000024 00000240655 14562313516 021241 0ustar00felipestaff000000 000000 /* * Regular Expression Engine * * Copyright (c) 2017-2018 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include #include #include #include #include #include #include "cutils.h" #include "libregexp.h" /* TODO: - Add a lock step execution mode (=linear time execution guaranteed) when the regular expression is "simple" i.e. no backreference nor complicated lookahead. The opcodes are designed for this execution model. */ #if defined(TEST) #define DUMP_REOP #endif typedef enum { #define DEF(id, size) REOP_ ## id, #include "libregexp-opcode.h" #undef DEF REOP_COUNT, } REOPCodeEnum; #define CAPTURE_COUNT_MAX 255 #define STACK_SIZE_MAX 255 /* unicode code points */ #define CP_LS 0x2028 #define CP_PS 0x2029 #define TMP_BUF_SIZE 128 typedef struct { DynBuf byte_code; const uint8_t *buf_ptr; const uint8_t *buf_end; const uint8_t *buf_start; int re_flags; BOOL is_utf16; BOOL ignore_case; BOOL dotall; int capture_count; int total_capture_count; /* -1 = not computed yet */ int has_named_captures; /* -1 = don't know, 0 = no, 1 = yes */ void *opaque; DynBuf group_names; union { char error_msg[TMP_BUF_SIZE]; char tmp_buf[TMP_BUF_SIZE]; } u; } REParseState; typedef struct { #ifdef DUMP_REOP const char *name; #endif uint8_t size; } REOpCode; static const REOpCode reopcode_info[REOP_COUNT] = { #ifdef DUMP_REOP #define DEF(id, size) { #id, size }, #else #define DEF(id, size) { size }, #endif #include "libregexp-opcode.h" #undef DEF }; #define RE_HEADER_FLAGS 0 #define RE_HEADER_CAPTURE_COUNT 1 #define RE_HEADER_STACK_SIZE 2 #define RE_HEADER_LEN 7 static inline int is_digit(int c) { return c >= '0' && c <= '9'; } /* insert 'len' bytes at position 'pos'. Return < 0 if error. */ static int dbuf_insert(DynBuf *s, int pos, int len) { if (dbuf_realloc(s, s->size + len)) return -1; memmove(s->buf + pos + len, s->buf + pos, s->size - pos); s->size += len; return 0; } static const uint16_t char_range_d[] = { 1, 0x0030, 0x0039 + 1, }; /* code point ranges for Zs,Zl or Zp property */ static const uint16_t char_range_s[] = { 10, 0x0009, 0x000D + 1, 0x0020, 0x0020 + 1, 0x00A0, 0x00A0 + 1, 0x1680, 0x1680 + 1, 0x2000, 0x200A + 1, /* 2028;LINE SEPARATOR;Zl;0;WS;;;;;N;;;;; */ /* 2029;PARAGRAPH SEPARATOR;Zp;0;B;;;;;N;;;;; */ 0x2028, 0x2029 + 1, 0x202F, 0x202F + 1, 0x205F, 0x205F + 1, 0x3000, 0x3000 + 1, /* FEFF;ZERO WIDTH NO-BREAK SPACE;Cf;0;BN;;;;;N;BYTE ORDER MARK;;;; */ 0xFEFF, 0xFEFF + 1, }; BOOL lre_is_space(int c) { int i, n, low, high; n = (countof(char_range_s) - 1) / 2; for(i = 0; i < n; i++) { low = char_range_s[2 * i + 1]; if (c < low) return FALSE; high = char_range_s[2 * i + 2]; if (c < high) return TRUE; } return FALSE; } uint32_t const lre_id_start_table_ascii[4] = { /* $ A-Z _ a-z */ 0x00000000, 0x00000010, 0x87FFFFFE, 0x07FFFFFE }; uint32_t const lre_id_continue_table_ascii[4] = { /* $ 0-9 A-Z _ a-z */ 0x00000000, 0x03FF0010, 0x87FFFFFE, 0x07FFFFFE }; static const uint16_t char_range_w[] = { 4, 0x0030, 0x0039 + 1, 0x0041, 0x005A + 1, 0x005F, 0x005F + 1, 0x0061, 0x007A + 1, }; #define CLASS_RANGE_BASE 0x40000000 typedef enum { CHAR_RANGE_d, CHAR_RANGE_D, CHAR_RANGE_s, CHAR_RANGE_S, CHAR_RANGE_w, CHAR_RANGE_W, } CharRangeEnum; static const uint16_t *char_range_table[] = { char_range_d, char_range_s, char_range_w, }; static int cr_init_char_range(REParseState *s, CharRange *cr, uint32_t c) { BOOL invert; const uint16_t *c_pt; int len, i; invert = c & 1; c_pt = char_range_table[c >> 1]; len = *c_pt++; cr_init(cr, s->opaque, lre_realloc); for(i = 0; i < len * 2; i++) { if (cr_add_point(cr, c_pt[i])) goto fail; } if (invert) { if (cr_invert(cr)) goto fail; } return 0; fail: cr_free(cr); return -1; } #ifdef DUMP_REOP static __maybe_unused void lre_dump_bytecode(const uint8_t *buf, int buf_len) { int pos, len, opcode, bc_len, re_flags, i; uint32_t val; assert(buf_len >= RE_HEADER_LEN); re_flags= buf[0]; bc_len = get_u32(buf + 3); assert(bc_len + RE_HEADER_LEN <= buf_len); printf("flags: 0x%x capture_count=%d stack_size=%d\n", re_flags, buf[1], buf[2]); if (re_flags & LRE_FLAG_NAMED_GROUPS) { const char *p; p = (char *)buf + RE_HEADER_LEN + bc_len; printf("named groups: "); for(i = 1; i < buf[1]; i++) { if (i != 1) printf(","); printf("<%s>", p); p += strlen(p) + 1; } printf("\n"); assert(p == (char *)(buf + buf_len)); } printf("bytecode_len=%d\n", bc_len); buf += RE_HEADER_LEN; pos = 0; while (pos < bc_len) { printf("%5u: ", pos); opcode = buf[pos]; len = reopcode_info[opcode].size; if (opcode >= REOP_COUNT) { printf(" invalid opcode=0x%02x\n", opcode); break; } if ((pos + len) > bc_len) { printf(" buffer overflow (opcode=0x%02x)\n", opcode); break; } printf("%s", reopcode_info[opcode].name); switch(opcode) { case REOP_char: val = get_u16(buf + pos + 1); if (val >= ' ' && val <= 126) printf(" '%c'", val); else printf(" 0x%04x", val); break; case REOP_char32: val = get_u32(buf + pos + 1); if (val >= ' ' && val <= 126) printf(" '%c'", val); else printf(" 0x%08x", val); break; case REOP_goto: case REOP_split_goto_first: case REOP_split_next_first: case REOP_loop: case REOP_lookahead: case REOP_negative_lookahead: val = get_u32(buf + pos + 1); val += (pos + 5); printf(" %u", val); break; case REOP_simple_greedy_quant: printf(" %u %u %u %u", get_u32(buf + pos + 1) + (pos + 17), get_u32(buf + pos + 1 + 4), get_u32(buf + pos + 1 + 8), get_u32(buf + pos + 1 + 12)); break; case REOP_save_start: case REOP_save_end: case REOP_back_reference: case REOP_backward_back_reference: printf(" %u", buf[pos + 1]); break; case REOP_save_reset: printf(" %u %u", buf[pos + 1], buf[pos + 2]); break; case REOP_push_i32: val = get_u32(buf + pos + 1); printf(" %d", val); break; case REOP_range: { int n, i; n = get_u16(buf + pos + 1); len += n * 4; for(i = 0; i < n * 2; i++) { val = get_u16(buf + pos + 3 + i * 2); printf(" 0x%04x", val); } } break; case REOP_range32: { int n, i; n = get_u16(buf + pos + 1); len += n * 8; for(i = 0; i < n * 2; i++) { val = get_u32(buf + pos + 3 + i * 4); printf(" 0x%08x", val); } } break; default: break; } printf("\n"); pos += len; } } #endif static void re_emit_op(REParseState *s, int op) { dbuf_putc(&s->byte_code, op); } /* return the offset of the u32 value */ static int re_emit_op_u32(REParseState *s, int op, uint32_t val) { int pos; dbuf_putc(&s->byte_code, op); pos = s->byte_code.size; dbuf_put_u32(&s->byte_code, val); return pos; } static int re_emit_goto(REParseState *s, int op, uint32_t val) { int pos; dbuf_putc(&s->byte_code, op); pos = s->byte_code.size; dbuf_put_u32(&s->byte_code, val - (pos + 4)); return pos; } static void re_emit_op_u8(REParseState *s, int op, uint32_t val) { dbuf_putc(&s->byte_code, op); dbuf_putc(&s->byte_code, val); } static void re_emit_op_u16(REParseState *s, int op, uint32_t val) { dbuf_putc(&s->byte_code, op); dbuf_put_u16(&s->byte_code, val); } static int __attribute__((format(printf, 2, 3))) re_parse_error(REParseState *s, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vsnprintf(s->u.error_msg, sizeof(s->u.error_msg), fmt, ap); va_end(ap); return -1; } static int re_parse_out_of_memory(REParseState *s) { return re_parse_error(s, "out of memory"); } /* If allow_overflow is false, return -1 in case of overflow. Otherwise return INT32_MAX. */ static int parse_digits(const uint8_t **pp, BOOL allow_overflow) { const uint8_t *p; uint64_t v; int c; p = *pp; v = 0; for(;;) { c = *p; if (c < '0' || c > '9') break; v = v * 10 + c - '0'; if (v >= INT32_MAX) { if (allow_overflow) v = INT32_MAX; else return -1; } p++; } *pp = p; return v; } static int re_parse_expect(REParseState *s, const uint8_t **pp, int c) { const uint8_t *p; p = *pp; if (*p != c) return re_parse_error(s, "expecting '%c'", c); p++; *pp = p; return 0; } /* Parse an escape sequence, *pp points after the '\': allow_utf16 value: 0 : no UTF-16 escapes allowed 1 : UTF-16 escapes allowed 2 : UTF-16 escapes allowed and escapes of surrogate pairs are converted to a unicode character (unicode regexp case). Return the unicode char and update *pp if recognized, return -1 if malformed escape, return -2 otherwise. */ int lre_parse_escape(const uint8_t **pp, int allow_utf16) { const uint8_t *p; uint32_t c; p = *pp; c = *p++; switch(c) { case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case 'x': case 'u': { int h, n, i; uint32_t c1; if (*p == '{' && allow_utf16) { p++; c = 0; for(;;) { h = from_hex(*p++); if (h < 0) return -1; c = (c << 4) | h; if (c > 0x10FFFF) return -1; if (*p == '}') break; } p++; } else { if (c == 'x') { n = 2; } else { n = 4; } c = 0; for(i = 0; i < n; i++) { h = from_hex(*p++); if (h < 0) { return -1; } c = (c << 4) | h; } if (c >= 0xd800 && c < 0xdc00 && allow_utf16 == 2 && p[0] == '\\' && p[1] == 'u') { /* convert an escaped surrogate pair into a unicode char */ c1 = 0; for(i = 0; i < 4; i++) { h = from_hex(p[2 + i]); if (h < 0) break; c1 = (c1 << 4) | h; } if (i == 4 && c1 >= 0xdc00 && c1 < 0xe000) { p += 6; c = (((c & 0x3ff) << 10) | (c1 & 0x3ff)) + 0x10000; } } } } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': c -= '0'; if (allow_utf16 == 2) { /* only accept \0 not followed by digit */ if (c != 0 || is_digit(*p)) return -1; } else { /* parse a legacy octal sequence */ uint32_t v; v = *p - '0'; if (v > 7) break; c = (c << 3) | v; p++; if (c >= 32) break; v = *p - '0'; if (v > 7) break; c = (c << 3) | v; p++; } break; default: return -2; } *pp = p; return c; } #ifdef CONFIG_ALL_UNICODE /* XXX: we use the same chars for name and value */ static BOOL is_unicode_char(int c) { return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '_')); } static int parse_unicode_property(REParseState *s, CharRange *cr, const uint8_t **pp, BOOL is_inv) { const uint8_t *p; char name[64], value[64]; char *q; BOOL script_ext; int ret; p = *pp; if (*p != '{') return re_parse_error(s, "expecting '{' after \\p"); p++; q = name; while (is_unicode_char(*p)) { if ((q - name) >= sizeof(name) - 1) goto unknown_property_name; *q++ = *p++; } *q = '\0'; q = value; if (*p == '=') { p++; while (is_unicode_char(*p)) { if ((q - value) >= sizeof(value) - 1) return re_parse_error(s, "unknown unicode property value"); *q++ = *p++; } } *q = '\0'; if (*p != '}') return re_parse_error(s, "expecting '}'"); p++; // printf("name=%s value=%s\n", name, value); if (!strcmp(name, "Script") || !strcmp(name, "sc")) { script_ext = FALSE; goto do_script; } else if (!strcmp(name, "Script_Extensions") || !strcmp(name, "scx")) { script_ext = TRUE; do_script: cr_init(cr, s->opaque, lre_realloc); ret = unicode_script(cr, value, script_ext); if (ret) { cr_free(cr); if (ret == -2) return re_parse_error(s, "unknown unicode script"); else goto out_of_memory; } } else if (!strcmp(name, "General_Category") || !strcmp(name, "gc")) { cr_init(cr, s->opaque, lre_realloc); ret = unicode_general_category(cr, value); if (ret) { cr_free(cr); if (ret == -2) return re_parse_error(s, "unknown unicode general category"); else goto out_of_memory; } } else if (value[0] == '\0') { cr_init(cr, s->opaque, lre_realloc); ret = unicode_general_category(cr, name); if (ret == -1) { cr_free(cr); goto out_of_memory; } if (ret < 0) { ret = unicode_prop(cr, name); if (ret) { cr_free(cr); if (ret == -2) goto unknown_property_name; else goto out_of_memory; } } } else { unknown_property_name: return re_parse_error(s, "unknown unicode property name"); } if (is_inv) { if (cr_invert(cr)) { cr_free(cr); return -1; } } *pp = p; return 0; out_of_memory: return re_parse_out_of_memory(s); } #endif /* CONFIG_ALL_UNICODE */ /* return -1 if error otherwise the character or a class range (CLASS_RANGE_BASE). In case of class range, 'cr' is initialized. Otherwise, it is ignored. */ static int get_class_atom(REParseState *s, CharRange *cr, const uint8_t **pp, BOOL inclass) { const uint8_t *p; uint32_t c; int ret; p = *pp; c = *p; switch(c) { case '\\': p++; if (p >= s->buf_end) goto unexpected_end; c = *p++; switch(c) { case 'd': c = CHAR_RANGE_d; goto class_range; case 'D': c = CHAR_RANGE_D; goto class_range; case 's': c = CHAR_RANGE_s; goto class_range; case 'S': c = CHAR_RANGE_S; goto class_range; case 'w': c = CHAR_RANGE_w; goto class_range; case 'W': c = CHAR_RANGE_W; class_range: if (cr_init_char_range(s, cr, c)) return -1; c = CLASS_RANGE_BASE; break; case 'c': c = *p; if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (((c >= '0' && c <= '9') || c == '_') && inclass && !s->is_utf16)) { /* Annex B.1.4 */ c &= 0x1f; p++; } else if (s->is_utf16) { goto invalid_escape; } else { /* otherwise return '\' and 'c' */ p--; c = '\\'; } break; #ifdef CONFIG_ALL_UNICODE case 'p': case 'P': if (s->is_utf16) { if (parse_unicode_property(s, cr, &p, (c == 'P'))) return -1; c = CLASS_RANGE_BASE; break; } /* fall thru */ #endif default: p--; ret = lre_parse_escape(&p, s->is_utf16 * 2); if (ret >= 0) { c = ret; } else { if (ret == -2 && *p != '\0' && strchr("^$\\.*+?()[]{}|/", *p)) { /* always valid to escape these characters */ goto normal_char; } else if (s->is_utf16) { invalid_escape: return re_parse_error(s, "invalid escape sequence in regular expression"); } else { /* just ignore the '\' */ goto normal_char; } } break; } break; case '\0': if (p >= s->buf_end) { unexpected_end: return re_parse_error(s, "unexpected end"); } /* fall thru */ default: normal_char: /* normal char */ if (c >= 128) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p); if ((unsigned)c > 0xffff && !s->is_utf16) { /* XXX: should handle non BMP-1 code points */ return re_parse_error(s, "malformed unicode char"); } } else { p++; } break; } *pp = p; return c; } static int re_emit_range(REParseState *s, const CharRange *cr) { int len, i; uint32_t high; len = (unsigned)cr->len / 2; if (len >= 65535) return re_parse_error(s, "too many ranges"); if (len == 0) { /* not sure it can really happen. Emit a match that is always false */ re_emit_op_u32(s, REOP_char32, -1); } else { high = cr->points[cr->len - 1]; if (high == UINT32_MAX) high = cr->points[cr->len - 2]; if (high <= 0xffff) { /* can use 16 bit ranges with the conversion that 0xffff = infinity */ re_emit_op_u16(s, REOP_range, len); for(i = 0; i < cr->len; i += 2) { dbuf_put_u16(&s->byte_code, cr->points[i]); high = cr->points[i + 1] - 1; if (high == UINT32_MAX - 1) high = 0xffff; dbuf_put_u16(&s->byte_code, high); } } else { re_emit_op_u16(s, REOP_range32, len); for(i = 0; i < cr->len; i += 2) { dbuf_put_u32(&s->byte_code, cr->points[i]); dbuf_put_u32(&s->byte_code, cr->points[i + 1] - 1); } } } return 0; } static int re_parse_char_class(REParseState *s, const uint8_t **pp) { const uint8_t *p; uint32_t c1, c2; CharRange cr_s, *cr = &cr_s; CharRange cr1_s, *cr1 = &cr1_s; BOOL invert; cr_init(cr, s->opaque, lre_realloc); p = *pp; p++; /* skip '[' */ invert = FALSE; if (*p == '^') { p++; invert = TRUE; } for(;;) { if (*p == ']') break; c1 = get_class_atom(s, cr1, &p, TRUE); if ((int)c1 < 0) goto fail; if (*p == '-' && p[1] != ']') { const uint8_t *p0 = p + 1; if (c1 >= CLASS_RANGE_BASE) { if (s->is_utf16) { cr_free(cr1); goto invalid_class_range; } /* Annex B: match '-' character */ goto class_atom; } c2 = get_class_atom(s, cr1, &p0, TRUE); if ((int)c2 < 0) goto fail; if (c2 >= CLASS_RANGE_BASE) { cr_free(cr1); if (s->is_utf16) { goto invalid_class_range; } /* Annex B: match '-' character */ goto class_atom; } p = p0; if (c2 < c1) { invalid_class_range: re_parse_error(s, "invalid class range"); goto fail; } if (cr_union_interval(cr, c1, c2)) goto memory_error; } else { class_atom: if (c1 >= CLASS_RANGE_BASE) { int ret; ret = cr_union1(cr, cr1->points, cr1->len); cr_free(cr1); if (ret) goto memory_error; } else { if (cr_union_interval(cr, c1, c1)) goto memory_error; } } } if (s->ignore_case) { if (cr_regexp_canonicalize(cr, s->is_utf16)) goto memory_error; } if (invert) { if (cr_invert(cr)) goto memory_error; } if (re_emit_range(s, cr)) goto fail; cr_free(cr); p++; /* skip ']' */ *pp = p; return 0; memory_error: re_parse_out_of_memory(s); fail: cr_free(cr); return -1; } /* Return: - true if the opcodes may not advance the char pointer - false if the opcodes always advance the char pointer */ static BOOL re_need_check_advance(const uint8_t *bc_buf, int bc_buf_len) { int pos, opcode, len; uint32_t val; BOOL ret; ret = TRUE; pos = 0; while (pos < bc_buf_len) { opcode = bc_buf[pos]; len = reopcode_info[opcode].size; switch(opcode) { case REOP_range: val = get_u16(bc_buf + pos + 1); len += val * 4; goto simple_char; case REOP_range32: val = get_u16(bc_buf + pos + 1); len += val * 8; goto simple_char; case REOP_char: case REOP_char32: case REOP_dot: case REOP_any: simple_char: ret = FALSE; break; case REOP_line_start: case REOP_line_end: case REOP_push_i32: case REOP_push_char_pos: case REOP_drop: case REOP_word_boundary: case REOP_not_word_boundary: case REOP_prev: /* no effect */ break; case REOP_save_start: case REOP_save_end: case REOP_save_reset: case REOP_back_reference: case REOP_backward_back_reference: break; default: /* safe behvior: we cannot predict the outcome */ return TRUE; } pos += len; } return ret; } /* return -1 if a simple quantifier cannot be used. Otherwise return the number of characters in the atom. */ static int re_is_simple_quantifier(const uint8_t *bc_buf, int bc_buf_len) { int pos, opcode, len, count; uint32_t val; count = 0; pos = 0; while (pos < bc_buf_len) { opcode = bc_buf[pos]; len = reopcode_info[opcode].size; switch(opcode) { case REOP_range: val = get_u16(bc_buf + pos + 1); len += val * 4; goto simple_char; case REOP_range32: val = get_u16(bc_buf + pos + 1); len += val * 8; goto simple_char; case REOP_char: case REOP_char32: case REOP_dot: case REOP_any: simple_char: count++; break; case REOP_line_start: case REOP_line_end: case REOP_word_boundary: case REOP_not_word_boundary: break; default: return -1; } pos += len; } return count; } /* '*pp' is the first char after '<' */ static int re_parse_group_name(char *buf, int buf_size, const uint8_t **pp) { const uint8_t *p, *p1; uint32_t c, d; char *q; p = *pp; q = buf; for(;;) { c = *p; if (c == '\\') { p++; if (*p != 'u') return -1; c = lre_parse_escape(&p, 2); // accept surrogate pairs } else if (c == '>') { break; } else if (c >= 128) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p); if (c >= 0xD800 && c <= 0xDBFF) { d = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p1); if (d >= 0xDC00 && d <= 0xDFFF) { c = 0x10000 + 0x400 * (c - 0xD800) + (d - 0xDC00); p = p1; } } } else { p++; } if (c > 0x10FFFF) return -1; if (q == buf) { if (!lre_js_is_ident_first(c)) return -1; } else { if (!lre_js_is_ident_next(c)) return -1; } if ((q - buf + UTF8_CHAR_LEN_MAX + 1) > buf_size) return -1; if (c < 128) { *q++ = c; } else { q += unicode_to_utf8((uint8_t*)q, c); } } if (q == buf) return -1; *q = '\0'; p++; *pp = p; return 0; } /* if capture_name = NULL: return the number of captures + 1. Otherwise, return the capture index corresponding to capture_name or -1 if none */ static int re_parse_captures(REParseState *s, int *phas_named_captures, const char *capture_name) { const uint8_t *p; int capture_index; char name[TMP_BUF_SIZE]; capture_index = 1; *phas_named_captures = 0; for (p = s->buf_start; p < s->buf_end; p++) { switch (*p) { case '(': if (p[1] == '?') { if (p[2] == '<' && p[3] != '=' && p[3] != '!') { *phas_named_captures = 1; /* potential named capture */ if (capture_name) { p += 3; if (re_parse_group_name(name, sizeof(name), &p) == 0) { if (!strcmp(name, capture_name)) return capture_index; } } capture_index++; if (capture_index >= CAPTURE_COUNT_MAX) goto done; } } else { capture_index++; if (capture_index >= CAPTURE_COUNT_MAX) goto done; } break; case '\\': p++; break; case '[': for (p += 1 + (*p == ']'); p < s->buf_end && *p != ']'; p++) { if (*p == '\\') p++; } break; } } done: if (capture_name) return -1; else return capture_index; } static int re_count_captures(REParseState *s) { if (s->total_capture_count < 0) { s->total_capture_count = re_parse_captures(s, &s->has_named_captures, NULL); } return s->total_capture_count; } static BOOL re_has_named_captures(REParseState *s) { if (s->has_named_captures < 0) re_count_captures(s); return s->has_named_captures; } static int find_group_name(REParseState *s, const char *name) { const char *p, *buf_end; size_t len, name_len; int capture_index; name_len = strlen(name); p = (char *)s->group_names.buf; buf_end = (char *)s->group_names.buf + s->group_names.size; capture_index = 1; while (p < buf_end) { len = strlen(p); if (len == name_len && memcmp(name, p, name_len) == 0) return capture_index; p += len + 1; capture_index++; } return -1; } static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir); static int re_parse_term(REParseState *s, BOOL is_backward_dir) { const uint8_t *p; int c, last_atom_start, quant_min, quant_max, last_capture_count; BOOL greedy, add_zero_advance_check, is_neg, is_backward_lookahead; CharRange cr_s, *cr = &cr_s; last_atom_start = -1; last_capture_count = 0; p = s->buf_ptr; c = *p; switch(c) { case '^': p++; re_emit_op(s, REOP_line_start); break; case '$': p++; re_emit_op(s, REOP_line_end); break; case '.': p++; last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; if (is_backward_dir) re_emit_op(s, REOP_prev); re_emit_op(s, s->dotall ? REOP_any : REOP_dot); if (is_backward_dir) re_emit_op(s, REOP_prev); break; case '{': if (s->is_utf16) { return re_parse_error(s, "syntax error"); } else if (!is_digit(p[1])) { /* Annex B: we accept '{' not followed by digits as a normal atom */ goto parse_class_atom; } else { const uint8_t *p1 = p + 1; /* Annex B: error if it is like a repetition count */ parse_digits(&p1, TRUE); if (*p1 == ',') { p1++; if (is_digit(*p1)) { parse_digits(&p1, TRUE); } } if (*p1 != '}') { goto parse_class_atom; } } /* fall thru */ case '*': case '+': case '?': return re_parse_error(s, "nothing to repeat"); case '(': if (p[1] == '?') { if (p[2] == ':') { p += 3; last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; s->buf_ptr = p; if (re_parse_disjunction(s, is_backward_dir)) return -1; p = s->buf_ptr; if (re_parse_expect(s, &p, ')')) return -1; } else if ((p[2] == '=' || p[2] == '!')) { is_neg = (p[2] == '!'); is_backward_lookahead = FALSE; p += 3; goto lookahead; } else if (p[2] == '<' && (p[3] == '=' || p[3] == '!')) { int pos; is_neg = (p[3] == '!'); is_backward_lookahead = TRUE; p += 4; /* lookahead */ lookahead: /* Annex B allows lookahead to be used as an atom for the quantifiers */ if (!s->is_utf16 && !is_backward_lookahead) { last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; } pos = re_emit_op_u32(s, REOP_lookahead + is_neg, 0); s->buf_ptr = p; if (re_parse_disjunction(s, is_backward_lookahead)) return -1; p = s->buf_ptr; if (re_parse_expect(s, &p, ')')) return -1; re_emit_op(s, REOP_match); /* jump after the 'match' after the lookahead is successful */ if (dbuf_error(&s->byte_code)) return -1; put_u32(s->byte_code.buf + pos, s->byte_code.size - (pos + 4)); } else if (p[2] == '<') { p += 3; if (re_parse_group_name(s->u.tmp_buf, sizeof(s->u.tmp_buf), &p)) { return re_parse_error(s, "invalid group name"); } if (find_group_name(s, s->u.tmp_buf) > 0) { return re_parse_error(s, "duplicate group name"); } /* group name with a trailing zero */ dbuf_put(&s->group_names, (uint8_t *)s->u.tmp_buf, strlen(s->u.tmp_buf) + 1); s->has_named_captures = 1; goto parse_capture; } else { return re_parse_error(s, "invalid group"); } } else { int capture_index; p++; /* capture without group name */ dbuf_putc(&s->group_names, 0); parse_capture: if (s->capture_count >= CAPTURE_COUNT_MAX) return re_parse_error(s, "too many captures"); last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; capture_index = s->capture_count++; re_emit_op_u8(s, REOP_save_start + is_backward_dir, capture_index); s->buf_ptr = p; if (re_parse_disjunction(s, is_backward_dir)) return -1; p = s->buf_ptr; re_emit_op_u8(s, REOP_save_start + 1 - is_backward_dir, capture_index); if (re_parse_expect(s, &p, ')')) return -1; } break; case '\\': switch(p[1]) { case 'b': case 'B': re_emit_op(s, REOP_word_boundary + (p[1] != 'b')); p += 2; break; case 'k': { const uint8_t *p1; int dummy_res; p1 = p; if (p1[2] != '<') { /* annex B: we tolerate invalid group names in non unicode mode if there is no named capture definition */ if (s->is_utf16 || re_has_named_captures(s)) return re_parse_error(s, "expecting group name"); else goto parse_class_atom; } p1 += 3; if (re_parse_group_name(s->u.tmp_buf, sizeof(s->u.tmp_buf), &p1)) { if (s->is_utf16 || re_has_named_captures(s)) return re_parse_error(s, "invalid group name"); else goto parse_class_atom; } c = find_group_name(s, s->u.tmp_buf); if (c < 0) { /* no capture name parsed before, try to look after (inefficient, but hopefully not common */ c = re_parse_captures(s, &dummy_res, s->u.tmp_buf); if (c < 0) { if (s->is_utf16 || re_has_named_captures(s)) return re_parse_error(s, "group name not defined"); else goto parse_class_atom; } } p = p1; } goto emit_back_reference; case '0': p += 2; c = 0; if (s->is_utf16) { if (is_digit(*p)) { return re_parse_error(s, "invalid decimal escape in regular expression"); } } else { /* Annex B.1.4: accept legacy octal */ if (*p >= '0' && *p <= '7') { c = *p++ - '0'; if (*p >= '0' && *p <= '7') { c = (c << 3) + *p++ - '0'; } } } goto normal_char; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { const uint8_t *q = ++p; c = parse_digits(&p, FALSE); if (c < 0 || (c >= s->capture_count && c >= re_count_captures(s))) { if (!s->is_utf16) { /* Annex B.1.4: accept legacy octal */ p = q; if (*p <= '7') { c = 0; if (*p <= '3') c = *p++ - '0'; if (*p >= '0' && *p <= '7') { c = (c << 3) + *p++ - '0'; if (*p >= '0' && *p <= '7') { c = (c << 3) + *p++ - '0'; } } } else { c = *p++; } goto normal_char; } return re_parse_error(s, "back reference out of range in regular expression"); } emit_back_reference: last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; re_emit_op_u8(s, REOP_back_reference + is_backward_dir, c); } break; default: goto parse_class_atom; } break; case '[': last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; if (is_backward_dir) re_emit_op(s, REOP_prev); if (re_parse_char_class(s, &p)) return -1; if (is_backward_dir) re_emit_op(s, REOP_prev); break; case ']': case '}': if (s->is_utf16) return re_parse_error(s, "syntax error"); goto parse_class_atom; default: parse_class_atom: c = get_class_atom(s, cr, &p, FALSE); if ((int)c < 0) return -1; normal_char: last_atom_start = s->byte_code.size; last_capture_count = s->capture_count; if (is_backward_dir) re_emit_op(s, REOP_prev); if (c >= CLASS_RANGE_BASE) { int ret; /* Note: canonicalization is not needed */ ret = re_emit_range(s, cr); cr_free(cr); if (ret) return -1; } else { if (s->ignore_case) c = lre_canonicalize(c, s->is_utf16); if (c <= 0xffff) re_emit_op_u16(s, REOP_char, c); else re_emit_op_u32(s, REOP_char32, c); } if (is_backward_dir) re_emit_op(s, REOP_prev); break; } /* quantifier */ if (last_atom_start >= 0) { c = *p; switch(c) { case '*': p++; quant_min = 0; quant_max = INT32_MAX; goto quantifier; case '+': p++; quant_min = 1; quant_max = INT32_MAX; goto quantifier; case '?': p++; quant_min = 0; quant_max = 1; goto quantifier; case '{': { const uint8_t *p1 = p; /* As an extension (see ES6 annex B), we accept '{' not followed by digits as a normal atom */ if (!is_digit(p[1])) { if (s->is_utf16) goto invalid_quant_count; break; } p++; quant_min = parse_digits(&p, TRUE); quant_max = quant_min; if (*p == ',') { p++; if (is_digit(*p)) { quant_max = parse_digits(&p, TRUE); if (quant_max < quant_min) { invalid_quant_count: return re_parse_error(s, "invalid repetition count"); } } else { quant_max = INT32_MAX; /* infinity */ } } if (*p != '}' && !s->is_utf16) { /* Annex B: normal atom if invalid '{' syntax */ p = p1; break; } if (re_parse_expect(s, &p, '}')) return -1; } quantifier: greedy = TRUE; if (*p == '?') { p++; greedy = FALSE; } if (last_atom_start < 0) { return re_parse_error(s, "nothing to repeat"); } if (greedy) { int len, pos; if (quant_max > 0) { /* specific optimization for simple quantifiers */ if (dbuf_error(&s->byte_code)) goto out_of_memory; len = re_is_simple_quantifier(s->byte_code.buf + last_atom_start, s->byte_code.size - last_atom_start); if (len > 0) { re_emit_op(s, REOP_match); if (dbuf_insert(&s->byte_code, last_atom_start, 17)) goto out_of_memory; pos = last_atom_start; s->byte_code.buf[pos++] = REOP_simple_greedy_quant; put_u32(&s->byte_code.buf[pos], s->byte_code.size - last_atom_start - 17); pos += 4; put_u32(&s->byte_code.buf[pos], quant_min); pos += 4; put_u32(&s->byte_code.buf[pos], quant_max); pos += 4; put_u32(&s->byte_code.buf[pos], len); pos += 4; goto done; } } if (dbuf_error(&s->byte_code)) goto out_of_memory; /* the spec tells that if there is no advance when running the atom after the first quant_min times, then there is no match. We remove this test when we are sure the atom always advances the position. */ add_zero_advance_check = re_need_check_advance(s->byte_code.buf + last_atom_start, s->byte_code.size - last_atom_start); } else { add_zero_advance_check = FALSE; } { int len, pos; len = s->byte_code.size - last_atom_start; if (quant_min == 0) { /* need to reset the capture in case the atom is not executed */ if (last_capture_count != s->capture_count) { if (dbuf_insert(&s->byte_code, last_atom_start, 3)) goto out_of_memory; s->byte_code.buf[last_atom_start++] = REOP_save_reset; s->byte_code.buf[last_atom_start++] = last_capture_count; s->byte_code.buf[last_atom_start++] = s->capture_count - 1; } if (quant_max == 0) { s->byte_code.size = last_atom_start; } else if (quant_max == 1 || quant_max == INT32_MAX) { BOOL has_goto = (quant_max == INT32_MAX); if (dbuf_insert(&s->byte_code, last_atom_start, 5 + add_zero_advance_check)) goto out_of_memory; s->byte_code.buf[last_atom_start] = REOP_split_goto_first + greedy; put_u32(s->byte_code.buf + last_atom_start + 1, len + 5 * has_goto + add_zero_advance_check * 2); if (add_zero_advance_check) { s->byte_code.buf[last_atom_start + 1 + 4] = REOP_push_char_pos; re_emit_op(s, REOP_check_advance); } if (has_goto) re_emit_goto(s, REOP_goto, last_atom_start); } else { if (dbuf_insert(&s->byte_code, last_atom_start, 10 + add_zero_advance_check)) goto out_of_memory; pos = last_atom_start; s->byte_code.buf[pos++] = REOP_push_i32; put_u32(s->byte_code.buf + pos, quant_max); pos += 4; s->byte_code.buf[pos++] = REOP_split_goto_first + greedy; put_u32(s->byte_code.buf + pos, len + 5 + add_zero_advance_check * 2); pos += 4; if (add_zero_advance_check) { s->byte_code.buf[pos++] = REOP_push_char_pos; re_emit_op(s, REOP_check_advance); } re_emit_goto(s, REOP_loop, last_atom_start + 5); re_emit_op(s, REOP_drop); } } else if (quant_min == 1 && quant_max == INT32_MAX && !add_zero_advance_check) { re_emit_goto(s, REOP_split_next_first - greedy, last_atom_start); } else { if (quant_min == 1) { /* nothing to add */ } else { if (dbuf_insert(&s->byte_code, last_atom_start, 5)) goto out_of_memory; s->byte_code.buf[last_atom_start] = REOP_push_i32; put_u32(s->byte_code.buf + last_atom_start + 1, quant_min); last_atom_start += 5; re_emit_goto(s, REOP_loop, last_atom_start); re_emit_op(s, REOP_drop); } if (quant_max == INT32_MAX) { pos = s->byte_code.size; re_emit_op_u32(s, REOP_split_goto_first + greedy, len + 5 + add_zero_advance_check * 2); if (add_zero_advance_check) re_emit_op(s, REOP_push_char_pos); /* copy the atom */ dbuf_put_self(&s->byte_code, last_atom_start, len); if (add_zero_advance_check) re_emit_op(s, REOP_check_advance); re_emit_goto(s, REOP_goto, pos); } else if (quant_max > quant_min) { re_emit_op_u32(s, REOP_push_i32, quant_max - quant_min); pos = s->byte_code.size; re_emit_op_u32(s, REOP_split_goto_first + greedy, len + 5 + add_zero_advance_check * 2); if (add_zero_advance_check) re_emit_op(s, REOP_push_char_pos); /* copy the atom */ dbuf_put_self(&s->byte_code, last_atom_start, len); if (add_zero_advance_check) re_emit_op(s, REOP_check_advance); re_emit_goto(s, REOP_loop, pos); re_emit_op(s, REOP_drop); } } last_atom_start = -1; } break; default: break; } } done: s->buf_ptr = p; return 0; out_of_memory: return re_parse_out_of_memory(s); } static int re_parse_alternative(REParseState *s, BOOL is_backward_dir) { const uint8_t *p; int ret; size_t start, term_start, end, term_size; start = s->byte_code.size; for(;;) { p = s->buf_ptr; if (p >= s->buf_end) break; if (*p == '|' || *p == ')') break; term_start = s->byte_code.size; ret = re_parse_term(s, is_backward_dir); if (ret) return ret; if (is_backward_dir) { /* reverse the order of the terms (XXX: inefficient, but speed is not really critical here) */ end = s->byte_code.size; term_size = end - term_start; if (dbuf_realloc(&s->byte_code, end + term_size)) return -1; memmove(s->byte_code.buf + start + term_size, s->byte_code.buf + start, end - start); memcpy(s->byte_code.buf + start, s->byte_code.buf + end, term_size); } } return 0; } static int re_parse_disjunction(REParseState *s, BOOL is_backward_dir) { int start, len, pos; if (lre_check_stack_overflow(s->opaque, 0)) return re_parse_error(s, "stack overflow"); start = s->byte_code.size; if (re_parse_alternative(s, is_backward_dir)) return -1; while (*s->buf_ptr == '|') { s->buf_ptr++; len = s->byte_code.size - start; /* insert a split before the first alternative */ if (dbuf_insert(&s->byte_code, start, 5)) { return re_parse_out_of_memory(s); } s->byte_code.buf[start] = REOP_split_next_first; put_u32(s->byte_code.buf + start + 1, len + 5); pos = re_emit_op_u32(s, REOP_goto, 0); if (re_parse_alternative(s, is_backward_dir)) return -1; /* patch the goto */ len = s->byte_code.size - (pos + 4); put_u32(s->byte_code.buf + pos, len); } return 0; } /* the control flow is recursive so the analysis can be linear */ static int compute_stack_size(const uint8_t *bc_buf, int bc_buf_len) { int stack_size, stack_size_max, pos, opcode, len; uint32_t val; stack_size = 0; stack_size_max = 0; bc_buf += RE_HEADER_LEN; bc_buf_len -= RE_HEADER_LEN; pos = 0; while (pos < bc_buf_len) { opcode = bc_buf[pos]; len = reopcode_info[opcode].size; assert(opcode < REOP_COUNT); assert((pos + len) <= bc_buf_len); switch(opcode) { case REOP_push_i32: case REOP_push_char_pos: stack_size++; if (stack_size > stack_size_max) { if (stack_size > STACK_SIZE_MAX) return -1; stack_size_max = stack_size; } break; case REOP_drop: case REOP_check_advance: assert(stack_size > 0); stack_size--; break; case REOP_range: val = get_u16(bc_buf + pos + 1); len += val * 4; break; case REOP_range32: val = get_u16(bc_buf + pos + 1); len += val * 8; break; } pos += len; } return stack_size_max; } /* 'buf' must be a zero terminated UTF-8 string of length buf_len. Return NULL if error and allocate an error message in *perror_msg, otherwise the compiled bytecode and its length in plen. */ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size, const char *buf, size_t buf_len, int re_flags, void *opaque) { REParseState s_s, *s = &s_s; int stack_size; BOOL is_sticky; memset(s, 0, sizeof(*s)); s->opaque = opaque; s->buf_ptr = (const uint8_t *)buf; s->buf_end = s->buf_ptr + buf_len; s->buf_start = s->buf_ptr; s->re_flags = re_flags; s->is_utf16 = ((re_flags & LRE_FLAG_UTF16) != 0); is_sticky = ((re_flags & LRE_FLAG_STICKY) != 0); s->ignore_case = ((re_flags & LRE_FLAG_IGNORECASE) != 0); s->dotall = ((re_flags & LRE_FLAG_DOTALL) != 0); s->capture_count = 1; s->total_capture_count = -1; s->has_named_captures = -1; dbuf_init2(&s->byte_code, opaque, lre_realloc); dbuf_init2(&s->group_names, opaque, lre_realloc); dbuf_putc(&s->byte_code, re_flags); /* first element is the flags */ dbuf_putc(&s->byte_code, 0); /* second element is the number of captures */ dbuf_putc(&s->byte_code, 0); /* stack size */ dbuf_put_u32(&s->byte_code, 0); /* bytecode length */ if (!is_sticky) { /* iterate thru all positions (about the same as .*?( ... ) ) . We do it without an explicit loop so that lock step thread execution will be possible in an optimized implementation */ re_emit_op_u32(s, REOP_split_goto_first, 1 + 5); re_emit_op(s, REOP_any); re_emit_op_u32(s, REOP_goto, -(5 + 1 + 5)); } re_emit_op_u8(s, REOP_save_start, 0); if (re_parse_disjunction(s, FALSE)) { error: dbuf_free(&s->byte_code); dbuf_free(&s->group_names); pstrcpy(error_msg, error_msg_size, s->u.error_msg); *plen = 0; return NULL; } re_emit_op_u8(s, REOP_save_end, 0); re_emit_op(s, REOP_match); if (*s->buf_ptr != '\0') { re_parse_error(s, "extraneous characters at the end"); goto error; } if (dbuf_error(&s->byte_code)) { re_parse_out_of_memory(s); goto error; } stack_size = compute_stack_size(s->byte_code.buf, s->byte_code.size); if (stack_size < 0) { re_parse_error(s, "too many imbricated quantifiers"); goto error; } s->byte_code.buf[RE_HEADER_CAPTURE_COUNT] = s->capture_count; s->byte_code.buf[RE_HEADER_STACK_SIZE] = stack_size; put_u32(s->byte_code.buf + 3, s->byte_code.size - RE_HEADER_LEN); /* add the named groups if needed */ if (s->group_names.size > (s->capture_count - 1)) { dbuf_put(&s->byte_code, s->group_names.buf, s->group_names.size); s->byte_code.buf[RE_HEADER_FLAGS] |= LRE_FLAG_NAMED_GROUPS; } dbuf_free(&s->group_names); #ifdef DUMP_REOP lre_dump_bytecode(s->byte_code.buf, s->byte_code.size); #endif error_msg[0] = '\0'; *plen = s->byte_code.size; return s->byte_code.buf; } static BOOL is_line_terminator(uint32_t c) { return (c == '\n' || c == '\r' || c == CP_LS || c == CP_PS); } static BOOL is_word_char(uint32_t c) { return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_')); } #define GET_CHAR(c, cptr, cbuf_end) \ do { \ if (cbuf_type == 0) { \ c = *cptr++; \ } else { \ uint32_t __c1; \ c = *(uint16_t *)cptr; \ cptr += 2; \ if (c >= 0xd800 && c < 0xdc00 && \ cbuf_type == 2 && cptr < cbuf_end) { \ __c1 = *(uint16_t *)cptr; \ if (__c1 >= 0xdc00 && __c1 < 0xe000) { \ c = (((c & 0x3ff) << 10) | (__c1 & 0x3ff)) + 0x10000; \ cptr += 2; \ } \ } \ } \ } while (0) #define PEEK_CHAR(c, cptr, cbuf_end) \ do { \ if (cbuf_type == 0) { \ c = cptr[0]; \ } else { \ uint32_t __c1; \ c = ((uint16_t *)cptr)[0]; \ if (c >= 0xd800 && c < 0xdc00 && \ cbuf_type == 2 && (cptr + 2) < cbuf_end) { \ __c1 = ((uint16_t *)cptr)[1]; \ if (__c1 >= 0xdc00 && __c1 < 0xe000) { \ c = (((c & 0x3ff) << 10) | (__c1 & 0x3ff)) + 0x10000; \ } \ } \ } \ } while (0) #define PEEK_PREV_CHAR(c, cptr, cbuf_start) \ do { \ if (cbuf_type == 0) { \ c = cptr[-1]; \ } else { \ uint32_t __c1; \ c = ((uint16_t *)cptr)[-1]; \ if (c >= 0xdc00 && c < 0xe000 && \ cbuf_type == 2 && (cptr - 4) >= cbuf_start) { \ __c1 = ((uint16_t *)cptr)[-2]; \ if (__c1 >= 0xd800 && __c1 < 0xdc00 ) { \ c = (((__c1 & 0x3ff) << 10) | (c & 0x3ff)) + 0x10000; \ } \ } \ } \ } while (0) #define GET_PREV_CHAR(c, cptr, cbuf_start) \ do { \ if (cbuf_type == 0) { \ cptr--; \ c = cptr[0]; \ } else { \ uint32_t __c1; \ cptr -= 2; \ c = ((uint16_t *)cptr)[0]; \ if (c >= 0xdc00 && c < 0xe000 && \ cbuf_type == 2 && cptr > cbuf_start) { \ __c1 = ((uint16_t *)cptr)[-1]; \ if (__c1 >= 0xd800 && __c1 < 0xdc00 ) { \ cptr -= 2; \ c = (((__c1 & 0x3ff) << 10) | (c & 0x3ff)) + 0x10000; \ } \ } \ } \ } while (0) #define PREV_CHAR(cptr, cbuf_start) \ do { \ if (cbuf_type == 0) { \ cptr--; \ } else { \ cptr -= 2; \ if (cbuf_type == 2) { \ c = ((uint16_t *)cptr)[0]; \ if (c >= 0xdc00 && c < 0xe000 && cptr > cbuf_start) { \ c = ((uint16_t *)cptr)[-1]; \ if (c >= 0xd800 && c < 0xdc00) \ cptr -= 2; \ } \ } \ } \ } while (0) typedef uintptr_t StackInt; typedef enum { RE_EXEC_STATE_SPLIT, RE_EXEC_STATE_LOOKAHEAD, RE_EXEC_STATE_NEGATIVE_LOOKAHEAD, RE_EXEC_STATE_GREEDY_QUANT, } REExecStateEnum; typedef struct REExecState { REExecStateEnum type : 8; uint8_t stack_len; size_t count; /* only used for RE_EXEC_STATE_GREEDY_QUANT */ const uint8_t *cptr; const uint8_t *pc; void *buf[0]; } REExecState; typedef struct { const uint8_t *cbuf; const uint8_t *cbuf_end; /* 0 = 8 bit chars, 1 = 16 bit chars, 2 = 16 bit chars, UTF-16 */ int cbuf_type; int capture_count; int stack_size_max; BOOL multi_line; BOOL ignore_case; BOOL is_utf16; void *opaque; /* used for stack overflow check */ size_t state_size; uint8_t *state_stack; size_t state_stack_size; size_t state_stack_len; } REExecContext; static int push_state(REExecContext *s, uint8_t **capture, StackInt *stack, size_t stack_len, const uint8_t *pc, const uint8_t *cptr, REExecStateEnum type, size_t count) { REExecState *rs; uint8_t *new_stack; size_t new_size, i, n; StackInt *stack_buf; if (unlikely((s->state_stack_len + 1) > s->state_stack_size)) { /* reallocate the stack */ new_size = s->state_stack_size * 3 / 2; if (new_size < 8) new_size = 8; new_stack = lre_realloc(s->opaque, s->state_stack, new_size * s->state_size); if (!new_stack) return -1; s->state_stack_size = new_size; s->state_stack = new_stack; } rs = (REExecState *)(s->state_stack + s->state_stack_len * s->state_size); s->state_stack_len++; rs->type = type; rs->count = count; rs->stack_len = stack_len; rs->cptr = cptr; rs->pc = pc; n = 2 * s->capture_count; for(i = 0; i < n; i++) rs->buf[i] = capture[i]; stack_buf = (StackInt *)(rs->buf + n); for(i = 0; i < stack_len; i++) stack_buf[i] = stack[i]; return 0; } /* return 1 if match, 0 if not match or -1 if error. */ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture, StackInt *stack, int stack_len, const uint8_t *pc, const uint8_t *cptr, BOOL no_recurse) { int opcode, ret; int cbuf_type; uint32_t val, c; const uint8_t *cbuf_end; cbuf_type = s->cbuf_type; cbuf_end = s->cbuf_end; for(;;) { // printf("top=%p: pc=%d\n", th_list.top, (int)(pc - (bc_buf + RE_HEADER_LEN))); opcode = *pc++; switch(opcode) { case REOP_match: { REExecState *rs; if (no_recurse) return (intptr_t)cptr; ret = 1; goto recurse; no_match: if (no_recurse) return 0; ret = 0; recurse: for(;;) { if (s->state_stack_len == 0) return ret; rs = (REExecState *)(s->state_stack + (s->state_stack_len - 1) * s->state_size); if (rs->type == RE_EXEC_STATE_SPLIT) { if (!ret) { pop_state: memcpy(capture, rs->buf, sizeof(capture[0]) * 2 * s->capture_count); pop_state1: pc = rs->pc; cptr = rs->cptr; stack_len = rs->stack_len; memcpy(stack, rs->buf + 2 * s->capture_count, stack_len * sizeof(stack[0])); s->state_stack_len--; break; } } else if (rs->type == RE_EXEC_STATE_GREEDY_QUANT) { if (!ret) { uint32_t char_count, i; memcpy(capture, rs->buf, sizeof(capture[0]) * 2 * s->capture_count); stack_len = rs->stack_len; memcpy(stack, rs->buf + 2 * s->capture_count, stack_len * sizeof(stack[0])); pc = rs->pc; cptr = rs->cptr; /* go backward */ char_count = get_u32(pc + 12); for(i = 0; i < char_count; i++) { PREV_CHAR(cptr, s->cbuf); } pc = (pc + 16) + (int)get_u32(pc); rs->cptr = cptr; rs->count--; if (rs->count == 0) { s->state_stack_len--; } break; } } else { ret = ((rs->type == RE_EXEC_STATE_LOOKAHEAD && ret) || (rs->type == RE_EXEC_STATE_NEGATIVE_LOOKAHEAD && !ret)); if (ret) { /* keep the capture in case of positive lookahead */ if (rs->type == RE_EXEC_STATE_LOOKAHEAD) goto pop_state1; else goto pop_state; } } s->state_stack_len--; } } break; case REOP_char32: val = get_u32(pc); pc += 4; goto test_char; case REOP_char: val = get_u16(pc); pc += 2; test_char: if (cptr >= cbuf_end) goto no_match; GET_CHAR(c, cptr, cbuf_end); if (s->ignore_case) { c = lre_canonicalize(c, s->is_utf16); } if (val != c) goto no_match; break; case REOP_split_goto_first: case REOP_split_next_first: { const uint8_t *pc1; val = get_u32(pc); pc += 4; if (opcode == REOP_split_next_first) { pc1 = pc + (int)val; } else { pc1 = pc; pc = pc + (int)val; } ret = push_state(s, capture, stack, stack_len, pc1, cptr, RE_EXEC_STATE_SPLIT, 0); if (ret < 0) return -1; break; } case REOP_lookahead: case REOP_negative_lookahead: val = get_u32(pc); pc += 4; ret = push_state(s, capture, stack, stack_len, pc + (int)val, cptr, RE_EXEC_STATE_LOOKAHEAD + opcode - REOP_lookahead, 0); if (ret < 0) return -1; break; case REOP_goto: val = get_u32(pc); pc += 4 + (int)val; break; case REOP_line_start: if (cptr == s->cbuf) break; if (!s->multi_line) goto no_match; PEEK_PREV_CHAR(c, cptr, s->cbuf); if (!is_line_terminator(c)) goto no_match; break; case REOP_line_end: if (cptr == cbuf_end) break; if (!s->multi_line) goto no_match; PEEK_CHAR(c, cptr, cbuf_end); if (!is_line_terminator(c)) goto no_match; break; case REOP_dot: if (cptr == cbuf_end) goto no_match; GET_CHAR(c, cptr, cbuf_end); if (is_line_terminator(c)) goto no_match; break; case REOP_any: if (cptr == cbuf_end) goto no_match; GET_CHAR(c, cptr, cbuf_end); break; case REOP_save_start: case REOP_save_end: val = *pc++; assert(val < s->capture_count); capture[2 * val + opcode - REOP_save_start] = (uint8_t *)cptr; break; case REOP_save_reset: { uint32_t val2; val = pc[0]; val2 = pc[1]; pc += 2; assert(val2 < s->capture_count); while (val <= val2) { capture[2 * val] = NULL; capture[2 * val + 1] = NULL; val++; } } break; case REOP_push_i32: val = get_u32(pc); pc += 4; stack[stack_len++] = val; break; case REOP_drop: stack_len--; break; case REOP_loop: val = get_u32(pc); pc += 4; if (--stack[stack_len - 1] != 0) { pc += (int)val; } break; case REOP_push_char_pos: stack[stack_len++] = (uintptr_t)cptr; break; case REOP_check_advance: if (stack[--stack_len] == (uintptr_t)cptr) goto no_match; break; case REOP_word_boundary: case REOP_not_word_boundary: { BOOL v1, v2; /* char before */ if (cptr == s->cbuf) { v1 = FALSE; } else { PEEK_PREV_CHAR(c, cptr, s->cbuf); v1 = is_word_char(c); } /* current char */ if (cptr >= cbuf_end) { v2 = FALSE; } else { PEEK_CHAR(c, cptr, cbuf_end); v2 = is_word_char(c); } if (v1 ^ v2 ^ (REOP_not_word_boundary - opcode)) goto no_match; } break; case REOP_back_reference: case REOP_backward_back_reference: { const uint8_t *cptr1, *cptr1_end, *cptr1_start; uint32_t c1, c2; val = *pc++; if (val >= s->capture_count) goto no_match; cptr1_start = capture[2 * val]; cptr1_end = capture[2 * val + 1]; if (!cptr1_start || !cptr1_end) break; if (opcode == REOP_back_reference) { cptr1 = cptr1_start; while (cptr1 < cptr1_end) { if (cptr >= cbuf_end) goto no_match; GET_CHAR(c1, cptr1, cptr1_end); GET_CHAR(c2, cptr, cbuf_end); if (s->ignore_case) { c1 = lre_canonicalize(c1, s->is_utf16); c2 = lre_canonicalize(c2, s->is_utf16); } if (c1 != c2) goto no_match; } } else { cptr1 = cptr1_end; while (cptr1 > cptr1_start) { if (cptr == s->cbuf) goto no_match; GET_PREV_CHAR(c1, cptr1, cptr1_start); GET_PREV_CHAR(c2, cptr, s->cbuf); if (s->ignore_case) { c1 = lre_canonicalize(c1, s->is_utf16); c2 = lre_canonicalize(c2, s->is_utf16); } if (c1 != c2) goto no_match; } } } break; case REOP_range: { int n; uint32_t low, high, idx_min, idx_max, idx; n = get_u16(pc); /* n must be >= 1 */ pc += 2; if (cptr >= cbuf_end) goto no_match; GET_CHAR(c, cptr, cbuf_end); if (s->ignore_case) { c = lre_canonicalize(c, s->is_utf16); } idx_min = 0; low = get_u16(pc + 0 * 4); if (c < low) goto no_match; idx_max = n - 1; high = get_u16(pc + idx_max * 4 + 2); /* 0xffff in for last value means +infinity */ if (unlikely(c >= 0xffff) && high == 0xffff) goto range_match; if (c > high) goto no_match; while (idx_min <= idx_max) { idx = (idx_min + idx_max) / 2; low = get_u16(pc + idx * 4); high = get_u16(pc + idx * 4 + 2); if (c < low) idx_max = idx - 1; else if (c > high) idx_min = idx + 1; else goto range_match; } goto no_match; range_match: pc += 4 * n; } break; case REOP_range32: { int n; uint32_t low, high, idx_min, idx_max, idx; n = get_u16(pc); /* n must be >= 1 */ pc += 2; if (cptr >= cbuf_end) goto no_match; GET_CHAR(c, cptr, cbuf_end); if (s->ignore_case) { c = lre_canonicalize(c, s->is_utf16); } idx_min = 0; low = get_u32(pc + 0 * 8); if (c < low) goto no_match; idx_max = n - 1; high = get_u32(pc + idx_max * 8 + 4); if (c > high) goto no_match; while (idx_min <= idx_max) { idx = (idx_min + idx_max) / 2; low = get_u32(pc + idx * 8); high = get_u32(pc + idx * 8 + 4); if (c < low) idx_max = idx - 1; else if (c > high) idx_min = idx + 1; else goto range32_match; } goto no_match; range32_match: pc += 8 * n; } break; case REOP_prev: /* go to the previous char */ if (cptr == s->cbuf) goto no_match; PREV_CHAR(cptr, s->cbuf); break; case REOP_simple_greedy_quant: { uint32_t next_pos, quant_min, quant_max; size_t q; intptr_t res; const uint8_t *pc1; next_pos = get_u32(pc); quant_min = get_u32(pc + 4); quant_max = get_u32(pc + 8); pc += 16; pc1 = pc; pc += (int)next_pos; q = 0; for(;;) { res = lre_exec_backtrack(s, capture, stack, stack_len, pc1, cptr, TRUE); if (res == -1) return res; if (!res) break; cptr = (uint8_t *)res; q++; if (q >= quant_max && quant_max != INT32_MAX) break; } if (q < quant_min) goto no_match; if (q > quant_min) { /* will examine all matches down to quant_min */ ret = push_state(s, capture, stack, stack_len, pc1 - 16, cptr, RE_EXEC_STATE_GREEDY_QUANT, q - quant_min); if (ret < 0) return -1; } } break; default: abort(); } } } /* Return 1 if match, 0 if not match or -1 if error. cindex is the starting position of the match and must be such as 0 <= cindex <= clen. */ int lre_exec(uint8_t **capture, const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen, int cbuf_type, void *opaque) { REExecContext s_s, *s = &s_s; int re_flags, i, alloca_size, ret; StackInt *stack_buf; re_flags = bc_buf[RE_HEADER_FLAGS]; s->multi_line = (re_flags & LRE_FLAG_MULTILINE) != 0; s->ignore_case = (re_flags & LRE_FLAG_IGNORECASE) != 0; s->is_utf16 = (re_flags & LRE_FLAG_UTF16) != 0; s->capture_count = bc_buf[RE_HEADER_CAPTURE_COUNT]; s->stack_size_max = bc_buf[RE_HEADER_STACK_SIZE]; s->cbuf = cbuf; s->cbuf_end = cbuf + (clen << cbuf_type); s->cbuf_type = cbuf_type; if (s->cbuf_type == 1 && s->is_utf16) s->cbuf_type = 2; s->opaque = opaque; s->state_size = sizeof(REExecState) + s->capture_count * sizeof(capture[0]) * 2 + s->stack_size_max * sizeof(stack_buf[0]); s->state_stack = NULL; s->state_stack_len = 0; s->state_stack_size = 0; for(i = 0; i < s->capture_count * 2; i++) capture[i] = NULL; alloca_size = s->stack_size_max * sizeof(stack_buf[0]); stack_buf = alloca(alloca_size); ret = lre_exec_backtrack(s, capture, stack_buf, 0, bc_buf + RE_HEADER_LEN, cbuf + (cindex << cbuf_type), FALSE); lre_realloc(s->opaque, s->state_stack, 0); return ret; } int lre_get_capture_count(const uint8_t *bc_buf) { return bc_buf[RE_HEADER_CAPTURE_COUNT]; } int lre_get_flags(const uint8_t *bc_buf) { return bc_buf[RE_HEADER_FLAGS]; } /* Return NULL if no group names. Otherwise, return a pointer to 'capture_count - 1' zero terminated UTF-8 strings. */ const char *lre_get_groupnames(const uint8_t *bc_buf) { uint32_t re_bytecode_len; if ((lre_get_flags(bc_buf) & LRE_FLAG_NAMED_GROUPS) == 0) return NULL; re_bytecode_len = get_u32(bc_buf + 3); return (const char *)(bc_buf + 7 + re_bytecode_len); } #ifdef TEST BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size) { return FALSE; } void *lre_realloc(void *opaque, void *ptr, size_t size) { return realloc(ptr, size); } int main(int argc, char **argv) { int len, ret, i; uint8_t *bc; char error_msg[64]; uint8_t *capture[CAPTURE_COUNT_MAX * 2]; const char *input; int input_len, capture_count; if (argc < 3) { printf("usage: %s regexp input\n", argv[0]); exit(1); } bc = lre_compile(&len, error_msg, sizeof(error_msg), argv[1], strlen(argv[1]), 0, NULL); if (!bc) { fprintf(stderr, "error: %s\n", error_msg); exit(1); } input = argv[2]; input_len = strlen(input); ret = lre_exec(capture, bc, (uint8_t *)input, 0, input_len, 0, NULL); printf("ret=%d\n", ret); if (ret == 1) { capture_count = lre_get_capture_count(bc); for(i = 0; i < 2 * capture_count; i++) { uint8_t *ptr; ptr = capture[i]; printf("%d: ", i); if (!ptr) printf(""); else printf("%u", (int)(ptr - (uint8_t *)input)); printf("\n"); } } return 0; } #endif JavaScript-QuickJS-0.21/quickjs/repl.js000644 000766 000024 00000141202 14562316303 020375 0ustar00felipestaff000000 000000 /* * QuickJS Read Eval Print Loop * * Copyright (c) 2017-2020 Fabrice Bellard * Copyright (c) 2017-2020 Charlie Gordon * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ "use strip"; import * as std from "std"; import * as os from "os"; (function(g) { /* add 'os' and 'std' bindings */ g.os = os; g.std = std; /* close global objects */ var Object = g.Object; var String = g.String; var Array = g.Array; var Date = g.Date; var Math = g.Math; var isFinite = g.isFinite; var parseFloat = g.parseFloat; /* XXX: use preprocessor ? */ var config_numcalc = (typeof os.open === "undefined"); var has_jscalc = (typeof Fraction === "function"); var has_bignum = (typeof BigFloat === "function"); var colors = { none: "\x1b[0m", black: "\x1b[30m", red: "\x1b[31m", green: "\x1b[32m", yellow: "\x1b[33m", blue: "\x1b[34m", magenta: "\x1b[35m", cyan: "\x1b[36m", white: "\x1b[37m", gray: "\x1b[30;1m", grey: "\x1b[30;1m", bright_red: "\x1b[31;1m", bright_green: "\x1b[32;1m", bright_yellow: "\x1b[33;1m", bright_blue: "\x1b[34;1m", bright_magenta: "\x1b[35;1m", bright_cyan: "\x1b[36;1m", bright_white: "\x1b[37;1m", }; var styles; if (config_numcalc) { styles = { 'default': 'black', 'comment': 'white', 'string': 'green', 'regex': 'cyan', 'number': 'green', 'keyword': 'blue', 'function': 'gray', 'type': 'bright_magenta', 'identifier': 'yellow', 'error': 'bright_red', 'result': 'black', 'error_msg': 'bright_red', }; } else { styles = { 'default': 'bright_green', 'comment': 'white', 'string': 'bright_cyan', 'regex': 'cyan', 'number': 'green', 'keyword': 'bright_white', 'function': 'bright_yellow', 'type': 'bright_magenta', 'identifier': 'bright_green', 'error': 'red', 'result': 'bright_white', 'error_msg': 'bright_red', }; } var history = []; var clip_board = ""; var prec; var expBits; var log2_10; var pstate = ""; var prompt = ""; var plen = 0; var ps1; if (config_numcalc) ps1 = "> "; else ps1 = "qjs > "; var ps2 = " ... "; var utf8 = true; var show_time = false; var show_colors = true; var eval_start_time; var eval_time = 0; var mexpr = ""; var level = 0; var cmd = ""; var cursor_pos = 0; var last_cmd = ""; var last_cursor_pos = 0; var history_index; var this_fun, last_fun; var quote_flag = false; var utf8_state = 0; var utf8_val = 0; var term_fd; var term_read_buf; var term_width; /* current X position of the cursor in the terminal */ var term_cursor_x = 0; function termInit() { var tab; term_fd = std.in.fileno(); /* get the terminal size */ term_width = 80; if (os.isatty(term_fd)) { if (os.ttyGetWinSize) { tab = os.ttyGetWinSize(term_fd); if (tab) term_width = tab[0]; } if (os.ttySetRaw) { /* set the TTY to raw mode */ os.ttySetRaw(term_fd); } } /* install a Ctrl-C signal handler */ os.signal(os.SIGINT, sigint_handler); /* install a handler to read stdin */ term_read_buf = new Uint8Array(64); os.setReadHandler(term_fd, term_read_handler); } function sigint_handler() { /* send Ctrl-C to readline */ handle_byte(3); } function term_read_handler() { var l, i; l = os.read(term_fd, term_read_buf.buffer, 0, term_read_buf.length); for(i = 0; i < l; i++) handle_byte(term_read_buf[i]); } function handle_byte(c) { if (!utf8) { handle_char(c); } else if (utf8_state !== 0 && (c >= 0x80 && c < 0xc0)) { utf8_val = (utf8_val << 6) | (c & 0x3F); utf8_state--; if (utf8_state === 0) { handle_char(utf8_val); } } else if (c >= 0xc0 && c < 0xf8) { utf8_state = 1 + (c >= 0xe0) + (c >= 0xf0); utf8_val = c & ((1 << (6 - utf8_state)) - 1); } else { utf8_state = 0; handle_char(c); } } function is_alpha(c) { return typeof c === "string" && ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); } function is_digit(c) { return typeof c === "string" && (c >= '0' && c <= '9'); } function is_word(c) { return typeof c === "string" && (is_alpha(c) || is_digit(c) || c == '_' || c == '$'); } function ucs_length(str) { var len, c, i, str_len = str.length; len = 0; /* we never count the trailing surrogate to have the following property: ucs_length(str) = ucs_length(str.substring(0, a)) + ucs_length(str.substring(a, str.length)) for 0 <= a <= str.length */ for(i = 0; i < str_len; i++) { c = str.charCodeAt(i); if (c < 0xdc00 || c >= 0xe000) len++; } return len; } function is_trailing_surrogate(c) { var d; if (typeof c !== "string") return false; d = c.codePointAt(0); /* can be NaN if empty string */ return d >= 0xdc00 && d < 0xe000; } function is_balanced(a, b) { switch (a + b) { case "()": case "[]": case "{}": return true; } return false; } function print_color_text(str, start, style_names) { var i, j; for (j = start; j < str.length;) { var style = style_names[i = j]; while (++j < str.length && style_names[j] == style) continue; std.puts(colors[styles[style] || 'default']); std.puts(str.substring(i, j)); std.puts(colors['none']); } } function print_csi(n, code) { std.puts("\x1b[" + ((n != 1) ? n : "") + code); } /* XXX: handle double-width characters */ function move_cursor(delta) { var i, l; if (delta > 0) { while (delta != 0) { if (term_cursor_x == (term_width - 1)) { std.puts("\n"); /* translated to CRLF */ term_cursor_x = 0; delta--; } else { l = Math.min(term_width - 1 - term_cursor_x, delta); print_csi(l, "C"); /* right */ delta -= l; term_cursor_x += l; } } } else { delta = -delta; while (delta != 0) { if (term_cursor_x == 0) { print_csi(1, "A"); /* up */ print_csi(term_width - 1, "C"); /* right */ delta--; term_cursor_x = term_width - 1; } else { l = Math.min(delta, term_cursor_x); print_csi(l, "D"); /* left */ delta -= l; term_cursor_x -= l; } } } } function update() { var i, cmd_len; /* cursor_pos is the position in 16 bit characters inside the UTF-16 string 'cmd' */ if (cmd != last_cmd) { if (!show_colors && last_cmd.substring(0, last_cursor_pos) == cmd.substring(0, last_cursor_pos)) { /* optimize common case */ std.puts(cmd.substring(last_cursor_pos)); } else { /* goto the start of the line */ move_cursor(-ucs_length(last_cmd.substring(0, last_cursor_pos))); if (show_colors) { var str = mexpr ? mexpr + '\n' + cmd : cmd; var start = str.length - cmd.length; var colorstate = colorize_js(str); print_color_text(str, start, colorstate[2]); } else { std.puts(cmd); } } term_cursor_x = (term_cursor_x + ucs_length(cmd)) % term_width; if (term_cursor_x == 0) { /* show the cursor on the next line */ std.puts(" \x08"); } /* remove the trailing characters */ std.puts("\x1b[J"); last_cmd = cmd; last_cursor_pos = cmd.length; } if (cursor_pos > last_cursor_pos) { move_cursor(ucs_length(cmd.substring(last_cursor_pos, cursor_pos))); } else if (cursor_pos < last_cursor_pos) { move_cursor(-ucs_length(cmd.substring(cursor_pos, last_cursor_pos))); } last_cursor_pos = cursor_pos; std.out.flush(); } /* editing commands */ function insert(str) { if (str) { cmd = cmd.substring(0, cursor_pos) + str + cmd.substring(cursor_pos); cursor_pos += str.length; } } function quoted_insert() { quote_flag = true; } function abort() { cmd = ""; cursor_pos = 0; return -2; } function alert() { } function beginning_of_line() { cursor_pos = 0; } function end_of_line() { cursor_pos = cmd.length; } function forward_char() { if (cursor_pos < cmd.length) { cursor_pos++; while (is_trailing_surrogate(cmd.charAt(cursor_pos))) cursor_pos++; } } function backward_char() { if (cursor_pos > 0) { cursor_pos--; while (is_trailing_surrogate(cmd.charAt(cursor_pos))) cursor_pos--; } } function skip_word_forward(pos) { while (pos < cmd.length && !is_word(cmd.charAt(pos))) pos++; while (pos < cmd.length && is_word(cmd.charAt(pos))) pos++; return pos; } function skip_word_backward(pos) { while (pos > 0 && !is_word(cmd.charAt(pos - 1))) pos--; while (pos > 0 && is_word(cmd.charAt(pos - 1))) pos--; return pos; } function forward_word() { cursor_pos = skip_word_forward(cursor_pos); } function backward_word() { cursor_pos = skip_word_backward(cursor_pos); } function accept_line() { std.puts("\n"); history_add(cmd); return -1; } function history_add(str) { if (str) { history.push(str); } history_index = history.length; } function previous_history() { if (history_index > 0) { if (history_index == history.length) { history.push(cmd); } history_index--; cmd = history[history_index]; cursor_pos = cmd.length; } } function next_history() { if (history_index < history.length - 1) { history_index++; cmd = history[history_index]; cursor_pos = cmd.length; } } function history_search(dir) { var pos = cursor_pos; for (var i = 1; i <= history.length; i++) { var index = (history.length + i * dir + history_index) % history.length; if (history[index].substring(0, pos) == cmd.substring(0, pos)) { history_index = index; cmd = history[index]; return; } } } function history_search_backward() { return history_search(-1); } function history_search_forward() { return history_search(1); } function delete_char_dir(dir) { var start, end; start = cursor_pos; if (dir < 0) { start--; while (is_trailing_surrogate(cmd.charAt(start))) start--; } end = start + 1; while (is_trailing_surrogate(cmd.charAt(end))) end++; if (start >= 0 && start < cmd.length) { if (last_fun === kill_region) { kill_region(start, end, dir); } else { cmd = cmd.substring(0, start) + cmd.substring(end); cursor_pos = start; } } } function delete_char() { delete_char_dir(1); } function control_d() { if (cmd.length == 0) { std.puts("\n"); return -3; /* exit read eval print loop */ } else { delete_char_dir(1); } } function backward_delete_char() { delete_char_dir(-1); } function transpose_chars() { var pos = cursor_pos; if (cmd.length > 1 && pos > 0) { if (pos == cmd.length) pos--; cmd = cmd.substring(0, pos - 1) + cmd.substring(pos, pos + 1) + cmd.substring(pos - 1, pos) + cmd.substring(pos + 1); cursor_pos = pos + 1; } } function transpose_words() { var p1 = skip_word_backward(cursor_pos); var p2 = skip_word_forward(p1); var p4 = skip_word_forward(cursor_pos); var p3 = skip_word_backward(p4); if (p1 < p2 && p2 <= cursor_pos && cursor_pos <= p3 && p3 < p4) { cmd = cmd.substring(0, p1) + cmd.substring(p3, p4) + cmd.substring(p2, p3) + cmd.substring(p1, p2); cursor_pos = p4; } } function upcase_word() { var end = skip_word_forward(cursor_pos); cmd = cmd.substring(0, cursor_pos) + cmd.substring(cursor_pos, end).toUpperCase() + cmd.substring(end); } function downcase_word() { var end = skip_word_forward(cursor_pos); cmd = cmd.substring(0, cursor_pos) + cmd.substring(cursor_pos, end).toLowerCase() + cmd.substring(end); } function kill_region(start, end, dir) { var s = cmd.substring(start, end); if (last_fun !== kill_region) clip_board = s; else if (dir < 0) clip_board = s + clip_board; else clip_board = clip_board + s; cmd = cmd.substring(0, start) + cmd.substring(end); if (cursor_pos > end) cursor_pos -= end - start; else if (cursor_pos > start) cursor_pos = start; this_fun = kill_region; } function kill_line() { kill_region(cursor_pos, cmd.length, 1); } function backward_kill_line() { kill_region(0, cursor_pos, -1); } function kill_word() { kill_region(cursor_pos, skip_word_forward(cursor_pos), 1); } function backward_kill_word() { kill_region(skip_word_backward(cursor_pos), cursor_pos, -1); } function yank() { insert(clip_board); } function control_c() { if (last_fun === control_c) { std.puts("\n"); std.exit(0); } else { std.puts("\n(Press Ctrl-C again to quit)\n"); readline_print_prompt(); } } function reset() { cmd = ""; cursor_pos = 0; } function get_context_word(line, pos) { var s = ""; while (pos > 0 && is_word(line[pos - 1])) { pos--; s = line[pos] + s; } return s; } function get_context_object(line, pos) { var obj, base, c; if (pos <= 0 || " ~!%^&*(-+={[|:;,<>?/".indexOf(line[pos - 1]) >= 0) return g; if (pos >= 2 && line[pos - 1] === ".") { pos--; obj = {}; switch (c = line[pos - 1]) { case '\'': case '\"': return "a"; case ']': return []; case '}': return {}; case '/': return / /; default: if (is_word(c)) { base = get_context_word(line, pos); if (["true", "false", "null", "this"].includes(base) || !isNaN(+base)) return eval(base); obj = get_context_object(line, pos - base.length); if (obj === null || obj === void 0) return obj; if (obj === g && obj[base] === void 0) return eval(base); else return obj[base]; } return {}; } } return void 0; } function get_completions(line, pos) { var s, obj, ctx_obj, r, i, j, paren; s = get_context_word(line, pos); ctx_obj = get_context_object(line, pos - s.length); r = []; /* enumerate properties from object and its prototype chain, add non-numeric regular properties with s as e prefix */ for (i = 0, obj = ctx_obj; i < 10 && obj !== null && obj !== void 0; i++) { var props = Object.getOwnPropertyNames(obj); /* add non-numeric regular properties */ for (j = 0; j < props.length; j++) { var prop = props[j]; if (typeof prop == "string" && ""+(+prop) != prop && prop.startsWith(s)) r.push(prop); } obj = Object.getPrototypeOf(obj); } if (r.length > 1) { /* sort list with internal names last and remove duplicates */ function symcmp(a, b) { if (a[0] != b[0]) { if (a[0] == '_') return 1; if (b[0] == '_') return -1; } if (a < b) return -1; if (a > b) return +1; return 0; } r.sort(symcmp); for(i = j = 1; i < r.length; i++) { if (r[i] != r[i - 1]) r[j++] = r[i]; } r.length = j; } /* 'tab' = list of completions, 'pos' = cursor position inside the completions */ return { tab: r, pos: s.length, ctx: ctx_obj }; } function completion() { var tab, res, s, i, j, len, t, max_width, col, n_cols, row, n_rows; res = get_completions(cmd, cursor_pos); tab = res.tab; if (tab.length === 0) return; s = tab[0]; len = s.length; /* add the chars which are identical in all the completions */ for(i = 1; i < tab.length; i++) { t = tab[i]; for(j = 0; j < len; j++) { if (t[j] !== s[j]) { len = j; break; } } } for(i = res.pos; i < len; i++) { insert(s[i]); } if (last_fun === completion && tab.length == 1) { /* append parentheses to function names */ var m = res.ctx[tab[0]]; if (typeof m == "function") { insert('('); if (m.length == 0) insert(')'); } else if (typeof m == "object") { insert('.'); } } /* show the possible completions */ if (last_fun === completion && tab.length >= 2) { max_width = 0; for(i = 0; i < tab.length; i++) max_width = Math.max(max_width, tab[i].length); max_width += 2; n_cols = Math.max(1, Math.floor((term_width + 1) / max_width)); n_rows = Math.ceil(tab.length / n_cols); std.puts("\n"); /* display the sorted list column-wise */ for (row = 0; row < n_rows; row++) { for (col = 0; col < n_cols; col++) { i = col * n_rows + row; if (i >= tab.length) break; s = tab[i]; if (col != n_cols - 1) s = s.padEnd(max_width); std.puts(s); } std.puts("\n"); } /* show a new prompt */ readline_print_prompt(); } } var commands = { /* command table */ "\x01": beginning_of_line, /* ^A - bol */ "\x02": backward_char, /* ^B - backward-char */ "\x03": control_c, /* ^C - abort */ "\x04": control_d, /* ^D - delete-char or exit */ "\x05": end_of_line, /* ^E - eol */ "\x06": forward_char, /* ^F - forward-char */ "\x07": abort, /* ^G - bell */ "\x08": backward_delete_char, /* ^H - backspace */ "\x09": completion, /* ^I - history-search-backward */ "\x0a": accept_line, /* ^J - newline */ "\x0b": kill_line, /* ^K - delete to end of line */ "\x0d": accept_line, /* ^M - enter */ "\x0e": next_history, /* ^N - down */ "\x10": previous_history, /* ^P - up */ "\x11": quoted_insert, /* ^Q - quoted-insert */ "\x12": alert, /* ^R - reverse-search */ "\x13": alert, /* ^S - search */ "\x14": transpose_chars, /* ^T - transpose */ "\x18": reset, /* ^X - cancel */ "\x19": yank, /* ^Y - yank */ "\x1bOA": previous_history, /* ^[OA - up */ "\x1bOB": next_history, /* ^[OB - down */ "\x1bOC": forward_char, /* ^[OC - right */ "\x1bOD": backward_char, /* ^[OD - left */ "\x1bOF": forward_word, /* ^[OF - ctrl-right */ "\x1bOH": backward_word, /* ^[OH - ctrl-left */ "\x1b[1;5C": forward_word, /* ^[[1;5C - ctrl-right */ "\x1b[1;5D": backward_word, /* ^[[1;5D - ctrl-left */ "\x1b[1~": beginning_of_line, /* ^[[1~ - bol */ "\x1b[3~": delete_char, /* ^[[3~ - delete */ "\x1b[4~": end_of_line, /* ^[[4~ - eol */ "\x1b[5~": history_search_backward,/* ^[[5~ - page up */ "\x1b[6~": history_search_forward, /* ^[[5~ - page down */ "\x1b[A": previous_history, /* ^[[A - up */ "\x1b[B": next_history, /* ^[[B - down */ "\x1b[C": forward_char, /* ^[[C - right */ "\x1b[D": backward_char, /* ^[[D - left */ "\x1b[F": end_of_line, /* ^[[F - end */ "\x1b[H": beginning_of_line, /* ^[[H - home */ "\x1b\x7f": backward_kill_word, /* M-C-? - backward_kill_word */ "\x1bb": backward_word, /* M-b - backward_word */ "\x1bd": kill_word, /* M-d - kill_word */ "\x1bf": forward_word, /* M-f - backward_word */ "\x1bk": backward_kill_line, /* M-k - backward_kill_line */ "\x1bl": downcase_word, /* M-l - downcase_word */ "\x1bt": transpose_words, /* M-t - transpose_words */ "\x1bu": upcase_word, /* M-u - upcase_word */ "\x7f": backward_delete_char, /* ^? - delete */ }; function dupstr(str, count) { var res = ""; while (count-- > 0) res += str; return res; } var readline_keys; var readline_state; var readline_cb; function readline_print_prompt() { std.puts(prompt); term_cursor_x = ucs_length(prompt) % term_width; last_cmd = ""; last_cursor_pos = 0; } function readline_start(defstr, cb) { cmd = defstr || ""; cursor_pos = cmd.length; history_index = history.length; readline_cb = cb; prompt = pstate; if (mexpr) { prompt += dupstr(" ", plen - prompt.length); prompt += ps2; } else { if (show_time) { var t = eval_time / 1000; prompt += t.toFixed(6) + " "; } plen = prompt.length; prompt += ps1; } readline_print_prompt(); update(); readline_state = 0; } function handle_char(c1) { var c; c = String.fromCodePoint(c1); switch(readline_state) { case 0: if (c == '\x1b') { /* '^[' - ESC */ readline_keys = c; readline_state = 1; } else { handle_key(c); } break; case 1: /* '^[ */ readline_keys += c; if (c == '[') { readline_state = 2; } else if (c == 'O') { readline_state = 3; } else { handle_key(readline_keys); readline_state = 0; } break; case 2: /* '^[[' - CSI */ readline_keys += c; if (!(c == ';' || (c >= '0' && c <= '9'))) { handle_key(readline_keys); readline_state = 0; } break; case 3: /* '^[O' - ESC2 */ readline_keys += c; handle_key(readline_keys); readline_state = 0; break; } } function handle_key(keys) { var fun; if (quote_flag) { if (ucs_length(keys) === 1) insert(keys); quote_flag = false; } else if (fun = commands[keys]) { this_fun = fun; switch (fun(keys)) { case -1: readline_cb(cmd); return; case -2: readline_cb(null); return; case -3: /* uninstall a Ctrl-C signal handler */ os.signal(os.SIGINT, null); /* uninstall the stdin read handler */ os.setReadHandler(term_fd, null); return; } last_fun = this_fun; } else if (ucs_length(keys) === 1 && keys >= ' ') { insert(keys); last_fun = insert; } else { alert(); /* beep! */ } cursor_pos = (cursor_pos < 0) ? 0 : (cursor_pos > cmd.length) ? cmd.length : cursor_pos; update(); } var hex_mode = false; var eval_mode = "std"; function number_to_string(a, radix) { var s; if (!isFinite(a)) { /* NaN, Infinite */ return a.toString(); } else { if (a == 0) { if (1 / a < 0) s = "-0"; else s = "0"; } else { if (radix == 16 && a === Math.floor(a)) { var s; if (a < 0) { a = -a; s = "-"; } else { s = ""; } s += "0x" + a.toString(16); } else { s = a.toString(); } } return s; } } function bigfloat_to_string(a, radix) { var s; if (!BigFloat.isFinite(a)) { /* NaN, Infinite */ if (eval_mode !== "math") { return "BigFloat(" + a.toString() + ")"; } else { return a.toString(); } } else { if (a == 0) { if (1 / a < 0) s = "-0"; else s = "0"; } else { if (radix == 16) { var s; if (a < 0) { a = -a; s = "-"; } else { s = ""; } s += "0x" + a.toString(16); } else { s = a.toString(); } } if (typeof a === "bigfloat" && eval_mode !== "math") { s += "l"; } else if (eval_mode !== "std" && s.indexOf(".") < 0 && ((radix == 16 && s.indexOf("p") < 0) || (radix == 10 && s.indexOf("e") < 0))) { /* add a decimal point so that the floating point type is visible */ s += ".0"; } return s; } } function bigint_to_string(a, radix) { var s; if (radix == 16) { var s; if (a < 0) { a = -a; s = "-"; } else { s = ""; } s += "0x" + a.toString(16); } else { s = a.toString(); } if (eval_mode === "std") s += "n"; return s; } function print(a) { var stack = []; function print_rec(a) { var n, i, keys, key, type, s; type = typeof(a); if (type === "object") { if (a === null) { std.puts(a); } else if (stack.indexOf(a) >= 0) { std.puts("[circular]"); } else if (has_jscalc && (a instanceof Fraction || a instanceof Complex || a instanceof Mod || a instanceof Polynomial || a instanceof PolyMod || a instanceof RationalFunction || a instanceof Series)) { std.puts(a.toString()); } else { stack.push(a); if (Array.isArray(a)) { n = a.length; std.puts("[ "); for(i = 0; i < n; i++) { if (i !== 0) std.puts(", "); if (i in a) { print_rec(a[i]); } else { std.puts(""); } if (i > 20) { std.puts("..."); break; } } std.puts(" ]"); } else if (Object.__getClass(a) === "RegExp") { std.puts(a.toString()); } else { keys = Object.keys(a); n = keys.length; std.puts("{ "); for(i = 0; i < n; i++) { if (i !== 0) std.puts(", "); key = keys[i]; std.puts(key, ": "); print_rec(a[key]); } std.puts(" }"); } stack.pop(a); } } else if (type === "string") { s = a.__quote(); if (s.length > 79) s = s.substring(0, 75) + "...\""; std.puts(s); } else if (type === "number") { std.puts(number_to_string(a, hex_mode ? 16 : 10)); } else if (type === "bigint") { std.puts(bigint_to_string(a, hex_mode ? 16 : 10)); } else if (type === "bigfloat") { std.puts(bigfloat_to_string(a, hex_mode ? 16 : 10)); } else if (type === "bigdecimal") { std.puts(a.toString() + "m"); } else if (type === "symbol") { std.puts(String(a)); } else if (type === "function") { std.puts("function " + a.name + "()"); } else { std.puts(a); } } print_rec(a); } function extract_directive(a) { var pos; if (a[0] !== '\\') return ""; for (pos = 1; pos < a.length; pos++) { if (!is_alpha(a[pos])) break; } return a.substring(1, pos); } /* return true if the string after cmd can be evaluted as JS */ function handle_directive(cmd, expr) { var param, prec1, expBits1; if (cmd === "h" || cmd === "?" || cmd == "help") { help(); } else if (cmd === "load") { var filename = expr.substring(cmd.length + 1).trim(); if (filename.lastIndexOf(".") <= filename.lastIndexOf("/")) filename += ".js"; std.loadScript(filename); return false; } else if (cmd === "x") { hex_mode = true; } else if (cmd === "d") { hex_mode = false; } else if (cmd === "t") { show_time = !show_time; } else if (has_bignum && cmd === "p") { param = expr.substring(cmd.length + 1).trim().split(" "); if (param.length === 1 && param[0] === "") { std.puts("BigFloat precision=" + prec + " bits (~" + Math.floor(prec / log2_10) + " digits), exponent size=" + expBits + " bits\n"); } else if (param[0] === "f16") { prec = 11; expBits = 5; } else if (param[0] === "f32") { prec = 24; expBits = 8; } else if (param[0] === "f64") { prec = 53; expBits = 11; } else if (param[0] === "f128") { prec = 113; expBits = 15; } else { prec1 = parseInt(param[0]); if (param.length >= 2) expBits1 = parseInt(param[1]); else expBits1 = BigFloatEnv.expBitsMax; if (Number.isNaN(prec1) || prec1 < BigFloatEnv.precMin || prec1 > BigFloatEnv.precMax) { std.puts("Invalid precision\n"); return false; } if (Number.isNaN(expBits1) || expBits1 < BigFloatEnv.expBitsMin || expBits1 > BigFloatEnv.expBitsMax) { std.puts("Invalid exponent bits\n"); return false; } prec = prec1; expBits = expBits1; } return false; } else if (has_bignum && cmd === "digits") { param = expr.substring(cmd.length + 1).trim(); prec1 = Math.ceil(parseFloat(param) * log2_10); if (prec1 < BigFloatEnv.precMin || prec1 > BigFloatEnv.precMax) { std.puts("Invalid precision\n"); return false; } prec = prec1; expBits = BigFloatEnv.expBitsMax; return false; } else if (has_bignum && cmd === "mode") { param = expr.substring(cmd.length + 1).trim(); if (param === "") { std.puts("Running mode=" + eval_mode + "\n"); } else if (param === "std" || param === "math") { eval_mode = param; } else { std.puts("Invalid mode\n"); } return false; } else if (cmd === "clear") { std.puts("\x1b[H\x1b[J"); } else if (cmd === "q") { std.exit(0); } else if (has_jscalc && cmd === "a") { algebraicMode = true; } else if (has_jscalc && cmd === "n") { algebraicMode = false; } else { std.puts("Unknown directive: " + cmd + "\n"); return false; } return true; } if (config_numcalc) { /* called by the GUI */ g.execCmd = function (cmd) { switch(cmd) { case "dec": hex_mode = false; break; case "hex": hex_mode = true; break; case "num": algebraicMode = false; break; case "alg": algebraicMode = true; break; } } } function help() { function sel(n) { return n ? "*": " "; } std.puts("\\h this help\n" + "\\x " + sel(hex_mode) + "hexadecimal number display\n" + "\\d " + sel(!hex_mode) + "decimal number display\n" + "\\t " + sel(show_time) + "toggle timing display\n" + "\\clear clear the terminal\n"); if (has_jscalc) { std.puts("\\a " + sel(algebraicMode) + "algebraic mode\n" + "\\n " + sel(!algebraicMode) + "numeric mode\n"); } if (has_bignum) { std.puts("\\p [m [e]] set the BigFloat precision to 'm' bits\n" + "\\digits n set the BigFloat precision to 'ceil(n*log2(10))' bits\n"); if (!has_jscalc) { std.puts("\\mode [std|math] change the running mode (current = " + eval_mode + ")\n"); } } if (!config_numcalc) { std.puts("\\q exit\n"); } } function cmd_start() { if (!config_numcalc) { if (has_jscalc) std.puts('QJSCalc - Type "\\h" for help\n'); else std.puts('QuickJS - Type "\\h" for help\n'); } if (has_bignum) { log2_10 = Math.log(10) / Math.log(2); prec = 113; expBits = 15; if (has_jscalc) { eval_mode = "math"; /* XXX: numeric mode should always be the default ? */ g.algebraicMode = config_numcalc; } } cmd_readline_start(); } function cmd_readline_start() { readline_start(dupstr(" ", level), readline_handle_cmd); } function readline_handle_cmd(expr) { if (!handle_cmd(expr)) { cmd_readline_start(); } } /* return true if async termination */ function handle_cmd(expr) { var colorstate, cmd; if (expr === null) { expr = ""; return false; } if (expr === "?") { help(); return false; } cmd = extract_directive(expr); if (cmd.length > 0) { if (!handle_directive(cmd, expr)) { return false; } expr = expr.substring(cmd.length + 1); } if (expr === "") return false; if (mexpr) expr = mexpr + '\n' + expr; colorstate = colorize_js(expr); pstate = colorstate[0]; level = colorstate[1]; if (pstate) { mexpr = expr; return false; } mexpr = ""; if (has_bignum) { /* XXX: async is not supported in this case */ BigFloatEnv.setPrec(eval_and_print_start.bind(null, expr, false), prec, expBits); } else { eval_and_print_start(expr, true); } return true; } function eval_and_print_start(expr, is_async) { var result; try { if (eval_mode === "math") expr = '"use math"; void 0;' + expr; eval_start_time = os.now(); /* eval as a script */ result = std.evalScript(expr, { backtrace_barrier: true, async: is_async }); if (is_async) { /* result is a promise */ result.then(print_eval_result, print_eval_error); } else { print_eval_result(result); } } catch (error) { print_eval_error(error); } } function print_eval_result(result) { eval_time = os.now() - eval_start_time; std.puts(colors[styles.result]); print(result); std.puts("\n"); std.puts(colors.none); /* set the last result */ g._ = result; handle_cmd_end(); } function print_eval_error(error) { std.puts(colors[styles.error_msg]); if (error instanceof Error) { console.log(error); if (error.stack) { std.puts(error.stack); } } else { std.puts("Throw: "); console.log(error); } std.puts(colors.none); handle_cmd_end(); } function handle_cmd_end() { level = 0; /* run the garbage collector after each command */ std.gc(); cmd_readline_start(); } function colorize_js(str) { var i, c, start, n = str.length; var style, state = "", level = 0; var primary, can_regex = 1; var r = []; function push_state(c) { state += c; } function last_state(c) { return state.substring(state.length - 1); } function pop_state(c) { var c = last_state(); state = state.substring(0, state.length - 1); return c; } function parse_block_comment() { style = 'comment'; push_state('/'); for (i++; i < n - 1; i++) { if (str[i] == '*' && str[i + 1] == '/') { i += 2; pop_state('/'); break; } } } function parse_line_comment() { style = 'comment'; for (i++; i < n; i++) { if (str[i] == '\n') { break; } } } function parse_string(delim) { style = 'string'; push_state(delim); while (i < n) { c = str[i++]; if (c == '\n') { style = 'error'; continue; } if (c == '\\') { if (i >= n) break; i++; } else if (c == delim) { pop_state(); break; } } } function parse_regex() { style = 'regex'; push_state('/'); while (i < n) { c = str[i++]; if (c == '\n') { style = 'error'; continue; } if (c == '\\') { if (i < n) { i++; } continue; } if (last_state() == '[') { if (c == ']') { pop_state() } // ECMA 5: ignore '/' inside char classes continue; } if (c == '[') { push_state('['); if (str[i] == '[' || str[i] == ']') i++; continue; } if (c == '/') { pop_state(); while (i < n && is_word(str[i])) i++; break; } } } function parse_number() { style = 'number'; while (i < n && (is_word(str[i]) || (str[i] == '.' && (i == n - 1 || str[i + 1] != '.')))) { i++; } } var js_keywords = "|" + "break|case|catch|continue|debugger|default|delete|do|" + "else|finally|for|function|if|in|instanceof|new|" + "return|switch|this|throw|try|typeof|while|with|" + "class|const|enum|import|export|extends|super|" + "implements|interface|let|package|private|protected|" + "public|static|yield|" + "undefined|null|true|false|Infinity|NaN|" + "eval|arguments|" + "await|"; var js_no_regex = "|this|super|undefined|null|true|false|Infinity|NaN|arguments|"; var js_types = "|void|var|"; function parse_identifier() { can_regex = 1; while (i < n && is_word(str[i])) i++; var w = '|' + str.substring(start, i) + '|'; if (js_keywords.indexOf(w) >= 0) { style = 'keyword'; if (js_no_regex.indexOf(w) >= 0) can_regex = 0; return; } var i1 = i; while (i1 < n && str[i1] == ' ') i1++; if (i1 < n && str[i1] == '(') { style = 'function'; return; } if (js_types.indexOf(w) >= 0) { style = 'type'; return; } style = 'identifier'; can_regex = 0; } function set_style(from, to) { while (r.length < from) r.push('default'); while (r.length < to) r.push(style); } for (i = 0; i < n;) { style = null; start = i; switch (c = str[i++]) { case ' ': case '\t': case '\r': case '\n': continue; case '+': case '-': if (i < n && str[i] == c) { i++; continue; } can_regex = 1; continue; case '/': if (i < n && str[i] == '*') { // block comment parse_block_comment(); break; } if (i < n && str[i] == '/') { // line comment parse_line_comment(); break; } if (can_regex) { parse_regex(); can_regex = 0; break; } can_regex = 1; continue; case '\'': case '\"': case '`': parse_string(c); can_regex = 0; break; case '(': case '[': case '{': can_regex = 1; level++; push_state(c); continue; case ')': case ']': case '}': can_regex = 0; if (level > 0 && is_balanced(last_state(), c)) { level--; pop_state(); continue; } style = 'error'; break; default: if (is_digit(c)) { parse_number(); can_regex = 0; break; } if (is_word(c) || c == '$') { parse_identifier(); break; } can_regex = 1; continue; } if (style) set_style(start, i); } set_style(n, n); return [ state, level, r ]; } termInit(); cmd_start(); })(globalThis); JavaScript-QuickJS-0.21/quickjs/test262.conf000644 000766 000024 00000011226 14562313205 021155 0ustar00felipestaff000000 000000 [config] # general settings for test262 ES6 version # framework style: old, new style=new # handle tests tagged as [noStrict]: yes, no, skip nostrict=yes # handle tests tagged as [strictOnly]: yes, no, skip strict=yes # test mode: default, default-nostrict, default-strict, strict, nostrict, both, all mode=default # handle tests flagged as [async]: yes, no, skip # for these, load 'harness/doneprintHandle.js' prior to test # and expect `print('Test262:AsyncTestComplete')` to be called for # successful termination async=yes # handle tests flagged as [module]: yes, no, skip module=yes # output error messages: yes, no verbose=yes # load harness files from this directory harnessdir=test262/harness # names of harness include files to skip #harnessexclude= # name of the error file for known errors errorfile=test262_errors.txt # exclude tests enumerated in this file (see also [exclude] section) #excludefile=test262_exclude.txt # report test results to this file reportfile=test262_report.txt # enumerate tests from this directory testdir=test262/test [features] # Standard language features and proposed extensions # list the features that are included # skipped features are tagged as such to avoid warnings # Keep this list alpha-sorted (:sort i in vim) __getter__ __proto__ __setter__ AggregateError align-detached-buffer-semantics-with-web-reality arbitrary-module-namespace-names=skip array-find-from-last array-grouping Array.fromAsync=skip Array.prototype.at Array.prototype.flat Array.prototype.flatMap Array.prototype.flatten Array.prototype.includes Array.prototype.values ArrayBuffer arraybuffer-transfer=skip arrow-function async-functions async-iteration Atomics Atomics.waitAsync=skip BigInt caller change-array-by-copy class class-fields-private class-fields-private-in class-fields-public class-methods-private class-static-block class-static-fields-private class-static-fields-public class-static-methods-private cleanupSome=skip coalesce-expression computed-property-names const cross-realm DataView DataView.prototype.getFloat32 DataView.prototype.getFloat64 DataView.prototype.getInt16 DataView.prototype.getInt32 DataView.prototype.getInt8 DataView.prototype.getUint16 DataView.prototype.getUint32 DataView.prototype.setUint8 decorators=skip default-parameters destructuring-assignment destructuring-binding dynamic-import error-cause exponentiation export-star-as-namespace-from-module FinalizationGroup=skip FinalizationRegistry.prototype.cleanupSome=skip FinalizationRegistry=skip Float32Array Float64Array for-in-order for-of generators globalThis hashbang host-gc-required=skip import-assertions=skip import-attributes=skip import.meta Int16Array Int32Array Int8Array IsHTMLDDA iterator-helpers=skip json-modules=skip json-parse-with-source=skip json-superset legacy-regexp=skip let logical-assignment-operators Map new.target numeric-separator-literal object-rest object-spread Object.fromEntries Object.hasOwn Object.is optional-catch-binding optional-chaining Promise promise-with-resolvers Promise.allSettled Promise.any Promise.prototype.finally Proxy proxy-missing-checks Reflect Reflect.construct Reflect.set Reflect.setPrototypeOf regexp-dotall regexp-duplicate-named-groups=skip regexp-lookbehind regexp-match-indices regexp-named-groups regexp-unicode-property-escapes regexp-v-flag=skip resizable-arraybuffer=skip rest-parameters Set set-methods=skip ShadowRealm=skip SharedArrayBuffer string-trimming String.fromCodePoint String.prototype.at String.prototype.endsWith String.prototype.includes String.prototype.isWellFormed String.prototype.matchAll String.prototype.replaceAll String.prototype.toWellFormed String.prototype.trimEnd String.prototype.trimStart super Symbol Symbol.asyncIterator Symbol.hasInstance Symbol.isConcatSpreadable Symbol.iterator Symbol.match Symbol.matchAll Symbol.prototype.description Symbol.replace Symbol.search Symbol.species Symbol.split Symbol.toPrimitive Symbol.toStringTag Symbol.unscopables symbols-as-weakmap-keys=skip tail-call-optimization=skip template Temporal=skip top-level-await TypedArray TypedArray.prototype.at u180e Uint16Array Uint32Array Uint8Array Uint8ClampedArray WeakMap WeakRef=skip WeakSet well-formed-json-stringify [exclude] # list excluded tests and directories here # intl not supported test262/test/intl402/ # incompatible with the "caller" feature test262/test/built-ins/Function/prototype/restricted-property-caller.js test262/test/built-ins/Function/prototype/restricted-property-arguments.js test262/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js # slow tests #test262/test/built-ins/RegExp/CharacterClassEscapes/ #test262/test/built-ins/RegExp/property-escapes/ [tests] # list test files or use config.testdir JavaScript-QuickJS-0.21/quickjs/quickjs.c000644 000766 000024 00006722415 14562330746 020742 0ustar00felipestaff000000 000000 /* * QuickJS Javascript Engine * * Copyright (c) 2017-2021 Fabrice Bellard * Copyright (c) 2017-2021 Charlie Gordon * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #if defined(__APPLE__) #include #elif defined(__linux__) || defined(__CYGWIN__) #include #elif defined(__FreeBSD__) #include #elif defined(__OpenBSD__) #define malloc_usable_size js_malloc_usable_size_unknown #endif #include "cutils.h" #include "list.h" #include "quickjs.h" #include "libregexp.h" #include "libbf.h" #define OPTIMIZE 1 #define SHORT_OPCODES 1 #if defined(EMSCRIPTEN) #define DIRECT_DISPATCH 0 #else #define DIRECT_DISPATCH 1 #endif #if defined(__APPLE__) #define MALLOC_OVERHEAD 0 #else #define MALLOC_OVERHEAD 8 #endif #if !defined(_WIN32) /* define it if printf uses the RNDN rounding mode instead of RNDNA */ #define CONFIG_PRINTF_RNDN #endif /* define to include Atomics.* operations which depend on the OS threads */ #if !defined(EMSCRIPTEN) #define CONFIG_ATOMICS #endif #if !defined(EMSCRIPTEN) /* enable stack limitation */ #define CONFIG_STACK_CHECK #endif /* dump object free */ //#define DUMP_FREE //#define DUMP_CLOSURE /* dump the bytecode of the compiled functions: combination of bits 1: dump pass 3 final byte code 2: dump pass 2 code 4: dump pass 1 code 8: dump stdlib functions 16: dump bytecode in hex 32: dump line number table 64: dump compute_stack_size */ //#define DUMP_BYTECODE (1) /* dump the occurence of the automatic GC */ //#define DUMP_GC /* dump objects freed by the garbage collector */ //#define DUMP_GC_FREE /* dump objects leaking when freeing the runtime */ //#define DUMP_LEAKS 1 /* dump memory usage before running the garbage collector */ //#define DUMP_MEM //#define DUMP_OBJECTS /* dump objects in JS_FreeContext */ //#define DUMP_ATOMS /* dump atoms in JS_FreeContext */ //#define DUMP_SHAPES /* dump shapes in JS_FreeContext */ //#define DUMP_MODULE_RESOLVE //#define DUMP_PROMISE //#define DUMP_READ_OBJECT /* test the GC by forcing it before each object allocation */ //#define FORCE_GC_AT_MALLOC #ifdef CONFIG_ATOMICS #include #include #include #endif enum { /* classid tag */ /* union usage | properties */ JS_CLASS_OBJECT = 1, /* must be first */ JS_CLASS_ARRAY, /* u.array | length */ JS_CLASS_ERROR, JS_CLASS_NUMBER, /* u.object_data */ JS_CLASS_STRING, /* u.object_data */ JS_CLASS_BOOLEAN, /* u.object_data */ JS_CLASS_SYMBOL, /* u.object_data */ JS_CLASS_ARGUMENTS, /* u.array | length */ JS_CLASS_MAPPED_ARGUMENTS, /* | length */ JS_CLASS_DATE, /* u.object_data */ JS_CLASS_MODULE_NS, JS_CLASS_C_FUNCTION, /* u.cfunc */ JS_CLASS_BYTECODE_FUNCTION, /* u.func */ JS_CLASS_BOUND_FUNCTION, /* u.bound_function */ JS_CLASS_C_FUNCTION_DATA, /* u.c_function_data_record */ JS_CLASS_GENERATOR_FUNCTION, /* u.func */ JS_CLASS_FOR_IN_ITERATOR, /* u.for_in_iterator */ JS_CLASS_REGEXP, /* u.regexp */ JS_CLASS_ARRAY_BUFFER, /* u.array_buffer */ JS_CLASS_SHARED_ARRAY_BUFFER, /* u.array_buffer */ JS_CLASS_UINT8C_ARRAY, /* u.array (typed_array) */ JS_CLASS_INT8_ARRAY, /* u.array (typed_array) */ JS_CLASS_UINT8_ARRAY, /* u.array (typed_array) */ JS_CLASS_INT16_ARRAY, /* u.array (typed_array) */ JS_CLASS_UINT16_ARRAY, /* u.array (typed_array) */ JS_CLASS_INT32_ARRAY, /* u.array (typed_array) */ JS_CLASS_UINT32_ARRAY, /* u.array (typed_array) */ JS_CLASS_BIG_INT64_ARRAY, /* u.array (typed_array) */ JS_CLASS_BIG_UINT64_ARRAY, /* u.array (typed_array) */ JS_CLASS_FLOAT32_ARRAY, /* u.array (typed_array) */ JS_CLASS_FLOAT64_ARRAY, /* u.array (typed_array) */ JS_CLASS_DATAVIEW, /* u.typed_array */ JS_CLASS_BIG_INT, /* u.object_data */ #ifdef CONFIG_BIGNUM JS_CLASS_BIG_FLOAT, /* u.object_data */ JS_CLASS_FLOAT_ENV, /* u.float_env */ JS_CLASS_BIG_DECIMAL, /* u.object_data */ JS_CLASS_OPERATOR_SET, /* u.operator_set */ #endif JS_CLASS_MAP, /* u.map_state */ JS_CLASS_SET, /* u.map_state */ JS_CLASS_WEAKMAP, /* u.map_state */ JS_CLASS_WEAKSET, /* u.map_state */ JS_CLASS_MAP_ITERATOR, /* u.map_iterator_data */ JS_CLASS_SET_ITERATOR, /* u.map_iterator_data */ JS_CLASS_ARRAY_ITERATOR, /* u.array_iterator_data */ JS_CLASS_STRING_ITERATOR, /* u.array_iterator_data */ JS_CLASS_REGEXP_STRING_ITERATOR, /* u.regexp_string_iterator_data */ JS_CLASS_GENERATOR, /* u.generator_data */ JS_CLASS_PROXY, /* u.proxy_data */ JS_CLASS_PROMISE, /* u.promise_data */ JS_CLASS_PROMISE_RESOLVE_FUNCTION, /* u.promise_function_data */ JS_CLASS_PROMISE_REJECT_FUNCTION, /* u.promise_function_data */ JS_CLASS_ASYNC_FUNCTION, /* u.func */ JS_CLASS_ASYNC_FUNCTION_RESOLVE, /* u.async_function_data */ JS_CLASS_ASYNC_FUNCTION_REJECT, /* u.async_function_data */ JS_CLASS_ASYNC_FROM_SYNC_ITERATOR, /* u.async_from_sync_iterator_data */ JS_CLASS_ASYNC_GENERATOR_FUNCTION, /* u.func */ JS_CLASS_ASYNC_GENERATOR, /* u.async_generator_data */ JS_CLASS_INIT_COUNT, /* last entry for predefined classes */ }; /* number of typed array types */ #define JS_TYPED_ARRAY_COUNT (JS_CLASS_FLOAT64_ARRAY - JS_CLASS_UINT8C_ARRAY + 1) static uint8_t const typed_array_size_log2[JS_TYPED_ARRAY_COUNT]; #define typed_array_size_log2(classid) (typed_array_size_log2[(classid)- JS_CLASS_UINT8C_ARRAY]) typedef enum JSErrorEnum { JS_EVAL_ERROR, JS_RANGE_ERROR, JS_REFERENCE_ERROR, JS_SYNTAX_ERROR, JS_TYPE_ERROR, JS_URI_ERROR, JS_INTERNAL_ERROR, JS_AGGREGATE_ERROR, JS_NATIVE_ERROR_COUNT, /* number of different NativeError objects */ } JSErrorEnum; #define JS_MAX_LOCAL_VARS 65535 #define JS_STACK_SIZE_MAX 65534 #define JS_STRING_LEN_MAX ((1 << 30) - 1) #define __exception __attribute__((warn_unused_result)) typedef struct JSShape JSShape; typedef struct JSString JSString; typedef struct JSString JSAtomStruct; typedef enum { JS_GC_PHASE_NONE, JS_GC_PHASE_DECREF, JS_GC_PHASE_REMOVE_CYCLES, } JSGCPhaseEnum; typedef enum OPCodeEnum OPCodeEnum; /* function pointers are used for numeric operations so that it is possible to remove some numeric types */ typedef struct { JSValue (*to_string)(JSContext *ctx, JSValueConst val); JSValue (*from_string)(JSContext *ctx, const char *buf, int radix, int flags, slimb_t *pexponent); int (*unary_arith)(JSContext *ctx, JSValue *pres, OPCodeEnum op, JSValue op1); int (*binary_arith)(JSContext *ctx, OPCodeEnum op, JSValue *pres, JSValue op1, JSValue op2); int (*compare)(JSContext *ctx, OPCodeEnum op, JSValue op1, JSValue op2); /* only for bigfloat: */ JSValue (*mul_pow10_to_float64)(JSContext *ctx, const bf_t *a, int64_t exponent); int (*mul_pow10)(JSContext *ctx, JSValue *sp); } JSNumericOperations; struct JSRuntime { JSMallocFunctions mf; JSMallocState malloc_state; const char *rt_info; int atom_hash_size; /* power of two */ int atom_count; int atom_size; int atom_count_resize; /* resize hash table at this count */ uint32_t *atom_hash; JSAtomStruct **atom_array; int atom_free_index; /* 0 = none */ int class_count; /* size of class_array */ JSClass *class_array; struct list_head context_list; /* list of JSContext.link */ /* list of JSGCObjectHeader.link. List of allocated GC objects (used by the garbage collector) */ struct list_head gc_obj_list; /* list of JSGCObjectHeader.link. Used during JS_FreeValueRT() */ struct list_head gc_zero_ref_count_list; struct list_head tmp_obj_list; /* used during GC */ JSGCPhaseEnum gc_phase : 8; size_t malloc_gc_threshold; #ifdef DUMP_LEAKS struct list_head string_list; /* list of JSString.link */ #endif /* stack limitation */ uintptr_t stack_size; /* in bytes, 0 if no limit */ uintptr_t stack_top; uintptr_t stack_limit; /* lower stack limit */ JSValue current_exception; /* true if inside an out of memory error, to avoid recursing */ BOOL in_out_of_memory : 8; struct JSStackFrame *current_stack_frame; JSInterruptHandler *interrupt_handler; void *interrupt_opaque; JSHostPromiseRejectionTracker *host_promise_rejection_tracker; void *host_promise_rejection_tracker_opaque; struct list_head job_list; /* list of JSJobEntry.link */ JSModuleNormalizeFunc *module_normalize_func; JSModuleLoaderFunc *module_loader_func; void *module_loader_opaque; /* timestamp for internal use in module evaluation */ int64_t module_async_evaluation_next_timestamp; BOOL can_block : 8; /* TRUE if Atomics.wait can block */ /* used to allocate, free and clone SharedArrayBuffers */ JSSharedArrayBufferFunctions sab_funcs; /* Shape hash table */ int shape_hash_bits; int shape_hash_size; int shape_hash_count; /* number of hashed shapes */ JSShape **shape_hash; bf_context_t bf_ctx; JSNumericOperations bigint_ops; #ifdef CONFIG_BIGNUM JSNumericOperations bigfloat_ops; JSNumericOperations bigdecimal_ops; uint32_t operator_count; #endif void *user_opaque; }; struct JSClass { uint32_t class_id; /* 0 means free entry */ JSAtom class_name; JSClassFinalizer *finalizer; JSClassGCMark *gc_mark; JSClassCall *call; /* pointers for exotic behavior, can be NULL if none are present */ const JSClassExoticMethods *exotic; }; #define JS_MODE_STRICT (1 << 0) #define JS_MODE_STRIP (1 << 1) #define JS_MODE_MATH (1 << 2) #define JS_MODE_ASYNC (1 << 3) /* async function */ typedef struct JSStackFrame { struct JSStackFrame *prev_frame; /* NULL if first stack frame */ JSValue cur_func; /* current function, JS_UNDEFINED if the frame is detached */ JSValue *arg_buf; /* arguments */ JSValue *var_buf; /* variables */ struct list_head var_ref_list; /* list of JSVarRef.var_ref_link */ const uint8_t *cur_pc; /* only used in bytecode functions : PC of the instruction after the call */ int arg_count; int js_mode; /* for C functions, only JS_MODE_MATH may be set */ /* only used in generators. Current stack pointer value. NULL if the function is running. */ JSValue *cur_sp; } JSStackFrame; typedef enum { JS_GC_OBJ_TYPE_JS_OBJECT, JS_GC_OBJ_TYPE_FUNCTION_BYTECODE, JS_GC_OBJ_TYPE_SHAPE, JS_GC_OBJ_TYPE_VAR_REF, JS_GC_OBJ_TYPE_ASYNC_FUNCTION, JS_GC_OBJ_TYPE_JS_CONTEXT, } JSGCObjectTypeEnum; /* header for GC objects. GC objects are C data structures with a reference count that can reference other GC objects. JS Objects are a particular type of GC object. */ struct JSGCObjectHeader { int ref_count; /* must come first, 32-bit */ JSGCObjectTypeEnum gc_obj_type : 4; uint8_t mark : 4; /* used by the GC */ uint8_t dummy1; /* not used by the GC */ uint16_t dummy2; /* not used by the GC */ struct list_head link; }; typedef struct JSVarRef { union { JSGCObjectHeader header; /* must come first */ struct { int __gc_ref_count; /* corresponds to header.ref_count */ uint8_t __gc_mark; /* corresponds to header.mark/gc_obj_type */ uint8_t is_detached : 1; uint8_t is_arg : 1; uint16_t var_idx; /* index of the corresponding function variable on the stack */ }; }; JSValue *pvalue; /* pointer to the value, either on the stack or to 'value' */ union { JSValue value; /* used when is_detached = TRUE */ struct { struct list_head var_ref_link; /* JSStackFrame.var_ref_list list */ struct JSAsyncFunctionState *async_func; /* != NULL if async stack frame */ }; /* used when is_detached = FALSE */ }; } JSVarRef; /* the same structure is used for big integers and big floats. Big integers are never infinite or NaNs */ typedef struct JSBigFloat { JSRefCountHeader header; /* must come first, 32-bit */ bf_t num; } JSBigFloat; #ifdef CONFIG_BIGNUM typedef struct JSFloatEnv { limb_t prec; bf_flags_t flags; unsigned int status; } JSFloatEnv; typedef struct JSBigDecimal { JSRefCountHeader header; /* must come first, 32-bit */ bfdec_t num; } JSBigDecimal; #endif typedef enum { JS_AUTOINIT_ID_PROTOTYPE, JS_AUTOINIT_ID_MODULE_NS, JS_AUTOINIT_ID_PROP, } JSAutoInitIDEnum; /* must be large enough to have a negligible runtime cost and small enough to call the interrupt callback often. */ #define JS_INTERRUPT_COUNTER_INIT 10000 struct JSContext { JSGCObjectHeader header; /* must come first */ JSRuntime *rt; struct list_head link; uint16_t binary_object_count; int binary_object_size; JSShape *array_shape; /* initial shape for Array objects */ JSValue *class_proto; JSValue function_proto; JSValue function_ctor; JSValue array_ctor; JSValue regexp_ctor; JSValue promise_ctor; JSValue native_error_proto[JS_NATIVE_ERROR_COUNT]; JSValue iterator_proto; JSValue async_iterator_proto; JSValue array_proto_values; JSValue throw_type_error; JSValue eval_obj; JSValue global_obj; /* global object */ JSValue global_var_obj; /* contains the global let/const definitions */ uint64_t random_state; bf_context_t *bf_ctx; /* points to rt->bf_ctx, shared by all contexts */ #ifdef CONFIG_BIGNUM JSFloatEnv fp_env; /* global FP environment */ BOOL bignum_ext : 8; /* enable math mode */ BOOL allow_operator_overloading : 8; #endif /* when the counter reaches zero, JSRutime.interrupt_handler is called */ int interrupt_counter; struct list_head loaded_modules; /* list of JSModuleDef.link */ /* if NULL, RegExp compilation is not supported */ JSValue (*compile_regexp)(JSContext *ctx, JSValueConst pattern, JSValueConst flags); /* if NULL, eval is not supported */ JSValue (*eval_internal)(JSContext *ctx, JSValueConst this_obj, const char *input, size_t input_len, const char *filename, int flags, int scope_idx); void *user_opaque; }; typedef union JSFloat64Union { double d; uint64_t u64; uint32_t u32[2]; } JSFloat64Union; enum { JS_ATOM_TYPE_STRING = 1, JS_ATOM_TYPE_GLOBAL_SYMBOL, JS_ATOM_TYPE_SYMBOL, JS_ATOM_TYPE_PRIVATE, }; enum { JS_ATOM_HASH_SYMBOL, JS_ATOM_HASH_PRIVATE, }; typedef enum { JS_ATOM_KIND_STRING, JS_ATOM_KIND_SYMBOL, JS_ATOM_KIND_PRIVATE, } JSAtomKindEnum; #define JS_ATOM_HASH_MASK ((1 << 30) - 1) struct JSString { JSRefCountHeader header; /* must come first, 32-bit */ uint32_t len : 31; uint8_t is_wide_char : 1; /* 0 = 8 bits, 1 = 16 bits characters */ /* for JS_ATOM_TYPE_SYMBOL: hash = 0, atom_type = 3, for JS_ATOM_TYPE_PRIVATE: hash = 1, atom_type = 3 XXX: could change encoding to have one more bit in hash */ uint32_t hash : 30; uint8_t atom_type : 2; /* != 0 if atom, JS_ATOM_TYPE_x */ uint32_t hash_next; /* atom_index for JS_ATOM_TYPE_SYMBOL */ #ifdef DUMP_LEAKS struct list_head link; /* string list */ #endif union { uint8_t str8[0]; /* 8 bit strings will get an extra null terminator */ uint16_t str16[0]; } u; }; typedef struct JSClosureVar { uint8_t is_local : 1; uint8_t is_arg : 1; uint8_t is_const : 1; uint8_t is_lexical : 1; uint8_t var_kind : 4; /* see JSVarKindEnum */ /* 8 bits available */ uint16_t var_idx; /* is_local = TRUE: index to a normal variable of the parent function. otherwise: index to a closure variable of the parent function */ JSAtom var_name; } JSClosureVar; #define ARG_SCOPE_INDEX 1 #define ARG_SCOPE_END (-2) typedef struct JSVarScope { int parent; /* index into fd->scopes of the enclosing scope */ int first; /* index into fd->vars of the last variable in this scope */ } JSVarScope; typedef enum { /* XXX: add more variable kinds here instead of using bit fields */ JS_VAR_NORMAL, JS_VAR_FUNCTION_DECL, /* lexical var with function declaration */ JS_VAR_NEW_FUNCTION_DECL, /* lexical var with async/generator function declaration */ JS_VAR_CATCH, JS_VAR_FUNCTION_NAME, /* function expression name */ JS_VAR_PRIVATE_FIELD, JS_VAR_PRIVATE_METHOD, JS_VAR_PRIVATE_GETTER, JS_VAR_PRIVATE_SETTER, /* must come after JS_VAR_PRIVATE_GETTER */ JS_VAR_PRIVATE_GETTER_SETTER, /* must come after JS_VAR_PRIVATE_SETTER */ } JSVarKindEnum; /* XXX: could use a different structure in bytecode functions to save memory */ typedef struct JSVarDef { JSAtom var_name; /* index into fd->scopes of this variable lexical scope */ int scope_level; /* during compilation: - if scope_level = 0: scope in which the variable is defined - if scope_level != 0: index into fd->vars of the next variable in the same or enclosing lexical scope in a bytecode function: index into fd->vars of the next variable in the same or enclosing lexical scope */ int scope_next; uint8_t is_const : 1; uint8_t is_lexical : 1; uint8_t is_captured : 1; uint8_t is_static_private : 1; /* only used during private class field parsing */ uint8_t var_kind : 4; /* see JSVarKindEnum */ /* only used during compilation: function pool index for lexical variables with var_kind = JS_VAR_FUNCTION_DECL/JS_VAR_NEW_FUNCTION_DECL or scope level of the definition of the 'var' variables (they have scope_level = 0) */ int func_pool_idx : 24; /* only used during compilation : index in the constant pool for hoisted function definition */ } JSVarDef; /* for the encoding of the pc2line table */ #define PC2LINE_BASE (-1) #define PC2LINE_RANGE 5 #define PC2LINE_OP_FIRST 1 #define PC2LINE_DIFF_PC_MAX ((255 - PC2LINE_OP_FIRST) / PC2LINE_RANGE) typedef enum JSFunctionKindEnum { JS_FUNC_NORMAL = 0, JS_FUNC_GENERATOR = (1 << 0), JS_FUNC_ASYNC = (1 << 1), JS_FUNC_ASYNC_GENERATOR = (JS_FUNC_GENERATOR | JS_FUNC_ASYNC), } JSFunctionKindEnum; typedef struct JSFunctionBytecode { JSGCObjectHeader header; /* must come first */ uint8_t js_mode; uint8_t has_prototype : 1; /* true if a prototype field is necessary */ uint8_t has_simple_parameter_list : 1; uint8_t is_derived_class_constructor : 1; /* true if home_object needs to be initialized */ uint8_t need_home_object : 1; uint8_t func_kind : 2; uint8_t new_target_allowed : 1; uint8_t super_call_allowed : 1; uint8_t super_allowed : 1; uint8_t arguments_allowed : 1; uint8_t has_debug : 1; uint8_t backtrace_barrier : 1; /* stop backtrace on this function */ uint8_t read_only_bytecode : 1; uint8_t is_direct_or_indirect_eval : 1; /* used by JS_GetScriptOrModuleName() */ /* XXX: 4 bits available */ uint8_t *byte_code_buf; /* (self pointer) */ int byte_code_len; JSAtom func_name; JSVarDef *vardefs; /* arguments + local variables (arg_count + var_count) (self pointer) */ JSClosureVar *closure_var; /* list of variables in the closure (self pointer) */ uint16_t arg_count; uint16_t var_count; uint16_t defined_arg_count; /* for length function property */ uint16_t stack_size; /* maximum stack size */ JSContext *realm; /* function realm */ JSValue *cpool; /* constant pool (self pointer) */ int cpool_count; int closure_var_count; struct { /* debug info, move to separate structure to save memory? */ JSAtom filename; int line_num; int source_len; int pc2line_len; uint8_t *pc2line_buf; char *source; } debug; } JSFunctionBytecode; typedef struct JSBoundFunction { JSValue func_obj; JSValue this_val; int argc; JSValue argv[0]; } JSBoundFunction; typedef enum JSIteratorKindEnum { JS_ITERATOR_KIND_KEY, JS_ITERATOR_KIND_VALUE, JS_ITERATOR_KIND_KEY_AND_VALUE, } JSIteratorKindEnum; typedef struct JSForInIterator { JSValue obj; uint32_t idx; uint32_t atom_count; uint8_t in_prototype_chain; uint8_t is_array; JSPropertyEnum *tab_atom; /* is_array = FALSE */ } JSForInIterator; typedef struct JSRegExp { JSString *pattern; JSString *bytecode; /* also contains the flags */ } JSRegExp; typedef struct JSProxyData { JSValue target; JSValue handler; uint8_t is_func; uint8_t is_revoked; } JSProxyData; typedef struct JSArrayBuffer { int byte_length; /* 0 if detached */ uint8_t detached; uint8_t shared; /* if shared, the array buffer cannot be detached */ uint8_t *data; /* NULL if detached */ struct list_head array_list; void *opaque; JSFreeArrayBufferDataFunc *free_func; } JSArrayBuffer; typedef struct JSTypedArray { struct list_head link; /* link to arraybuffer */ JSObject *obj; /* back pointer to the TypedArray/DataView object */ JSObject *buffer; /* based array buffer */ uint32_t offset; /* offset in the array buffer */ uint32_t length; /* length in the array buffer */ } JSTypedArray; typedef struct JSAsyncFunctionState { JSGCObjectHeader header; JSValue this_val; /* 'this' argument */ int argc; /* number of function arguments */ BOOL throw_flag; /* used to throw an exception in JS_CallInternal() */ BOOL is_completed; /* TRUE if the function has returned. The stack frame is no longer valid */ JSValue resolving_funcs[2]; /* only used in JS async functions */ JSStackFrame frame; } JSAsyncFunctionState; typedef enum { /* binary operators */ JS_OVOP_ADD, JS_OVOP_SUB, JS_OVOP_MUL, JS_OVOP_DIV, JS_OVOP_MOD, JS_OVOP_POW, JS_OVOP_OR, JS_OVOP_AND, JS_OVOP_XOR, JS_OVOP_SHL, JS_OVOP_SAR, JS_OVOP_SHR, JS_OVOP_EQ, JS_OVOP_LESS, JS_OVOP_BINARY_COUNT, /* unary operators */ JS_OVOP_POS = JS_OVOP_BINARY_COUNT, JS_OVOP_NEG, JS_OVOP_INC, JS_OVOP_DEC, JS_OVOP_NOT, JS_OVOP_COUNT, } JSOverloadableOperatorEnum; typedef struct { uint32_t operator_index; JSObject *ops[JS_OVOP_BINARY_COUNT]; /* self operators */ } JSBinaryOperatorDefEntry; typedef struct { int count; JSBinaryOperatorDefEntry *tab; } JSBinaryOperatorDef; typedef struct { uint32_t operator_counter; BOOL is_primitive; /* OperatorSet for a primitive type */ /* NULL if no operator is defined */ JSObject *self_ops[JS_OVOP_COUNT]; /* self operators */ JSBinaryOperatorDef left; JSBinaryOperatorDef right; } JSOperatorSetData; typedef struct JSReqModuleEntry { JSAtom module_name; JSModuleDef *module; /* used using resolution */ } JSReqModuleEntry; typedef enum JSExportTypeEnum { JS_EXPORT_TYPE_LOCAL, JS_EXPORT_TYPE_INDIRECT, } JSExportTypeEnum; typedef struct JSExportEntry { union { struct { int var_idx; /* closure variable index */ JSVarRef *var_ref; /* if != NULL, reference to the variable */ } local; /* for local export */ int req_module_idx; /* module for indirect export */ } u; JSExportTypeEnum export_type; JSAtom local_name; /* '*' if export ns from. not used for local export after compilation */ JSAtom export_name; /* exported variable name */ } JSExportEntry; typedef struct JSStarExportEntry { int req_module_idx; /* in req_module_entries */ } JSStarExportEntry; typedef struct JSImportEntry { int var_idx; /* closure variable index */ JSAtom import_name; int req_module_idx; /* in req_module_entries */ } JSImportEntry; typedef enum { JS_MODULE_STATUS_UNLINKED, JS_MODULE_STATUS_LINKING, JS_MODULE_STATUS_LINKED, JS_MODULE_STATUS_EVALUATING, JS_MODULE_STATUS_EVALUATING_ASYNC, JS_MODULE_STATUS_EVALUATED, } JSModuleStatus; struct JSModuleDef { JSRefCountHeader header; /* must come first, 32-bit */ JSAtom module_name; struct list_head link; JSReqModuleEntry *req_module_entries; int req_module_entries_count; int req_module_entries_size; JSExportEntry *export_entries; int export_entries_count; int export_entries_size; JSStarExportEntry *star_export_entries; int star_export_entries_count; int star_export_entries_size; JSImportEntry *import_entries; int import_entries_count; int import_entries_size; JSValue module_ns; JSValue func_obj; /* only used for JS modules */ JSModuleInitFunc *init_func; /* only used for C modules */ BOOL has_tla : 8; /* true if func_obj contains await */ BOOL resolved : 8; BOOL func_created : 8; JSModuleStatus status : 8; /* temp use during js_module_link() & js_module_evaluate() */ int dfs_index, dfs_ancestor_index; JSModuleDef *stack_prev; /* temp use during js_module_evaluate() */ JSModuleDef **async_parent_modules; int async_parent_modules_count; int async_parent_modules_size; int pending_async_dependencies; BOOL async_evaluation; int64_t async_evaluation_timestamp; JSModuleDef *cycle_root; JSValue promise; /* corresponds to spec field: capability */ JSValue resolving_funcs[2]; /* corresponds to spec field: capability */ /* true if evaluation yielded an exception. It is saved in eval_exception */ BOOL eval_has_exception : 8; JSValue eval_exception; JSValue meta_obj; /* for import.meta */ }; typedef struct JSJobEntry { struct list_head link; JSContext *ctx; JSJobFunc *job_func; int argc; JSValue argv[0]; } JSJobEntry; typedef struct JSProperty { union { JSValue value; /* JS_PROP_NORMAL */ struct { /* JS_PROP_GETSET */ JSObject *getter; /* NULL if undefined */ JSObject *setter; /* NULL if undefined */ } getset; JSVarRef *var_ref; /* JS_PROP_VARREF */ struct { /* JS_PROP_AUTOINIT */ /* in order to use only 2 pointers, we compress the realm and the init function pointer */ uintptr_t realm_and_id; /* realm and init_id (JS_AUTOINIT_ID_x) in the 2 low bits */ void *opaque; } init; } u; } JSProperty; #define JS_PROP_INITIAL_SIZE 2 #define JS_PROP_INITIAL_HASH_SIZE 4 /* must be a power of two */ #define JS_ARRAY_INITIAL_SIZE 2 typedef struct JSShapeProperty { uint32_t hash_next : 26; /* 0 if last in list */ uint32_t flags : 6; /* JS_PROP_XXX */ JSAtom atom; /* JS_ATOM_NULL = free property entry */ } JSShapeProperty; struct JSShape { /* hash table of size hash_mask + 1 before the start of the structure (see prop_hash_end()). */ JSGCObjectHeader header; /* true if the shape is inserted in the shape hash table. If not, JSShape.hash is not valid */ uint8_t is_hashed; /* If true, the shape may have small array index properties 'n' with 0 <= n <= 2^31-1. If false, the shape is guaranteed not to have small array index properties */ uint8_t has_small_array_index; uint32_t hash; /* current hash value */ uint32_t prop_hash_mask; int prop_size; /* allocated properties */ int prop_count; /* include deleted properties */ int deleted_prop_count; JSShape *shape_hash_next; /* in JSRuntime.shape_hash[h] list */ JSObject *proto; JSShapeProperty prop[0]; /* prop_size elements */ }; struct JSObject { union { JSGCObjectHeader header; struct { int __gc_ref_count; /* corresponds to header.ref_count */ uint8_t __gc_mark; /* corresponds to header.mark/gc_obj_type */ uint8_t extensible : 1; uint8_t free_mark : 1; /* only used when freeing objects with cycles */ uint8_t is_exotic : 1; /* TRUE if object has exotic property handlers */ uint8_t fast_array : 1; /* TRUE if u.array is used for get/put (for JS_CLASS_ARRAY, JS_CLASS_ARGUMENTS and typed arrays) */ uint8_t is_constructor : 1; /* TRUE if object is a constructor function */ uint8_t is_uncatchable_error : 1; /* if TRUE, error is not catchable */ uint8_t tmp_mark : 1; /* used in JS_WriteObjectRec() */ uint8_t is_HTMLDDA : 1; /* specific annex B IsHtmlDDA behavior */ uint16_t class_id; /* see JS_CLASS_x */ }; }; /* byte offsets: 16/24 */ JSShape *shape; /* prototype and property names + flag */ JSProperty *prop; /* array of properties */ /* byte offsets: 24/40 */ struct JSMapRecord *first_weak_ref; /* XXX: use a bit and an external hash table? */ /* byte offsets: 28/48 */ union { void *opaque; struct JSBoundFunction *bound_function; /* JS_CLASS_BOUND_FUNCTION */ struct JSCFunctionDataRecord *c_function_data_record; /* JS_CLASS_C_FUNCTION_DATA */ struct JSForInIterator *for_in_iterator; /* JS_CLASS_FOR_IN_ITERATOR */ struct JSArrayBuffer *array_buffer; /* JS_CLASS_ARRAY_BUFFER, JS_CLASS_SHARED_ARRAY_BUFFER */ struct JSTypedArray *typed_array; /* JS_CLASS_UINT8C_ARRAY..JS_CLASS_DATAVIEW */ #ifdef CONFIG_BIGNUM struct JSFloatEnv *float_env; /* JS_CLASS_FLOAT_ENV */ struct JSOperatorSetData *operator_set; /* JS_CLASS_OPERATOR_SET */ #endif struct JSMapState *map_state; /* JS_CLASS_MAP..JS_CLASS_WEAKSET */ struct JSMapIteratorData *map_iterator_data; /* JS_CLASS_MAP_ITERATOR, JS_CLASS_SET_ITERATOR */ struct JSArrayIteratorData *array_iterator_data; /* JS_CLASS_ARRAY_ITERATOR, JS_CLASS_STRING_ITERATOR */ struct JSRegExpStringIteratorData *regexp_string_iterator_data; /* JS_CLASS_REGEXP_STRING_ITERATOR */ struct JSGeneratorData *generator_data; /* JS_CLASS_GENERATOR */ struct JSProxyData *proxy_data; /* JS_CLASS_PROXY */ struct JSPromiseData *promise_data; /* JS_CLASS_PROMISE */ struct JSPromiseFunctionData *promise_function_data; /* JS_CLASS_PROMISE_RESOLVE_FUNCTION, JS_CLASS_PROMISE_REJECT_FUNCTION */ struct JSAsyncFunctionState *async_function_data; /* JS_CLASS_ASYNC_FUNCTION_RESOLVE, JS_CLASS_ASYNC_FUNCTION_REJECT */ struct JSAsyncFromSyncIteratorData *async_from_sync_iterator_data; /* JS_CLASS_ASYNC_FROM_SYNC_ITERATOR */ struct JSAsyncGeneratorData *async_generator_data; /* JS_CLASS_ASYNC_GENERATOR */ struct { /* JS_CLASS_BYTECODE_FUNCTION: 12/24 bytes */ /* also used by JS_CLASS_GENERATOR_FUNCTION, JS_CLASS_ASYNC_FUNCTION and JS_CLASS_ASYNC_GENERATOR_FUNCTION */ struct JSFunctionBytecode *function_bytecode; JSVarRef **var_refs; JSObject *home_object; /* for 'super' access */ } func; struct { /* JS_CLASS_C_FUNCTION: 12/20 bytes */ JSContext *realm; JSCFunctionType c_function; uint8_t length; uint8_t cproto; int16_t magic; } cfunc; /* array part for fast arrays and typed arrays */ struct { /* JS_CLASS_ARRAY, JS_CLASS_ARGUMENTS, JS_CLASS_UINT8C_ARRAY..JS_CLASS_FLOAT64_ARRAY */ union { uint32_t size; /* JS_CLASS_ARRAY, JS_CLASS_ARGUMENTS */ struct JSTypedArray *typed_array; /* JS_CLASS_UINT8C_ARRAY..JS_CLASS_FLOAT64_ARRAY */ } u1; union { JSValue *values; /* JS_CLASS_ARRAY, JS_CLASS_ARGUMENTS */ void *ptr; /* JS_CLASS_UINT8C_ARRAY..JS_CLASS_FLOAT64_ARRAY */ int8_t *int8_ptr; /* JS_CLASS_INT8_ARRAY */ uint8_t *uint8_ptr; /* JS_CLASS_UINT8_ARRAY, JS_CLASS_UINT8C_ARRAY */ int16_t *int16_ptr; /* JS_CLASS_INT16_ARRAY */ uint16_t *uint16_ptr; /* JS_CLASS_UINT16_ARRAY */ int32_t *int32_ptr; /* JS_CLASS_INT32_ARRAY */ uint32_t *uint32_ptr; /* JS_CLASS_UINT32_ARRAY */ int64_t *int64_ptr; /* JS_CLASS_INT64_ARRAY */ uint64_t *uint64_ptr; /* JS_CLASS_UINT64_ARRAY */ float *float_ptr; /* JS_CLASS_FLOAT32_ARRAY */ double *double_ptr; /* JS_CLASS_FLOAT64_ARRAY */ } u; uint32_t count; /* <= 2^31-1. 0 for a detached typed array */ } array; /* 12/20 bytes */ JSRegExp regexp; /* JS_CLASS_REGEXP: 8/16 bytes */ JSValue object_data; /* for JS_SetObjectData(): 8/16/16 bytes */ } u; /* byte sizes: 40/48/72 */ }; enum { __JS_ATOM_NULL = JS_ATOM_NULL, #define DEF(name, str) JS_ATOM_ ## name, #include "quickjs-atom.h" #undef DEF JS_ATOM_END, }; #define JS_ATOM_LAST_KEYWORD JS_ATOM_super #define JS_ATOM_LAST_STRICT_KEYWORD JS_ATOM_yield static const char js_atom_init[] = #define DEF(name, str) str "\0" #include "quickjs-atom.h" #undef DEF ; typedef enum OPCodeFormat { #define FMT(f) OP_FMT_ ## f, #define DEF(id, size, n_pop, n_push, f) #include "quickjs-opcode.h" #undef DEF #undef FMT } OPCodeFormat; enum OPCodeEnum { #define FMT(f) #define DEF(id, size, n_pop, n_push, f) OP_ ## id, #define def(id, size, n_pop, n_push, f) #include "quickjs-opcode.h" #undef def #undef DEF #undef FMT OP_COUNT, /* excluding temporary opcodes */ /* temporary opcodes : overlap with the short opcodes */ OP_TEMP_START = OP_nop + 1, OP___dummy = OP_TEMP_START - 1, #define FMT(f) #define DEF(id, size, n_pop, n_push, f) #define def(id, size, n_pop, n_push, f) OP_ ## id, #include "quickjs-opcode.h" #undef def #undef DEF #undef FMT OP_TEMP_END, }; static int JS_InitAtoms(JSRuntime *rt); static JSAtom __JS_NewAtomInit(JSRuntime *rt, const char *str, int len, int atom_type); static void JS_FreeAtomStruct(JSRuntime *rt, JSAtomStruct *p); static void free_function_bytecode(JSRuntime *rt, JSFunctionBytecode *b); static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags); static JSValue js_call_bound_function(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags); static JSValue JS_CallInternal(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, JSValueConst new_target, int argc, JSValue *argv, int flags); static JSValue JS_CallConstructorInternal(JSContext *ctx, JSValueConst func_obj, JSValueConst new_target, int argc, JSValue *argv, int flags); static JSValue JS_CallFree(JSContext *ctx, JSValue func_obj, JSValueConst this_obj, int argc, JSValueConst *argv); static JSValue JS_InvokeFree(JSContext *ctx, JSValue this_val, JSAtom atom, int argc, JSValueConst *argv); static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, JSValue val, BOOL is_array_ctor); static JSValue JS_EvalObject(JSContext *ctx, JSValueConst this_obj, JSValueConst val, int flags, int scope_idx); JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...); static __maybe_unused void JS_DumpAtoms(JSRuntime *rt); static __maybe_unused void JS_DumpString(JSRuntime *rt, const JSString *p); static __maybe_unused void JS_DumpObjectHeader(JSRuntime *rt); static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p); static __maybe_unused void JS_DumpGCObject(JSRuntime *rt, JSGCObjectHeader *p); static __maybe_unused void JS_DumpValueShort(JSRuntime *rt, JSValueConst val); static __maybe_unused void JS_DumpValue(JSContext *ctx, JSValueConst val); static __maybe_unused void JS_PrintValue(JSContext *ctx, const char *str, JSValueConst val); static __maybe_unused void JS_DumpShapes(JSRuntime *rt); static JSValue js_function_apply(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); static void js_array_finalizer(JSRuntime *rt, JSValue val); static void js_array_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_object_data_finalizer(JSRuntime *rt, JSValue val); static void js_object_data_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_c_function_finalizer(JSRuntime *rt, JSValue val); static void js_c_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_bytecode_function_finalizer(JSRuntime *rt, JSValue val); static void js_bytecode_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_bound_function_finalizer(JSRuntime *rt, JSValue val); static void js_bound_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_for_in_iterator_finalizer(JSRuntime *rt, JSValue val); static void js_for_in_iterator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_regexp_finalizer(JSRuntime *rt, JSValue val); static void js_array_buffer_finalizer(JSRuntime *rt, JSValue val); static void js_typed_array_finalizer(JSRuntime *rt, JSValue val); static void js_typed_array_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_proxy_finalizer(JSRuntime *rt, JSValue val); static void js_proxy_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_map_finalizer(JSRuntime *rt, JSValue val); static void js_map_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_map_iterator_finalizer(JSRuntime *rt, JSValue val); static void js_map_iterator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_array_iterator_finalizer(JSRuntime *rt, JSValue val); static void js_array_iterator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_regexp_string_iterator_finalizer(JSRuntime *rt, JSValue val); static void js_regexp_string_iterator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_generator_finalizer(JSRuntime *rt, JSValue obj); static void js_generator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_promise_finalizer(JSRuntime *rt, JSValue val); static void js_promise_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static void js_promise_resolve_function_finalizer(JSRuntime *rt, JSValue val); static void js_promise_resolve_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); #ifdef CONFIG_BIGNUM static void js_operator_set_finalizer(JSRuntime *rt, JSValue val); static void js_operator_set_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); #endif static JSValue JS_ToStringFree(JSContext *ctx, JSValue val); static int JS_ToBoolFree(JSContext *ctx, JSValue val); static int JS_ToInt32Free(JSContext *ctx, int32_t *pres, JSValue val); static int JS_ToFloat64Free(JSContext *ctx, double *pres, JSValue val); static int JS_ToUint8ClampFree(JSContext *ctx, int32_t *pres, JSValue val); static JSValue js_compile_regexp(JSContext *ctx, JSValueConst pattern, JSValueConst flags); static JSValue js_regexp_constructor_internal(JSContext *ctx, JSValueConst ctor, JSValue pattern, JSValue bc); static void gc_decref(JSRuntime *rt); static int JS_NewClass1(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def, JSAtom name); typedef enum JSStrictEqModeEnum { JS_EQ_STRICT, JS_EQ_SAME_VALUE, JS_EQ_SAME_VALUE_ZERO, } JSStrictEqModeEnum; static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, JSStrictEqModeEnum eq_mode); static BOOL js_strict_eq(JSContext *ctx, JSValue op1, JSValue op2); static BOOL js_same_value(JSContext *ctx, JSValueConst op1, JSValueConst op2); static BOOL js_same_value_zero(JSContext *ctx, JSValueConst op1, JSValueConst op2); static JSValue JS_ToObject(JSContext *ctx, JSValueConst val); static JSValue JS_ToObjectFree(JSContext *ctx, JSValue val); static JSProperty *add_property(JSContext *ctx, JSObject *p, JSAtom prop, int prop_flags); static JSValue JS_NewBigInt(JSContext *ctx); static inline bf_t *JS_GetBigInt(JSValueConst val) { JSBigFloat *p = JS_VALUE_GET_PTR(val); return &p->num; } static JSValue JS_CompactBigInt1(JSContext *ctx, JSValue val, BOOL convert_to_safe_integer); static JSValue JS_CompactBigInt(JSContext *ctx, JSValue val); static int JS_ToBigInt64Free(JSContext *ctx, int64_t *pres, JSValue val); static bf_t *JS_ToBigInt(JSContext *ctx, bf_t *buf, JSValueConst val); static void JS_FreeBigInt(JSContext *ctx, bf_t *a, bf_t *buf); #ifdef CONFIG_BIGNUM static void js_float_env_finalizer(JSRuntime *rt, JSValue val); static JSValue JS_NewBigFloat(JSContext *ctx); static inline bf_t *JS_GetBigFloat(JSValueConst val) { JSBigFloat *p = JS_VALUE_GET_PTR(val); return &p->num; } static JSValue JS_NewBigDecimal(JSContext *ctx); static inline bfdec_t *JS_GetBigDecimal(JSValueConst val) { JSBigDecimal *p = JS_VALUE_GET_PTR(val); return &p->num; } static bf_t *JS_ToBigFloat(JSContext *ctx, bf_t *buf, JSValueConst val); static JSValue JS_ToBigDecimalFree(JSContext *ctx, JSValue val, BOOL allow_null_or_undefined); static bfdec_t *JS_ToBigDecimal(JSContext *ctx, JSValueConst val); #endif JSValue JS_ThrowOutOfMemory(JSContext *ctx); static JSValue JS_ThrowTypeErrorRevokedProxy(JSContext *ctx); static JSValue js_proxy_getPrototypeOf(JSContext *ctx, JSValueConst obj); static int js_proxy_setPrototypeOf(JSContext *ctx, JSValueConst obj, JSValueConst proto_val, BOOL throw_flag); static int js_proxy_isExtensible(JSContext *ctx, JSValueConst obj); static int js_proxy_preventExtensions(JSContext *ctx, JSValueConst obj); static int js_proxy_isArray(JSContext *ctx, JSValueConst obj); static int JS_CreateProperty(JSContext *ctx, JSObject *p, JSAtom prop, JSValueConst val, JSValueConst getter, JSValueConst setter, int flags); static int js_string_memcmp(const JSString *p1, const JSString *p2, int len); static void reset_weak_ref(JSRuntime *rt, JSObject *p); static JSValue js_array_buffer_constructor3(JSContext *ctx, JSValueConst new_target, uint64_t len, JSClassID class_id, uint8_t *buf, JSFreeArrayBufferDataFunc *free_func, void *opaque, BOOL alloc_flag); static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValueConst obj); static JSValue js_typed_array_constructor(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int classid); static JSValue js_typed_array_constructor_ta(JSContext *ctx, JSValueConst new_target, JSValueConst src_obj, int classid); static BOOL typed_array_is_detached(JSContext *ctx, JSObject *p); static uint32_t typed_array_get_length(JSContext *ctx, JSObject *p); static JSValue JS_ThrowTypeErrorDetachedArrayBuffer(JSContext *ctx); static JSVarRef *get_var_ref(JSContext *ctx, JSStackFrame *sf, int var_idx, BOOL is_arg); static void __async_func_free(JSRuntime *rt, JSAsyncFunctionState *s); static void async_func_free(JSRuntime *rt, JSAsyncFunctionState *s); static JSValue js_generator_function_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags); static void js_async_function_resolve_finalizer(JSRuntime *rt, JSValue val); static void js_async_function_resolve_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static JSValue JS_EvalInternal(JSContext *ctx, JSValueConst this_obj, const char *input, size_t input_len, const char *filename, int flags, int scope_idx); static void js_free_module_def(JSContext *ctx, JSModuleDef *m); static void js_mark_module_def(JSRuntime *rt, JSModuleDef *m, JS_MarkFunc *mark_func); static JSValue js_import_meta(JSContext *ctx); static JSValue js_dynamic_import(JSContext *ctx, JSValueConst specifier); static void free_var_ref(JSRuntime *rt, JSVarRef *var_ref); static JSValue js_new_promise_capability(JSContext *ctx, JSValue *resolving_funcs, JSValueConst ctor); static __exception int perform_promise_then(JSContext *ctx, JSValueConst promise, JSValueConst *resolve_reject, JSValueConst *cap_resolving_funcs); static JSValue js_promise_resolve(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); static JSValue js_promise_then(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv); static int js_string_compare(JSContext *ctx, const JSString *p1, const JSString *p2); static JSValue JS_ToNumber(JSContext *ctx, JSValueConst val); static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj, JSValue prop, JSValue val, int flags); static int JS_NumberIsInteger(JSContext *ctx, JSValueConst val); static BOOL JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValueConst val); static JSValue JS_ToNumberFree(JSContext *ctx, JSValue val); static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, JSObject *p, JSAtom prop); static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc); static void JS_AddIntrinsicBasicObjects(JSContext *ctx); static void js_free_shape(JSRuntime *rt, JSShape *sh); static void js_free_shape_null(JSRuntime *rt, JSShape *sh); static int js_shape_prepare_update(JSContext *ctx, JSObject *p, JSShapeProperty **pprs); static int init_shape_hash(JSRuntime *rt); static __exception int js_get_length32(JSContext *ctx, uint32_t *pres, JSValueConst obj); static __exception int js_get_length64(JSContext *ctx, int64_t *pres, JSValueConst obj); static void free_arg_list(JSContext *ctx, JSValue *tab, uint32_t len); static JSValue *build_arg_list(JSContext *ctx, uint32_t *plen, JSValueConst array_arg); static BOOL js_get_fast_array(JSContext *ctx, JSValueConst obj, JSValue **arrpp, uint32_t *countp); static JSValue JS_CreateAsyncFromSyncIterator(JSContext *ctx, JSValueConst sync_iter); static void js_c_function_data_finalizer(JSRuntime *rt, JSValue val); static void js_c_function_data_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func); static JSValue js_c_function_data_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst *argv, int flags); static JSAtom js_symbol_to_atom(JSContext *ctx, JSValue val); static void add_gc_object(JSRuntime *rt, JSGCObjectHeader *h, JSGCObjectTypeEnum type); static void remove_gc_object(JSGCObjectHeader *h); static JSValue js_instantiate_prototype(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); static JSValue js_module_ns_autoinit(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); void JS_SetUncatchableError(JSContext *ctx, JSValueConst val, BOOL flag); static JSValue js_object_groupBy(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int is_map); static const JSClassExoticMethods js_arguments_exotic_methods; static const JSClassExoticMethods js_string_exotic_methods; static const JSClassExoticMethods js_proxy_exotic_methods; static const JSClassExoticMethods js_module_ns_exotic_methods; static JSClassID js_class_id_alloc = JS_CLASS_INIT_COUNT; static void js_trigger_gc(JSRuntime *rt, size_t size) { BOOL force_gc; #ifdef FORCE_GC_AT_MALLOC force_gc = TRUE; #else force_gc = ((rt->malloc_state.malloc_size + size) > rt->malloc_gc_threshold); #endif if (force_gc) { #ifdef DUMP_GC printf("GC: size=%" PRIu64 "\n", (uint64_t)rt->malloc_state.malloc_size); #endif JS_RunGC(rt); rt->malloc_gc_threshold = rt->malloc_state.malloc_size + (rt->malloc_state.malloc_size >> 1); } } static size_t js_malloc_usable_size_unknown(const void *ptr) { return 0; } void *js_malloc_rt(JSRuntime *rt, size_t size) { return rt->mf.js_malloc(&rt->malloc_state, size); } void js_free_rt(JSRuntime *rt, void *ptr) { rt->mf.js_free(&rt->malloc_state, ptr); } void *js_realloc_rt(JSRuntime *rt, void *ptr, size_t size) { return rt->mf.js_realloc(&rt->malloc_state, ptr, size); } size_t js_malloc_usable_size_rt(JSRuntime *rt, const void *ptr) { return rt->mf.js_malloc_usable_size(ptr); } void *js_mallocz_rt(JSRuntime *rt, size_t size) { void *ptr; ptr = js_malloc_rt(rt, size); if (!ptr) return NULL; return memset(ptr, 0, size); } /* called by libbf */ static void *js_bf_realloc(void *opaque, void *ptr, size_t size) { JSRuntime *rt = opaque; return js_realloc_rt(rt, ptr, size); } /* Throw out of memory in case of error */ void *js_malloc(JSContext *ctx, size_t size) { void *ptr; ptr = js_malloc_rt(ctx->rt, size); if (unlikely(!ptr)) { JS_ThrowOutOfMemory(ctx); return NULL; } return ptr; } /* Throw out of memory in case of error */ void *js_mallocz(JSContext *ctx, size_t size) { void *ptr; ptr = js_mallocz_rt(ctx->rt, size); if (unlikely(!ptr)) { JS_ThrowOutOfMemory(ctx); return NULL; } return ptr; } void js_free(JSContext *ctx, void *ptr) { js_free_rt(ctx->rt, ptr); } /* Throw out of memory in case of error */ void *js_realloc(JSContext *ctx, void *ptr, size_t size) { void *ret; ret = js_realloc_rt(ctx->rt, ptr, size); if (unlikely(!ret && size != 0)) { JS_ThrowOutOfMemory(ctx); return NULL; } return ret; } /* store extra allocated size in *pslack if successful */ void *js_realloc2(JSContext *ctx, void *ptr, size_t size, size_t *pslack) { void *ret; ret = js_realloc_rt(ctx->rt, ptr, size); if (unlikely(!ret && size != 0)) { JS_ThrowOutOfMemory(ctx); return NULL; } if (pslack) { size_t new_size = js_malloc_usable_size_rt(ctx->rt, ret); *pslack = (new_size > size) ? new_size - size : 0; } return ret; } size_t js_malloc_usable_size(JSContext *ctx, const void *ptr) { return js_malloc_usable_size_rt(ctx->rt, ptr); } /* Throw out of memory exception in case of error */ char *js_strndup(JSContext *ctx, const char *s, size_t n) { char *ptr; ptr = js_malloc(ctx, n + 1); if (ptr) { memcpy(ptr, s, n); ptr[n] = '\0'; } return ptr; } char *js_strdup(JSContext *ctx, const char *str) { return js_strndup(ctx, str, strlen(str)); } static no_inline int js_realloc_array(JSContext *ctx, void **parray, int elem_size, int *psize, int req_size) { int new_size; size_t slack; void *new_array; /* XXX: potential arithmetic overflow */ new_size = max_int(req_size, *psize * 3 / 2); new_array = js_realloc2(ctx, *parray, new_size * elem_size, &slack); if (!new_array) return -1; new_size += slack / elem_size; *psize = new_size; *parray = new_array; return 0; } /* resize the array and update its size if req_size > *psize */ static inline int js_resize_array(JSContext *ctx, void **parray, int elem_size, int *psize, int req_size) { if (unlikely(req_size > *psize)) return js_realloc_array(ctx, parray, elem_size, psize, req_size); else return 0; } static inline void js_dbuf_init(JSContext *ctx, DynBuf *s) { dbuf_init2(s, ctx->rt, (DynBufReallocFunc *)js_realloc_rt); } static inline int is_digit(int c) { return c >= '0' && c <= '9'; } typedef struct JSClassShortDef { JSAtom class_name; JSClassFinalizer *finalizer; JSClassGCMark *gc_mark; } JSClassShortDef; static JSClassShortDef const js_std_class_def[] = { { JS_ATOM_Object, NULL, NULL }, /* JS_CLASS_OBJECT */ { JS_ATOM_Array, js_array_finalizer, js_array_mark }, /* JS_CLASS_ARRAY */ { JS_ATOM_Error, NULL, NULL }, /* JS_CLASS_ERROR */ { JS_ATOM_Number, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_NUMBER */ { JS_ATOM_String, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_STRING */ { JS_ATOM_Boolean, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_BOOLEAN */ { JS_ATOM_Symbol, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_SYMBOL */ { JS_ATOM_Arguments, js_array_finalizer, js_array_mark }, /* JS_CLASS_ARGUMENTS */ { JS_ATOM_Arguments, NULL, NULL }, /* JS_CLASS_MAPPED_ARGUMENTS */ { JS_ATOM_Date, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_DATE */ { JS_ATOM_Object, NULL, NULL }, /* JS_CLASS_MODULE_NS */ { JS_ATOM_Function, js_c_function_finalizer, js_c_function_mark }, /* JS_CLASS_C_FUNCTION */ { JS_ATOM_Function, js_bytecode_function_finalizer, js_bytecode_function_mark }, /* JS_CLASS_BYTECODE_FUNCTION */ { JS_ATOM_Function, js_bound_function_finalizer, js_bound_function_mark }, /* JS_CLASS_BOUND_FUNCTION */ { JS_ATOM_Function, js_c_function_data_finalizer, js_c_function_data_mark }, /* JS_CLASS_C_FUNCTION_DATA */ { JS_ATOM_GeneratorFunction, js_bytecode_function_finalizer, js_bytecode_function_mark }, /* JS_CLASS_GENERATOR_FUNCTION */ { JS_ATOM_ForInIterator, js_for_in_iterator_finalizer, js_for_in_iterator_mark }, /* JS_CLASS_FOR_IN_ITERATOR */ { JS_ATOM_RegExp, js_regexp_finalizer, NULL }, /* JS_CLASS_REGEXP */ { JS_ATOM_ArrayBuffer, js_array_buffer_finalizer, NULL }, /* JS_CLASS_ARRAY_BUFFER */ { JS_ATOM_SharedArrayBuffer, js_array_buffer_finalizer, NULL }, /* JS_CLASS_SHARED_ARRAY_BUFFER */ { JS_ATOM_Uint8ClampedArray, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_UINT8C_ARRAY */ { JS_ATOM_Int8Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_INT8_ARRAY */ { JS_ATOM_Uint8Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_UINT8_ARRAY */ { JS_ATOM_Int16Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_INT16_ARRAY */ { JS_ATOM_Uint16Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_UINT16_ARRAY */ { JS_ATOM_Int32Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_INT32_ARRAY */ { JS_ATOM_Uint32Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_UINT32_ARRAY */ { JS_ATOM_BigInt64Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_BIG_INT64_ARRAY */ { JS_ATOM_BigUint64Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_BIG_UINT64_ARRAY */ { JS_ATOM_Float32Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_FLOAT32_ARRAY */ { JS_ATOM_Float64Array, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_FLOAT64_ARRAY */ { JS_ATOM_DataView, js_typed_array_finalizer, js_typed_array_mark }, /* JS_CLASS_DATAVIEW */ { JS_ATOM_BigInt, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_BIG_INT */ #ifdef CONFIG_BIGNUM { JS_ATOM_BigFloat, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_BIG_FLOAT */ { JS_ATOM_BigFloatEnv, js_float_env_finalizer, NULL }, /* JS_CLASS_FLOAT_ENV */ { JS_ATOM_BigDecimal, js_object_data_finalizer, js_object_data_mark }, /* JS_CLASS_BIG_DECIMAL */ { JS_ATOM_OperatorSet, js_operator_set_finalizer, js_operator_set_mark }, /* JS_CLASS_OPERATOR_SET */ #endif { JS_ATOM_Map, js_map_finalizer, js_map_mark }, /* JS_CLASS_MAP */ { JS_ATOM_Set, js_map_finalizer, js_map_mark }, /* JS_CLASS_SET */ { JS_ATOM_WeakMap, js_map_finalizer, js_map_mark }, /* JS_CLASS_WEAKMAP */ { JS_ATOM_WeakSet, js_map_finalizer, js_map_mark }, /* JS_CLASS_WEAKSET */ { JS_ATOM_Map_Iterator, js_map_iterator_finalizer, js_map_iterator_mark }, /* JS_CLASS_MAP_ITERATOR */ { JS_ATOM_Set_Iterator, js_map_iterator_finalizer, js_map_iterator_mark }, /* JS_CLASS_SET_ITERATOR */ { JS_ATOM_Array_Iterator, js_array_iterator_finalizer, js_array_iterator_mark }, /* JS_CLASS_ARRAY_ITERATOR */ { JS_ATOM_String_Iterator, js_array_iterator_finalizer, js_array_iterator_mark }, /* JS_CLASS_STRING_ITERATOR */ { JS_ATOM_RegExp_String_Iterator, js_regexp_string_iterator_finalizer, js_regexp_string_iterator_mark }, /* JS_CLASS_REGEXP_STRING_ITERATOR */ { JS_ATOM_Generator, js_generator_finalizer, js_generator_mark }, /* JS_CLASS_GENERATOR */ }; static int init_class_range(JSRuntime *rt, JSClassShortDef const *tab, int start, int count) { JSClassDef cm_s, *cm = &cm_s; int i, class_id; for(i = 0; i < count; i++) { class_id = i + start; memset(cm, 0, sizeof(*cm)); cm->finalizer = tab[i].finalizer; cm->gc_mark = tab[i].gc_mark; if (JS_NewClass1(rt, class_id, cm, tab[i].class_name) < 0) return -1; } return 0; } static JSValue JS_ThrowUnsupportedOperation(JSContext *ctx) { return JS_ThrowTypeError(ctx, "unsupported operation"); } static JSValue invalid_to_string(JSContext *ctx, JSValueConst val) { return JS_ThrowUnsupportedOperation(ctx); } static JSValue invalid_from_string(JSContext *ctx, const char *buf, int radix, int flags, slimb_t *pexponent) { return JS_NAN; } static int invalid_unary_arith(JSContext *ctx, JSValue *pres, OPCodeEnum op, JSValue op1) { JS_FreeValue(ctx, op1); JS_ThrowUnsupportedOperation(ctx); return -1; } static int invalid_binary_arith(JSContext *ctx, OPCodeEnum op, JSValue *pres, JSValue op1, JSValue op2) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); JS_ThrowUnsupportedOperation(ctx); return -1; } static JSValue invalid_mul_pow10_to_float64(JSContext *ctx, const bf_t *a, int64_t exponent) { return JS_ThrowUnsupportedOperation(ctx); } static int invalid_mul_pow10(JSContext *ctx, JSValue *sp) { JS_ThrowUnsupportedOperation(ctx); return -1; } static void set_dummy_numeric_ops(JSNumericOperations *ops) { ops->to_string = invalid_to_string; ops->from_string = invalid_from_string; ops->unary_arith = invalid_unary_arith; ops->binary_arith = invalid_binary_arith; ops->mul_pow10_to_float64 = invalid_mul_pow10_to_float64; ops->mul_pow10 = invalid_mul_pow10; } #if !defined(CONFIG_STACK_CHECK) /* no stack limitation */ static inline uintptr_t js_get_stack_pointer(void) { return 0; } static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size) { return FALSE; } #else /* Note: OS and CPU dependent */ static inline uintptr_t js_get_stack_pointer(void) { return (uintptr_t)__builtin_frame_address(0); } static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size) { uintptr_t sp; sp = js_get_stack_pointer() - alloca_size; return unlikely(sp < rt->stack_limit); } #endif JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque) { JSRuntime *rt; JSMallocState ms; memset(&ms, 0, sizeof(ms)); ms.opaque = opaque; ms.malloc_limit = -1; rt = mf->js_malloc(&ms, sizeof(JSRuntime)); if (!rt) return NULL; memset(rt, 0, sizeof(*rt)); rt->mf = *mf; if (!rt->mf.js_malloc_usable_size) { /* use dummy function if none provided */ rt->mf.js_malloc_usable_size = js_malloc_usable_size_unknown; } rt->malloc_state = ms; rt->malloc_gc_threshold = 256 * 1024; bf_context_init(&rt->bf_ctx, js_bf_realloc, rt); set_dummy_numeric_ops(&rt->bigint_ops); #ifdef CONFIG_BIGNUM set_dummy_numeric_ops(&rt->bigfloat_ops); set_dummy_numeric_ops(&rt->bigdecimal_ops); #endif init_list_head(&rt->context_list); init_list_head(&rt->gc_obj_list); init_list_head(&rt->gc_zero_ref_count_list); rt->gc_phase = JS_GC_PHASE_NONE; #ifdef DUMP_LEAKS init_list_head(&rt->string_list); #endif init_list_head(&rt->job_list); if (JS_InitAtoms(rt)) goto fail; /* create the object, array and function classes */ if (init_class_range(rt, js_std_class_def, JS_CLASS_OBJECT, countof(js_std_class_def)) < 0) goto fail; rt->class_array[JS_CLASS_ARGUMENTS].exotic = &js_arguments_exotic_methods; rt->class_array[JS_CLASS_STRING].exotic = &js_string_exotic_methods; rt->class_array[JS_CLASS_MODULE_NS].exotic = &js_module_ns_exotic_methods; rt->class_array[JS_CLASS_C_FUNCTION].call = js_call_c_function; rt->class_array[JS_CLASS_C_FUNCTION_DATA].call = js_c_function_data_call; rt->class_array[JS_CLASS_BOUND_FUNCTION].call = js_call_bound_function; rt->class_array[JS_CLASS_GENERATOR_FUNCTION].call = js_generator_function_call; if (init_shape_hash(rt)) goto fail; rt->stack_size = JS_DEFAULT_STACK_SIZE; JS_UpdateStackTop(rt); rt->current_exception = JS_NULL; return rt; fail: JS_FreeRuntime(rt); return NULL; } void *JS_GetRuntimeOpaque(JSRuntime *rt) { return rt->user_opaque; } void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque) { rt->user_opaque = opaque; } /* default memory allocation functions with memory limitation */ static size_t js_def_malloc_usable_size(const void *ptr) { #if defined(__APPLE__) return malloc_size(ptr); #elif defined(_WIN32) return _msize((void *)ptr); #elif defined(EMSCRIPTEN) return 0; #elif defined(__linux__) return malloc_usable_size((void *)ptr); #else /* change this to `return 0;` if compilation fails */ return malloc_usable_size((void *)ptr); #endif } static void *js_def_malloc(JSMallocState *s, size_t size) { void *ptr; /* Do not allocate zero bytes: behavior is platform dependent */ assert(size != 0); if (unlikely(s->malloc_size + size > s->malloc_limit)) return NULL; ptr = malloc(size); if (!ptr) return NULL; s->malloc_count++; s->malloc_size += js_def_malloc_usable_size(ptr) + MALLOC_OVERHEAD; return ptr; } static void js_def_free(JSMallocState *s, void *ptr) { if (!ptr) return; s->malloc_count--; s->malloc_size -= js_def_malloc_usable_size(ptr) + MALLOC_OVERHEAD; free(ptr); } static void *js_def_realloc(JSMallocState *s, void *ptr, size_t size) { size_t old_size; if (!ptr) { if (size == 0) return NULL; return js_def_malloc(s, size); } old_size = js_def_malloc_usable_size(ptr); if (size == 0) { s->malloc_count--; s->malloc_size -= old_size + MALLOC_OVERHEAD; free(ptr); return NULL; } if (s->malloc_size + size - old_size > s->malloc_limit) return NULL; ptr = realloc(ptr, size); if (!ptr) return NULL; s->malloc_size += js_def_malloc_usable_size(ptr) - old_size; return ptr; } static const JSMallocFunctions def_malloc_funcs = { js_def_malloc, js_def_free, js_def_realloc, js_def_malloc_usable_size, }; JSRuntime *JS_NewRuntime(void) { return JS_NewRuntime2(&def_malloc_funcs, NULL); } void JS_SetMemoryLimit(JSRuntime *rt, size_t limit) { rt->malloc_state.malloc_limit = limit; } /* use -1 to disable automatic GC */ void JS_SetGCThreshold(JSRuntime *rt, size_t gc_threshold) { rt->malloc_gc_threshold = gc_threshold; } #define malloc(s) malloc_is_forbidden(s) #define free(p) free_is_forbidden(p) #define realloc(p,s) realloc_is_forbidden(p,s) void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque) { rt->interrupt_handler = cb; rt->interrupt_opaque = opaque; } void JS_SetCanBlock(JSRuntime *rt, BOOL can_block) { rt->can_block = can_block; } void JS_SetSharedArrayBufferFunctions(JSRuntime *rt, const JSSharedArrayBufferFunctions *sf) { rt->sab_funcs = *sf; } /* return 0 if OK, < 0 if exception */ int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func, int argc, JSValueConst *argv) { JSRuntime *rt = ctx->rt; JSJobEntry *e; int i; e = js_malloc(ctx, sizeof(*e) + argc * sizeof(JSValue)); if (!e) return -1; e->ctx = ctx; e->job_func = job_func; e->argc = argc; for(i = 0; i < argc; i++) { e->argv[i] = JS_DupValue(ctx, argv[i]); } list_add_tail(&e->link, &rt->job_list); return 0; } BOOL JS_IsJobPending(JSRuntime *rt) { return !list_empty(&rt->job_list); } /* return < 0 if exception, 0 if no job pending, 1 if a job was executed successfully. the context of the job is stored in '*pctx' */ int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx) { JSContext *ctx; JSJobEntry *e; JSValue res; int i, ret; if (list_empty(&rt->job_list)) { *pctx = NULL; return 0; } /* get the first pending job and execute it */ e = list_entry(rt->job_list.next, JSJobEntry, link); list_del(&e->link); ctx = e->ctx; res = e->job_func(e->ctx, e->argc, (JSValueConst *)e->argv); for(i = 0; i < e->argc; i++) JS_FreeValue(ctx, e->argv[i]); if (JS_IsException(res)) ret = -1; else ret = 1; JS_FreeValue(ctx, res); js_free(ctx, e); *pctx = ctx; return ret; } static inline uint32_t atom_get_free(const JSAtomStruct *p) { return (uintptr_t)p >> 1; } static inline BOOL atom_is_free(const JSAtomStruct *p) { return (uintptr_t)p & 1; } static inline JSAtomStruct *atom_set_free(uint32_t v) { return (JSAtomStruct *)(((uintptr_t)v << 1) | 1); } /* Note: the string contents are uninitialized */ static JSString *js_alloc_string_rt(JSRuntime *rt, int max_len, int is_wide_char) { JSString *str; str = js_malloc_rt(rt, sizeof(JSString) + (max_len << is_wide_char) + 1 - is_wide_char); if (unlikely(!str)) return NULL; str->header.ref_count = 1; str->is_wide_char = is_wide_char; str->len = max_len; str->atom_type = 0; str->hash = 0; /* optional but costless */ str->hash_next = 0; /* optional */ #ifdef DUMP_LEAKS list_add_tail(&str->link, &rt->string_list); #endif return str; } static JSString *js_alloc_string(JSContext *ctx, int max_len, int is_wide_char) { JSString *p; p = js_alloc_string_rt(ctx->rt, max_len, is_wide_char); if (unlikely(!p)) { JS_ThrowOutOfMemory(ctx); return NULL; } return p; } /* same as JS_FreeValueRT() but faster */ static inline void js_free_string(JSRuntime *rt, JSString *str) { if (--str->header.ref_count <= 0) { if (str->atom_type) { JS_FreeAtomStruct(rt, str); } else { #ifdef DUMP_LEAKS list_del(&str->link); #endif js_free_rt(rt, str); } } } void JS_SetRuntimeInfo(JSRuntime *rt, const char *s) { if (rt) rt->rt_info = s; } void JS_FreeRuntime(JSRuntime *rt) { struct list_head *el, *el1; int i; JS_FreeValueRT(rt, rt->current_exception); list_for_each_safe(el, el1, &rt->job_list) { JSJobEntry *e = list_entry(el, JSJobEntry, link); for(i = 0; i < e->argc; i++) JS_FreeValueRT(rt, e->argv[i]); js_free_rt(rt, e); } init_list_head(&rt->job_list); JS_RunGC(rt); #ifdef DUMP_LEAKS /* leaking objects */ { BOOL header_done; JSGCObjectHeader *p; int count; /* remove the internal refcounts to display only the object referenced externally */ list_for_each(el, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); p->mark = 0; } gc_decref(rt); header_done = FALSE; list_for_each(el, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); if (p->ref_count != 0) { if (!header_done) { printf("Object leaks:\n"); JS_DumpObjectHeader(rt); header_done = TRUE; } JS_DumpGCObject(rt, p); } } count = 0; list_for_each(el, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); if (p->ref_count == 0) { count++; } } if (count != 0) printf("Secondary object leaks: %d\n", count); } #endif assert(list_empty(&rt->gc_obj_list)); /* free the classes */ for(i = 0; i < rt->class_count; i++) { JSClass *cl = &rt->class_array[i]; if (cl->class_id != 0) { JS_FreeAtomRT(rt, cl->class_name); } } js_free_rt(rt, rt->class_array); bf_context_end(&rt->bf_ctx); #ifdef DUMP_LEAKS /* only the atoms defined in JS_InitAtoms() should be left */ { BOOL header_done = FALSE; for(i = 0; i < rt->atom_size; i++) { JSAtomStruct *p = rt->atom_array[i]; if (!atom_is_free(p) /* && p->str*/) { if (i >= JS_ATOM_END || p->header.ref_count != 1) { if (!header_done) { header_done = TRUE; if (rt->rt_info) { printf("%s:1: atom leakage:", rt->rt_info); } else { printf("Atom leaks:\n" " %6s %6s %s\n", "ID", "REFCNT", "NAME"); } } if (rt->rt_info) { printf(" "); } else { printf(" %6u %6u ", i, p->header.ref_count); } switch (p->atom_type) { case JS_ATOM_TYPE_STRING: JS_DumpString(rt, p); break; case JS_ATOM_TYPE_GLOBAL_SYMBOL: printf("Symbol.for("); JS_DumpString(rt, p); printf(")"); break; case JS_ATOM_TYPE_SYMBOL: if (p->hash == JS_ATOM_HASH_SYMBOL) { printf("Symbol("); JS_DumpString(rt, p); printf(")"); } else { printf("Private("); JS_DumpString(rt, p); printf(")"); } break; } if (rt->rt_info) { printf(":%u", p->header.ref_count); } else { printf("\n"); } } } } if (rt->rt_info && header_done) printf("\n"); } #endif /* free the atoms */ for(i = 0; i < rt->atom_size; i++) { JSAtomStruct *p = rt->atom_array[i]; if (!atom_is_free(p)) { #ifdef DUMP_LEAKS list_del(&p->link); #endif js_free_rt(rt, p); } } js_free_rt(rt, rt->atom_array); js_free_rt(rt, rt->atom_hash); js_free_rt(rt, rt->shape_hash); #ifdef DUMP_LEAKS if (!list_empty(&rt->string_list)) { if (rt->rt_info) { printf("%s:1: string leakage:", rt->rt_info); } else { printf("String leaks:\n" " %6s %s\n", "REFCNT", "VALUE"); } list_for_each_safe(el, el1, &rt->string_list) { JSString *str = list_entry(el, JSString, link); if (rt->rt_info) { printf(" "); } else { printf(" %6u ", str->header.ref_count); } JS_DumpString(rt, str); if (rt->rt_info) { printf(":%u", str->header.ref_count); } else { printf("\n"); } list_del(&str->link); js_free_rt(rt, str); } if (rt->rt_info) printf("\n"); } { JSMallocState *s = &rt->malloc_state; if (s->malloc_count > 1) { if (rt->rt_info) printf("%s:1: ", rt->rt_info); printf("Memory leak: %"PRIu64" bytes lost in %"PRIu64" block%s\n", (uint64_t)(s->malloc_size - sizeof(JSRuntime)), (uint64_t)(s->malloc_count - 1), &"s"[s->malloc_count == 2]); } } #endif { JSMallocState ms = rt->malloc_state; rt->mf.js_free(&ms, rt); } } JSContext *JS_NewContextRaw(JSRuntime *rt) { JSContext *ctx; int i; ctx = js_mallocz_rt(rt, sizeof(JSContext)); if (!ctx) return NULL; ctx->header.ref_count = 1; add_gc_object(rt, &ctx->header, JS_GC_OBJ_TYPE_JS_CONTEXT); ctx->class_proto = js_malloc_rt(rt, sizeof(ctx->class_proto[0]) * rt->class_count); if (!ctx->class_proto) { js_free_rt(rt, ctx); return NULL; } ctx->rt = rt; list_add_tail(&ctx->link, &rt->context_list); ctx->bf_ctx = &rt->bf_ctx; #ifdef CONFIG_BIGNUM ctx->fp_env.prec = 113; ctx->fp_env.flags = bf_set_exp_bits(15) | BF_RNDN | BF_FLAG_SUBNORMAL; #endif for(i = 0; i < rt->class_count; i++) ctx->class_proto[i] = JS_NULL; ctx->array_ctor = JS_NULL; ctx->regexp_ctor = JS_NULL; ctx->promise_ctor = JS_NULL; init_list_head(&ctx->loaded_modules); JS_AddIntrinsicBasicObjects(ctx); return ctx; } JSContext *JS_NewContext(JSRuntime *rt) { JSContext *ctx; ctx = JS_NewContextRaw(rt); if (!ctx) return NULL; JS_AddIntrinsicBaseObjects(ctx); JS_AddIntrinsicDate(ctx); JS_AddIntrinsicEval(ctx); JS_AddIntrinsicStringNormalize(ctx); JS_AddIntrinsicRegExp(ctx); JS_AddIntrinsicJSON(ctx); JS_AddIntrinsicProxy(ctx); JS_AddIntrinsicMapSet(ctx); JS_AddIntrinsicTypedArrays(ctx); JS_AddIntrinsicPromise(ctx); JS_AddIntrinsicBigInt(ctx); return ctx; } void *JS_GetContextOpaque(JSContext *ctx) { return ctx->user_opaque; } void JS_SetContextOpaque(JSContext *ctx, void *opaque) { ctx->user_opaque = opaque; } /* set the new value and free the old value after (freeing the value can reallocate the object data) */ static inline void set_value(JSContext *ctx, JSValue *pval, JSValue new_val) { JSValue old_val; old_val = *pval; *pval = new_val; JS_FreeValue(ctx, old_val); } void JS_SetClassProto(JSContext *ctx, JSClassID class_id, JSValue obj) { JSRuntime *rt = ctx->rt; assert(class_id < rt->class_count); set_value(ctx, &ctx->class_proto[class_id], obj); } JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id) { JSRuntime *rt = ctx->rt; assert(class_id < rt->class_count); return JS_DupValue(ctx, ctx->class_proto[class_id]); } typedef enum JSFreeModuleEnum { JS_FREE_MODULE_ALL, JS_FREE_MODULE_NOT_RESOLVED, } JSFreeModuleEnum; /* XXX: would be more efficient with separate module lists */ static void js_free_modules(JSContext *ctx, JSFreeModuleEnum flag) { struct list_head *el, *el1; list_for_each_safe(el, el1, &ctx->loaded_modules) { JSModuleDef *m = list_entry(el, JSModuleDef, link); if (flag == JS_FREE_MODULE_ALL || (flag == JS_FREE_MODULE_NOT_RESOLVED && !m->resolved)) { js_free_module_def(ctx, m); } } } JSContext *JS_DupContext(JSContext *ctx) { ctx->header.ref_count++; return ctx; } /* used by the GC */ static void JS_MarkContext(JSRuntime *rt, JSContext *ctx, JS_MarkFunc *mark_func) { int i; struct list_head *el; /* modules are not seen by the GC, so we directly mark the objects referenced by each module */ list_for_each(el, &ctx->loaded_modules) { JSModuleDef *m = list_entry(el, JSModuleDef, link); js_mark_module_def(rt, m, mark_func); } JS_MarkValue(rt, ctx->global_obj, mark_func); JS_MarkValue(rt, ctx->global_var_obj, mark_func); JS_MarkValue(rt, ctx->throw_type_error, mark_func); JS_MarkValue(rt, ctx->eval_obj, mark_func); JS_MarkValue(rt, ctx->array_proto_values, mark_func); for(i = 0; i < JS_NATIVE_ERROR_COUNT; i++) { JS_MarkValue(rt, ctx->native_error_proto[i], mark_func); } for(i = 0; i < rt->class_count; i++) { JS_MarkValue(rt, ctx->class_proto[i], mark_func); } JS_MarkValue(rt, ctx->iterator_proto, mark_func); JS_MarkValue(rt, ctx->async_iterator_proto, mark_func); JS_MarkValue(rt, ctx->promise_ctor, mark_func); JS_MarkValue(rt, ctx->array_ctor, mark_func); JS_MarkValue(rt, ctx->regexp_ctor, mark_func); JS_MarkValue(rt, ctx->function_ctor, mark_func); JS_MarkValue(rt, ctx->function_proto, mark_func); if (ctx->array_shape) mark_func(rt, &ctx->array_shape->header); } void JS_FreeContext(JSContext *ctx) { JSRuntime *rt = ctx->rt; int i; if (--ctx->header.ref_count > 0) return; assert(ctx->header.ref_count == 0); #ifdef DUMP_ATOMS JS_DumpAtoms(ctx->rt); #endif #ifdef DUMP_SHAPES JS_DumpShapes(ctx->rt); #endif #ifdef DUMP_OBJECTS { struct list_head *el; JSGCObjectHeader *p; printf("JSObjects: {\n"); JS_DumpObjectHeader(ctx->rt); list_for_each(el, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); JS_DumpGCObject(rt, p); } printf("}\n"); } #endif #ifdef DUMP_MEM { JSMemoryUsage stats; JS_ComputeMemoryUsage(rt, &stats); JS_DumpMemoryUsage(stdout, &stats, rt); } #endif js_free_modules(ctx, JS_FREE_MODULE_ALL); JS_FreeValue(ctx, ctx->global_obj); JS_FreeValue(ctx, ctx->global_var_obj); JS_FreeValue(ctx, ctx->throw_type_error); JS_FreeValue(ctx, ctx->eval_obj); JS_FreeValue(ctx, ctx->array_proto_values); for(i = 0; i < JS_NATIVE_ERROR_COUNT; i++) { JS_FreeValue(ctx, ctx->native_error_proto[i]); } for(i = 0; i < rt->class_count; i++) { JS_FreeValue(ctx, ctx->class_proto[i]); } js_free_rt(rt, ctx->class_proto); JS_FreeValue(ctx, ctx->iterator_proto); JS_FreeValue(ctx, ctx->async_iterator_proto); JS_FreeValue(ctx, ctx->promise_ctor); JS_FreeValue(ctx, ctx->array_ctor); JS_FreeValue(ctx, ctx->regexp_ctor); JS_FreeValue(ctx, ctx->function_ctor); JS_FreeValue(ctx, ctx->function_proto); js_free_shape_null(ctx->rt, ctx->array_shape); list_del(&ctx->link); remove_gc_object(&ctx->header); js_free_rt(ctx->rt, ctx); } JSRuntime *JS_GetRuntime(JSContext *ctx) { return ctx->rt; } static void update_stack_limit(JSRuntime *rt) { if (rt->stack_size == 0) { rt->stack_limit = 0; /* no limit */ } else { rt->stack_limit = rt->stack_top - rt->stack_size; } } void JS_SetMaxStackSize(JSRuntime *rt, size_t stack_size) { rt->stack_size = stack_size; update_stack_limit(rt); } void JS_UpdateStackTop(JSRuntime *rt) { rt->stack_top = js_get_stack_pointer(); update_stack_limit(rt); } static inline BOOL is_strict_mode(JSContext *ctx) { JSStackFrame *sf = ctx->rt->current_stack_frame; return (sf && (sf->js_mode & JS_MODE_STRICT)); } #ifdef CONFIG_BIGNUM static inline BOOL is_math_mode(JSContext *ctx) { JSStackFrame *sf = ctx->rt->current_stack_frame; return (sf && (sf->js_mode & JS_MODE_MATH)); } #else static inline BOOL is_math_mode(JSContext *ctx) { return FALSE; } #endif /* JSAtom support */ #define JS_ATOM_TAG_INT (1U << 31) #define JS_ATOM_MAX_INT (JS_ATOM_TAG_INT - 1) #define JS_ATOM_MAX ((1U << 30) - 1) /* return the max count from the hash size */ #define JS_ATOM_COUNT_RESIZE(n) ((n) * 2) static inline BOOL __JS_AtomIsConst(JSAtom v) { #if defined(DUMP_LEAKS) && DUMP_LEAKS > 1 return (int32_t)v <= 0; #else return (int32_t)v < JS_ATOM_END; #endif } static inline BOOL __JS_AtomIsTaggedInt(JSAtom v) { return (v & JS_ATOM_TAG_INT) != 0; } static inline JSAtom __JS_AtomFromUInt32(uint32_t v) { return v | JS_ATOM_TAG_INT; } static inline uint32_t __JS_AtomToUInt32(JSAtom atom) { return atom & ~JS_ATOM_TAG_INT; } static inline int is_num(int c) { return c >= '0' && c <= '9'; } /* return TRUE if the string is a number n with 0 <= n <= 2^32-1 */ static inline BOOL is_num_string(uint32_t *pval, const JSString *p) { uint32_t n; uint64_t n64; int c, i, len; len = p->len; if (len == 0 || len > 10) return FALSE; if (p->is_wide_char) c = p->u.str16[0]; else c = p->u.str8[0]; if (is_num(c)) { if (c == '0') { if (len != 1) return FALSE; n = 0; } else { n = c - '0'; for(i = 1; i < len; i++) { if (p->is_wide_char) c = p->u.str16[i]; else c = p->u.str8[i]; if (!is_num(c)) return FALSE; n64 = (uint64_t)n * 10 + (c - '0'); if ((n64 >> 32) != 0) return FALSE; n = n64; } } *pval = n; return TRUE; } else { return FALSE; } } /* XXX: could use faster version ? */ static inline uint32_t hash_string8(const uint8_t *str, size_t len, uint32_t h) { size_t i; for(i = 0; i < len; i++) h = h * 263 + str[i]; return h; } static inline uint32_t hash_string16(const uint16_t *str, size_t len, uint32_t h) { size_t i; for(i = 0; i < len; i++) h = h * 263 + str[i]; return h; } static uint32_t hash_string(const JSString *str, uint32_t h) { if (str->is_wide_char) h = hash_string16(str->u.str16, str->len, h); else h = hash_string8(str->u.str8, str->len, h); return h; } static __maybe_unused void JS_DumpString(JSRuntime *rt, const JSString *p) { int i, c, sep; if (p == NULL) { printf(""); return; } printf("%d", p->header.ref_count); sep = (p->header.ref_count == 1) ? '\"' : '\''; putchar(sep); for(i = 0; i < p->len; i++) { if (p->is_wide_char) c = p->u.str16[i]; else c = p->u.str8[i]; if (c == sep || c == '\\') { putchar('\\'); putchar(c); } else if (c >= ' ' && c <= 126) { putchar(c); } else if (c == '\n') { putchar('\\'); putchar('n'); } else { printf("\\u%04x", c); } } putchar(sep); } static __maybe_unused void JS_DumpAtoms(JSRuntime *rt) { JSAtomStruct *p; int h, i; /* This only dumps hashed atoms, not JS_ATOM_TYPE_SYMBOL atoms */ printf("JSAtom count=%d size=%d hash_size=%d:\n", rt->atom_count, rt->atom_size, rt->atom_hash_size); printf("JSAtom hash table: {\n"); for(i = 0; i < rt->atom_hash_size; i++) { h = rt->atom_hash[i]; if (h) { printf(" %d:", i); while (h) { p = rt->atom_array[h]; printf(" "); JS_DumpString(rt, p); h = p->hash_next; } printf("\n"); } } printf("}\n"); printf("JSAtom table: {\n"); for(i = 0; i < rt->atom_size; i++) { p = rt->atom_array[i]; if (!atom_is_free(p)) { printf(" %d: { %d %08x ", i, p->atom_type, p->hash); if (!(p->len == 0 && p->is_wide_char != 0)) JS_DumpString(rt, p); printf(" %d }\n", p->hash_next); } } printf("}\n"); } static int JS_ResizeAtomHash(JSRuntime *rt, int new_hash_size) { JSAtomStruct *p; uint32_t new_hash_mask, h, i, hash_next1, j, *new_hash; assert((new_hash_size & (new_hash_size - 1)) == 0); /* power of two */ new_hash_mask = new_hash_size - 1; new_hash = js_mallocz_rt(rt, sizeof(rt->atom_hash[0]) * new_hash_size); if (!new_hash) return -1; for(i = 0; i < rt->atom_hash_size; i++) { h = rt->atom_hash[i]; while (h != 0) { p = rt->atom_array[h]; hash_next1 = p->hash_next; /* add in new hash table */ j = p->hash & new_hash_mask; p->hash_next = new_hash[j]; new_hash[j] = h; h = hash_next1; } } js_free_rt(rt, rt->atom_hash); rt->atom_hash = new_hash; rt->atom_hash_size = new_hash_size; rt->atom_count_resize = JS_ATOM_COUNT_RESIZE(new_hash_size); // JS_DumpAtoms(rt); return 0; } static int JS_InitAtoms(JSRuntime *rt) { int i, len, atom_type; const char *p; rt->atom_hash_size = 0; rt->atom_hash = NULL; rt->atom_count = 0; rt->atom_size = 0; rt->atom_free_index = 0; if (JS_ResizeAtomHash(rt, 256)) /* there are at least 195 predefined atoms */ return -1; p = js_atom_init; for(i = 1; i < JS_ATOM_END; i++) { if (i == JS_ATOM_Private_brand) atom_type = JS_ATOM_TYPE_PRIVATE; else if (i >= JS_ATOM_Symbol_toPrimitive) atom_type = JS_ATOM_TYPE_SYMBOL; else atom_type = JS_ATOM_TYPE_STRING; len = strlen(p); if (__JS_NewAtomInit(rt, p, len, atom_type) == JS_ATOM_NULL) return -1; p = p + len + 1; } return 0; } static JSAtom JS_DupAtomRT(JSRuntime *rt, JSAtom v) { JSAtomStruct *p; if (!__JS_AtomIsConst(v)) { p = rt->atom_array[v]; p->header.ref_count++; } return v; } JSAtom JS_DupAtom(JSContext *ctx, JSAtom v) { JSRuntime *rt; JSAtomStruct *p; if (!__JS_AtomIsConst(v)) { rt = ctx->rt; p = rt->atom_array[v]; p->header.ref_count++; } return v; } static JSAtomKindEnum JS_AtomGetKind(JSContext *ctx, JSAtom v) { JSRuntime *rt; JSAtomStruct *p; rt = ctx->rt; if (__JS_AtomIsTaggedInt(v)) return JS_ATOM_KIND_STRING; p = rt->atom_array[v]; switch(p->atom_type) { case JS_ATOM_TYPE_STRING: return JS_ATOM_KIND_STRING; case JS_ATOM_TYPE_GLOBAL_SYMBOL: return JS_ATOM_KIND_SYMBOL; case JS_ATOM_TYPE_SYMBOL: switch(p->hash) { case JS_ATOM_HASH_SYMBOL: return JS_ATOM_KIND_SYMBOL; case JS_ATOM_HASH_PRIVATE: return JS_ATOM_KIND_PRIVATE; default: abort(); } default: abort(); } } static BOOL JS_AtomIsString(JSContext *ctx, JSAtom v) { return JS_AtomGetKind(ctx, v) == JS_ATOM_KIND_STRING; } static JSAtom js_get_atom_index(JSRuntime *rt, JSAtomStruct *p) { uint32_t i = p->hash_next; /* atom_index */ if (p->atom_type != JS_ATOM_TYPE_SYMBOL) { JSAtomStruct *p1; i = rt->atom_hash[p->hash & (rt->atom_hash_size - 1)]; p1 = rt->atom_array[i]; while (p1 != p) { assert(i != 0); i = p1->hash_next; p1 = rt->atom_array[i]; } } return i; } /* string case (internal). Return JS_ATOM_NULL if error. 'str' is freed. */ static JSAtom __JS_NewAtom(JSRuntime *rt, JSString *str, int atom_type) { uint32_t h, h1, i; JSAtomStruct *p; int len; #if 0 printf("__JS_NewAtom: "); JS_DumpString(rt, str); printf("\n"); #endif if (atom_type < JS_ATOM_TYPE_SYMBOL) { /* str is not NULL */ if (str->atom_type == atom_type) { /* str is the atom, return its index */ i = js_get_atom_index(rt, str); /* reduce string refcount and increase atom's unless constant */ if (__JS_AtomIsConst(i)) str->header.ref_count--; return i; } /* try and locate an already registered atom */ len = str->len; h = hash_string(str, atom_type); h &= JS_ATOM_HASH_MASK; h1 = h & (rt->atom_hash_size - 1); i = rt->atom_hash[h1]; while (i != 0) { p = rt->atom_array[i]; if (p->hash == h && p->atom_type == atom_type && p->len == len && js_string_memcmp(p, str, len) == 0) { if (!__JS_AtomIsConst(i)) p->header.ref_count++; goto done; } i = p->hash_next; } } else { h1 = 0; /* avoid warning */ if (atom_type == JS_ATOM_TYPE_SYMBOL) { h = JS_ATOM_HASH_SYMBOL; } else { h = JS_ATOM_HASH_PRIVATE; atom_type = JS_ATOM_TYPE_SYMBOL; } } if (rt->atom_free_index == 0) { /* allow new atom entries */ uint32_t new_size, start; JSAtomStruct **new_array; /* alloc new with size progression 3/2: 4 6 9 13 19 28 42 63 94 141 211 316 474 711 1066 1599 2398 3597 5395 8092 preallocating space for predefined atoms (at least 195). */ new_size = max_int(211, rt->atom_size * 3 / 2); if (new_size > JS_ATOM_MAX) goto fail; /* XXX: should use realloc2 to use slack space */ new_array = js_realloc_rt(rt, rt->atom_array, sizeof(*new_array) * new_size); if (!new_array) goto fail; /* Note: the atom 0 is not used */ start = rt->atom_size; if (start == 0) { /* JS_ATOM_NULL entry */ p = js_mallocz_rt(rt, sizeof(JSAtomStruct)); if (!p) { js_free_rt(rt, new_array); goto fail; } p->header.ref_count = 1; /* not refcounted */ p->atom_type = JS_ATOM_TYPE_SYMBOL; #ifdef DUMP_LEAKS list_add_tail(&p->link, &rt->string_list); #endif new_array[0] = p; rt->atom_count++; start = 1; } rt->atom_size = new_size; rt->atom_array = new_array; rt->atom_free_index = start; for(i = start; i < new_size; i++) { uint32_t next; if (i == (new_size - 1)) next = 0; else next = i + 1; rt->atom_array[i] = atom_set_free(next); } } if (str) { if (str->atom_type == 0) { p = str; p->atom_type = atom_type; } else { p = js_malloc_rt(rt, sizeof(JSString) + (str->len << str->is_wide_char) + 1 - str->is_wide_char); if (unlikely(!p)) goto fail; p->header.ref_count = 1; p->is_wide_char = str->is_wide_char; p->len = str->len; #ifdef DUMP_LEAKS list_add_tail(&p->link, &rt->string_list); #endif memcpy(p->u.str8, str->u.str8, (str->len << str->is_wide_char) + 1 - str->is_wide_char); js_free_string(rt, str); } } else { p = js_malloc_rt(rt, sizeof(JSAtomStruct)); /* empty wide string */ if (!p) return JS_ATOM_NULL; p->header.ref_count = 1; p->is_wide_char = 1; /* Hack to represent NULL as a JSString */ p->len = 0; #ifdef DUMP_LEAKS list_add_tail(&p->link, &rt->string_list); #endif } /* use an already free entry */ i = rt->atom_free_index; rt->atom_free_index = atom_get_free(rt->atom_array[i]); rt->atom_array[i] = p; p->hash = h; p->hash_next = i; /* atom_index */ p->atom_type = atom_type; rt->atom_count++; if (atom_type != JS_ATOM_TYPE_SYMBOL) { p->hash_next = rt->atom_hash[h1]; rt->atom_hash[h1] = i; if (unlikely(rt->atom_count >= rt->atom_count_resize)) JS_ResizeAtomHash(rt, rt->atom_hash_size * 2); } // JS_DumpAtoms(rt); return i; fail: i = JS_ATOM_NULL; done: if (str) js_free_string(rt, str); return i; } /* only works with zero terminated 8 bit strings */ static JSAtom __JS_NewAtomInit(JSRuntime *rt, const char *str, int len, int atom_type) { JSString *p; p = js_alloc_string_rt(rt, len, 0); if (!p) return JS_ATOM_NULL; memcpy(p->u.str8, str, len); p->u.str8[len] = '\0'; return __JS_NewAtom(rt, p, atom_type); } static JSAtom __JS_FindAtom(JSRuntime *rt, const char *str, size_t len, int atom_type) { uint32_t h, h1, i; JSAtomStruct *p; h = hash_string8((const uint8_t *)str, len, JS_ATOM_TYPE_STRING); h &= JS_ATOM_HASH_MASK; h1 = h & (rt->atom_hash_size - 1); i = rt->atom_hash[h1]; while (i != 0) { p = rt->atom_array[i]; if (p->hash == h && p->atom_type == JS_ATOM_TYPE_STRING && p->len == len && p->is_wide_char == 0 && memcmp(p->u.str8, str, len) == 0) { if (!__JS_AtomIsConst(i)) p->header.ref_count++; return i; } i = p->hash_next; } return JS_ATOM_NULL; } static void JS_FreeAtomStruct(JSRuntime *rt, JSAtomStruct *p) { #if 0 /* JS_ATOM_NULL is not refcounted: __JS_AtomIsConst() includes 0 */ if (unlikely(i == JS_ATOM_NULL)) { p->header.ref_count = INT32_MAX / 2; return; } #endif uint32_t i = p->hash_next; /* atom_index */ if (p->atom_type != JS_ATOM_TYPE_SYMBOL) { JSAtomStruct *p0, *p1; uint32_t h0; h0 = p->hash & (rt->atom_hash_size - 1); i = rt->atom_hash[h0]; p1 = rt->atom_array[i]; if (p1 == p) { rt->atom_hash[h0] = p1->hash_next; } else { for(;;) { assert(i != 0); p0 = p1; i = p1->hash_next; p1 = rt->atom_array[i]; if (p1 == p) { p0->hash_next = p1->hash_next; break; } } } } /* insert in free atom list */ rt->atom_array[i] = atom_set_free(rt->atom_free_index); rt->atom_free_index = i; /* free the string structure */ #ifdef DUMP_LEAKS list_del(&p->link); #endif js_free_rt(rt, p); rt->atom_count--; assert(rt->atom_count >= 0); } static void __JS_FreeAtom(JSRuntime *rt, uint32_t i) { JSAtomStruct *p; p = rt->atom_array[i]; if (--p->header.ref_count > 0) return; JS_FreeAtomStruct(rt, p); } /* Warning: 'p' is freed */ static JSAtom JS_NewAtomStr(JSContext *ctx, JSString *p) { JSRuntime *rt = ctx->rt; uint32_t n; if (is_num_string(&n, p)) { if (n <= JS_ATOM_MAX_INT) { js_free_string(rt, p); return __JS_AtomFromUInt32(n); } } /* XXX: should generate an exception */ return __JS_NewAtom(rt, p, JS_ATOM_TYPE_STRING); } JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len) { JSValue val; if (len == 0 || !is_digit(*str)) { JSAtom atom = __JS_FindAtom(ctx->rt, str, len, JS_ATOM_TYPE_STRING); if (atom) return atom; } val = JS_NewStringLen(ctx, str, len); if (JS_IsException(val)) return JS_ATOM_NULL; return JS_NewAtomStr(ctx, JS_VALUE_GET_STRING(val)); } JSAtom JS_NewAtom(JSContext *ctx, const char *str) { return JS_NewAtomLen(ctx, str, strlen(str)); } JSAtom JS_NewAtomUInt32(JSContext *ctx, uint32_t n) { if (n <= JS_ATOM_MAX_INT) { return __JS_AtomFromUInt32(n); } else { char buf[11]; JSValue val; snprintf(buf, sizeof(buf), "%u", n); val = JS_NewString(ctx, buf); if (JS_IsException(val)) return JS_ATOM_NULL; return __JS_NewAtom(ctx->rt, JS_VALUE_GET_STRING(val), JS_ATOM_TYPE_STRING); } } static JSAtom JS_NewAtomInt64(JSContext *ctx, int64_t n) { if ((uint64_t)n <= JS_ATOM_MAX_INT) { return __JS_AtomFromUInt32((uint32_t)n); } else { char buf[24]; JSValue val; snprintf(buf, sizeof(buf), "%" PRId64 , n); val = JS_NewString(ctx, buf); if (JS_IsException(val)) return JS_ATOM_NULL; return __JS_NewAtom(ctx->rt, JS_VALUE_GET_STRING(val), JS_ATOM_TYPE_STRING); } } /* 'p' is freed */ static JSValue JS_NewSymbol(JSContext *ctx, JSString *p, int atom_type) { JSRuntime *rt = ctx->rt; JSAtom atom; atom = __JS_NewAtom(rt, p, atom_type); if (atom == JS_ATOM_NULL) return JS_ThrowOutOfMemory(ctx); return JS_MKPTR(JS_TAG_SYMBOL, rt->atom_array[atom]); } /* descr must be a non-numeric string atom */ static JSValue JS_NewSymbolFromAtom(JSContext *ctx, JSAtom descr, int atom_type) { JSRuntime *rt = ctx->rt; JSString *p; assert(!__JS_AtomIsTaggedInt(descr)); assert(descr < rt->atom_size); p = rt->atom_array[descr]; JS_DupValue(ctx, JS_MKPTR(JS_TAG_STRING, p)); return JS_NewSymbol(ctx, p, atom_type); } #define ATOM_GET_STR_BUF_SIZE 64 /* Should only be used for debug. */ static const char *JS_AtomGetStrRT(JSRuntime *rt, char *buf, int buf_size, JSAtom atom) { if (__JS_AtomIsTaggedInt(atom)) { snprintf(buf, buf_size, "%u", __JS_AtomToUInt32(atom)); } else { JSAtomStruct *p; assert(atom < rt->atom_size); if (atom == JS_ATOM_NULL) { snprintf(buf, buf_size, ""); } else { int i, c; char *q; JSString *str; q = buf; p = rt->atom_array[atom]; assert(!atom_is_free(p)); str = p; if (str) { if (!str->is_wide_char) { /* special case ASCII strings */ c = 0; for(i = 0; i < str->len; i++) { c |= str->u.str8[i]; } if (c < 0x80) return (const char *)str->u.str8; } for(i = 0; i < str->len; i++) { if (str->is_wide_char) c = str->u.str16[i]; else c = str->u.str8[i]; if ((q - buf) >= buf_size - UTF8_CHAR_LEN_MAX) break; if (c < 128) { *q++ = c; } else { q += unicode_to_utf8((uint8_t *)q, c); } } } *q = '\0'; } } return buf; } static const char *JS_AtomGetStr(JSContext *ctx, char *buf, int buf_size, JSAtom atom) { return JS_AtomGetStrRT(ctx->rt, buf, buf_size, atom); } static JSValue __JS_AtomToValue(JSContext *ctx, JSAtom atom, BOOL force_string) { char buf[ATOM_GET_STR_BUF_SIZE]; if (__JS_AtomIsTaggedInt(atom)) { snprintf(buf, sizeof(buf), "%u", __JS_AtomToUInt32(atom)); return JS_NewString(ctx, buf); } else { JSRuntime *rt = ctx->rt; JSAtomStruct *p; assert(atom < rt->atom_size); p = rt->atom_array[atom]; if (p->atom_type == JS_ATOM_TYPE_STRING) { goto ret_string; } else if (force_string) { if (p->len == 0 && p->is_wide_char != 0) { /* no description string */ p = rt->atom_array[JS_ATOM_empty_string]; } ret_string: return JS_DupValue(ctx, JS_MKPTR(JS_TAG_STRING, p)); } else { return JS_DupValue(ctx, JS_MKPTR(JS_TAG_SYMBOL, p)); } } } JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom) { return __JS_AtomToValue(ctx, atom, FALSE); } JSValue JS_AtomToString(JSContext *ctx, JSAtom atom) { return __JS_AtomToValue(ctx, atom, TRUE); } /* return TRUE if the atom is an array index (i.e. 0 <= index <= 2^32-2 and return its value */ static BOOL JS_AtomIsArrayIndex(JSContext *ctx, uint32_t *pval, JSAtom atom) { if (__JS_AtomIsTaggedInt(atom)) { *pval = __JS_AtomToUInt32(atom); return TRUE; } else { JSRuntime *rt = ctx->rt; JSAtomStruct *p; uint32_t val; assert(atom < rt->atom_size); p = rt->atom_array[atom]; if (p->atom_type == JS_ATOM_TYPE_STRING && is_num_string(&val, p) && val != -1) { *pval = val; return TRUE; } else { *pval = 0; return FALSE; } } } /* This test must be fast if atom is not a numeric index (e.g. a method name). Return JS_UNDEFINED if not a numeric index. JS_EXCEPTION can also be returned. */ static JSValue JS_AtomIsNumericIndex1(JSContext *ctx, JSAtom atom) { JSRuntime *rt = ctx->rt; JSAtomStruct *p1; JSString *p; int c, len, ret; JSValue num, str; if (__JS_AtomIsTaggedInt(atom)) return JS_NewInt32(ctx, __JS_AtomToUInt32(atom)); assert(atom < rt->atom_size); p1 = rt->atom_array[atom]; if (p1->atom_type != JS_ATOM_TYPE_STRING) return JS_UNDEFINED; p = p1; len = p->len; if (p->is_wide_char) { const uint16_t *r = p->u.str16, *r_end = p->u.str16 + len; if (r >= r_end) return JS_UNDEFINED; c = *r; if (c == '-') { if (r >= r_end) return JS_UNDEFINED; r++; c = *r; /* -0 case is specific */ if (c == '0' && len == 2) goto minus_zero; } /* XXX: should test NaN, but the tests do not check it */ if (!is_num(c)) { /* XXX: String should be normalized, therefore 8-bit only */ const uint16_t nfinity16[7] = { 'n', 'f', 'i', 'n', 'i', 't', 'y' }; if (!(c =='I' && (r_end - r) == 8 && !memcmp(r + 1, nfinity16, sizeof(nfinity16)))) return JS_UNDEFINED; } } else { const uint8_t *r = p->u.str8, *r_end = p->u.str8 + len; if (r >= r_end) return JS_UNDEFINED; c = *r; if (c == '-') { if (r >= r_end) return JS_UNDEFINED; r++; c = *r; /* -0 case is specific */ if (c == '0' && len == 2) { minus_zero: return __JS_NewFloat64(ctx, -0.0); } } if (!is_num(c)) { if (!(c =='I' && (r_end - r) == 8 && !memcmp(r + 1, "nfinity", 7))) return JS_UNDEFINED; } } /* XXX: bignum: would be better to only accept integer to avoid relying on current floating point precision */ /* this is ECMA CanonicalNumericIndexString primitive */ num = JS_ToNumber(ctx, JS_MKPTR(JS_TAG_STRING, p)); if (JS_IsException(num)) return num; str = JS_ToString(ctx, num); if (JS_IsException(str)) { JS_FreeValue(ctx, num); return str; } ret = js_string_compare(ctx, p, JS_VALUE_GET_STRING(str)); JS_FreeValue(ctx, str); if (ret == 0) { return num; } else { JS_FreeValue(ctx, num); return JS_UNDEFINED; } } /* return -1 if exception or TRUE/FALSE */ static int JS_AtomIsNumericIndex(JSContext *ctx, JSAtom atom) { JSValue num; num = JS_AtomIsNumericIndex1(ctx, atom); if (likely(JS_IsUndefined(num))) return FALSE; if (JS_IsException(num)) return -1; JS_FreeValue(ctx, num); return TRUE; } void JS_FreeAtom(JSContext *ctx, JSAtom v) { if (!__JS_AtomIsConst(v)) __JS_FreeAtom(ctx->rt, v); } void JS_FreeAtomRT(JSRuntime *rt, JSAtom v) { if (!__JS_AtomIsConst(v)) __JS_FreeAtom(rt, v); } /* return TRUE if 'v' is a symbol with a string description */ static BOOL JS_AtomSymbolHasDescription(JSContext *ctx, JSAtom v) { JSRuntime *rt; JSAtomStruct *p; rt = ctx->rt; if (__JS_AtomIsTaggedInt(v)) return FALSE; p = rt->atom_array[v]; return (((p->atom_type == JS_ATOM_TYPE_SYMBOL && p->hash == JS_ATOM_HASH_SYMBOL) || p->atom_type == JS_ATOM_TYPE_GLOBAL_SYMBOL) && !(p->len == 0 && p->is_wide_char != 0)); } static __maybe_unused void print_atom(JSContext *ctx, JSAtom atom) { char buf[ATOM_GET_STR_BUF_SIZE]; const char *p; int i; /* XXX: should handle embedded null characters */ /* XXX: should move encoding code to JS_AtomGetStr */ p = JS_AtomGetStr(ctx, buf, sizeof(buf), atom); for (i = 0; p[i]; i++) { int c = (unsigned char)p[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_' || c == '$') || (c >= '0' && c <= '9' && i > 0))) break; } if (i > 0 && p[i] == '\0') { printf("%s", p); } else { putchar('"'); printf("%.*s", i, p); for (; p[i]; i++) { int c = (unsigned char)p[i]; if (c == '\"' || c == '\\') { putchar('\\'); putchar(c); } else if (c >= ' ' && c <= 126) { putchar(c); } else if (c == '\n') { putchar('\\'); putchar('n'); } else { printf("\\u%04x", c); } } putchar('\"'); } } /* free with JS_FreeCString() */ const char *JS_AtomToCString(JSContext *ctx, JSAtom atom) { JSValue str; const char *cstr; str = JS_AtomToString(ctx, atom); if (JS_IsException(str)) return NULL; cstr = JS_ToCString(ctx, str); JS_FreeValue(ctx, str); return cstr; } /* return a string atom containing name concatenated with str1 */ static JSAtom js_atom_concat_str(JSContext *ctx, JSAtom name, const char *str1) { JSValue str; JSAtom atom; const char *cstr; char *cstr2; size_t len, len1; str = JS_AtomToString(ctx, name); if (JS_IsException(str)) return JS_ATOM_NULL; cstr = JS_ToCStringLen(ctx, &len, str); if (!cstr) goto fail; len1 = strlen(str1); cstr2 = js_malloc(ctx, len + len1 + 1); if (!cstr2) goto fail; memcpy(cstr2, cstr, len); memcpy(cstr2 + len, str1, len1); cstr2[len + len1] = '\0'; atom = JS_NewAtomLen(ctx, cstr2, len + len1); js_free(ctx, cstr2); JS_FreeCString(ctx, cstr); JS_FreeValue(ctx, str); return atom; fail: JS_FreeCString(ctx, cstr); JS_FreeValue(ctx, str); return JS_ATOM_NULL; } static JSAtom js_atom_concat_num(JSContext *ctx, JSAtom name, uint32_t n) { char buf[16]; snprintf(buf, sizeof(buf), "%u", n); return js_atom_concat_str(ctx, name, buf); } static inline BOOL JS_IsEmptyString(JSValueConst v) { return JS_VALUE_GET_TAG(v) == JS_TAG_STRING && JS_VALUE_GET_STRING(v)->len == 0; } /* JSClass support */ #ifdef CONFIG_ATOMICS static pthread_mutex_t js_class_id_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /* a new class ID is allocated if *pclass_id != 0 */ JSClassID JS_NewClassID(JSClassID *pclass_id) { JSClassID class_id; #ifdef CONFIG_ATOMICS pthread_mutex_lock(&js_class_id_mutex); #endif class_id = *pclass_id; if (class_id == 0) { class_id = js_class_id_alloc++; *pclass_id = class_id; } #ifdef CONFIG_ATOMICS pthread_mutex_unlock(&js_class_id_mutex); #endif return class_id; } BOOL JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id) { return (class_id < rt->class_count && rt->class_array[class_id].class_id != 0); } /* create a new object internal class. Return -1 if error, 0 if OK. The finalizer can be NULL if none is needed. */ static int JS_NewClass1(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def, JSAtom name) { int new_size, i; JSClass *cl, *new_class_array; struct list_head *el; if (class_id >= (1 << 16)) return -1; if (class_id < rt->class_count && rt->class_array[class_id].class_id != 0) return -1; if (class_id >= rt->class_count) { new_size = max_int(JS_CLASS_INIT_COUNT, max_int(class_id + 1, rt->class_count * 3 / 2)); /* reallocate the context class prototype array, if any */ list_for_each(el, &rt->context_list) { JSContext *ctx = list_entry(el, JSContext, link); JSValue *new_tab; new_tab = js_realloc_rt(rt, ctx->class_proto, sizeof(ctx->class_proto[0]) * new_size); if (!new_tab) return -1; for(i = rt->class_count; i < new_size; i++) new_tab[i] = JS_NULL; ctx->class_proto = new_tab; } /* reallocate the class array */ new_class_array = js_realloc_rt(rt, rt->class_array, sizeof(JSClass) * new_size); if (!new_class_array) return -1; memset(new_class_array + rt->class_count, 0, (new_size - rt->class_count) * sizeof(JSClass)); rt->class_array = new_class_array; rt->class_count = new_size; } cl = &rt->class_array[class_id]; cl->class_id = class_id; cl->class_name = JS_DupAtomRT(rt, name); cl->finalizer = class_def->finalizer; cl->gc_mark = class_def->gc_mark; cl->call = class_def->call; cl->exotic = class_def->exotic; return 0; } int JS_NewClass(JSRuntime *rt, JSClassID class_id, const JSClassDef *class_def) { int ret, len; JSAtom name; len = strlen(class_def->class_name); name = __JS_FindAtom(rt, class_def->class_name, len, JS_ATOM_TYPE_STRING); if (name == JS_ATOM_NULL) { name = __JS_NewAtomInit(rt, class_def->class_name, len, JS_ATOM_TYPE_STRING); if (name == JS_ATOM_NULL) return -1; } ret = JS_NewClass1(rt, class_id, class_def, name); JS_FreeAtomRT(rt, name); return ret; } static JSValue js_new_string8(JSContext *ctx, const uint8_t *buf, int len) { JSString *str; if (len <= 0) { return JS_AtomToString(ctx, JS_ATOM_empty_string); } str = js_alloc_string(ctx, len, 0); if (!str) return JS_EXCEPTION; memcpy(str->u.str8, buf, len); str->u.str8[len] = '\0'; return JS_MKPTR(JS_TAG_STRING, str); } static JSValue js_new_string16(JSContext *ctx, const uint16_t *buf, int len) { JSString *str; str = js_alloc_string(ctx, len, 1); if (!str) return JS_EXCEPTION; memcpy(str->u.str16, buf, len * 2); return JS_MKPTR(JS_TAG_STRING, str); } static JSValue js_new_string_char(JSContext *ctx, uint16_t c) { if (c < 0x100) { uint8_t ch8 = c; return js_new_string8(ctx, &ch8, 1); } else { uint16_t ch16 = c; return js_new_string16(ctx, &ch16, 1); } } static JSValue js_sub_string(JSContext *ctx, JSString *p, int start, int end) { int len = end - start; if (start == 0 && end == p->len) { return JS_DupValue(ctx, JS_MKPTR(JS_TAG_STRING, p)); } if (p->is_wide_char && len > 0) { JSString *str; int i; uint16_t c = 0; for (i = start; i < end; i++) { c |= p->u.str16[i]; } if (c > 0xFF) return js_new_string16(ctx, p->u.str16 + start, len); str = js_alloc_string(ctx, len, 0); if (!str) return JS_EXCEPTION; for (i = 0; i < len; i++) { str->u.str8[i] = p->u.str16[start + i]; } str->u.str8[len] = '\0'; return JS_MKPTR(JS_TAG_STRING, str); } else { return js_new_string8(ctx, p->u.str8 + start, len); } } typedef struct StringBuffer { JSContext *ctx; JSString *str; int len; int size; int is_wide_char; int error_status; } StringBuffer; /* It is valid to call string_buffer_end() and all string_buffer functions even if string_buffer_init() or another string_buffer function returns an error. If the error_status is set, string_buffer_end() returns JS_EXCEPTION. */ static int string_buffer_init2(JSContext *ctx, StringBuffer *s, int size, int is_wide) { s->ctx = ctx; s->size = size; s->len = 0; s->is_wide_char = is_wide; s->error_status = 0; s->str = js_alloc_string(ctx, size, is_wide); if (unlikely(!s->str)) { s->size = 0; return s->error_status = -1; } #ifdef DUMP_LEAKS /* the StringBuffer may reallocate the JSString, only link it at the end */ list_del(&s->str->link); #endif return 0; } static inline int string_buffer_init(JSContext *ctx, StringBuffer *s, int size) { return string_buffer_init2(ctx, s, size, 0); } static void string_buffer_free(StringBuffer *s) { js_free(s->ctx, s->str); s->str = NULL; } static int string_buffer_set_error(StringBuffer *s) { js_free(s->ctx, s->str); s->str = NULL; s->size = 0; s->len = 0; return s->error_status = -1; } static no_inline int string_buffer_widen(StringBuffer *s, int size) { JSString *str; size_t slack; int i; if (s->error_status) return -1; str = js_realloc2(s->ctx, s->str, sizeof(JSString) + (size << 1), &slack); if (!str) return string_buffer_set_error(s); size += slack >> 1; for(i = s->len; i-- > 0;) { str->u.str16[i] = str->u.str8[i]; } s->is_wide_char = 1; s->size = size; s->str = str; return 0; } static no_inline int string_buffer_realloc(StringBuffer *s, int new_len, int c) { JSString *new_str; int new_size; size_t new_size_bytes, slack; if (s->error_status) return -1; if (new_len > JS_STRING_LEN_MAX) { JS_ThrowInternalError(s->ctx, "string too long"); return string_buffer_set_error(s); } new_size = min_int(max_int(new_len, s->size * 3 / 2), JS_STRING_LEN_MAX); if (!s->is_wide_char && c >= 0x100) { return string_buffer_widen(s, new_size); } new_size_bytes = sizeof(JSString) + (new_size << s->is_wide_char) + 1 - s->is_wide_char; new_str = js_realloc2(s->ctx, s->str, new_size_bytes, &slack); if (!new_str) return string_buffer_set_error(s); new_size = min_int(new_size + (slack >> s->is_wide_char), JS_STRING_LEN_MAX); s->size = new_size; s->str = new_str; return 0; } static no_inline int string_buffer_putc_slow(StringBuffer *s, uint32_t c) { if (unlikely(s->len >= s->size)) { if (string_buffer_realloc(s, s->len + 1, c)) return -1; } if (s->is_wide_char) { s->str->u.str16[s->len++] = c; } else if (c < 0x100) { s->str->u.str8[s->len++] = c; } else { if (string_buffer_widen(s, s->size)) return -1; s->str->u.str16[s->len++] = c; } return 0; } /* 0 <= c <= 0xff */ static int string_buffer_putc8(StringBuffer *s, uint32_t c) { if (unlikely(s->len >= s->size)) { if (string_buffer_realloc(s, s->len + 1, c)) return -1; } if (s->is_wide_char) { s->str->u.str16[s->len++] = c; } else { s->str->u.str8[s->len++] = c; } return 0; } /* 0 <= c <= 0xffff */ static int string_buffer_putc16(StringBuffer *s, uint32_t c) { if (likely(s->len < s->size)) { if (s->is_wide_char) { s->str->u.str16[s->len++] = c; return 0; } else if (c < 0x100) { s->str->u.str8[s->len++] = c; return 0; } } return string_buffer_putc_slow(s, c); } /* 0 <= c <= 0x10ffff */ static int string_buffer_putc(StringBuffer *s, uint32_t c) { if (unlikely(c >= 0x10000)) { /* surrogate pair */ c -= 0x10000; if (string_buffer_putc16(s, (c >> 10) + 0xd800)) return -1; c = (c & 0x3ff) + 0xdc00; } return string_buffer_putc16(s, c); } static int string_get(const JSString *p, int idx) { return p->is_wide_char ? p->u.str16[idx] : p->u.str8[idx]; } static int string_getc(const JSString *p, int *pidx) { int idx, c, c1; idx = *pidx; if (p->is_wide_char) { c = p->u.str16[idx++]; if (c >= 0xd800 && c < 0xdc00 && idx < p->len) { c1 = p->u.str16[idx]; if (c1 >= 0xdc00 && c1 < 0xe000) { c = (((c & 0x3ff) << 10) | (c1 & 0x3ff)) + 0x10000; idx++; } } } else { c = p->u.str8[idx++]; } *pidx = idx; return c; } static int string_buffer_write8(StringBuffer *s, const uint8_t *p, int len) { int i; if (s->len + len > s->size) { if (string_buffer_realloc(s, s->len + len, 0)) return -1; } if (s->is_wide_char) { for (i = 0; i < len; i++) { s->str->u.str16[s->len + i] = p[i]; } s->len += len; } else { memcpy(&s->str->u.str8[s->len], p, len); s->len += len; } return 0; } static int string_buffer_write16(StringBuffer *s, const uint16_t *p, int len) { int c = 0, i; for (i = 0; i < len; i++) { c |= p[i]; } if (s->len + len > s->size) { if (string_buffer_realloc(s, s->len + len, c)) return -1; } else if (!s->is_wide_char && c >= 0x100) { if (string_buffer_widen(s, s->size)) return -1; } if (s->is_wide_char) { memcpy(&s->str->u.str16[s->len], p, len << 1); s->len += len; } else { for (i = 0; i < len; i++) { s->str->u.str8[s->len + i] = p[i]; } s->len += len; } return 0; } /* appending an ASCII string */ static int string_buffer_puts8(StringBuffer *s, const char *str) { return string_buffer_write8(s, (const uint8_t *)str, strlen(str)); } static int string_buffer_concat(StringBuffer *s, const JSString *p, uint32_t from, uint32_t to) { if (to <= from) return 0; if (p->is_wide_char) return string_buffer_write16(s, p->u.str16 + from, to - from); else return string_buffer_write8(s, p->u.str8 + from, to - from); } static int string_buffer_concat_value(StringBuffer *s, JSValueConst v) { JSString *p; JSValue v1; int res; if (s->error_status) { /* prevent exception overload */ return -1; } if (unlikely(JS_VALUE_GET_TAG(v) != JS_TAG_STRING)) { v1 = JS_ToString(s->ctx, v); if (JS_IsException(v1)) return string_buffer_set_error(s); p = JS_VALUE_GET_STRING(v1); res = string_buffer_concat(s, p, 0, p->len); JS_FreeValue(s->ctx, v1); return res; } p = JS_VALUE_GET_STRING(v); return string_buffer_concat(s, p, 0, p->len); } static int string_buffer_concat_value_free(StringBuffer *s, JSValue v) { JSString *p; int res; if (s->error_status) { /* prevent exception overload */ JS_FreeValue(s->ctx, v); return -1; } if (unlikely(JS_VALUE_GET_TAG(v) != JS_TAG_STRING)) { v = JS_ToStringFree(s->ctx, v); if (JS_IsException(v)) return string_buffer_set_error(s); } p = JS_VALUE_GET_STRING(v); res = string_buffer_concat(s, p, 0, p->len); JS_FreeValue(s->ctx, v); return res; } static int string_buffer_fill(StringBuffer *s, int c, int count) { /* XXX: optimize */ if (s->len + count > s->size) { if (string_buffer_realloc(s, s->len + count, c)) return -1; } while (count-- > 0) { if (string_buffer_putc16(s, c)) return -1; } return 0; } static JSValue string_buffer_end(StringBuffer *s) { JSString *str; str = s->str; if (s->error_status) return JS_EXCEPTION; if (s->len == 0) { js_free(s->ctx, str); s->str = NULL; return JS_AtomToString(s->ctx, JS_ATOM_empty_string); } if (s->len < s->size) { /* smaller size so js_realloc should not fail, but OK if it does */ /* XXX: should add some slack to avoid unnecessary calls */ /* XXX: might need to use malloc+free to ensure smaller size */ str = js_realloc_rt(s->ctx->rt, str, sizeof(JSString) + (s->len << s->is_wide_char) + 1 - s->is_wide_char); if (str == NULL) str = s->str; s->str = str; } if (!s->is_wide_char) str->u.str8[s->len] = 0; #ifdef DUMP_LEAKS list_add_tail(&str->link, &s->ctx->rt->string_list); #endif str->is_wide_char = s->is_wide_char; str->len = s->len; s->str = NULL; return JS_MKPTR(JS_TAG_STRING, str); } /* create a string from a UTF-8 buffer */ JSValue JS_NewStringLen(JSContext *ctx, const char *buf, size_t buf_len) { const uint8_t *p, *p_end, *p_start, *p_next; uint32_t c; StringBuffer b_s, *b = &b_s; size_t len1; p_start = (const uint8_t *)buf; p_end = p_start + buf_len; p = p_start; while (p < p_end && *p < 128) p++; len1 = p - p_start; if (len1 > JS_STRING_LEN_MAX) return JS_ThrowInternalError(ctx, "string too long"); if (p == p_end) { /* ASCII string */ return js_new_string8(ctx, (const uint8_t *)buf, buf_len); } else { if (string_buffer_init(ctx, b, buf_len)) goto fail; string_buffer_write8(b, p_start, len1); while (p < p_end) { if (*p < 128) { string_buffer_putc8(b, *p++); } else { /* parse utf-8 sequence, return 0xFFFFFFFF for error */ c = unicode_from_utf8(p, p_end - p, &p_next); if (c < 0x10000) { p = p_next; } else if (c <= 0x10FFFF) { p = p_next; /* surrogate pair */ c -= 0x10000; string_buffer_putc16(b, (c >> 10) + 0xd800); c = (c & 0x3ff) + 0xdc00; } else { /* invalid char */ c = 0xfffd; /* skip the invalid chars */ /* XXX: seems incorrect. Why not just use c = *p++; ? */ while (p < p_end && (*p >= 0x80 && *p < 0xc0)) p++; if (p < p_end) { p++; while (p < p_end && (*p >= 0x80 && *p < 0xc0)) p++; } } string_buffer_putc16(b, c); } } } return string_buffer_end(b); fail: string_buffer_free(b); return JS_EXCEPTION; } static JSValue JS_ConcatString3(JSContext *ctx, const char *str1, JSValue str2, const char *str3) { StringBuffer b_s, *b = &b_s; int len1, len3; JSString *p; if (unlikely(JS_VALUE_GET_TAG(str2) != JS_TAG_STRING)) { str2 = JS_ToStringFree(ctx, str2); if (JS_IsException(str2)) goto fail; } p = JS_VALUE_GET_STRING(str2); len1 = strlen(str1); len3 = strlen(str3); if (string_buffer_init2(ctx, b, len1 + p->len + len3, p->is_wide_char)) goto fail; string_buffer_write8(b, (const uint8_t *)str1, len1); string_buffer_concat(b, p, 0, p->len); string_buffer_write8(b, (const uint8_t *)str3, len3); JS_FreeValue(ctx, str2); return string_buffer_end(b); fail: JS_FreeValue(ctx, str2); return JS_EXCEPTION; } JSValue JS_NewString(JSContext *ctx, const char *str) { return JS_NewStringLen(ctx, str, strlen(str)); } JSValue JS_NewAtomString(JSContext *ctx, const char *str) { JSAtom atom = JS_NewAtom(ctx, str); if (atom == JS_ATOM_NULL) return JS_EXCEPTION; JSValue val = JS_AtomToString(ctx, atom); JS_FreeAtom(ctx, atom); return val; } /* return (NULL, 0) if exception. */ /* return pointer into a JSString with a live ref_count */ /* cesu8 determines if non-BMP1 codepoints are encoded as 1 or 2 utf-8 sequences */ const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, BOOL cesu8) { JSValue val; JSString *str, *str_new; int pos, len, c, c1; uint8_t *q; if (JS_VALUE_GET_TAG(val1) != JS_TAG_STRING) { val = JS_ToString(ctx, val1); if (JS_IsException(val)) goto fail; } else { val = JS_DupValue(ctx, val1); } str = JS_VALUE_GET_STRING(val); len = str->len; if (!str->is_wide_char) { const uint8_t *src = str->u.str8; int count; /* count the number of non-ASCII characters */ /* Scanning the whole string is required for ASCII strings, and computing the number of non-ASCII bytes is less expensive than testing each byte, hence this method is faster for ASCII strings, which is the most common case. */ count = 0; for (pos = 0; pos < len; pos++) { count += src[pos] >> 7; } if (count == 0) { if (plen) *plen = len; return (const char *)src; } str_new = js_alloc_string(ctx, len + count, 0); if (!str_new) goto fail; q = str_new->u.str8; for (pos = 0; pos < len; pos++) { c = src[pos]; if (c < 0x80) { *q++ = c; } else { *q++ = (c >> 6) | 0xc0; *q++ = (c & 0x3f) | 0x80; } } } else { const uint16_t *src = str->u.str16; /* Allocate 3 bytes per 16 bit code point. Surrogate pairs may produce 4 bytes but use 2 code points. */ str_new = js_alloc_string(ctx, len * 3, 0); if (!str_new) goto fail; q = str_new->u.str8; pos = 0; while (pos < len) { c = src[pos++]; if (c < 0x80) { *q++ = c; } else { if (c >= 0xd800 && c < 0xdc00) { if (pos < len && !cesu8) { c1 = src[pos]; if (c1 >= 0xdc00 && c1 < 0xe000) { pos++; /* surrogate pair */ c = (((c & 0x3ff) << 10) | (c1 & 0x3ff)) + 0x10000; } else { /* Keep unmatched surrogate code points */ /* c = 0xfffd; */ /* error */ } } else { /* Keep unmatched surrogate code points */ /* c = 0xfffd; */ /* error */ } } q += unicode_to_utf8(q, c); } } } *q = '\0'; str_new->len = q - str_new->u.str8; JS_FreeValue(ctx, val); if (plen) *plen = str_new->len; return (const char *)str_new->u.str8; fail: if (plen) *plen = 0; return NULL; } void JS_FreeCString(JSContext *ctx, const char *ptr) { JSString *p; if (!ptr) return; /* purposely removing constness */ p = container_of(ptr, JSString, u); JS_FreeValue(ctx, JS_MKPTR(JS_TAG_STRING, p)); } static int memcmp16_8(const uint16_t *src1, const uint8_t *src2, int len) { int c, i; for(i = 0; i < len; i++) { c = src1[i] - src2[i]; if (c != 0) return c; } return 0; } static int memcmp16(const uint16_t *src1, const uint16_t *src2, int len) { int c, i; for(i = 0; i < len; i++) { c = src1[i] - src2[i]; if (c != 0) return c; } return 0; } static int js_string_memcmp(const JSString *p1, const JSString *p2, int len) { int res; if (likely(!p1->is_wide_char)) { if (likely(!p2->is_wide_char)) res = memcmp(p1->u.str8, p2->u.str8, len); else res = -memcmp16_8(p2->u.str16, p1->u.str8, len); } else { if (!p2->is_wide_char) res = memcmp16_8(p1->u.str16, p2->u.str8, len); else res = memcmp16(p1->u.str16, p2->u.str16, len); } return res; } /* return < 0, 0 or > 0 */ static int js_string_compare(JSContext *ctx, const JSString *p1, const JSString *p2) { int res, len; len = min_int(p1->len, p2->len); res = js_string_memcmp(p1, p2, len); if (res == 0) { if (p1->len == p2->len) res = 0; else if (p1->len < p2->len) res = -1; else res = 1; } return res; } static void copy_str16(uint16_t *dst, const JSString *p, int offset, int len) { if (p->is_wide_char) { memcpy(dst, p->u.str16 + offset, len * 2); } else { const uint8_t *src1 = p->u.str8 + offset; int i; for(i = 0; i < len; i++) dst[i] = src1[i]; } } static JSValue JS_ConcatString1(JSContext *ctx, const JSString *p1, const JSString *p2) { JSString *p; uint32_t len; int is_wide_char; len = p1->len + p2->len; if (len > JS_STRING_LEN_MAX) return JS_ThrowInternalError(ctx, "string too long"); is_wide_char = p1->is_wide_char | p2->is_wide_char; p = js_alloc_string(ctx, len, is_wide_char); if (!p) return JS_EXCEPTION; if (!is_wide_char) { memcpy(p->u.str8, p1->u.str8, p1->len); memcpy(p->u.str8 + p1->len, p2->u.str8, p2->len); p->u.str8[len] = '\0'; } else { copy_str16(p->u.str16, p1, 0, p1->len); copy_str16(p->u.str16 + p1->len, p2, 0, p2->len); } return JS_MKPTR(JS_TAG_STRING, p); } /* op1 and op2 are converted to strings. For convience, op1 or op2 = JS_EXCEPTION are accepted and return JS_EXCEPTION. */ static JSValue JS_ConcatString(JSContext *ctx, JSValue op1, JSValue op2) { JSValue ret; JSString *p1, *p2; if (unlikely(JS_VALUE_GET_TAG(op1) != JS_TAG_STRING)) { op1 = JS_ToStringFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); return JS_EXCEPTION; } } if (unlikely(JS_VALUE_GET_TAG(op2) != JS_TAG_STRING)) { op2 = JS_ToStringFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); return JS_EXCEPTION; } } p1 = JS_VALUE_GET_STRING(op1); p2 = JS_VALUE_GET_STRING(op2); /* XXX: could also check if p1 is empty */ if (p2->len == 0) { goto ret_op1; } if (p1->header.ref_count == 1 && p1->is_wide_char == p2->is_wide_char && js_malloc_usable_size(ctx, p1) >= sizeof(*p1) + ((p1->len + p2->len) << p2->is_wide_char) + 1 - p1->is_wide_char) { /* Concatenate in place in available space at the end of p1 */ if (p1->is_wide_char) { memcpy(p1->u.str16 + p1->len, p2->u.str16, p2->len << 1); p1->len += p2->len; } else { memcpy(p1->u.str8 + p1->len, p2->u.str8, p2->len); p1->len += p2->len; p1->u.str8[p1->len] = '\0'; } ret_op1: JS_FreeValue(ctx, op2); return op1; } ret = JS_ConcatString1(ctx, p1, p2); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); return ret; } /* Shape support */ static inline size_t get_shape_size(size_t hash_size, size_t prop_size) { return hash_size * sizeof(uint32_t) + sizeof(JSShape) + prop_size * sizeof(JSShapeProperty); } static inline JSShape *get_shape_from_alloc(void *sh_alloc, size_t hash_size) { return (JSShape *)(void *)((uint32_t *)sh_alloc + hash_size); } static inline uint32_t *prop_hash_end(JSShape *sh) { return (uint32_t *)sh; } static inline void *get_alloc_from_shape(JSShape *sh) { return prop_hash_end(sh) - ((intptr_t)sh->prop_hash_mask + 1); } static inline JSShapeProperty *get_shape_prop(JSShape *sh) { return sh->prop; } static int init_shape_hash(JSRuntime *rt) { rt->shape_hash_bits = 4; /* 16 shapes */ rt->shape_hash_size = 1 << rt->shape_hash_bits; rt->shape_hash_count = 0; rt->shape_hash = js_mallocz_rt(rt, sizeof(rt->shape_hash[0]) * rt->shape_hash_size); if (!rt->shape_hash) return -1; return 0; } /* same magic hash multiplier as the Linux kernel */ static uint32_t shape_hash(uint32_t h, uint32_t val) { return (h + val) * 0x9e370001; } /* truncate the shape hash to 'hash_bits' bits */ static uint32_t get_shape_hash(uint32_t h, int hash_bits) { return h >> (32 - hash_bits); } static uint32_t shape_initial_hash(JSObject *proto) { uint32_t h; h = shape_hash(1, (uintptr_t)proto); if (sizeof(proto) > 4) h = shape_hash(h, (uint64_t)(uintptr_t)proto >> 32); return h; } static int resize_shape_hash(JSRuntime *rt, int new_shape_hash_bits) { int new_shape_hash_size, i; uint32_t h; JSShape **new_shape_hash, *sh, *sh_next; new_shape_hash_size = 1 << new_shape_hash_bits; new_shape_hash = js_mallocz_rt(rt, sizeof(rt->shape_hash[0]) * new_shape_hash_size); if (!new_shape_hash) return -1; for(i = 0; i < rt->shape_hash_size; i++) { for(sh = rt->shape_hash[i]; sh != NULL; sh = sh_next) { sh_next = sh->shape_hash_next; h = get_shape_hash(sh->hash, new_shape_hash_bits); sh->shape_hash_next = new_shape_hash[h]; new_shape_hash[h] = sh; } } js_free_rt(rt, rt->shape_hash); rt->shape_hash_bits = new_shape_hash_bits; rt->shape_hash_size = new_shape_hash_size; rt->shape_hash = new_shape_hash; return 0; } static void js_shape_hash_link(JSRuntime *rt, JSShape *sh) { uint32_t h; h = get_shape_hash(sh->hash, rt->shape_hash_bits); sh->shape_hash_next = rt->shape_hash[h]; rt->shape_hash[h] = sh; rt->shape_hash_count++; } static void js_shape_hash_unlink(JSRuntime *rt, JSShape *sh) { uint32_t h; JSShape **psh; h = get_shape_hash(sh->hash, rt->shape_hash_bits); psh = &rt->shape_hash[h]; while (*psh != sh) psh = &(*psh)->shape_hash_next; *psh = sh->shape_hash_next; rt->shape_hash_count--; } /* create a new empty shape with prototype 'proto' */ static no_inline JSShape *js_new_shape2(JSContext *ctx, JSObject *proto, int hash_size, int prop_size) { JSRuntime *rt = ctx->rt; void *sh_alloc; JSShape *sh; /* resize the shape hash table if necessary */ if (2 * (rt->shape_hash_count + 1) > rt->shape_hash_size) { resize_shape_hash(rt, rt->shape_hash_bits + 1); } sh_alloc = js_malloc(ctx, get_shape_size(hash_size, prop_size)); if (!sh_alloc) return NULL; sh = get_shape_from_alloc(sh_alloc, hash_size); sh->header.ref_count = 1; add_gc_object(rt, &sh->header, JS_GC_OBJ_TYPE_SHAPE); if (proto) JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, proto)); sh->proto = proto; memset(prop_hash_end(sh) - hash_size, 0, sizeof(prop_hash_end(sh)[0]) * hash_size); sh->prop_hash_mask = hash_size - 1; sh->prop_size = prop_size; sh->prop_count = 0; sh->deleted_prop_count = 0; /* insert in the hash table */ sh->hash = shape_initial_hash(proto); sh->is_hashed = TRUE; sh->has_small_array_index = FALSE; js_shape_hash_link(ctx->rt, sh); return sh; } static JSShape *js_new_shape(JSContext *ctx, JSObject *proto) { return js_new_shape2(ctx, proto, JS_PROP_INITIAL_HASH_SIZE, JS_PROP_INITIAL_SIZE); } /* The shape is cloned. The new shape is not inserted in the shape hash table */ static JSShape *js_clone_shape(JSContext *ctx, JSShape *sh1) { JSShape *sh; void *sh_alloc, *sh_alloc1; size_t size; JSShapeProperty *pr; uint32_t i, hash_size; hash_size = sh1->prop_hash_mask + 1; size = get_shape_size(hash_size, sh1->prop_size); sh_alloc = js_malloc(ctx, size); if (!sh_alloc) return NULL; sh_alloc1 = get_alloc_from_shape(sh1); memcpy(sh_alloc, sh_alloc1, size); sh = get_shape_from_alloc(sh_alloc, hash_size); sh->header.ref_count = 1; add_gc_object(ctx->rt, &sh->header, JS_GC_OBJ_TYPE_SHAPE); sh->is_hashed = FALSE; if (sh->proto) { JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, sh->proto)); } for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; i++, pr++) { JS_DupAtom(ctx, pr->atom); } return sh; } static JSShape *js_dup_shape(JSShape *sh) { sh->header.ref_count++; return sh; } static void js_free_shape0(JSRuntime *rt, JSShape *sh) { uint32_t i; JSShapeProperty *pr; assert(sh->header.ref_count == 0); if (sh->is_hashed) js_shape_hash_unlink(rt, sh); if (sh->proto != NULL) { JS_FreeValueRT(rt, JS_MKPTR(JS_TAG_OBJECT, sh->proto)); } pr = get_shape_prop(sh); for(i = 0; i < sh->prop_count; i++) { JS_FreeAtomRT(rt, pr->atom); pr++; } remove_gc_object(&sh->header); js_free_rt(rt, get_alloc_from_shape(sh)); } static void js_free_shape(JSRuntime *rt, JSShape *sh) { if (unlikely(--sh->header.ref_count <= 0)) { js_free_shape0(rt, sh); } } static void js_free_shape_null(JSRuntime *rt, JSShape *sh) { if (sh) js_free_shape(rt, sh); } /* make space to hold at least 'count' properties */ static no_inline int resize_properties(JSContext *ctx, JSShape **psh, JSObject *p, uint32_t count) { JSShape *sh; uint32_t new_size, new_hash_size, new_hash_mask, i; JSShapeProperty *pr; void *sh_alloc; intptr_t h; JSShape *old_sh; sh = *psh; new_size = max_int(count, sh->prop_size * 3 / 2); /* Reallocate prop array first to avoid crash or size inconsistency in case of memory allocation failure */ if (p) { JSProperty *new_prop; new_prop = js_realloc(ctx, p->prop, sizeof(new_prop[0]) * new_size); if (unlikely(!new_prop)) return -1; p->prop = new_prop; } new_hash_size = sh->prop_hash_mask + 1; while (new_hash_size < new_size) new_hash_size = 2 * new_hash_size; /* resize the property shapes. Using js_realloc() is not possible in case the GC runs during the allocation */ old_sh = sh; sh_alloc = js_malloc(ctx, get_shape_size(new_hash_size, new_size)); if (!sh_alloc) return -1; sh = get_shape_from_alloc(sh_alloc, new_hash_size); list_del(&old_sh->header.link); /* copy all the shape properties */ memcpy(sh, old_sh, sizeof(JSShape) + sizeof(sh->prop[0]) * old_sh->prop_count); list_add_tail(&sh->header.link, &ctx->rt->gc_obj_list); if (new_hash_size != (sh->prop_hash_mask + 1)) { /* resize the hash table and the properties */ new_hash_mask = new_hash_size - 1; sh->prop_hash_mask = new_hash_mask; memset(prop_hash_end(sh) - new_hash_size, 0, sizeof(prop_hash_end(sh)[0]) * new_hash_size); for(i = 0, pr = sh->prop; i < sh->prop_count; i++, pr++) { if (pr->atom != JS_ATOM_NULL) { h = ((uintptr_t)pr->atom & new_hash_mask); pr->hash_next = prop_hash_end(sh)[-h - 1]; prop_hash_end(sh)[-h - 1] = i + 1; } } } else { /* just copy the previous hash table */ memcpy(prop_hash_end(sh) - new_hash_size, prop_hash_end(old_sh) - new_hash_size, sizeof(prop_hash_end(sh)[0]) * new_hash_size); } js_free(ctx, get_alloc_from_shape(old_sh)); *psh = sh; sh->prop_size = new_size; return 0; } /* remove the deleted properties. */ static int compact_properties(JSContext *ctx, JSObject *p) { JSShape *sh, *old_sh; void *sh_alloc; intptr_t h; uint32_t new_hash_size, i, j, new_hash_mask, new_size; JSShapeProperty *old_pr, *pr; JSProperty *prop, *new_prop; sh = p->shape; assert(!sh->is_hashed); new_size = max_int(JS_PROP_INITIAL_SIZE, sh->prop_count - sh->deleted_prop_count); assert(new_size <= sh->prop_size); new_hash_size = sh->prop_hash_mask + 1; while ((new_hash_size / 2) >= new_size) new_hash_size = new_hash_size / 2; new_hash_mask = new_hash_size - 1; /* resize the hash table and the properties */ old_sh = sh; sh_alloc = js_malloc(ctx, get_shape_size(new_hash_size, new_size)); if (!sh_alloc) return -1; sh = get_shape_from_alloc(sh_alloc, new_hash_size); list_del(&old_sh->header.link); memcpy(sh, old_sh, sizeof(JSShape)); list_add_tail(&sh->header.link, &ctx->rt->gc_obj_list); memset(prop_hash_end(sh) - new_hash_size, 0, sizeof(prop_hash_end(sh)[0]) * new_hash_size); j = 0; old_pr = old_sh->prop; pr = sh->prop; prop = p->prop; for(i = 0; i < sh->prop_count; i++) { if (old_pr->atom != JS_ATOM_NULL) { pr->atom = old_pr->atom; pr->flags = old_pr->flags; h = ((uintptr_t)old_pr->atom & new_hash_mask); pr->hash_next = prop_hash_end(sh)[-h - 1]; prop_hash_end(sh)[-h - 1] = j + 1; prop[j] = prop[i]; j++; pr++; } old_pr++; } assert(j == (sh->prop_count - sh->deleted_prop_count)); sh->prop_hash_mask = new_hash_mask; sh->prop_size = new_size; sh->deleted_prop_count = 0; sh->prop_count = j; p->shape = sh; js_free(ctx, get_alloc_from_shape(old_sh)); /* reduce the size of the object properties */ new_prop = js_realloc(ctx, p->prop, sizeof(new_prop[0]) * new_size); if (new_prop) p->prop = new_prop; return 0; } static int add_shape_property(JSContext *ctx, JSShape **psh, JSObject *p, JSAtom atom, int prop_flags) { JSRuntime *rt = ctx->rt; JSShape *sh = *psh; JSShapeProperty *pr, *prop; uint32_t hash_mask, new_shape_hash = 0; intptr_t h; /* update the shape hash */ if (sh->is_hashed) { js_shape_hash_unlink(rt, sh); new_shape_hash = shape_hash(shape_hash(sh->hash, atom), prop_flags); } if (unlikely(sh->prop_count >= sh->prop_size)) { if (resize_properties(ctx, psh, p, sh->prop_count + 1)) { /* in case of error, reinsert in the hash table. sh is still valid if resize_properties() failed */ if (sh->is_hashed) js_shape_hash_link(rt, sh); return -1; } sh = *psh; } if (sh->is_hashed) { sh->hash = new_shape_hash; js_shape_hash_link(rt, sh); } /* Initialize the new shape property. The object property at p->prop[sh->prop_count] is uninitialized */ prop = get_shape_prop(sh); pr = &prop[sh->prop_count++]; pr->atom = JS_DupAtom(ctx, atom); pr->flags = prop_flags; sh->has_small_array_index |= __JS_AtomIsTaggedInt(atom); /* add in hash table */ hash_mask = sh->prop_hash_mask; h = atom & hash_mask; pr->hash_next = prop_hash_end(sh)[-h - 1]; prop_hash_end(sh)[-h - 1] = sh->prop_count; return 0; } /* find a hashed empty shape matching the prototype. Return NULL if not found */ static JSShape *find_hashed_shape_proto(JSRuntime *rt, JSObject *proto) { JSShape *sh1; uint32_t h, h1; h = shape_initial_hash(proto); h1 = get_shape_hash(h, rt->shape_hash_bits); for(sh1 = rt->shape_hash[h1]; sh1 != NULL; sh1 = sh1->shape_hash_next) { if (sh1->hash == h && sh1->proto == proto && sh1->prop_count == 0) { return sh1; } } return NULL; } /* find a hashed shape matching sh + (prop, prop_flags). Return NULL if not found */ static JSShape *find_hashed_shape_prop(JSRuntime *rt, JSShape *sh, JSAtom atom, int prop_flags) { JSShape *sh1; uint32_t h, h1, i, n; h = sh->hash; h = shape_hash(h, atom); h = shape_hash(h, prop_flags); h1 = get_shape_hash(h, rt->shape_hash_bits); for(sh1 = rt->shape_hash[h1]; sh1 != NULL; sh1 = sh1->shape_hash_next) { /* we test the hash first so that the rest is done only if the shapes really match */ if (sh1->hash == h && sh1->proto == sh->proto && sh1->prop_count == ((n = sh->prop_count) + 1)) { for(i = 0; i < n; i++) { if (unlikely(sh1->prop[i].atom != sh->prop[i].atom) || unlikely(sh1->prop[i].flags != sh->prop[i].flags)) goto next; } if (unlikely(sh1->prop[n].atom != atom) || unlikely(sh1->prop[n].flags != prop_flags)) goto next; return sh1; } next: ; } return NULL; } static __maybe_unused void JS_DumpShape(JSRuntime *rt, int i, JSShape *sh) { char atom_buf[ATOM_GET_STR_BUF_SIZE]; int j; /* XXX: should output readable class prototype */ printf("%5d %3d%c %14p %5d %5d", i, sh->header.ref_count, " *"[sh->is_hashed], (void *)sh->proto, sh->prop_size, sh->prop_count); for(j = 0; j < sh->prop_count; j++) { printf(" %s", JS_AtomGetStrRT(rt, atom_buf, sizeof(atom_buf), sh->prop[j].atom)); } printf("\n"); } static __maybe_unused void JS_DumpShapes(JSRuntime *rt) { int i; JSShape *sh; struct list_head *el; JSObject *p; JSGCObjectHeader *gp; printf("JSShapes: {\n"); printf("%5s %4s %14s %5s %5s %s\n", "SLOT", "REFS", "PROTO", "SIZE", "COUNT", "PROPS"); for(i = 0; i < rt->shape_hash_size; i++) { for(sh = rt->shape_hash[i]; sh != NULL; sh = sh->shape_hash_next) { JS_DumpShape(rt, i, sh); assert(sh->is_hashed); } } /* dump non-hashed shapes */ list_for_each(el, &rt->gc_obj_list) { gp = list_entry(el, JSGCObjectHeader, link); if (gp->gc_obj_type == JS_GC_OBJ_TYPE_JS_OBJECT) { p = (JSObject *)gp; if (!p->shape->is_hashed) { JS_DumpShape(rt, -1, p->shape); } } } printf("}\n"); } static JSValue JS_NewObjectFromShape(JSContext *ctx, JSShape *sh, JSClassID class_id) { JSObject *p; js_trigger_gc(ctx->rt, sizeof(JSObject)); p = js_malloc(ctx, sizeof(JSObject)); if (unlikely(!p)) goto fail; p->class_id = class_id; p->extensible = TRUE; p->free_mark = 0; p->is_exotic = 0; p->fast_array = 0; p->is_constructor = 0; p->is_uncatchable_error = 0; p->tmp_mark = 0; p->is_HTMLDDA = 0; p->first_weak_ref = NULL; p->u.opaque = NULL; p->shape = sh; p->prop = js_malloc(ctx, sizeof(JSProperty) * sh->prop_size); if (unlikely(!p->prop)) { js_free(ctx, p); fail: js_free_shape(ctx->rt, sh); return JS_EXCEPTION; } switch(class_id) { case JS_CLASS_OBJECT: break; case JS_CLASS_ARRAY: { JSProperty *pr; p->is_exotic = 1; p->fast_array = 1; p->u.array.u.values = NULL; p->u.array.count = 0; p->u.array.u1.size = 0; /* the length property is always the first one */ if (likely(sh == ctx->array_shape)) { pr = &p->prop[0]; } else { /* only used for the first array */ /* cannot fail */ pr = add_property(ctx, p, JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_LENGTH); } pr->u.value = JS_NewInt32(ctx, 0); } break; case JS_CLASS_C_FUNCTION: p->prop[0].u.value = JS_UNDEFINED; break; case JS_CLASS_ARGUMENTS: case JS_CLASS_UINT8C_ARRAY: case JS_CLASS_INT8_ARRAY: case JS_CLASS_UINT8_ARRAY: case JS_CLASS_INT16_ARRAY: case JS_CLASS_UINT16_ARRAY: case JS_CLASS_INT32_ARRAY: case JS_CLASS_UINT32_ARRAY: case JS_CLASS_BIG_INT64_ARRAY: case JS_CLASS_BIG_UINT64_ARRAY: case JS_CLASS_FLOAT32_ARRAY: case JS_CLASS_FLOAT64_ARRAY: p->is_exotic = 1; p->fast_array = 1; p->u.array.u.ptr = NULL; p->u.array.count = 0; break; case JS_CLASS_DATAVIEW: p->u.array.u.ptr = NULL; p->u.array.count = 0; break; case JS_CLASS_NUMBER: case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: case JS_CLASS_SYMBOL: case JS_CLASS_DATE: case JS_CLASS_BIG_INT: #ifdef CONFIG_BIGNUM case JS_CLASS_BIG_FLOAT: case JS_CLASS_BIG_DECIMAL: #endif p->u.object_data = JS_UNDEFINED; goto set_exotic; case JS_CLASS_REGEXP: p->u.regexp.pattern = NULL; p->u.regexp.bytecode = NULL; goto set_exotic; default: set_exotic: if (ctx->rt->class_array[class_id].exotic) { p->is_exotic = 1; } break; } p->header.ref_count = 1; add_gc_object(ctx->rt, &p->header, JS_GC_OBJ_TYPE_JS_OBJECT); return JS_MKPTR(JS_TAG_OBJECT, p); } static JSObject *get_proto_obj(JSValueConst proto_val) { if (JS_VALUE_GET_TAG(proto_val) != JS_TAG_OBJECT) return NULL; else return JS_VALUE_GET_OBJ(proto_val); } /* WARNING: proto must be an object or JS_NULL */ JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val, JSClassID class_id) { JSShape *sh; JSObject *proto; proto = get_proto_obj(proto_val); sh = find_hashed_shape_proto(ctx->rt, proto); if (likely(sh)) { sh = js_dup_shape(sh); } else { sh = js_new_shape(ctx, proto); if (!sh) return JS_EXCEPTION; } return JS_NewObjectFromShape(ctx, sh, class_id); } #if 0 static JSValue JS_GetObjectData(JSContext *ctx, JSValueConst obj) { JSObject *p; if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { p = JS_VALUE_GET_OBJ(obj); switch(p->class_id) { case JS_CLASS_NUMBER: case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: case JS_CLASS_SYMBOL: case JS_CLASS_DATE: case JS_CLASS_BIG_INT: #ifdef CONFIG_BIGNUM case JS_CLASS_BIG_FLOAT: case JS_CLASS_BIG_DECIMAL: #endif return JS_DupValue(ctx, p->u.object_data); } } return JS_UNDEFINED; } #endif static int JS_SetObjectData(JSContext *ctx, JSValueConst obj, JSValue val) { JSObject *p; if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { p = JS_VALUE_GET_OBJ(obj); switch(p->class_id) { case JS_CLASS_NUMBER: case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: case JS_CLASS_SYMBOL: case JS_CLASS_DATE: case JS_CLASS_BIG_INT: #ifdef CONFIG_BIGNUM case JS_CLASS_BIG_FLOAT: case JS_CLASS_BIG_DECIMAL: #endif JS_FreeValue(ctx, p->u.object_data); p->u.object_data = val; return 0; } } JS_FreeValue(ctx, val); if (!JS_IsException(obj)) JS_ThrowTypeError(ctx, "invalid object type"); return -1; } JSValue JS_NewObjectClass(JSContext *ctx, int class_id) { return JS_NewObjectProtoClass(ctx, ctx->class_proto[class_id], class_id); } JSValue JS_NewObjectProto(JSContext *ctx, JSValueConst proto) { return JS_NewObjectProtoClass(ctx, proto, JS_CLASS_OBJECT); } JSValue JS_NewArray(JSContext *ctx) { return JS_NewObjectFromShape(ctx, js_dup_shape(ctx->array_shape), JS_CLASS_ARRAY); } JSValue JS_NewObject(JSContext *ctx) { /* inline JS_NewObjectClass(ctx, JS_CLASS_OBJECT); */ return JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], JS_CLASS_OBJECT); } static void js_function_set_properties(JSContext *ctx, JSValueConst func_obj, JSAtom name, int len) { /* ES6 feature non compatible with ES5.1: length is configurable */ JS_DefinePropertyValue(ctx, func_obj, JS_ATOM_length, JS_NewInt32(ctx, len), JS_PROP_CONFIGURABLE); JS_DefinePropertyValue(ctx, func_obj, JS_ATOM_name, JS_AtomToString(ctx, name), JS_PROP_CONFIGURABLE); } static BOOL js_class_has_bytecode(JSClassID class_id) { return (class_id == JS_CLASS_BYTECODE_FUNCTION || class_id == JS_CLASS_GENERATOR_FUNCTION || class_id == JS_CLASS_ASYNC_FUNCTION || class_id == JS_CLASS_ASYNC_GENERATOR_FUNCTION); } /* return NULL without exception if not a function or no bytecode */ static JSFunctionBytecode *JS_GetFunctionBytecode(JSValueConst val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return NULL; p = JS_VALUE_GET_OBJ(val); if (!js_class_has_bytecode(p->class_id)) return NULL; return p->u.func.function_bytecode; } static void js_method_set_home_object(JSContext *ctx, JSValueConst func_obj, JSValueConst home_obj) { JSObject *p, *p1; JSFunctionBytecode *b; if (JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT) return; p = JS_VALUE_GET_OBJ(func_obj); if (!js_class_has_bytecode(p->class_id)) return; b = p->u.func.function_bytecode; if (b->need_home_object) { p1 = p->u.func.home_object; if (p1) { JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p1)); } if (JS_VALUE_GET_TAG(home_obj) == JS_TAG_OBJECT) p1 = JS_VALUE_GET_OBJ(JS_DupValue(ctx, home_obj)); else p1 = NULL; p->u.func.home_object = p1; } } static JSValue js_get_function_name(JSContext *ctx, JSAtom name) { JSValue name_str; name_str = JS_AtomToString(ctx, name); if (JS_AtomSymbolHasDescription(ctx, name)) { name_str = JS_ConcatString3(ctx, "[", name_str, "]"); } return name_str; } /* Modify the name of a method according to the atom and 'flags'. 'flags' is a bitmask of JS_PROP_HAS_GET and JS_PROP_HAS_SET. Also set the home object of the method. Return < 0 if exception. */ static int js_method_set_properties(JSContext *ctx, JSValueConst func_obj, JSAtom name, int flags, JSValueConst home_obj) { JSValue name_str; name_str = js_get_function_name(ctx, name); if (flags & JS_PROP_HAS_GET) { name_str = JS_ConcatString3(ctx, "get ", name_str, ""); } else if (flags & JS_PROP_HAS_SET) { name_str = JS_ConcatString3(ctx, "set ", name_str, ""); } if (JS_IsException(name_str)) return -1; if (JS_DefinePropertyValue(ctx, func_obj, JS_ATOM_name, name_str, JS_PROP_CONFIGURABLE) < 0) return -1; js_method_set_home_object(ctx, func_obj, home_obj); return 0; } /* Note: at least 'length' arguments will be readable in 'argv' */ static JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic, JSValueConst proto_val) { JSValue func_obj; JSObject *p; JSAtom name_atom; func_obj = JS_NewObjectProtoClass(ctx, proto_val, JS_CLASS_C_FUNCTION); if (JS_IsException(func_obj)) return func_obj; p = JS_VALUE_GET_OBJ(func_obj); p->u.cfunc.realm = JS_DupContext(ctx); p->u.cfunc.c_function.generic = func; p->u.cfunc.length = length; p->u.cfunc.cproto = cproto; p->u.cfunc.magic = magic; p->is_constructor = (cproto == JS_CFUNC_constructor || cproto == JS_CFUNC_constructor_magic || cproto == JS_CFUNC_constructor_or_func || cproto == JS_CFUNC_constructor_or_func_magic); if (!name) name = ""; name_atom = JS_NewAtom(ctx, name); js_function_set_properties(ctx, func_obj, name_atom, length); JS_FreeAtom(ctx, name_atom); return func_obj; } /* Note: at least 'length' arguments will be readable in 'argv' */ JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic) { return JS_NewCFunction3(ctx, func, name, length, cproto, magic, ctx->function_proto); } typedef struct JSCFunctionDataRecord { JSCFunctionData *func; uint8_t length; uint8_t data_len; uint16_t magic; JSValue data[0]; } JSCFunctionDataRecord; static void js_c_function_data_finalizer(JSRuntime *rt, JSValue val) { JSCFunctionDataRecord *s = JS_GetOpaque(val, JS_CLASS_C_FUNCTION_DATA); int i; if (s) { for(i = 0; i < s->data_len; i++) { JS_FreeValueRT(rt, s->data[i]); } js_free_rt(rt, s); } } static void js_c_function_data_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSCFunctionDataRecord *s = JS_GetOpaque(val, JS_CLASS_C_FUNCTION_DATA); int i; if (s) { for(i = 0; i < s->data_len; i++) { JS_MarkValue(rt, s->data[i], mark_func); } } } static JSValue js_c_function_data_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst *argv, int flags) { JSCFunctionDataRecord *s = JS_GetOpaque(func_obj, JS_CLASS_C_FUNCTION_DATA); JSValueConst *arg_buf; int i; /* XXX: could add the function on the stack for debug */ if (unlikely(argc < s->length)) { arg_buf = alloca(sizeof(arg_buf[0]) * s->length); for(i = 0; i < argc; i++) arg_buf[i] = argv[i]; for(i = argc; i < s->length; i++) arg_buf[i] = JS_UNDEFINED; } else { arg_buf = argv; } return s->func(ctx, this_val, argc, arg_buf, s->magic, s->data); } JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func, int length, int magic, int data_len, JSValueConst *data) { JSCFunctionDataRecord *s; JSValue func_obj; int i; func_obj = JS_NewObjectProtoClass(ctx, ctx->function_proto, JS_CLASS_C_FUNCTION_DATA); if (JS_IsException(func_obj)) return func_obj; s = js_malloc(ctx, sizeof(*s) + data_len * sizeof(JSValue)); if (!s) { JS_FreeValue(ctx, func_obj); return JS_EXCEPTION; } s->func = func; s->length = length; s->data_len = data_len; s->magic = magic; for(i = 0; i < data_len; i++) s->data[i] = JS_DupValue(ctx, data[i]); JS_SetOpaque(func_obj, s); js_function_set_properties(ctx, func_obj, JS_ATOM_empty_string, length); return func_obj; } static JSContext *js_autoinit_get_realm(JSProperty *pr) { return (JSContext *)(pr->u.init.realm_and_id & ~3); } static JSAutoInitIDEnum js_autoinit_get_id(JSProperty *pr) { return pr->u.init.realm_and_id & 3; } static void js_autoinit_free(JSRuntime *rt, JSProperty *pr) { JS_FreeContext(js_autoinit_get_realm(pr)); } static void js_autoinit_mark(JSRuntime *rt, JSProperty *pr, JS_MarkFunc *mark_func) { mark_func(rt, &js_autoinit_get_realm(pr)->header); } static void free_property(JSRuntime *rt, JSProperty *pr, int prop_flags) { if (unlikely(prop_flags & JS_PROP_TMASK)) { if ((prop_flags & JS_PROP_TMASK) == JS_PROP_GETSET) { if (pr->u.getset.getter) JS_FreeValueRT(rt, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.getter)); if (pr->u.getset.setter) JS_FreeValueRT(rt, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.setter)); } else if ((prop_flags & JS_PROP_TMASK) == JS_PROP_VARREF) { free_var_ref(rt, pr->u.var_ref); } else if ((prop_flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { js_autoinit_free(rt, pr); } } else { JS_FreeValueRT(rt, pr->u.value); } } static force_inline JSShapeProperty *find_own_property1(JSObject *p, JSAtom atom) { JSShape *sh; JSShapeProperty *pr, *prop; intptr_t h; sh = p->shape; h = (uintptr_t)atom & sh->prop_hash_mask; h = prop_hash_end(sh)[-h - 1]; prop = get_shape_prop(sh); while (h) { pr = &prop[h - 1]; if (likely(pr->atom == atom)) { return pr; } h = pr->hash_next; } return NULL; } static force_inline JSShapeProperty *find_own_property(JSProperty **ppr, JSObject *p, JSAtom atom) { JSShape *sh; JSShapeProperty *pr, *prop; intptr_t h; sh = p->shape; h = (uintptr_t)atom & sh->prop_hash_mask; h = prop_hash_end(sh)[-h - 1]; prop = get_shape_prop(sh); while (h) { pr = &prop[h - 1]; if (likely(pr->atom == atom)) { *ppr = &p->prop[h - 1]; /* the compiler should be able to assume that pr != NULL here */ return pr; } h = pr->hash_next; } *ppr = NULL; return NULL; } /* indicate that the object may be part of a function prototype cycle */ static void set_cycle_flag(JSContext *ctx, JSValueConst obj) { } static void free_var_ref(JSRuntime *rt, JSVarRef *var_ref) { if (var_ref) { assert(var_ref->header.ref_count > 0); if (--var_ref->header.ref_count == 0) { if (var_ref->is_detached) { JS_FreeValueRT(rt, var_ref->value); } else { list_del(&var_ref->var_ref_link); /* still on the stack */ if (var_ref->async_func) async_func_free(rt, var_ref->async_func); } remove_gc_object(&var_ref->header); js_free_rt(rt, var_ref); } } } static void js_array_finalizer(JSRuntime *rt, JSValue val) { JSObject *p = JS_VALUE_GET_OBJ(val); int i; for(i = 0; i < p->u.array.count; i++) { JS_FreeValueRT(rt, p->u.array.u.values[i]); } js_free_rt(rt, p->u.array.u.values); } static void js_array_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); int i; for(i = 0; i < p->u.array.count; i++) { JS_MarkValue(rt, p->u.array.u.values[i], mark_func); } } static void js_object_data_finalizer(JSRuntime *rt, JSValue val) { JSObject *p = JS_VALUE_GET_OBJ(val); JS_FreeValueRT(rt, p->u.object_data); p->u.object_data = JS_UNDEFINED; } static void js_object_data_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); JS_MarkValue(rt, p->u.object_data, mark_func); } static void js_c_function_finalizer(JSRuntime *rt, JSValue val) { JSObject *p = JS_VALUE_GET_OBJ(val); if (p->u.cfunc.realm) JS_FreeContext(p->u.cfunc.realm); } static void js_c_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); if (p->u.cfunc.realm) mark_func(rt, &p->u.cfunc.realm->header); } static void js_bytecode_function_finalizer(JSRuntime *rt, JSValue val) { JSObject *p1, *p = JS_VALUE_GET_OBJ(val); JSFunctionBytecode *b; JSVarRef **var_refs; int i; p1 = p->u.func.home_object; if (p1) { JS_FreeValueRT(rt, JS_MKPTR(JS_TAG_OBJECT, p1)); } b = p->u.func.function_bytecode; if (b) { var_refs = p->u.func.var_refs; if (var_refs) { for(i = 0; i < b->closure_var_count; i++) free_var_ref(rt, var_refs[i]); js_free_rt(rt, var_refs); } JS_FreeValueRT(rt, JS_MKPTR(JS_TAG_FUNCTION_BYTECODE, b)); } } static void js_bytecode_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); JSVarRef **var_refs = p->u.func.var_refs; JSFunctionBytecode *b = p->u.func.function_bytecode; int i; if (p->u.func.home_object) { JS_MarkValue(rt, JS_MKPTR(JS_TAG_OBJECT, p->u.func.home_object), mark_func); } if (b) { if (var_refs) { for(i = 0; i < b->closure_var_count; i++) { JSVarRef *var_ref = var_refs[i]; if (var_ref) { mark_func(rt, &var_ref->header); } } } /* must mark the function bytecode because template objects may be part of a cycle */ JS_MarkValue(rt, JS_MKPTR(JS_TAG_FUNCTION_BYTECODE, b), mark_func); } } static void js_bound_function_finalizer(JSRuntime *rt, JSValue val) { JSObject *p = JS_VALUE_GET_OBJ(val); JSBoundFunction *bf = p->u.bound_function; int i; JS_FreeValueRT(rt, bf->func_obj); JS_FreeValueRT(rt, bf->this_val); for(i = 0; i < bf->argc; i++) { JS_FreeValueRT(rt, bf->argv[i]); } js_free_rt(rt, bf); } static void js_bound_function_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); JSBoundFunction *bf = p->u.bound_function; int i; JS_MarkValue(rt, bf->func_obj, mark_func); JS_MarkValue(rt, bf->this_val, mark_func); for(i = 0; i < bf->argc; i++) JS_MarkValue(rt, bf->argv[i], mark_func); } static void js_for_in_iterator_finalizer(JSRuntime *rt, JSValue val) { JSObject *p = JS_VALUE_GET_OBJ(val); JSForInIterator *it = p->u.for_in_iterator; int i; JS_FreeValueRT(rt, it->obj); if (!it->is_array) { for(i = 0; i < it->atom_count; i++) { JS_FreeAtomRT(rt, it->tab_atom[i].atom); } js_free_rt(rt, it->tab_atom); } js_free_rt(rt, it); } static void js_for_in_iterator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); JSForInIterator *it = p->u.for_in_iterator; JS_MarkValue(rt, it->obj, mark_func); } static void free_object(JSRuntime *rt, JSObject *p) { int i; JSClassFinalizer *finalizer; JSShape *sh; JSShapeProperty *pr; p->free_mark = 1; /* used to tell the object is invalid when freeing cycles */ /* free all the fields */ sh = p->shape; pr = get_shape_prop(sh); for(i = 0; i < sh->prop_count; i++) { free_property(rt, &p->prop[i], pr->flags); pr++; } js_free_rt(rt, p->prop); /* as an optimization we destroy the shape immediately without putting it in gc_zero_ref_count_list */ js_free_shape(rt, sh); /* fail safe */ p->shape = NULL; p->prop = NULL; if (unlikely(p->first_weak_ref)) { reset_weak_ref(rt, p); } finalizer = rt->class_array[p->class_id].finalizer; if (finalizer) (*finalizer)(rt, JS_MKPTR(JS_TAG_OBJECT, p)); /* fail safe */ p->class_id = 0; p->u.opaque = NULL; p->u.func.var_refs = NULL; p->u.func.home_object = NULL; remove_gc_object(&p->header); if (rt->gc_phase == JS_GC_PHASE_REMOVE_CYCLES && p->header.ref_count != 0) { list_add_tail(&p->header.link, &rt->gc_zero_ref_count_list); } else { js_free_rt(rt, p); } } static void free_gc_object(JSRuntime *rt, JSGCObjectHeader *gp) { switch(gp->gc_obj_type) { case JS_GC_OBJ_TYPE_JS_OBJECT: free_object(rt, (JSObject *)gp); break; case JS_GC_OBJ_TYPE_FUNCTION_BYTECODE: free_function_bytecode(rt, (JSFunctionBytecode *)gp); break; case JS_GC_OBJ_TYPE_ASYNC_FUNCTION: __async_func_free(rt, (JSAsyncFunctionState *)gp); break; default: abort(); } } static void free_zero_refcount(JSRuntime *rt) { struct list_head *el; JSGCObjectHeader *p; rt->gc_phase = JS_GC_PHASE_DECREF; for(;;) { el = rt->gc_zero_ref_count_list.next; if (el == &rt->gc_zero_ref_count_list) break; p = list_entry(el, JSGCObjectHeader, link); assert(p->ref_count == 0); free_gc_object(rt, p); } rt->gc_phase = JS_GC_PHASE_NONE; } /* called with the ref_count of 'v' reaches zero. */ void __JS_FreeValueRT(JSRuntime *rt, JSValue v) { uint32_t tag = JS_VALUE_GET_TAG(v); #ifdef DUMP_FREE { printf("Freeing "); if (tag == JS_TAG_OBJECT) { JS_DumpObject(rt, JS_VALUE_GET_OBJ(v)); } else { JS_DumpValueShort(rt, v); printf("\n"); } } #endif switch(tag) { case JS_TAG_STRING: { JSString *p = JS_VALUE_GET_STRING(v); if (p->atom_type) { JS_FreeAtomStruct(rt, p); } else { #ifdef DUMP_LEAKS list_del(&p->link); #endif js_free_rt(rt, p); } } break; case JS_TAG_OBJECT: case JS_TAG_FUNCTION_BYTECODE: { JSGCObjectHeader *p = JS_VALUE_GET_PTR(v); if (rt->gc_phase != JS_GC_PHASE_REMOVE_CYCLES) { list_del(&p->link); list_add(&p->link, &rt->gc_zero_ref_count_list); if (rt->gc_phase == JS_GC_PHASE_NONE) { free_zero_refcount(rt); } } } break; case JS_TAG_MODULE: abort(); /* never freed here */ break; case JS_TAG_BIG_INT: #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: #endif { JSBigFloat *bf = JS_VALUE_GET_PTR(v); bf_delete(&bf->num); js_free_rt(rt, bf); } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_DECIMAL: { JSBigDecimal *bf = JS_VALUE_GET_PTR(v); bfdec_delete(&bf->num); js_free_rt(rt, bf); } break; #endif case JS_TAG_SYMBOL: { JSAtomStruct *p = JS_VALUE_GET_PTR(v); JS_FreeAtomStruct(rt, p); } break; default: printf("__JS_FreeValue: unknown tag=%d\n", tag); abort(); } } void __JS_FreeValue(JSContext *ctx, JSValue v) { __JS_FreeValueRT(ctx->rt, v); } /* garbage collection */ static void add_gc_object(JSRuntime *rt, JSGCObjectHeader *h, JSGCObjectTypeEnum type) { h->mark = 0; h->gc_obj_type = type; list_add_tail(&h->link, &rt->gc_obj_list); } static void remove_gc_object(JSGCObjectHeader *h) { list_del(&h->link); } void JS_MarkValue(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { if (JS_VALUE_HAS_REF_COUNT(val)) { switch(JS_VALUE_GET_TAG(val)) { case JS_TAG_OBJECT: case JS_TAG_FUNCTION_BYTECODE: mark_func(rt, JS_VALUE_GET_PTR(val)); break; default: break; } } } static void mark_children(JSRuntime *rt, JSGCObjectHeader *gp, JS_MarkFunc *mark_func) { switch(gp->gc_obj_type) { case JS_GC_OBJ_TYPE_JS_OBJECT: { JSObject *p = (JSObject *)gp; JSShapeProperty *prs; JSShape *sh; int i; sh = p->shape; mark_func(rt, &sh->header); /* mark all the fields */ prs = get_shape_prop(sh); for(i = 0; i < sh->prop_count; i++) { JSProperty *pr = &p->prop[i]; if (prs->atom != JS_ATOM_NULL) { if (prs->flags & JS_PROP_TMASK) { if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { if (pr->u.getset.getter) mark_func(rt, &pr->u.getset.getter->header); if (pr->u.getset.setter) mark_func(rt, &pr->u.getset.setter->header); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { /* Note: the tag does not matter provided it is a GC object */ mark_func(rt, &pr->u.var_ref->header); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { js_autoinit_mark(rt, pr, mark_func); } } else { JS_MarkValue(rt, pr->u.value, mark_func); } } prs++; } if (p->class_id != JS_CLASS_OBJECT) { JSClassGCMark *gc_mark; gc_mark = rt->class_array[p->class_id].gc_mark; if (gc_mark) gc_mark(rt, JS_MKPTR(JS_TAG_OBJECT, p), mark_func); } } break; case JS_GC_OBJ_TYPE_FUNCTION_BYTECODE: /* the template objects can be part of a cycle */ { JSFunctionBytecode *b = (JSFunctionBytecode *)gp; int i; for(i = 0; i < b->cpool_count; i++) { JS_MarkValue(rt, b->cpool[i], mark_func); } if (b->realm) mark_func(rt, &b->realm->header); } break; case JS_GC_OBJ_TYPE_VAR_REF: { JSVarRef *var_ref = (JSVarRef *)gp; if (var_ref->is_detached) { JS_MarkValue(rt, *var_ref->pvalue, mark_func); } else if (var_ref->async_func) { mark_func(rt, &var_ref->async_func->header); } } break; case JS_GC_OBJ_TYPE_ASYNC_FUNCTION: { JSAsyncFunctionState *s = (JSAsyncFunctionState *)gp; JSStackFrame *sf = &s->frame; JSValue *sp; if (!s->is_completed) { JS_MarkValue(rt, sf->cur_func, mark_func); JS_MarkValue(rt, s->this_val, mark_func); /* sf->cur_sp = NULL if the function is running */ if (sf->cur_sp) { /* if the function is running, cur_sp is not known so we cannot mark the stack. Marking the variables is not needed because a running function cannot be part of a removable cycle */ for(sp = sf->arg_buf; sp < sf->cur_sp; sp++) JS_MarkValue(rt, *sp, mark_func); } } JS_MarkValue(rt, s->resolving_funcs[0], mark_func); JS_MarkValue(rt, s->resolving_funcs[1], mark_func); } break; case JS_GC_OBJ_TYPE_SHAPE: { JSShape *sh = (JSShape *)gp; if (sh->proto != NULL) { mark_func(rt, &sh->proto->header); } } break; case JS_GC_OBJ_TYPE_JS_CONTEXT: { JSContext *ctx = (JSContext *)gp; JS_MarkContext(rt, ctx, mark_func); } break; default: abort(); } } static void gc_decref_child(JSRuntime *rt, JSGCObjectHeader *p) { assert(p->ref_count > 0); p->ref_count--; if (p->ref_count == 0 && p->mark == 1) { list_del(&p->link); list_add_tail(&p->link, &rt->tmp_obj_list); } } static void gc_decref(JSRuntime *rt) { struct list_head *el, *el1; JSGCObjectHeader *p; init_list_head(&rt->tmp_obj_list); /* decrement the refcount of all the children of all the GC objects and move the GC objects with zero refcount to tmp_obj_list */ list_for_each_safe(el, el1, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); assert(p->mark == 0); mark_children(rt, p, gc_decref_child); p->mark = 1; if (p->ref_count == 0) { list_del(&p->link); list_add_tail(&p->link, &rt->tmp_obj_list); } } } static void gc_scan_incref_child(JSRuntime *rt, JSGCObjectHeader *p) { p->ref_count++; if (p->ref_count == 1) { /* ref_count was 0: remove from tmp_obj_list and add at the end of gc_obj_list */ list_del(&p->link); list_add_tail(&p->link, &rt->gc_obj_list); p->mark = 0; /* reset the mark for the next GC call */ } } static void gc_scan_incref_child2(JSRuntime *rt, JSGCObjectHeader *p) { p->ref_count++; } static void gc_scan(JSRuntime *rt) { struct list_head *el; JSGCObjectHeader *p; /* keep the objects with a refcount > 0 and their children. */ list_for_each(el, &rt->gc_obj_list) { p = list_entry(el, JSGCObjectHeader, link); assert(p->ref_count > 0); p->mark = 0; /* reset the mark for the next GC call */ mark_children(rt, p, gc_scan_incref_child); } /* restore the refcount of the objects to be deleted. */ list_for_each(el, &rt->tmp_obj_list) { p = list_entry(el, JSGCObjectHeader, link); mark_children(rt, p, gc_scan_incref_child2); } } static void gc_free_cycles(JSRuntime *rt) { struct list_head *el, *el1; JSGCObjectHeader *p; #ifdef DUMP_GC_FREE BOOL header_done = FALSE; #endif rt->gc_phase = JS_GC_PHASE_REMOVE_CYCLES; for(;;) { el = rt->tmp_obj_list.next; if (el == &rt->tmp_obj_list) break; p = list_entry(el, JSGCObjectHeader, link); /* Only need to free the GC object associated with JS values or async functions. The rest will be automatically removed because they must be referenced by them. */ switch(p->gc_obj_type) { case JS_GC_OBJ_TYPE_JS_OBJECT: case JS_GC_OBJ_TYPE_FUNCTION_BYTECODE: case JS_GC_OBJ_TYPE_ASYNC_FUNCTION: #ifdef DUMP_GC_FREE if (!header_done) { printf("Freeing cycles:\n"); JS_DumpObjectHeader(rt); header_done = TRUE; } JS_DumpGCObject(rt, p); #endif free_gc_object(rt, p); break; default: list_del(&p->link); list_add_tail(&p->link, &rt->gc_zero_ref_count_list); break; } } rt->gc_phase = JS_GC_PHASE_NONE; list_for_each_safe(el, el1, &rt->gc_zero_ref_count_list) { p = list_entry(el, JSGCObjectHeader, link); assert(p->gc_obj_type == JS_GC_OBJ_TYPE_JS_OBJECT || p->gc_obj_type == JS_GC_OBJ_TYPE_FUNCTION_BYTECODE || p->gc_obj_type == JS_GC_OBJ_TYPE_ASYNC_FUNCTION); js_free_rt(rt, p); } init_list_head(&rt->gc_zero_ref_count_list); } void JS_RunGC(JSRuntime *rt) { /* decrement the reference of the children of each object. mark = 1 after this pass. */ gc_decref(rt); /* keep the GC objects with a non zero refcount and their childs */ gc_scan(rt); /* free the GC objects in a cycle */ gc_free_cycles(rt); } /* Return false if not an object or if the object has already been freed (zombie objects are visible in finalizers when freeing cycles). */ BOOL JS_IsLiveObject(JSRuntime *rt, JSValueConst obj) { JSObject *p; if (!JS_IsObject(obj)) return FALSE; p = JS_VALUE_GET_OBJ(obj); return !p->free_mark; } /* Compute memory used by various object types */ /* XXX: poor man's approach to handling multiply referenced objects */ typedef struct JSMemoryUsage_helper { double memory_used_count; double str_count; double str_size; int64_t js_func_count; double js_func_size; int64_t js_func_code_size; int64_t js_func_pc2line_count; int64_t js_func_pc2line_size; } JSMemoryUsage_helper; static void compute_value_size(JSValueConst val, JSMemoryUsage_helper *hp); static void compute_jsstring_size(JSString *str, JSMemoryUsage_helper *hp) { if (!str->atom_type) { /* atoms are handled separately */ double s_ref_count = str->header.ref_count; hp->str_count += 1 / s_ref_count; hp->str_size += ((sizeof(*str) + (str->len << str->is_wide_char) + 1 - str->is_wide_char) / s_ref_count); } } static void compute_bytecode_size(JSFunctionBytecode *b, JSMemoryUsage_helper *hp) { int memory_used_count, js_func_size, i; memory_used_count = 0; js_func_size = offsetof(JSFunctionBytecode, debug); if (b->vardefs) { js_func_size += (b->arg_count + b->var_count) * sizeof(*b->vardefs); } if (b->cpool) { js_func_size += b->cpool_count * sizeof(*b->cpool); for (i = 0; i < b->cpool_count; i++) { JSValueConst val = b->cpool[i]; compute_value_size(val, hp); } } if (b->closure_var) { js_func_size += b->closure_var_count * sizeof(*b->closure_var); } if (!b->read_only_bytecode && b->byte_code_buf) { hp->js_func_code_size += b->byte_code_len; } if (b->has_debug) { js_func_size += sizeof(*b) - offsetof(JSFunctionBytecode, debug); if (b->debug.source) { memory_used_count++; js_func_size += b->debug.source_len + 1; } if (b->debug.pc2line_len) { memory_used_count++; hp->js_func_pc2line_count += 1; hp->js_func_pc2line_size += b->debug.pc2line_len; } } hp->js_func_size += js_func_size; hp->js_func_count += 1; hp->memory_used_count += memory_used_count; } static void compute_value_size(JSValueConst val, JSMemoryUsage_helper *hp) { switch(JS_VALUE_GET_TAG(val)) { case JS_TAG_STRING: compute_jsstring_size(JS_VALUE_GET_STRING(val), hp); break; case JS_TAG_BIG_INT: #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: case JS_TAG_BIG_DECIMAL: #endif /* should track JSBigFloat usage */ break; } } void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s) { struct list_head *el, *el1; int i; JSMemoryUsage_helper mem = { 0 }, *hp = &mem; memset(s, 0, sizeof(*s)); s->malloc_count = rt->malloc_state.malloc_count; s->malloc_size = rt->malloc_state.malloc_size; s->malloc_limit = rt->malloc_state.malloc_limit; s->memory_used_count = 2; /* rt + rt->class_array */ s->memory_used_size = sizeof(JSRuntime) + sizeof(JSValue) * rt->class_count; list_for_each(el, &rt->context_list) { JSContext *ctx = list_entry(el, JSContext, link); JSShape *sh = ctx->array_shape; s->memory_used_count += 2; /* ctx + ctx->class_proto */ s->memory_used_size += sizeof(JSContext) + sizeof(JSValue) * rt->class_count; s->binary_object_count += ctx->binary_object_count; s->binary_object_size += ctx->binary_object_size; /* the hashed shapes are counted separately */ if (sh && !sh->is_hashed) { int hash_size = sh->prop_hash_mask + 1; s->shape_count++; s->shape_size += get_shape_size(hash_size, sh->prop_size); } list_for_each(el1, &ctx->loaded_modules) { JSModuleDef *m = list_entry(el1, JSModuleDef, link); s->memory_used_count += 1; s->memory_used_size += sizeof(*m); if (m->req_module_entries) { s->memory_used_count += 1; s->memory_used_size += m->req_module_entries_count * sizeof(*m->req_module_entries); } if (m->export_entries) { s->memory_used_count += 1; s->memory_used_size += m->export_entries_count * sizeof(*m->export_entries); for (i = 0; i < m->export_entries_count; i++) { JSExportEntry *me = &m->export_entries[i]; if (me->export_type == JS_EXPORT_TYPE_LOCAL && me->u.local.var_ref) { /* potential multiple count */ s->memory_used_count += 1; compute_value_size(me->u.local.var_ref->value, hp); } } } if (m->star_export_entries) { s->memory_used_count += 1; s->memory_used_size += m->star_export_entries_count * sizeof(*m->star_export_entries); } if (m->import_entries) { s->memory_used_count += 1; s->memory_used_size += m->import_entries_count * sizeof(*m->import_entries); } compute_value_size(m->module_ns, hp); compute_value_size(m->func_obj, hp); } } list_for_each(el, &rt->gc_obj_list) { JSGCObjectHeader *gp = list_entry(el, JSGCObjectHeader, link); JSObject *p; JSShape *sh; JSShapeProperty *prs; /* XXX: could count the other GC object types too */ if (gp->gc_obj_type == JS_GC_OBJ_TYPE_FUNCTION_BYTECODE) { compute_bytecode_size((JSFunctionBytecode *)gp, hp); continue; } else if (gp->gc_obj_type != JS_GC_OBJ_TYPE_JS_OBJECT) { continue; } p = (JSObject *)gp; sh = p->shape; s->obj_count++; if (p->prop) { s->memory_used_count++; s->prop_size += sh->prop_size * sizeof(*p->prop); s->prop_count += sh->prop_count; prs = get_shape_prop(sh); for(i = 0; i < sh->prop_count; i++) { JSProperty *pr = &p->prop[i]; if (prs->atom != JS_ATOM_NULL && !(prs->flags & JS_PROP_TMASK)) { compute_value_size(pr->u.value, hp); } prs++; } } /* the hashed shapes are counted separately */ if (!sh->is_hashed) { int hash_size = sh->prop_hash_mask + 1; s->shape_count++; s->shape_size += get_shape_size(hash_size, sh->prop_size); } switch(p->class_id) { case JS_CLASS_ARRAY: /* u.array | length */ case JS_CLASS_ARGUMENTS: /* u.array | length */ s->array_count++; if (p->fast_array) { s->fast_array_count++; if (p->u.array.u.values) { s->memory_used_count++; s->memory_used_size += p->u.array.count * sizeof(*p->u.array.u.values); s->fast_array_elements += p->u.array.count; for (i = 0; i < p->u.array.count; i++) { compute_value_size(p->u.array.u.values[i], hp); } } } break; case JS_CLASS_NUMBER: /* u.object_data */ case JS_CLASS_STRING: /* u.object_data */ case JS_CLASS_BOOLEAN: /* u.object_data */ case JS_CLASS_SYMBOL: /* u.object_data */ case JS_CLASS_DATE: /* u.object_data */ case JS_CLASS_BIG_INT: /* u.object_data */ #ifdef CONFIG_BIGNUM case JS_CLASS_BIG_FLOAT: /* u.object_data */ case JS_CLASS_BIG_DECIMAL: /* u.object_data */ #endif compute_value_size(p->u.object_data, hp); break; case JS_CLASS_C_FUNCTION: /* u.cfunc */ s->c_func_count++; break; case JS_CLASS_BYTECODE_FUNCTION: /* u.func */ { JSFunctionBytecode *b = p->u.func.function_bytecode; JSVarRef **var_refs = p->u.func.var_refs; /* home_object: object will be accounted for in list scan */ if (var_refs) { s->memory_used_count++; s->js_func_size += b->closure_var_count * sizeof(*var_refs); for (i = 0; i < b->closure_var_count; i++) { if (var_refs[i]) { double ref_count = var_refs[i]->header.ref_count; s->memory_used_count += 1 / ref_count; s->js_func_size += sizeof(*var_refs[i]) / ref_count; /* handle non object closed values */ if (var_refs[i]->pvalue == &var_refs[i]->value) { /* potential multiple count */ compute_value_size(var_refs[i]->value, hp); } } } } } break; case JS_CLASS_BOUND_FUNCTION: /* u.bound_function */ { JSBoundFunction *bf = p->u.bound_function; /* func_obj and this_val are objects */ for (i = 0; i < bf->argc; i++) { compute_value_size(bf->argv[i], hp); } s->memory_used_count += 1; s->memory_used_size += sizeof(*bf) + bf->argc * sizeof(*bf->argv); } break; case JS_CLASS_C_FUNCTION_DATA: /* u.c_function_data_record */ { JSCFunctionDataRecord *fd = p->u.c_function_data_record; if (fd) { for (i = 0; i < fd->data_len; i++) { compute_value_size(fd->data[i], hp); } s->memory_used_count += 1; s->memory_used_size += sizeof(*fd) + fd->data_len * sizeof(*fd->data); } } break; case JS_CLASS_REGEXP: /* u.regexp */ compute_jsstring_size(p->u.regexp.pattern, hp); compute_jsstring_size(p->u.regexp.bytecode, hp); break; case JS_CLASS_FOR_IN_ITERATOR: /* u.for_in_iterator */ { JSForInIterator *it = p->u.for_in_iterator; if (it) { compute_value_size(it->obj, hp); s->memory_used_count += 1; s->memory_used_size += sizeof(*it); } } break; case JS_CLASS_ARRAY_BUFFER: /* u.array_buffer */ case JS_CLASS_SHARED_ARRAY_BUFFER: /* u.array_buffer */ { JSArrayBuffer *abuf = p->u.array_buffer; if (abuf) { s->memory_used_count += 1; s->memory_used_size += sizeof(*abuf); if (abuf->data) { s->memory_used_count += 1; s->memory_used_size += abuf->byte_length; } } } break; case JS_CLASS_GENERATOR: /* u.generator_data */ case JS_CLASS_UINT8C_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_INT8_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_UINT8_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_INT16_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_UINT16_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_INT32_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_UINT32_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_BIG_INT64_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_BIG_UINT64_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_FLOAT32_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_FLOAT64_ARRAY: /* u.typed_array / u.array */ case JS_CLASS_DATAVIEW: /* u.typed_array */ #ifdef CONFIG_BIGNUM case JS_CLASS_FLOAT_ENV: /* u.float_env */ #endif case JS_CLASS_MAP: /* u.map_state */ case JS_CLASS_SET: /* u.map_state */ case JS_CLASS_WEAKMAP: /* u.map_state */ case JS_CLASS_WEAKSET: /* u.map_state */ case JS_CLASS_MAP_ITERATOR: /* u.map_iterator_data */ case JS_CLASS_SET_ITERATOR: /* u.map_iterator_data */ case JS_CLASS_ARRAY_ITERATOR: /* u.array_iterator_data */ case JS_CLASS_STRING_ITERATOR: /* u.array_iterator_data */ case JS_CLASS_PROXY: /* u.proxy_data */ case JS_CLASS_PROMISE: /* u.promise_data */ case JS_CLASS_PROMISE_RESOLVE_FUNCTION: /* u.promise_function_data */ case JS_CLASS_PROMISE_REJECT_FUNCTION: /* u.promise_function_data */ case JS_CLASS_ASYNC_FUNCTION_RESOLVE: /* u.async_function_data */ case JS_CLASS_ASYNC_FUNCTION_REJECT: /* u.async_function_data */ case JS_CLASS_ASYNC_FROM_SYNC_ITERATOR: /* u.async_from_sync_iterator_data */ case JS_CLASS_ASYNC_GENERATOR: /* u.async_generator_data */ /* TODO */ default: /* XXX: class definition should have an opaque block size */ if (p->u.opaque) { s->memory_used_count += 1; } break; } } s->obj_size += s->obj_count * sizeof(JSObject); /* hashed shapes */ s->memory_used_count++; /* rt->shape_hash */ s->memory_used_size += sizeof(rt->shape_hash[0]) * rt->shape_hash_size; for(i = 0; i < rt->shape_hash_size; i++) { JSShape *sh; for(sh = rt->shape_hash[i]; sh != NULL; sh = sh->shape_hash_next) { int hash_size = sh->prop_hash_mask + 1; s->shape_count++; s->shape_size += get_shape_size(hash_size, sh->prop_size); } } /* atoms */ s->memory_used_count += 2; /* rt->atom_array, rt->atom_hash */ s->atom_count = rt->atom_count; s->atom_size = sizeof(rt->atom_array[0]) * rt->atom_size + sizeof(rt->atom_hash[0]) * rt->atom_hash_size; for(i = 0; i < rt->atom_size; i++) { JSAtomStruct *p = rt->atom_array[i]; if (!atom_is_free(p)) { s->atom_size += (sizeof(*p) + (p->len << p->is_wide_char) + 1 - p->is_wide_char); } } s->str_count = round(mem.str_count); s->str_size = round(mem.str_size); s->js_func_count = mem.js_func_count; s->js_func_size = round(mem.js_func_size); s->js_func_code_size = mem.js_func_code_size; s->js_func_pc2line_count = mem.js_func_pc2line_count; s->js_func_pc2line_size = mem.js_func_pc2line_size; s->memory_used_count += round(mem.memory_used_count) + s->atom_count + s->str_count + s->obj_count + s->shape_count + s->js_func_count + s->js_func_pc2line_count; s->memory_used_size += s->atom_size + s->str_size + s->obj_size + s->prop_size + s->shape_size + s->js_func_size + s->js_func_code_size + s->js_func_pc2line_size; } void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt) { fprintf(fp, "QuickJS memory usage -- " #ifdef CONFIG_BIGNUM "BigNum " #endif CONFIG_VERSION " version, %d-bit, malloc limit: %"PRId64"\n\n", (int)sizeof(void *) * 8, (int64_t)(ssize_t)s->malloc_limit); #if 1 if (rt) { static const struct { const char *name; size_t size; } object_types[] = { { "JSRuntime", sizeof(JSRuntime) }, { "JSContext", sizeof(JSContext) }, { "JSObject", sizeof(JSObject) }, { "JSString", sizeof(JSString) }, { "JSFunctionBytecode", sizeof(JSFunctionBytecode) }, }; int i, usage_size_ok = 0; for(i = 0; i < countof(object_types); i++) { unsigned int size = object_types[i].size; void *p = js_malloc_rt(rt, size); if (p) { unsigned int size1 = js_malloc_usable_size_rt(rt, p); if (size1 >= size) { usage_size_ok = 1; fprintf(fp, " %3u + %-2u %s\n", size, size1 - size, object_types[i].name); } js_free_rt(rt, p); } } if (!usage_size_ok) { fprintf(fp, " malloc_usable_size unavailable\n"); } { int obj_classes[JS_CLASS_INIT_COUNT + 1] = { 0 }; int class_id; struct list_head *el; list_for_each(el, &rt->gc_obj_list) { JSGCObjectHeader *gp = list_entry(el, JSGCObjectHeader, link); JSObject *p; if (gp->gc_obj_type == JS_GC_OBJ_TYPE_JS_OBJECT) { p = (JSObject *)gp; obj_classes[min_uint32(p->class_id, JS_CLASS_INIT_COUNT)]++; } } fprintf(fp, "\n" "JSObject classes\n"); if (obj_classes[0]) fprintf(fp, " %5d %2.0d %s\n", obj_classes[0], 0, "none"); for (class_id = 1; class_id < JS_CLASS_INIT_COUNT; class_id++) { if (obj_classes[class_id] && class_id < rt->class_count) { char buf[ATOM_GET_STR_BUF_SIZE]; fprintf(fp, " %5d %2.0d %s\n", obj_classes[class_id], class_id, JS_AtomGetStrRT(rt, buf, sizeof(buf), rt->class_array[class_id].class_name)); } } if (obj_classes[JS_CLASS_INIT_COUNT]) fprintf(fp, " %5d %2.0d %s\n", obj_classes[JS_CLASS_INIT_COUNT], 0, "other"); } fprintf(fp, "\n"); } #endif fprintf(fp, "%-20s %8s %8s\n", "NAME", "COUNT", "SIZE"); if (s->malloc_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per block)\n", "memory allocated", s->malloc_count, s->malloc_size, (double)s->malloc_size / s->malloc_count); fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%d overhead, %0.1f average slack)\n", "memory used", s->memory_used_count, s->memory_used_size, MALLOC_OVERHEAD, ((double)(s->malloc_size - s->memory_used_size) / s->memory_used_count)); } if (s->atom_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per atom)\n", "atoms", s->atom_count, s->atom_size, (double)s->atom_size / s->atom_count); } if (s->str_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per string)\n", "strings", s->str_count, s->str_size, (double)s->str_size / s->str_count); } if (s->obj_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per object)\n", "objects", s->obj_count, s->obj_size, (double)s->obj_size / s->obj_count); fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per object)\n", " properties", s->prop_count, s->prop_size, (double)s->prop_count / s->obj_count); fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per shape)\n", " shapes", s->shape_count, s->shape_size, (double)s->shape_size / s->shape_count); } if (s->js_func_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64"\n", "bytecode functions", s->js_func_count, s->js_func_size); fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per function)\n", " bytecode", s->js_func_count, s->js_func_code_size, (double)s->js_func_code_size / s->js_func_count); if (s->js_func_pc2line_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per function)\n", " pc2line", s->js_func_pc2line_count, s->js_func_pc2line_size, (double)s->js_func_pc2line_size / s->js_func_pc2line_count); } } if (s->c_func_count) { fprintf(fp, "%-20s %8"PRId64"\n", "C functions", s->c_func_count); } if (s->array_count) { fprintf(fp, "%-20s %8"PRId64"\n", "arrays", s->array_count); if (s->fast_array_count) { fprintf(fp, "%-20s %8"PRId64"\n", " fast arrays", s->fast_array_count); fprintf(fp, "%-20s %8"PRId64" %8"PRId64" (%0.1f per fast array)\n", " elements", s->fast_array_elements, s->fast_array_elements * (int)sizeof(JSValue), (double)s->fast_array_elements / s->fast_array_count); } } if (s->binary_object_count) { fprintf(fp, "%-20s %8"PRId64" %8"PRId64"\n", "binary objects", s->binary_object_count, s->binary_object_size); } } JSValue JS_GetGlobalObject(JSContext *ctx) { return JS_DupValue(ctx, ctx->global_obj); } /* WARNING: obj is freed */ JSValue JS_Throw(JSContext *ctx, JSValue obj) { JSRuntime *rt = ctx->rt; JS_FreeValue(ctx, rt->current_exception); rt->current_exception = obj; return JS_EXCEPTION; } /* return the pending exception (cannot be called twice). */ JSValue JS_GetException(JSContext *ctx) { JSValue val; JSRuntime *rt = ctx->rt; val = rt->current_exception; rt->current_exception = JS_NULL; return val; } static void dbuf_put_leb128(DynBuf *s, uint32_t v) { uint32_t a; for(;;) { a = v & 0x7f; v >>= 7; if (v != 0) { dbuf_putc(s, a | 0x80); } else { dbuf_putc(s, a); break; } } } static void dbuf_put_sleb128(DynBuf *s, int32_t v1) { uint32_t v = v1; dbuf_put_leb128(s, (2 * v) ^ -(v >> 31)); } static int get_leb128(uint32_t *pval, const uint8_t *buf, const uint8_t *buf_end) { const uint8_t *ptr = buf; uint32_t v, a, i; v = 0; for(i = 0; i < 5; i++) { if (unlikely(ptr >= buf_end)) break; a = *ptr++; v |= (a & 0x7f) << (i * 7); if (!(a & 0x80)) { *pval = v; return ptr - buf; } } *pval = 0; return -1; } static int get_sleb128(int32_t *pval, const uint8_t *buf, const uint8_t *buf_end) { int ret; uint32_t val; ret = get_leb128(&val, buf, buf_end); if (ret < 0) { *pval = 0; return -1; } *pval = (val >> 1) ^ -(val & 1); return ret; } static int find_line_num(JSContext *ctx, JSFunctionBytecode *b, uint32_t pc_value) { const uint8_t *p_end, *p; int new_line_num, line_num, pc, v, ret; unsigned int op; if (!b->has_debug || !b->debug.pc2line_buf) { /* function was stripped */ return -1; } p = b->debug.pc2line_buf; p_end = p + b->debug.pc2line_len; pc = 0; line_num = b->debug.line_num; while (p < p_end) { op = *p++; if (op == 0) { uint32_t val; ret = get_leb128(&val, p, p_end); if (ret < 0) goto fail; pc += val; p += ret; ret = get_sleb128(&v, p, p_end); if (ret < 0) { fail: /* should never happen */ return b->debug.line_num; } p += ret; new_line_num = line_num + v; } else { op -= PC2LINE_OP_FIRST; pc += (op / PC2LINE_RANGE); new_line_num = line_num + (op % PC2LINE_RANGE) + PC2LINE_BASE; } if (pc_value < pc) return line_num; line_num = new_line_num; } return line_num; } /* in order to avoid executing arbitrary code during the stack trace generation, we only look at simple 'name' properties containing a string. */ static const char *get_func_name(JSContext *ctx, JSValueConst func) { JSProperty *pr; JSShapeProperty *prs; JSValueConst val; if (JS_VALUE_GET_TAG(func) != JS_TAG_OBJECT) return NULL; prs = find_own_property(&pr, JS_VALUE_GET_OBJ(func), JS_ATOM_name); if (!prs) return NULL; if ((prs->flags & JS_PROP_TMASK) != JS_PROP_NORMAL) return NULL; val = pr->u.value; if (JS_VALUE_GET_TAG(val) != JS_TAG_STRING) return NULL; return JS_ToCString(ctx, val); } #define JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL (1 << 0) /* only taken into account if filename is provided */ #define JS_BACKTRACE_FLAG_SINGLE_LEVEL (1 << 1) /* if filename != NULL, an additional level is added with the filename and line number information (used for parse error). */ static void build_backtrace(JSContext *ctx, JSValueConst error_obj, const char *filename, int line_num, int backtrace_flags) { JSStackFrame *sf; JSValue str; DynBuf dbuf; const char *func_name_str; const char *str1; JSObject *p; BOOL backtrace_barrier; js_dbuf_init(ctx, &dbuf); if (filename) { dbuf_printf(&dbuf, " at %s", filename); if (line_num != -1) dbuf_printf(&dbuf, ":%d", line_num); dbuf_putc(&dbuf, '\n'); str = JS_NewString(ctx, filename); JS_DefinePropertyValue(ctx, error_obj, JS_ATOM_fileName, str, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); JS_DefinePropertyValue(ctx, error_obj, JS_ATOM_lineNumber, JS_NewInt32(ctx, line_num), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); if (backtrace_flags & JS_BACKTRACE_FLAG_SINGLE_LEVEL) goto done; } for(sf = ctx->rt->current_stack_frame; sf != NULL; sf = sf->prev_frame) { if (backtrace_flags & JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL) { backtrace_flags &= ~JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL; continue; } func_name_str = get_func_name(ctx, sf->cur_func); if (!func_name_str || func_name_str[0] == '\0') str1 = ""; else str1 = func_name_str; dbuf_printf(&dbuf, " at %s", str1); JS_FreeCString(ctx, func_name_str); p = JS_VALUE_GET_OBJ(sf->cur_func); backtrace_barrier = FALSE; if (js_class_has_bytecode(p->class_id)) { JSFunctionBytecode *b; const char *atom_str; int line_num1; b = p->u.func.function_bytecode; backtrace_barrier = b->backtrace_barrier; if (b->has_debug) { line_num1 = find_line_num(ctx, b, sf->cur_pc - b->byte_code_buf - 1); atom_str = JS_AtomToCString(ctx, b->debug.filename); dbuf_printf(&dbuf, " (%s", atom_str ? atom_str : ""); JS_FreeCString(ctx, atom_str); if (line_num1 != -1) dbuf_printf(&dbuf, ":%d", line_num1); dbuf_putc(&dbuf, ')'); } } else { dbuf_printf(&dbuf, " (native)"); } dbuf_putc(&dbuf, '\n'); /* stop backtrace if JS_EVAL_FLAG_BACKTRACE_BARRIER was used */ if (backtrace_barrier) break; } done: dbuf_putc(&dbuf, '\0'); if (dbuf_error(&dbuf)) str = JS_NULL; else str = JS_NewString(ctx, (char *)dbuf.buf); dbuf_free(&dbuf); JS_DefinePropertyValue(ctx, error_obj, JS_ATOM_stack, str, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); } /* Note: it is important that no exception is returned by this function */ static BOOL is_backtrace_needed(JSContext *ctx, JSValueConst obj) { JSObject *p; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(obj); if (p->class_id != JS_CLASS_ERROR) return FALSE; if (find_own_property1(p, JS_ATOM_stack)) return FALSE; return TRUE; } JSValue JS_NewError(JSContext *ctx) { return JS_NewObjectClass(ctx, JS_CLASS_ERROR); } static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num, const char *fmt, va_list ap, BOOL add_backtrace) { char buf[256]; JSValue obj, ret; vsnprintf(buf, sizeof(buf), fmt, ap); obj = JS_NewObjectProtoClass(ctx, ctx->native_error_proto[error_num], JS_CLASS_ERROR); if (unlikely(JS_IsException(obj))) { /* out of memory: throw JS_NULL to avoid recursing */ obj = JS_NULL; } else { JS_DefinePropertyValue(ctx, obj, JS_ATOM_message, JS_NewString(ctx, buf), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); } if (add_backtrace) { build_backtrace(ctx, obj, NULL, 0, 0); } ret = JS_Throw(ctx, obj); return ret; } static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num, const char *fmt, va_list ap) { JSRuntime *rt = ctx->rt; JSStackFrame *sf; BOOL add_backtrace; /* the backtrace is added later if called from a bytecode function */ sf = rt->current_stack_frame; add_backtrace = !rt->in_out_of_memory && (!sf || (JS_GetFunctionBytecode(sf->cur_func) == NULL)); return JS_ThrowError2(ctx, error_num, fmt, ap, add_backtrace); } JSValue __attribute__((format(printf, 2, 3))) JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; va_start(ap, fmt); val = JS_ThrowError(ctx, JS_SYNTAX_ERROR, fmt, ap); va_end(ap); return val; } JSValue __attribute__((format(printf, 2, 3))) JS_ThrowTypeError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; va_start(ap, fmt); val = JS_ThrowError(ctx, JS_TYPE_ERROR, fmt, ap); va_end(ap); return val; } static int __attribute__((format(printf, 3, 4))) JS_ThrowTypeErrorOrFalse(JSContext *ctx, int flags, const char *fmt, ...) { va_list ap; if ((flags & JS_PROP_THROW) || ((flags & JS_PROP_THROW_STRICT) && is_strict_mode(ctx))) { va_start(ap, fmt); JS_ThrowError(ctx, JS_TYPE_ERROR, fmt, ap); va_end(ap); return -1; } else { return FALSE; } } /* never use it directly */ static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowTypeErrorAtom(JSContext *ctx, JSAtom atom, const char *fmt, ...) { char buf[ATOM_GET_STR_BUF_SIZE]; return JS_ThrowTypeError(ctx, fmt, JS_AtomGetStr(ctx, buf, sizeof(buf), atom)); } /* never use it directly */ static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowSyntaxErrorAtom(JSContext *ctx, JSAtom atom, const char *fmt, ...) { char buf[ATOM_GET_STR_BUF_SIZE]; return JS_ThrowSyntaxError(ctx, fmt, JS_AtomGetStr(ctx, buf, sizeof(buf), atom)); } /* %s is replaced by 'atom'. The macro is used so that gcc can check the format string. */ #define JS_ThrowTypeErrorAtom(ctx, fmt, atom) __JS_ThrowTypeErrorAtom(ctx, atom, fmt, "") #define JS_ThrowSyntaxErrorAtom(ctx, fmt, atom) __JS_ThrowSyntaxErrorAtom(ctx, atom, fmt, "") static int JS_ThrowTypeErrorReadOnly(JSContext *ctx, int flags, JSAtom atom) { if ((flags & JS_PROP_THROW) || ((flags & JS_PROP_THROW_STRICT) && is_strict_mode(ctx))) { JS_ThrowTypeErrorAtom(ctx, "'%s' is read-only", atom); return -1; } else { return FALSE; } } JSValue __attribute__((format(printf, 2, 3))) JS_ThrowReferenceError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; va_start(ap, fmt); val = JS_ThrowError(ctx, JS_REFERENCE_ERROR, fmt, ap); va_end(ap); return val; } JSValue __attribute__((format(printf, 2, 3))) JS_ThrowRangeError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; va_start(ap, fmt); val = JS_ThrowError(ctx, JS_RANGE_ERROR, fmt, ap); va_end(ap); return val; } JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; va_start(ap, fmt); val = JS_ThrowError(ctx, JS_INTERNAL_ERROR, fmt, ap); va_end(ap); return val; } JSValue JS_ThrowOutOfMemory(JSContext *ctx) { JSRuntime *rt = ctx->rt; if (!rt->in_out_of_memory) { rt->in_out_of_memory = TRUE; JS_ThrowInternalError(ctx, "out of memory"); rt->in_out_of_memory = FALSE; } return JS_EXCEPTION; } static JSValue JS_ThrowStackOverflow(JSContext *ctx) { return JS_ThrowInternalError(ctx, "stack overflow"); } static JSValue JS_ThrowTypeErrorNotAnObject(JSContext *ctx) { return JS_ThrowTypeError(ctx, "not an object"); } static JSValue JS_ThrowTypeErrorNotASymbol(JSContext *ctx) { return JS_ThrowTypeError(ctx, "not a symbol"); } static JSValue JS_ThrowReferenceErrorNotDefined(JSContext *ctx, JSAtom name) { char buf[ATOM_GET_STR_BUF_SIZE]; return JS_ThrowReferenceError(ctx, "'%s' is not defined", JS_AtomGetStr(ctx, buf, sizeof(buf), name)); } static JSValue JS_ThrowReferenceErrorUninitialized(JSContext *ctx, JSAtom name) { char buf[ATOM_GET_STR_BUF_SIZE]; return JS_ThrowReferenceError(ctx, "%s is not initialized", name == JS_ATOM_NULL ? "lexical variable" : JS_AtomGetStr(ctx, buf, sizeof(buf), name)); } static JSValue JS_ThrowReferenceErrorUninitialized2(JSContext *ctx, JSFunctionBytecode *b, int idx, BOOL is_ref) { JSAtom atom = JS_ATOM_NULL; if (is_ref) { atom = b->closure_var[idx].var_name; } else { /* not present if the function is stripped and contains no eval() */ if (b->vardefs) atom = b->vardefs[b->arg_count + idx].var_name; } return JS_ThrowReferenceErrorUninitialized(ctx, atom); } static JSValue JS_ThrowTypeErrorInvalidClass(JSContext *ctx, int class_id) { JSRuntime *rt = ctx->rt; JSAtom name; name = rt->class_array[class_id].class_name; return JS_ThrowTypeErrorAtom(ctx, "%s object expected", name); } static no_inline __exception int __js_poll_interrupts(JSContext *ctx) { JSRuntime *rt = ctx->rt; ctx->interrupt_counter = JS_INTERRUPT_COUNTER_INIT; if (rt->interrupt_handler) { if (rt->interrupt_handler(rt, rt->interrupt_opaque)) { /* XXX: should set a specific flag to avoid catching */ JS_ThrowInternalError(ctx, "interrupted"); JS_SetUncatchableError(ctx, ctx->rt->current_exception, TRUE); return -1; } } return 0; } static inline __exception int js_poll_interrupts(JSContext *ctx) { if (unlikely(--ctx->interrupt_counter <= 0)) { return __js_poll_interrupts(ctx); } else { return 0; } } /* return -1 (exception) or TRUE/FALSE */ static int JS_SetPrototypeInternal(JSContext *ctx, JSValueConst obj, JSValueConst proto_val, BOOL throw_flag) { JSObject *proto, *p, *p1; JSShape *sh; if (throw_flag) { if (JS_VALUE_GET_TAG(obj) == JS_TAG_NULL || JS_VALUE_GET_TAG(obj) == JS_TAG_UNDEFINED) goto not_obj; } else { if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) goto not_obj; } p = JS_VALUE_GET_OBJ(obj); if (JS_VALUE_GET_TAG(proto_val) != JS_TAG_OBJECT) { if (JS_VALUE_GET_TAG(proto_val) != JS_TAG_NULL) { not_obj: JS_ThrowTypeErrorNotAnObject(ctx); return -1; } proto = NULL; } else { proto = JS_VALUE_GET_OBJ(proto_val); } if (throw_flag && JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return TRUE; if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_setPrototypeOf(ctx, obj, proto_val, throw_flag); sh = p->shape; if (sh->proto == proto) return TRUE; if (!p->extensible) { if (throw_flag) { JS_ThrowTypeError(ctx, "object is not extensible"); return -1; } else { return FALSE; } } if (proto) { /* check if there is a cycle */ p1 = proto; do { if (p1 == p) { if (throw_flag) { JS_ThrowTypeError(ctx, "circular prototype chain"); return -1; } else { return FALSE; } } /* Note: for Proxy objects, proto is NULL */ p1 = p1->shape->proto; } while (p1 != NULL); JS_DupValue(ctx, proto_val); } if (js_shape_prepare_update(ctx, p, NULL)) return -1; sh = p->shape; if (sh->proto) JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, sh->proto)); sh->proto = proto; return TRUE; } /* return -1 (exception) or TRUE/FALSE */ int JS_SetPrototype(JSContext *ctx, JSValueConst obj, JSValueConst proto_val) { return JS_SetPrototypeInternal(ctx, obj, proto_val, TRUE); } /* Only works for primitive types, otherwise return JS_NULL. */ static JSValueConst JS_GetPrototypePrimitive(JSContext *ctx, JSValueConst val) { switch(JS_VALUE_GET_NORM_TAG(val)) { case JS_TAG_BIG_INT: val = ctx->class_proto[JS_CLASS_BIG_INT]; break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: val = ctx->class_proto[JS_CLASS_BIG_FLOAT]; break; case JS_TAG_BIG_DECIMAL: val = ctx->class_proto[JS_CLASS_BIG_DECIMAL]; break; #endif case JS_TAG_INT: case JS_TAG_FLOAT64: val = ctx->class_proto[JS_CLASS_NUMBER]; break; case JS_TAG_BOOL: val = ctx->class_proto[JS_CLASS_BOOLEAN]; break; case JS_TAG_STRING: val = ctx->class_proto[JS_CLASS_STRING]; break; case JS_TAG_SYMBOL: val = ctx->class_proto[JS_CLASS_SYMBOL]; break; case JS_TAG_OBJECT: case JS_TAG_NULL: case JS_TAG_UNDEFINED: default: val = JS_NULL; break; } return val; } /* Return an Object, JS_NULL or JS_EXCEPTION in case of Proxy object. */ JSValue JS_GetPrototype(JSContext *ctx, JSValueConst obj) { JSValue val; if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { JSObject *p; p = JS_VALUE_GET_OBJ(obj); if (unlikely(p->class_id == JS_CLASS_PROXY)) { val = js_proxy_getPrototypeOf(ctx, obj); } else { p = p->shape->proto; if (!p) val = JS_NULL; else val = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); } } else { val = JS_DupValue(ctx, JS_GetPrototypePrimitive(ctx, obj)); } return val; } static JSValue JS_GetPrototypeFree(JSContext *ctx, JSValue obj) { JSValue obj1; obj1 = JS_GetPrototype(ctx, obj); JS_FreeValue(ctx, obj); return obj1; } /* return TRUE, FALSE or (-1) in case of exception */ static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj) { JSValue obj_proto; JSObject *proto; const JSObject *p, *proto1; BOOL ret; if (!JS_IsFunction(ctx, obj)) return FALSE; p = JS_VALUE_GET_OBJ(obj); if (p->class_id == JS_CLASS_BOUND_FUNCTION) { JSBoundFunction *s = p->u.bound_function; return JS_IsInstanceOf(ctx, val, s->func_obj); } /* Only explicitly boxed values are instances of constructors */ if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return FALSE; obj_proto = JS_GetProperty(ctx, obj, JS_ATOM_prototype); if (JS_VALUE_GET_TAG(obj_proto) != JS_TAG_OBJECT) { if (!JS_IsException(obj_proto)) JS_ThrowTypeError(ctx, "operand 'prototype' property is not an object"); ret = -1; goto done; } proto = JS_VALUE_GET_OBJ(obj_proto); p = JS_VALUE_GET_OBJ(val); for(;;) { proto1 = p->shape->proto; if (!proto1) { /* slow case if proxy in the prototype chain */ if (unlikely(p->class_id == JS_CLASS_PROXY)) { JSValue obj1; obj1 = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, (JSObject *)p)); for(;;) { obj1 = JS_GetPrototypeFree(ctx, obj1); if (JS_IsException(obj1)) { ret = -1; break; } if (JS_IsNull(obj1)) { ret = FALSE; break; } if (proto == JS_VALUE_GET_OBJ(obj1)) { JS_FreeValue(ctx, obj1); ret = TRUE; break; } /* must check for timeout to avoid infinite loop */ if (js_poll_interrupts(ctx)) { JS_FreeValue(ctx, obj1); ret = -1; break; } } } else { ret = FALSE; } break; } p = proto1; if (proto == p) { ret = TRUE; break; } } done: JS_FreeValue(ctx, obj_proto); return ret; } /* return TRUE, FALSE or (-1) in case of exception */ int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj) { JSValue method; if (!JS_IsObject(obj)) goto fail; method = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_hasInstance); if (JS_IsException(method)) return -1; if (!JS_IsNull(method) && !JS_IsUndefined(method)) { JSValue ret; ret = JS_CallFree(ctx, method, obj, 1, &val); return JS_ToBoolFree(ctx, ret); } /* legacy case */ if (!JS_IsFunction(ctx, obj)) { fail: JS_ThrowTypeError(ctx, "invalid 'instanceof' right operand"); return -1; } return JS_OrdinaryIsInstanceOf(ctx, val, obj); } /* return the value associated to the autoinit property or an exception */ typedef JSValue JSAutoInitFunc(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque); static JSAutoInitFunc *js_autoinit_func_table[] = { js_instantiate_prototype, /* JS_AUTOINIT_ID_PROTOTYPE */ js_module_ns_autoinit, /* JS_AUTOINIT_ID_MODULE_NS */ JS_InstantiateFunctionListItem2, /* JS_AUTOINIT_ID_PROP */ }; /* warning: 'prs' is reallocated after it */ static int JS_AutoInitProperty(JSContext *ctx, JSObject *p, JSAtom prop, JSProperty *pr, JSShapeProperty *prs) { JSValue val; JSContext *realm; JSAutoInitFunc *func; if (js_shape_prepare_update(ctx, p, &prs)) return -1; realm = js_autoinit_get_realm(pr); func = js_autoinit_func_table[js_autoinit_get_id(pr)]; /* 'func' shall not modify the object properties 'pr' */ val = func(realm, p, prop, pr->u.init.opaque); js_autoinit_free(ctx->rt, pr); prs->flags &= ~JS_PROP_TMASK; pr->u.value = JS_UNDEFINED; if (JS_IsException(val)) return -1; pr->u.value = val; return 0; } JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj, JSAtom prop, JSValueConst this_obj, BOOL throw_ref_error) { JSObject *p; JSProperty *pr; JSShapeProperty *prs; uint32_t tag; tag = JS_VALUE_GET_TAG(obj); if (unlikely(tag != JS_TAG_OBJECT)) { switch(tag) { case JS_TAG_NULL: return JS_ThrowTypeErrorAtom(ctx, "cannot read property '%s' of null", prop); case JS_TAG_UNDEFINED: return JS_ThrowTypeErrorAtom(ctx, "cannot read property '%s' of undefined", prop); case JS_TAG_EXCEPTION: return JS_EXCEPTION; case JS_TAG_STRING: { JSString *p1 = JS_VALUE_GET_STRING(obj); if (__JS_AtomIsTaggedInt(prop)) { uint32_t idx, ch; idx = __JS_AtomToUInt32(prop); if (idx < p1->len) { if (p1->is_wide_char) ch = p1->u.str16[idx]; else ch = p1->u.str8[idx]; return js_new_string_char(ctx, ch); } } else if (prop == JS_ATOM_length) { return JS_NewInt32(ctx, p1->len); } } break; default: break; } /* cannot raise an exception */ p = JS_VALUE_GET_OBJ(JS_GetPrototypePrimitive(ctx, obj)); if (!p) return JS_UNDEFINED; } else { p = JS_VALUE_GET_OBJ(obj); } for(;;) { prs = find_own_property(&pr, p, prop); if (prs) { /* found */ if (unlikely(prs->flags & JS_PROP_TMASK)) { if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { if (unlikely(!pr->u.getset.getter)) { return JS_UNDEFINED; } else { JSValue func = JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.getter); /* Note: the field could be removed in the getter */ func = JS_DupValue(ctx, func); return JS_CallFree(ctx, func, this_obj, 0, NULL); } } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { JSValue val = *pr->u.var_ref->pvalue; if (unlikely(JS_IsUninitialized(val))) return JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return JS_DupValue(ctx, val); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* Instantiate property and retry */ if (JS_AutoInitProperty(ctx, p, prop, pr, prs)) return JS_EXCEPTION; continue; } } else { return JS_DupValue(ctx, pr->u.value); } } if (unlikely(p->is_exotic)) { /* exotic behaviors */ if (p->fast_array) { if (__JS_AtomIsTaggedInt(prop)) { uint32_t idx = __JS_AtomToUInt32(prop); if (idx < p->u.array.count) { /* we avoid duplicating the code */ return JS_GetPropertyUint32(ctx, JS_MKPTR(JS_TAG_OBJECT, p), idx); } else if (p->class_id >= JS_CLASS_UINT8C_ARRAY && p->class_id <= JS_CLASS_FLOAT64_ARRAY) { return JS_UNDEFINED; } } else if (p->class_id >= JS_CLASS_UINT8C_ARRAY && p->class_id <= JS_CLASS_FLOAT64_ARRAY) { int ret; ret = JS_AtomIsNumericIndex(ctx, prop); if (ret != 0) { if (ret < 0) return JS_EXCEPTION; return JS_UNDEFINED; } } } else { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; if (em) { if (em->get_property) { JSValue obj1, retval; /* XXX: should pass throw_ref_error */ /* Note: if 'p' is a prototype, it can be freed in the called function */ obj1 = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); retval = em->get_property(ctx, obj1, prop, this_obj); JS_FreeValue(ctx, obj1); return retval; } if (em->get_own_property) { JSPropertyDescriptor desc; int ret; JSValue obj1; /* Note: if 'p' is a prototype, it can be freed in the called function */ obj1 = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); ret = em->get_own_property(ctx, &desc, obj1, prop); JS_FreeValue(ctx, obj1); if (ret < 0) return JS_EXCEPTION; if (ret) { if (desc.flags & JS_PROP_GETSET) { JS_FreeValue(ctx, desc.setter); return JS_CallFree(ctx, desc.getter, this_obj, 0, NULL); } else { return desc.value; } } } } } } p = p->shape->proto; if (!p) break; } if (unlikely(throw_ref_error)) { return JS_ThrowReferenceErrorNotDefined(ctx, prop); } else { return JS_UNDEFINED; } } static JSValue JS_ThrowTypeErrorPrivateNotFound(JSContext *ctx, JSAtom atom) { return JS_ThrowTypeErrorAtom(ctx, "private class field '%s' does not exist", atom); } /* Private fields can be added even on non extensible objects or Proxies */ static int JS_DefinePrivateField(JSContext *ctx, JSValueConst obj, JSValueConst name, JSValue val) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; JSAtom prop; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) { JS_ThrowTypeErrorNotAnObject(ctx); goto fail; } /* safety check */ if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL)) { JS_ThrowTypeErrorNotASymbol(ctx); goto fail; } prop = js_symbol_to_atom(ctx, (JSValue)name); p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, prop); if (prs) { JS_ThrowTypeErrorAtom(ctx, "private class field '%s' already exists", prop); goto fail; } pr = add_property(ctx, p, prop, JS_PROP_C_W_E); if (unlikely(!pr)) { fail: JS_FreeValue(ctx, val); return -1; } pr->u.value = val; return 0; } static JSValue JS_GetPrivateField(JSContext *ctx, JSValueConst obj, JSValueConst name) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; JSAtom prop; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) return JS_ThrowTypeErrorNotAnObject(ctx); /* safety check */ if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL)) return JS_ThrowTypeErrorNotASymbol(ctx); prop = js_symbol_to_atom(ctx, (JSValue)name); p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, prop); if (!prs) { JS_ThrowTypeErrorPrivateNotFound(ctx, prop); return JS_EXCEPTION; } return JS_DupValue(ctx, pr->u.value); } static int JS_SetPrivateField(JSContext *ctx, JSValueConst obj, JSValueConst name, JSValue val) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; JSAtom prop; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) { JS_ThrowTypeErrorNotAnObject(ctx); goto fail; } /* safety check */ if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL)) { JS_ThrowTypeErrorNotASymbol(ctx); goto fail; } prop = js_symbol_to_atom(ctx, (JSValue)name); p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, prop); if (!prs) { JS_ThrowTypeErrorPrivateNotFound(ctx, prop); fail: JS_FreeValue(ctx, val); return -1; } set_value(ctx, &pr->u.value, val); return 0; } /* add a private brand field to 'home_obj' if not already present and if obj is != null add a private brand to it */ static int JS_AddBrand(JSContext *ctx, JSValueConst obj, JSValueConst home_obj) { JSObject *p, *p1; JSShapeProperty *prs; JSProperty *pr; JSValue brand; JSAtom brand_atom; if (unlikely(JS_VALUE_GET_TAG(home_obj) != JS_TAG_OBJECT)) { JS_ThrowTypeErrorNotAnObject(ctx); return -1; } p = JS_VALUE_GET_OBJ(home_obj); prs = find_own_property(&pr, p, JS_ATOM_Private_brand); if (!prs) { /* if the brand is not present, add it */ brand = JS_NewSymbolFromAtom(ctx, JS_ATOM_brand, JS_ATOM_TYPE_PRIVATE); if (JS_IsException(brand)) return -1; pr = add_property(ctx, p, JS_ATOM_Private_brand, JS_PROP_C_W_E); if (!pr) { JS_FreeValue(ctx, brand); return -1; } pr->u.value = JS_DupValue(ctx, brand); } else { brand = JS_DupValue(ctx, pr->u.value); } brand_atom = js_symbol_to_atom(ctx, brand); if (JS_IsObject(obj)) { p1 = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p1, brand_atom); if (unlikely(prs)) { JS_FreeAtom(ctx, brand_atom); JS_ThrowTypeError(ctx, "private method is already present"); return -1; } pr = add_property(ctx, p1, brand_atom, JS_PROP_C_W_E); JS_FreeAtom(ctx, brand_atom); if (!pr) return -1; pr->u.value = JS_UNDEFINED; } else { JS_FreeAtom(ctx, brand_atom); } return 0; } /* return a boolean telling if the brand of the home object of 'func' is present on 'obj' or -1 in case of exception */ static int JS_CheckBrand(JSContext *ctx, JSValueConst obj, JSValueConst func) { JSObject *p, *p1, *home_obj; JSShapeProperty *prs; JSProperty *pr; JSValueConst brand; /* get the home object of 'func' */ if (unlikely(JS_VALUE_GET_TAG(func) != JS_TAG_OBJECT)) goto not_obj; p1 = JS_VALUE_GET_OBJ(func); if (!js_class_has_bytecode(p1->class_id)) goto not_obj; home_obj = p1->u.func.home_object; if (!home_obj) goto not_obj; prs = find_own_property(&pr, home_obj, JS_ATOM_Private_brand); if (!prs) { JS_ThrowTypeError(ctx, "expecting private field"); return -1; } brand = pr->u.value; /* safety check */ if (unlikely(JS_VALUE_GET_TAG(brand) != JS_TAG_SYMBOL)) goto not_obj; /* get the brand array of 'obj' */ if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) { not_obj: JS_ThrowTypeErrorNotAnObject(ctx); return -1; } p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, js_symbol_to_atom(ctx, (JSValue)brand)); return (prs != NULL); } static uint32_t js_string_obj_get_length(JSContext *ctx, JSValueConst obj) { JSObject *p; JSString *p1; uint32_t len = 0; /* This is a class exotic method: obj class_id is JS_CLASS_STRING */ p = JS_VALUE_GET_OBJ(obj); if (JS_VALUE_GET_TAG(p->u.object_data) == JS_TAG_STRING) { p1 = JS_VALUE_GET_STRING(p->u.object_data); len = p1->len; } return len; } static int num_keys_cmp(const void *p1, const void *p2, void *opaque) { JSContext *ctx = opaque; JSAtom atom1 = ((const JSPropertyEnum *)p1)->atom; JSAtom atom2 = ((const JSPropertyEnum *)p2)->atom; uint32_t v1, v2; BOOL atom1_is_integer, atom2_is_integer; atom1_is_integer = JS_AtomIsArrayIndex(ctx, &v1, atom1); atom2_is_integer = JS_AtomIsArrayIndex(ctx, &v2, atom2); assert(atom1_is_integer && atom2_is_integer); if (v1 < v2) return -1; else if (v1 == v2) return 0; else return 1; } static void js_free_prop_enum(JSContext *ctx, JSPropertyEnum *tab, uint32_t len) { uint32_t i; if (tab) { for(i = 0; i < len; i++) JS_FreeAtom(ctx, tab[i].atom); js_free(ctx, tab); } } /* return < 0 in case if exception, 0 if OK. ptab and its atoms must be freed by the user. */ static int __exception JS_GetOwnPropertyNamesInternal(JSContext *ctx, JSPropertyEnum **ptab, uint32_t *plen, JSObject *p, int flags) { int i, j; JSShape *sh; JSShapeProperty *prs; JSPropertyEnum *tab_atom, *tab_exotic; JSAtom atom; uint32_t num_keys_count, str_keys_count, sym_keys_count, atom_count; uint32_t num_index, str_index, sym_index, exotic_count, exotic_keys_count; BOOL is_enumerable, num_sorted; uint32_t num_key; JSAtomKindEnum kind; /* clear pointer for consistency in case of failure */ *ptab = NULL; *plen = 0; /* compute the number of returned properties */ num_keys_count = 0; str_keys_count = 0; sym_keys_count = 0; exotic_keys_count = 0; exotic_count = 0; tab_exotic = NULL; sh = p->shape; for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { atom = prs->atom; if (atom != JS_ATOM_NULL) { is_enumerable = ((prs->flags & JS_PROP_ENUMERABLE) != 0); kind = JS_AtomGetKind(ctx, atom); if ((!(flags & JS_GPN_ENUM_ONLY) || is_enumerable) && ((flags >> kind) & 1) != 0) { /* need to raise an exception in case of the module name space (implicit GetOwnProperty) */ if (unlikely((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) && (flags & (JS_GPN_SET_ENUM | JS_GPN_ENUM_ONLY))) { JSVarRef *var_ref = p->prop[i].u.var_ref; if (unlikely(JS_IsUninitialized(*var_ref->pvalue))) { JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return -1; } } if (JS_AtomIsArrayIndex(ctx, &num_key, atom)) { num_keys_count++; } else if (kind == JS_ATOM_KIND_STRING) { str_keys_count++; } else { sym_keys_count++; } } } } if (p->is_exotic) { if (p->fast_array) { if (flags & JS_GPN_STRING_MASK) { num_keys_count += p->u.array.count; } } else if (p->class_id == JS_CLASS_STRING) { if (flags & JS_GPN_STRING_MASK) { num_keys_count += js_string_obj_get_length(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); } } else { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; if (em && em->get_own_property_names) { if (em->get_own_property_names(ctx, &tab_exotic, &exotic_count, JS_MKPTR(JS_TAG_OBJECT, p))) return -1; for(i = 0; i < exotic_count; i++) { atom = tab_exotic[i].atom; kind = JS_AtomGetKind(ctx, atom); if (((flags >> kind) & 1) != 0) { is_enumerable = FALSE; if (flags & (JS_GPN_SET_ENUM | JS_GPN_ENUM_ONLY)) { JSPropertyDescriptor desc; int res; /* set the "is_enumerable" field if necessary */ res = JS_GetOwnPropertyInternal(ctx, &desc, p, atom); if (res < 0) { js_free_prop_enum(ctx, tab_exotic, exotic_count); return -1; } if (res) { is_enumerable = ((desc.flags & JS_PROP_ENUMERABLE) != 0); js_free_desc(ctx, &desc); } tab_exotic[i].is_enumerable = is_enumerable; } if (!(flags & JS_GPN_ENUM_ONLY) || is_enumerable) { exotic_keys_count++; } } } } } } /* fill them */ atom_count = num_keys_count + str_keys_count + sym_keys_count + exotic_keys_count; /* avoid allocating 0 bytes */ tab_atom = js_malloc(ctx, sizeof(tab_atom[0]) * max_int(atom_count, 1)); if (!tab_atom) { js_free_prop_enum(ctx, tab_exotic, exotic_count); return -1; } num_index = 0; str_index = num_keys_count; sym_index = str_index + str_keys_count; num_sorted = TRUE; sh = p->shape; for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { atom = prs->atom; if (atom != JS_ATOM_NULL) { is_enumerable = ((prs->flags & JS_PROP_ENUMERABLE) != 0); kind = JS_AtomGetKind(ctx, atom); if ((!(flags & JS_GPN_ENUM_ONLY) || is_enumerable) && ((flags >> kind) & 1) != 0) { if (JS_AtomIsArrayIndex(ctx, &num_key, atom)) { j = num_index++; num_sorted = FALSE; } else if (kind == JS_ATOM_KIND_STRING) { j = str_index++; } else { j = sym_index++; } tab_atom[j].atom = JS_DupAtom(ctx, atom); tab_atom[j].is_enumerable = is_enumerable; } } } if (p->is_exotic) { int len; if (p->fast_array) { if (flags & JS_GPN_STRING_MASK) { len = p->u.array.count; goto add_array_keys; } } else if (p->class_id == JS_CLASS_STRING) { if (flags & JS_GPN_STRING_MASK) { len = js_string_obj_get_length(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); add_array_keys: for(i = 0; i < len; i++) { tab_atom[num_index].atom = __JS_AtomFromUInt32(i); if (tab_atom[num_index].atom == JS_ATOM_NULL) { js_free_prop_enum(ctx, tab_atom, num_index); return -1; } tab_atom[num_index].is_enumerable = TRUE; num_index++; } } } else { /* Note: exotic keys are not reordered and comes after the object own properties. */ for(i = 0; i < exotic_count; i++) { atom = tab_exotic[i].atom; is_enumerable = tab_exotic[i].is_enumerable; kind = JS_AtomGetKind(ctx, atom); if ((!(flags & JS_GPN_ENUM_ONLY) || is_enumerable) && ((flags >> kind) & 1) != 0) { tab_atom[sym_index].atom = atom; tab_atom[sym_index].is_enumerable = is_enumerable; sym_index++; } else { JS_FreeAtom(ctx, atom); } } js_free(ctx, tab_exotic); } } assert(num_index == num_keys_count); assert(str_index == num_keys_count + str_keys_count); assert(sym_index == atom_count); if (num_keys_count != 0 && !num_sorted) { rqsort(tab_atom, num_keys_count, sizeof(tab_atom[0]), num_keys_cmp, ctx); } *ptab = tab_atom; *plen = atom_count; return 0; } int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab, uint32_t *plen, JSValueConst obj, int flags) { if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) { JS_ThrowTypeErrorNotAnObject(ctx); return -1; } return JS_GetOwnPropertyNamesInternal(ctx, ptab, plen, JS_VALUE_GET_OBJ(obj), flags); } /* Return -1 if exception, FALSE if the property does not exist, TRUE if it exists. If TRUE is returned, the property descriptor 'desc' is filled present. */ static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc, JSObject *p, JSAtom prop) { JSShapeProperty *prs; JSProperty *pr; retry: prs = find_own_property(&pr, p, prop); if (prs) { if (desc) { desc->flags = prs->flags & JS_PROP_C_W_E; desc->getter = JS_UNDEFINED; desc->setter = JS_UNDEFINED; desc->value = JS_UNDEFINED; if (unlikely(prs->flags & JS_PROP_TMASK)) { if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { desc->flags |= JS_PROP_GETSET; if (pr->u.getset.getter) desc->getter = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.getter)); if (pr->u.getset.setter) desc->setter = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.setter)); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { JSValue val = *pr->u.var_ref->pvalue; if (unlikely(JS_IsUninitialized(val))) { JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return -1; } desc->value = JS_DupValue(ctx, val); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* Instantiate property and retry */ if (JS_AutoInitProperty(ctx, p, prop, pr, prs)) return -1; goto retry; } } else { desc->value = JS_DupValue(ctx, pr->u.value); } } else { /* for consistency, send the exception even if desc is NULL */ if (unlikely((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF)) { if (unlikely(JS_IsUninitialized(*pr->u.var_ref->pvalue))) { JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return -1; } } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* nothing to do: delay instantiation until actual value and/or attributes are read */ } } return TRUE; } if (p->is_exotic) { if (p->fast_array) { /* specific case for fast arrays */ if (__JS_AtomIsTaggedInt(prop)) { uint32_t idx; idx = __JS_AtomToUInt32(prop); if (idx < p->u.array.count) { if (desc) { desc->flags = JS_PROP_WRITABLE | JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE; desc->getter = JS_UNDEFINED; desc->setter = JS_UNDEFINED; desc->value = JS_GetPropertyUint32(ctx, JS_MKPTR(JS_TAG_OBJECT, p), idx); } return TRUE; } } } else { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; if (em && em->get_own_property) { return em->get_own_property(ctx, desc, JS_MKPTR(JS_TAG_OBJECT, p), prop); } } } return FALSE; } int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc, JSValueConst obj, JSAtom prop) { if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) { JS_ThrowTypeErrorNotAnObject(ctx); return -1; } return JS_GetOwnPropertyInternal(ctx, desc, JS_VALUE_GET_OBJ(obj), prop); } /* return -1 if exception (Proxy object only) or TRUE/FALSE */ int JS_IsExtensible(JSContext *ctx, JSValueConst obj) { JSObject *p; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) return FALSE; p = JS_VALUE_GET_OBJ(obj); if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_isExtensible(ctx, obj); else return p->extensible; } /* return -1 if exception (Proxy object only) or TRUE/FALSE */ int JS_PreventExtensions(JSContext *ctx, JSValueConst obj) { JSObject *p; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) return FALSE; p = JS_VALUE_GET_OBJ(obj); if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_preventExtensions(ctx, obj); p->extensible = FALSE; return TRUE; } /* return -1 if exception otherwise TRUE or FALSE */ int JS_HasProperty(JSContext *ctx, JSValueConst obj, JSAtom prop) { JSObject *p; int ret; JSValue obj1; if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) return FALSE; p = JS_VALUE_GET_OBJ(obj); for(;;) { if (p->is_exotic) { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; if (em && em->has_property) { /* has_property can free the prototype */ obj1 = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); ret = em->has_property(ctx, obj1, prop); JS_FreeValue(ctx, obj1); return ret; } } /* JS_GetOwnPropertyInternal can free the prototype */ JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); ret = JS_GetOwnPropertyInternal(ctx, NULL, p, prop); JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); if (ret != 0) return ret; if (p->class_id >= JS_CLASS_UINT8C_ARRAY && p->class_id <= JS_CLASS_FLOAT64_ARRAY) { ret = JS_AtomIsNumericIndex(ctx, prop); if (ret != 0) { if (ret < 0) return -1; return FALSE; } } p = p->shape->proto; if (!p) break; } return FALSE; } /* val must be a symbol */ static JSAtom js_symbol_to_atom(JSContext *ctx, JSValue val) { JSAtomStruct *p = JS_VALUE_GET_PTR(val); return js_get_atom_index(ctx->rt, p); } /* return JS_ATOM_NULL in case of exception */ JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val) { JSAtom atom; uint32_t tag; tag = JS_VALUE_GET_TAG(val); if (tag == JS_TAG_INT && (uint32_t)JS_VALUE_GET_INT(val) <= JS_ATOM_MAX_INT) { /* fast path for integer values */ atom = __JS_AtomFromUInt32(JS_VALUE_GET_INT(val)); } else if (tag == JS_TAG_SYMBOL) { JSAtomStruct *p = JS_VALUE_GET_PTR(val); atom = JS_DupAtom(ctx, js_get_atom_index(ctx->rt, p)); } else { JSValue str; str = JS_ToPropertyKey(ctx, val); if (JS_IsException(str)) return JS_ATOM_NULL; if (JS_VALUE_GET_TAG(str) == JS_TAG_SYMBOL) { atom = js_symbol_to_atom(ctx, str); } else { atom = JS_NewAtomStr(ctx, JS_VALUE_GET_STRING(str)); } } return atom; } static JSValue JS_GetPropertyValue(JSContext *ctx, JSValueConst this_obj, JSValue prop) { JSAtom atom; JSValue ret; if (likely(JS_VALUE_GET_TAG(this_obj) == JS_TAG_OBJECT && JS_VALUE_GET_TAG(prop) == JS_TAG_INT)) { JSObject *p; uint32_t idx; /* fast path for array access */ p = JS_VALUE_GET_OBJ(this_obj); idx = JS_VALUE_GET_INT(prop); switch(p->class_id) { case JS_CLASS_ARRAY: case JS_CLASS_ARGUMENTS: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_DupValue(ctx, p->u.array.u.values[idx]); case JS_CLASS_INT8_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewInt32(ctx, p->u.array.u.int8_ptr[idx]); case JS_CLASS_UINT8C_ARRAY: case JS_CLASS_UINT8_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewInt32(ctx, p->u.array.u.uint8_ptr[idx]); case JS_CLASS_INT16_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewInt32(ctx, p->u.array.u.int16_ptr[idx]); case JS_CLASS_UINT16_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewInt32(ctx, p->u.array.u.uint16_ptr[idx]); case JS_CLASS_INT32_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewInt32(ctx, p->u.array.u.int32_ptr[idx]); case JS_CLASS_UINT32_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewUint32(ctx, p->u.array.u.uint32_ptr[idx]); case JS_CLASS_BIG_INT64_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewBigInt64(ctx, p->u.array.u.int64_ptr[idx]); case JS_CLASS_BIG_UINT64_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return JS_NewBigUint64(ctx, p->u.array.u.uint64_ptr[idx]); case JS_CLASS_FLOAT32_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return __JS_NewFloat64(ctx, p->u.array.u.float_ptr[idx]); case JS_CLASS_FLOAT64_ARRAY: if (unlikely(idx >= p->u.array.count)) goto slow_path; return __JS_NewFloat64(ctx, p->u.array.u.double_ptr[idx]); default: goto slow_path; } } else { slow_path: atom = JS_ValueToAtom(ctx, prop); JS_FreeValue(ctx, prop); if (unlikely(atom == JS_ATOM_NULL)) return JS_EXCEPTION; ret = JS_GetProperty(ctx, this_obj, atom); JS_FreeAtom(ctx, atom); return ret; } } JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj, uint32_t idx) { return JS_GetPropertyValue(ctx, this_obj, JS_NewUint32(ctx, idx)); } /* Check if an object has a generalized numeric property. Return value: -1 for exception, TRUE if property exists, stored into *pval, FALSE if proprty does not exist. */ static int JS_TryGetPropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx, JSValue *pval) { JSValue val = JS_UNDEFINED; JSAtom prop; int present; if (likely((uint64_t)idx <= JS_ATOM_MAX_INT)) { /* fast path */ present = JS_HasProperty(ctx, obj, __JS_AtomFromUInt32(idx)); if (present > 0) { val = JS_GetPropertyValue(ctx, obj, JS_NewInt32(ctx, idx)); if (unlikely(JS_IsException(val))) present = -1; } } else { prop = JS_NewAtomInt64(ctx, idx); present = -1; if (likely(prop != JS_ATOM_NULL)) { present = JS_HasProperty(ctx, obj, prop); if (present > 0) { val = JS_GetProperty(ctx, obj, prop); if (unlikely(JS_IsException(val))) present = -1; } JS_FreeAtom(ctx, prop); } } *pval = val; return present; } static JSValue JS_GetPropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx) { JSAtom prop; JSValue val; if ((uint64_t)idx <= INT32_MAX) { /* fast path for fast arrays */ return JS_GetPropertyValue(ctx, obj, JS_NewInt32(ctx, idx)); } prop = JS_NewAtomInt64(ctx, idx); if (prop == JS_ATOM_NULL) return JS_EXCEPTION; val = JS_GetProperty(ctx, obj, prop); JS_FreeAtom(ctx, prop); return val; } JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj, const char *prop) { JSAtom atom; JSValue ret; atom = JS_NewAtom(ctx, prop); ret = JS_GetProperty(ctx, this_obj, atom); JS_FreeAtom(ctx, atom); return ret; } /* Note: the property value is not initialized. Return NULL if memory error. */ static JSProperty *add_property(JSContext *ctx, JSObject *p, JSAtom prop, int prop_flags) { JSShape *sh, *new_sh; sh = p->shape; if (sh->is_hashed) { /* try to find an existing shape */ new_sh = find_hashed_shape_prop(ctx->rt, sh, prop, prop_flags); if (new_sh) { /* matching shape found: use it */ /* the property array may need to be resized */ if (new_sh->prop_size != sh->prop_size) { JSProperty *new_prop; new_prop = js_realloc(ctx, p->prop, sizeof(p->prop[0]) * new_sh->prop_size); if (!new_prop) return NULL; p->prop = new_prop; } p->shape = js_dup_shape(new_sh); js_free_shape(ctx->rt, sh); return &p->prop[new_sh->prop_count - 1]; } else if (sh->header.ref_count != 1) { /* if the shape is shared, clone it */ new_sh = js_clone_shape(ctx, sh); if (!new_sh) return NULL; /* hash the cloned shape */ new_sh->is_hashed = TRUE; js_shape_hash_link(ctx->rt, new_sh); js_free_shape(ctx->rt, p->shape); p->shape = new_sh; } } assert(p->shape->header.ref_count == 1); if (add_shape_property(ctx, &p->shape, p, prop, prop_flags)) return NULL; return &p->prop[p->shape->prop_count - 1]; } /* can be called on Array or Arguments objects. return < 0 if memory alloc error. */ static no_inline __exception int convert_fast_array_to_array(JSContext *ctx, JSObject *p) { JSProperty *pr; JSShape *sh; JSValue *tab; uint32_t i, len, new_count; if (js_shape_prepare_update(ctx, p, NULL)) return -1; len = p->u.array.count; /* resize the properties once to simplify the error handling */ sh = p->shape; new_count = sh->prop_count + len; if (new_count > sh->prop_size) { if (resize_properties(ctx, &p->shape, p, new_count)) return -1; } tab = p->u.array.u.values; for(i = 0; i < len; i++) { /* add_property cannot fail here but __JS_AtomFromUInt32(i) fails for i > INT32_MAX */ pr = add_property(ctx, p, __JS_AtomFromUInt32(i), JS_PROP_C_W_E); pr->u.value = *tab++; } js_free(ctx, p->u.array.u.values); p->u.array.count = 0; p->u.array.u.values = NULL; /* fail safe */ p->u.array.u1.size = 0; p->fast_array = 0; return 0; } static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom) { JSShape *sh; JSShapeProperty *pr, *lpr, *prop; JSProperty *pr1; uint32_t lpr_idx; intptr_t h, h1; redo: sh = p->shape; h1 = atom & sh->prop_hash_mask; h = prop_hash_end(sh)[-h1 - 1]; prop = get_shape_prop(sh); lpr = NULL; lpr_idx = 0; /* prevent warning */ while (h != 0) { pr = &prop[h - 1]; if (likely(pr->atom == atom)) { /* found ! */ if (!(pr->flags & JS_PROP_CONFIGURABLE)) return FALSE; /* realloc the shape if needed */ if (lpr) lpr_idx = lpr - get_shape_prop(sh); if (js_shape_prepare_update(ctx, p, &pr)) return -1; sh = p->shape; /* remove property */ if (lpr) { lpr = get_shape_prop(sh) + lpr_idx; lpr->hash_next = pr->hash_next; } else { prop_hash_end(sh)[-h1 - 1] = pr->hash_next; } sh->deleted_prop_count++; /* free the entry */ pr1 = &p->prop[h - 1]; free_property(ctx->rt, pr1, pr->flags); JS_FreeAtom(ctx, pr->atom); /* put default values */ pr->flags = 0; pr->atom = JS_ATOM_NULL; pr1->u.value = JS_UNDEFINED; /* compact the properties if too many deleted properties */ if (sh->deleted_prop_count >= 8 && sh->deleted_prop_count >= ((unsigned)sh->prop_count / 2)) { compact_properties(ctx, p); } return TRUE; } lpr = pr; h = pr->hash_next; } if (p->is_exotic) { if (p->fast_array) { uint32_t idx; if (JS_AtomIsArrayIndex(ctx, &idx, atom) && idx < p->u.array.count) { if (p->class_id == JS_CLASS_ARRAY || p->class_id == JS_CLASS_ARGUMENTS) { /* Special case deleting the last element of a fast Array */ if (idx == p->u.array.count - 1) { JS_FreeValue(ctx, p->u.array.u.values[idx]); p->u.array.count = idx; return TRUE; } if (convert_fast_array_to_array(ctx, p)) return -1; goto redo; } else { return FALSE; } } } else { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; if (em && em->delete_property) { return em->delete_property(ctx, JS_MKPTR(JS_TAG_OBJECT, p), atom); } } } /* not found */ return TRUE; } static int call_setter(JSContext *ctx, JSObject *setter, JSValueConst this_obj, JSValue val, int flags) { JSValue ret, func; if (likely(setter)) { func = JS_MKPTR(JS_TAG_OBJECT, setter); /* Note: the field could be removed in the setter */ func = JS_DupValue(ctx, func); ret = JS_CallFree(ctx, func, this_obj, 1, (JSValueConst *)&val); JS_FreeValue(ctx, val); if (JS_IsException(ret)) return -1; JS_FreeValue(ctx, ret); return TRUE; } else { JS_FreeValue(ctx, val); if ((flags & JS_PROP_THROW) || ((flags & JS_PROP_THROW_STRICT) && is_strict_mode(ctx))) { JS_ThrowTypeError(ctx, "no setter for property"); return -1; } return FALSE; } } /* set the array length and remove the array elements if necessary. */ static int set_array_length(JSContext *ctx, JSObject *p, JSValue val, int flags) { uint32_t len, idx, cur_len; int i, ret; /* Note: this call can reallocate the properties of 'p' */ ret = JS_ToArrayLengthFree(ctx, &len, val, FALSE); if (ret) return -1; /* JS_ToArrayLengthFree() must be done before the read-only test */ if (unlikely(!(p->shape->prop[0].flags & JS_PROP_WRITABLE))) return JS_ThrowTypeErrorReadOnly(ctx, flags, JS_ATOM_length); if (likely(p->fast_array)) { uint32_t old_len = p->u.array.count; if (len < old_len) { for(i = len; i < old_len; i++) { JS_FreeValue(ctx, p->u.array.u.values[i]); } p->u.array.count = len; } p->prop[0].u.value = JS_NewUint32(ctx, len); } else { /* Note: length is always a uint32 because the object is an array */ JS_ToUint32(ctx, &cur_len, p->prop[0].u.value); if (len < cur_len) { uint32_t d; JSShape *sh; JSShapeProperty *pr; d = cur_len - len; sh = p->shape; if (d <= sh->prop_count) { JSAtom atom; /* faster to iterate */ while (cur_len > len) { atom = JS_NewAtomUInt32(ctx, cur_len - 1); ret = delete_property(ctx, p, atom); JS_FreeAtom(ctx, atom); if (unlikely(!ret)) { /* unlikely case: property is not configurable */ break; } cur_len--; } } else { /* faster to iterate thru all the properties. Need two passes in case one of the property is not configurable */ cur_len = len; for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; i++, pr++) { if (pr->atom != JS_ATOM_NULL && JS_AtomIsArrayIndex(ctx, &idx, pr->atom)) { if (idx >= cur_len && !(pr->flags & JS_PROP_CONFIGURABLE)) { cur_len = idx + 1; } } } for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; i++, pr++) { if (pr->atom != JS_ATOM_NULL && JS_AtomIsArrayIndex(ctx, &idx, pr->atom)) { if (idx >= cur_len) { /* remove the property */ delete_property(ctx, p, pr->atom); /* WARNING: the shape may have been modified */ sh = p->shape; pr = get_shape_prop(sh) + i; } } } } } else { cur_len = len; } set_value(ctx, &p->prop[0].u.value, JS_NewUint32(ctx, cur_len)); if (unlikely(cur_len > len)) { return JS_ThrowTypeErrorOrFalse(ctx, flags, "not configurable"); } } return TRUE; } /* return -1 if exception */ static int expand_fast_array(JSContext *ctx, JSObject *p, uint32_t new_len) { uint32_t new_size; size_t slack; JSValue *new_array_prop; /* XXX: potential arithmetic overflow */ new_size = max_int(new_len, p->u.array.u1.size * 3 / 2); new_array_prop = js_realloc2(ctx, p->u.array.u.values, sizeof(JSValue) * new_size, &slack); if (!new_array_prop) return -1; new_size += slack / sizeof(*new_array_prop); p->u.array.u.values = new_array_prop; p->u.array.u1.size = new_size; return 0; } /* Preconditions: 'p' must be of class JS_CLASS_ARRAY, p->fast_array = TRUE and p->extensible = TRUE */ static int add_fast_array_element(JSContext *ctx, JSObject *p, JSValue val, int flags) { uint32_t new_len, array_len; /* extend the array by one */ /* XXX: convert to slow array if new_len > 2^31-1 elements */ new_len = p->u.array.count + 1; /* update the length if necessary. We assume that if the length is not an integer, then if it >= 2^31. */ if (likely(JS_VALUE_GET_TAG(p->prop[0].u.value) == JS_TAG_INT)) { array_len = JS_VALUE_GET_INT(p->prop[0].u.value); if (new_len > array_len) { if (unlikely(!(get_shape_prop(p->shape)->flags & JS_PROP_WRITABLE))) { JS_FreeValue(ctx, val); return JS_ThrowTypeErrorReadOnly(ctx, flags, JS_ATOM_length); } p->prop[0].u.value = JS_NewInt32(ctx, new_len); } } if (unlikely(new_len > p->u.array.u1.size)) { if (expand_fast_array(ctx, p, new_len)) { JS_FreeValue(ctx, val); return -1; } } p->u.array.u.values[new_len - 1] = val; p->u.array.count = new_len; return TRUE; } /* Allocate a new fast array. Its 'length' property is set to zero. It maximum size is 2^31-1 elements. For convenience, 'len' is a 64 bit integer. WARNING: the content of the array is not initialized. */ static JSValue js_allocate_fast_array(JSContext *ctx, int64_t len) { JSValue arr; JSObject *p; if (len > INT32_MAX) return JS_ThrowRangeError(ctx, "invalid array length"); arr = JS_NewArray(ctx); if (JS_IsException(arr)) return arr; if (len > 0) { p = JS_VALUE_GET_OBJ(arr); if (expand_fast_array(ctx, p, len) < 0) { JS_FreeValue(ctx, arr); return JS_EXCEPTION; } p->u.array.count = len; } return arr; } static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc) { JS_FreeValue(ctx, desc->getter); JS_FreeValue(ctx, desc->setter); JS_FreeValue(ctx, desc->value); } /* return -1 in case of exception or TRUE or FALSE. Warning: 'val' is freed by the function. 'flags' is a bitmask of JS_PROP_NO_ADD, JS_PROP_THROW or JS_PROP_THROW_STRICT. If JS_PROP_NO_ADD is set, the new property is not added and an error is raised. 'this_obj' is the receiver. If obj != this_obj, then obj must be an object (Reflect.set case). */ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj, JSAtom prop, JSValue val, JSValueConst this_obj, int flags) { JSObject *p, *p1; JSShapeProperty *prs; JSProperty *pr; uint32_t tag; JSPropertyDescriptor desc; int ret; #if 0 printf("JS_SetPropertyInternal: "); print_atom(ctx, prop); printf("\n"); #endif tag = JS_VALUE_GET_TAG(this_obj); if (unlikely(tag != JS_TAG_OBJECT)) { if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { p = NULL; p1 = JS_VALUE_GET_OBJ(obj); goto prototype_lookup; } else { switch(tag) { case JS_TAG_NULL: JS_FreeValue(ctx, val); JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of null", prop); return -1; case JS_TAG_UNDEFINED: JS_FreeValue(ctx, val); JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of undefined", prop); return -1; default: /* even on a primitive type we can have setters on the prototype */ p = NULL; p1 = JS_VALUE_GET_OBJ(JS_GetPrototypePrimitive(ctx, obj)); goto prototype_lookup; } } } else { p = JS_VALUE_GET_OBJ(this_obj); p1 = JS_VALUE_GET_OBJ(obj); if (unlikely(p != p1)) goto retry2; } /* fast path if obj == this_obj */ retry: prs = find_own_property(&pr, p1, prop); if (prs) { if (likely((prs->flags & (JS_PROP_TMASK | JS_PROP_WRITABLE | JS_PROP_LENGTH)) == JS_PROP_WRITABLE)) { /* fast case */ set_value(ctx, &pr->u.value, val); return TRUE; } else if (prs->flags & JS_PROP_LENGTH) { assert(p->class_id == JS_CLASS_ARRAY); assert(prop == JS_ATOM_length); return set_array_length(ctx, p, val, flags); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { return call_setter(ctx, pr->u.getset.setter, this_obj, val, flags); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { /* JS_PROP_WRITABLE is always true for variable references, but they are write protected in module name spaces. */ if (p->class_id == JS_CLASS_MODULE_NS) goto read_only_prop; set_value(ctx, pr->u.var_ref->pvalue, val); return TRUE; } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* Instantiate property and retry (potentially useless) */ if (JS_AutoInitProperty(ctx, p, prop, pr, prs)) { JS_FreeValue(ctx, val); return -1; } goto retry; } else { goto read_only_prop; } } for(;;) { if (p1->is_exotic) { if (p1->fast_array) { if (__JS_AtomIsTaggedInt(prop)) { uint32_t idx = __JS_AtomToUInt32(prop); if (idx < p1->u.array.count) { if (unlikely(p == p1)) return JS_SetPropertyValue(ctx, this_obj, JS_NewInt32(ctx, idx), val, flags); else break; } else if (p1->class_id >= JS_CLASS_UINT8C_ARRAY && p1->class_id <= JS_CLASS_FLOAT64_ARRAY) { goto typed_array_oob; } } else if (p1->class_id >= JS_CLASS_UINT8C_ARRAY && p1->class_id <= JS_CLASS_FLOAT64_ARRAY) { ret = JS_AtomIsNumericIndex(ctx, prop); if (ret != 0) { if (ret < 0) { JS_FreeValue(ctx, val); return -1; } typed_array_oob: /* must convert the argument even if out of bound access */ if (p1->class_id == JS_CLASS_BIG_INT64_ARRAY || p1->class_id == JS_CLASS_BIG_UINT64_ARRAY) { int64_t v; if (JS_ToBigInt64Free(ctx, &v, val)) return -1; } else { val = JS_ToNumberFree(ctx, val); JS_FreeValue(ctx, val); if (JS_IsException(val)) return -1; } return TRUE; } } } else { const JSClassExoticMethods *em = ctx->rt->class_array[p1->class_id].exotic; if (em) { JSValue obj1; if (em->set_property) { /* set_property can free the prototype */ obj1 = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p1)); ret = em->set_property(ctx, obj1, prop, val, this_obj, flags); JS_FreeValue(ctx, obj1); JS_FreeValue(ctx, val); return ret; } if (em->get_own_property) { /* get_own_property can free the prototype */ obj1 = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p1)); ret = em->get_own_property(ctx, &desc, obj1, prop); JS_FreeValue(ctx, obj1); if (ret < 0) { JS_FreeValue(ctx, val); return ret; } if (ret) { if (desc.flags & JS_PROP_GETSET) { JSObject *setter; if (JS_IsUndefined(desc.setter)) setter = NULL; else setter = JS_VALUE_GET_OBJ(desc.setter); ret = call_setter(ctx, setter, this_obj, val, flags); JS_FreeValue(ctx, desc.getter); JS_FreeValue(ctx, desc.setter); return ret; } else { JS_FreeValue(ctx, desc.value); if (!(desc.flags & JS_PROP_WRITABLE)) goto read_only_prop; if (likely(p == p1)) { ret = JS_DefineProperty(ctx, this_obj, prop, val, JS_UNDEFINED, JS_UNDEFINED, JS_PROP_HAS_VALUE); JS_FreeValue(ctx, val); return ret; } else { break; } } } } } } } p1 = p1->shape->proto; prototype_lookup: if (!p1) break; retry2: prs = find_own_property(&pr, p1, prop); if (prs) { if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { return call_setter(ctx, pr->u.getset.setter, this_obj, val, flags); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* Instantiate property and retry (potentially useless) */ if (JS_AutoInitProperty(ctx, p1, prop, pr, prs)) return -1; goto retry2; } else if (!(prs->flags & JS_PROP_WRITABLE)) { goto read_only_prop; } } } if (unlikely(flags & JS_PROP_NO_ADD)) { JS_FreeValue(ctx, val); JS_ThrowReferenceErrorNotDefined(ctx, prop); return -1; } if (unlikely(!p)) { JS_FreeValue(ctx, val); return JS_ThrowTypeErrorOrFalse(ctx, flags, "not an object"); } if (unlikely(!p->extensible)) { JS_FreeValue(ctx, val); return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible"); } if (likely(p == JS_VALUE_GET_OBJ(obj))) { if (p->is_exotic) { if (p->class_id == JS_CLASS_ARRAY && p->fast_array && __JS_AtomIsTaggedInt(prop)) { uint32_t idx = __JS_AtomToUInt32(prop); if (idx == p->u.array.count) { /* fast case */ return add_fast_array_element(ctx, p, val, flags); } else { goto generic_create_prop; } } else { goto generic_create_prop; } } else { pr = add_property(ctx, p, prop, JS_PROP_C_W_E); if (unlikely(!pr)) { JS_FreeValue(ctx, val); return -1; } pr->u.value = val; return TRUE; } } else { /* generic case: modify the property in this_obj if it already exists */ ret = JS_GetOwnPropertyInternal(ctx, &desc, p, prop); if (ret < 0) { JS_FreeValue(ctx, val); return ret; } if (ret) { if (desc.flags & JS_PROP_GETSET) { JS_FreeValue(ctx, desc.getter); JS_FreeValue(ctx, desc.setter); JS_FreeValue(ctx, val); return JS_ThrowTypeErrorOrFalse(ctx, flags, "setter is forbidden"); } else { JS_FreeValue(ctx, desc.value); if (!(desc.flags & JS_PROP_WRITABLE) || p->class_id == JS_CLASS_MODULE_NS) { read_only_prop: JS_FreeValue(ctx, val); return JS_ThrowTypeErrorReadOnly(ctx, flags, prop); } } ret = JS_DefineProperty(ctx, this_obj, prop, val, JS_UNDEFINED, JS_UNDEFINED, JS_PROP_HAS_VALUE); JS_FreeValue(ctx, val); return ret; } else { generic_create_prop: ret = JS_CreateProperty(ctx, p, prop, val, JS_UNDEFINED, JS_UNDEFINED, flags | JS_PROP_HAS_VALUE | JS_PROP_HAS_ENUMERABLE | JS_PROP_HAS_WRITABLE | JS_PROP_HAS_CONFIGURABLE | JS_PROP_C_W_E); JS_FreeValue(ctx, val); return ret; } } } /* flags can be JS_PROP_THROW or JS_PROP_THROW_STRICT */ static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj, JSValue prop, JSValue val, int flags) { if (likely(JS_VALUE_GET_TAG(this_obj) == JS_TAG_OBJECT && JS_VALUE_GET_TAG(prop) == JS_TAG_INT)) { JSObject *p; uint32_t idx; double d; int32_t v; /* fast path for array access */ p = JS_VALUE_GET_OBJ(this_obj); idx = JS_VALUE_GET_INT(prop); switch(p->class_id) { case JS_CLASS_ARRAY: if (unlikely(idx >= (uint32_t)p->u.array.count)) { JSObject *p1; JSShape *sh1; /* fast path to add an element to the array */ if (idx != (uint32_t)p->u.array.count || !p->fast_array || !p->extensible) goto slow_path; /* check if prototype chain has a numeric property */ p1 = p->shape->proto; while (p1 != NULL) { sh1 = p1->shape; if (p1->class_id == JS_CLASS_ARRAY) { if (unlikely(!p1->fast_array)) goto slow_path; } else if (p1->class_id == JS_CLASS_OBJECT) { if (unlikely(sh1->has_small_array_index)) goto slow_path; } else { goto slow_path; } p1 = sh1->proto; } /* add element */ return add_fast_array_element(ctx, p, val, flags); } set_value(ctx, &p->u.array.u.values[idx], val); break; case JS_CLASS_ARGUMENTS: if (unlikely(idx >= (uint32_t)p->u.array.count)) goto slow_path; set_value(ctx, &p->u.array.u.values[idx], val); break; case JS_CLASS_UINT8C_ARRAY: if (JS_ToUint8ClampFree(ctx, &v, val)) return -1; /* Note: the conversion can detach the typed array, so the array bound check must be done after */ if (unlikely(idx >= (uint32_t)p->u.array.count)) goto ta_out_of_bound; p->u.array.u.uint8_ptr[idx] = v; break; case JS_CLASS_INT8_ARRAY: case JS_CLASS_UINT8_ARRAY: if (JS_ToInt32Free(ctx, &v, val)) return -1; if (unlikely(idx >= (uint32_t)p->u.array.count)) goto ta_out_of_bound; p->u.array.u.uint8_ptr[idx] = v; break; case JS_CLASS_INT16_ARRAY: case JS_CLASS_UINT16_ARRAY: if (JS_ToInt32Free(ctx, &v, val)) return -1; if (unlikely(idx >= (uint32_t)p->u.array.count)) goto ta_out_of_bound; p->u.array.u.uint16_ptr[idx] = v; break; case JS_CLASS_INT32_ARRAY: case JS_CLASS_UINT32_ARRAY: if (JS_ToInt32Free(ctx, &v, val)) return -1; if (unlikely(idx >= (uint32_t)p->u.array.count)) goto ta_out_of_bound; p->u.array.u.uint32_ptr[idx] = v; break; case JS_CLASS_BIG_INT64_ARRAY: case JS_CLASS_BIG_UINT64_ARRAY: /* XXX: need specific conversion function */ { int64_t v; if (JS_ToBigInt64Free(ctx, &v, val)) return -1; if (unlikely(idx >= (uint32_t)p->u.array.count)) goto ta_out_of_bound; p->u.array.u.uint64_ptr[idx] = v; } break; case JS_CLASS_FLOAT32_ARRAY: if (JS_ToFloat64Free(ctx, &d, val)) return -1; if (unlikely(idx >= (uint32_t)p->u.array.count)) goto ta_out_of_bound; p->u.array.u.float_ptr[idx] = d; break; case JS_CLASS_FLOAT64_ARRAY: if (JS_ToFloat64Free(ctx, &d, val)) return -1; if (unlikely(idx >= (uint32_t)p->u.array.count)) { ta_out_of_bound: return TRUE; } p->u.array.u.double_ptr[idx] = d; break; default: goto slow_path; } return TRUE; } else { JSAtom atom; int ret; slow_path: atom = JS_ValueToAtom(ctx, prop); JS_FreeValue(ctx, prop); if (unlikely(atom == JS_ATOM_NULL)) { JS_FreeValue(ctx, val); return -1; } ret = JS_SetPropertyInternal(ctx, this_obj, atom, val, this_obj, flags); JS_FreeAtom(ctx, atom); return ret; } } int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj, uint32_t idx, JSValue val) { return JS_SetPropertyValue(ctx, this_obj, JS_NewUint32(ctx, idx), val, JS_PROP_THROW); } int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj, int64_t idx, JSValue val) { JSAtom prop; int res; if ((uint64_t)idx <= INT32_MAX) { /* fast path for fast arrays */ return JS_SetPropertyValue(ctx, this_obj, JS_NewInt32(ctx, idx), val, JS_PROP_THROW); } prop = JS_NewAtomInt64(ctx, idx); if (prop == JS_ATOM_NULL) { JS_FreeValue(ctx, val); return -1; } res = JS_SetProperty(ctx, this_obj, prop, val); JS_FreeAtom(ctx, prop); return res; } int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj, const char *prop, JSValue val) { JSAtom atom; int ret; atom = JS_NewAtom(ctx, prop); ret = JS_SetPropertyInternal(ctx, this_obj, atom, val, this_obj, JS_PROP_THROW); JS_FreeAtom(ctx, atom); return ret; } /* compute the property flags. For each flag: (JS_PROP_HAS_x forces it, otherwise def_flags is used) Note: makes assumption about the bit pattern of the flags */ static int get_prop_flags(int flags, int def_flags) { int mask; mask = (flags >> JS_PROP_HAS_SHIFT) & JS_PROP_C_W_E; return (flags & mask) | (def_flags & ~mask); } static int JS_CreateProperty(JSContext *ctx, JSObject *p, JSAtom prop, JSValueConst val, JSValueConst getter, JSValueConst setter, int flags) { JSProperty *pr; int ret, prop_flags; /* add a new property or modify an existing exotic one */ if (p->is_exotic) { if (p->class_id == JS_CLASS_ARRAY) { uint32_t idx, len; if (p->fast_array) { if (__JS_AtomIsTaggedInt(prop)) { idx = __JS_AtomToUInt32(prop); if (idx == p->u.array.count) { if (!p->extensible) goto not_extensible; if (flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) goto convert_to_array; prop_flags = get_prop_flags(flags, 0); if (prop_flags != JS_PROP_C_W_E) goto convert_to_array; return add_fast_array_element(ctx, p, JS_DupValue(ctx, val), flags); } else { goto convert_to_array; } } else if (JS_AtomIsArrayIndex(ctx, &idx, prop)) { /* convert the fast array to normal array */ convert_to_array: if (convert_fast_array_to_array(ctx, p)) return -1; goto generic_array; } } else if (JS_AtomIsArrayIndex(ctx, &idx, prop)) { JSProperty *plen; JSShapeProperty *pslen; generic_array: /* update the length field */ plen = &p->prop[0]; JS_ToUint32(ctx, &len, plen->u.value); if ((idx + 1) > len) { pslen = get_shape_prop(p->shape); if (unlikely(!(pslen->flags & JS_PROP_WRITABLE))) return JS_ThrowTypeErrorReadOnly(ctx, flags, JS_ATOM_length); /* XXX: should update the length after defining the property */ len = idx + 1; set_value(ctx, &plen->u.value, JS_NewUint32(ctx, len)); } } } else if (p->class_id >= JS_CLASS_UINT8C_ARRAY && p->class_id <= JS_CLASS_FLOAT64_ARRAY) { ret = JS_AtomIsNumericIndex(ctx, prop); if (ret != 0) { if (ret < 0) return -1; return JS_ThrowTypeErrorOrFalse(ctx, flags, "cannot create numeric index in typed array"); } } else if (!(flags & JS_PROP_NO_EXOTIC)) { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; if (em) { if (em->define_own_property) { return em->define_own_property(ctx, JS_MKPTR(JS_TAG_OBJECT, p), prop, val, getter, setter, flags); } ret = JS_IsExtensible(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); if (ret < 0) return -1; if (!ret) goto not_extensible; } } } if (!p->extensible) { not_extensible: return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible"); } if (flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { prop_flags = (flags & (JS_PROP_CONFIGURABLE | JS_PROP_ENUMERABLE)) | JS_PROP_GETSET; } else { prop_flags = flags & JS_PROP_C_W_E; } pr = add_property(ctx, p, prop, prop_flags); if (unlikely(!pr)) return -1; if (flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { pr->u.getset.getter = NULL; if ((flags & JS_PROP_HAS_GET) && JS_IsFunction(ctx, getter)) { pr->u.getset.getter = JS_VALUE_GET_OBJ(JS_DupValue(ctx, getter)); } pr->u.getset.setter = NULL; if ((flags & JS_PROP_HAS_SET) && JS_IsFunction(ctx, setter)) { pr->u.getset.setter = JS_VALUE_GET_OBJ(JS_DupValue(ctx, setter)); } } else { if (flags & JS_PROP_HAS_VALUE) { pr->u.value = JS_DupValue(ctx, val); } else { pr->u.value = JS_UNDEFINED; } } return TRUE; } /* return FALSE if not OK */ static BOOL check_define_prop_flags(int prop_flags, int flags) { BOOL has_accessor, is_getset; if (!(prop_flags & JS_PROP_CONFIGURABLE)) { if ((flags & (JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE)) == (JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE)) { return FALSE; } if ((flags & JS_PROP_HAS_ENUMERABLE) && (flags & JS_PROP_ENUMERABLE) != (prop_flags & JS_PROP_ENUMERABLE)) return FALSE; } if (flags & (JS_PROP_HAS_VALUE | JS_PROP_HAS_WRITABLE | JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { if (!(prop_flags & JS_PROP_CONFIGURABLE)) { has_accessor = ((flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) != 0); is_getset = ((prop_flags & JS_PROP_TMASK) == JS_PROP_GETSET); if (has_accessor != is_getset) return FALSE; if (!has_accessor && !is_getset && !(prop_flags & JS_PROP_WRITABLE)) { /* not writable: cannot set the writable bit */ if ((flags & (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) == (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) return FALSE; } } } return TRUE; } /* ensure that the shape can be safely modified */ static int js_shape_prepare_update(JSContext *ctx, JSObject *p, JSShapeProperty **pprs) { JSShape *sh; uint32_t idx = 0; /* prevent warning */ sh = p->shape; if (sh->is_hashed) { if (sh->header.ref_count != 1) { if (pprs) idx = *pprs - get_shape_prop(sh); /* clone the shape (the resulting one is no longer hashed) */ sh = js_clone_shape(ctx, sh); if (!sh) return -1; js_free_shape(ctx->rt, p->shape); p->shape = sh; if (pprs) *pprs = get_shape_prop(sh) + idx; } else { js_shape_hash_unlink(ctx->rt, sh); sh->is_hashed = FALSE; } } return 0; } static int js_update_property_flags(JSContext *ctx, JSObject *p, JSShapeProperty **pprs, int flags) { if (flags != (*pprs)->flags) { if (js_shape_prepare_update(ctx, p, pprs)) return -1; (*pprs)->flags = flags; } return 0; } /* allowed flags: JS_PROP_CONFIGURABLE, JS_PROP_WRITABLE, JS_PROP_ENUMERABLE JS_PROP_HAS_GET, JS_PROP_HAS_SET, JS_PROP_HAS_VALUE, JS_PROP_HAS_CONFIGURABLE, JS_PROP_HAS_WRITABLE, JS_PROP_HAS_ENUMERABLE, JS_PROP_THROW, JS_PROP_NO_EXOTIC. If JS_PROP_THROW is set, return an exception instead of FALSE. if JS_PROP_NO_EXOTIC is set, do not call the exotic define_own_property callback. return -1 (exception), FALSE or TRUE. */ int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj, JSAtom prop, JSValueConst val, JSValueConst getter, JSValueConst setter, int flags) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; int mask, res; if (JS_VALUE_GET_TAG(this_obj) != JS_TAG_OBJECT) { JS_ThrowTypeErrorNotAnObject(ctx); return -1; } p = JS_VALUE_GET_OBJ(this_obj); redo_prop_update: prs = find_own_property(&pr, p, prop); if (prs) { /* the range of the Array length property is always tested before */ if ((prs->flags & JS_PROP_LENGTH) && (flags & JS_PROP_HAS_VALUE)) { uint32_t array_length; if (JS_ToArrayLengthFree(ctx, &array_length, JS_DupValue(ctx, val), FALSE)) { return -1; } /* this code relies on the fact that Uint32 are never allocated */ val = (JSValueConst)JS_NewUint32(ctx, array_length); /* prs may have been modified */ prs = find_own_property(&pr, p, prop); assert(prs != NULL); } /* property already exists */ if (!check_define_prop_flags(prs->flags, flags)) { not_configurable: return JS_ThrowTypeErrorOrFalse(ctx, flags, "property is not configurable"); } if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { /* Instantiate property and retry */ if (JS_AutoInitProperty(ctx, p, prop, pr, prs)) return -1; goto redo_prop_update; } if (flags & (JS_PROP_HAS_VALUE | JS_PROP_HAS_WRITABLE | JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { if (flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { JSObject *new_getter, *new_setter; if (JS_IsFunction(ctx, getter)) { new_getter = JS_VALUE_GET_OBJ(getter); } else { new_getter = NULL; } if (JS_IsFunction(ctx, setter)) { new_setter = JS_VALUE_GET_OBJ(setter); } else { new_setter = NULL; } if ((prs->flags & JS_PROP_TMASK) != JS_PROP_GETSET) { if (js_shape_prepare_update(ctx, p, &prs)) return -1; /* convert to getset */ if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { free_var_ref(ctx->rt, pr->u.var_ref); } else { JS_FreeValue(ctx, pr->u.value); } prs->flags = (prs->flags & (JS_PROP_CONFIGURABLE | JS_PROP_ENUMERABLE)) | JS_PROP_GETSET; pr->u.getset.getter = NULL; pr->u.getset.setter = NULL; } else { if (!(prs->flags & JS_PROP_CONFIGURABLE)) { if ((flags & JS_PROP_HAS_GET) && new_getter != pr->u.getset.getter) { goto not_configurable; } if ((flags & JS_PROP_HAS_SET) && new_setter != pr->u.getset.setter) { goto not_configurable; } } } if (flags & JS_PROP_HAS_GET) { if (pr->u.getset.getter) JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.getter)); if (new_getter) JS_DupValue(ctx, getter); pr->u.getset.getter = new_getter; } if (flags & JS_PROP_HAS_SET) { if (pr->u.getset.setter) JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.setter)); if (new_setter) JS_DupValue(ctx, setter); pr->u.getset.setter = new_setter; } } else { if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { /* convert to data descriptor */ if (js_shape_prepare_update(ctx, p, &prs)) return -1; if (pr->u.getset.getter) JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.getter)); if (pr->u.getset.setter) JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, pr->u.getset.setter)); prs->flags &= ~(JS_PROP_TMASK | JS_PROP_WRITABLE); pr->u.value = JS_UNDEFINED; } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { /* Note: JS_PROP_VARREF is always writable */ } else { if ((prs->flags & (JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE)) == 0 && (flags & JS_PROP_HAS_VALUE)) { if (!js_same_value(ctx, val, pr->u.value)) { goto not_configurable; } else { return TRUE; } } } if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { if (flags & JS_PROP_HAS_VALUE) { if (p->class_id == JS_CLASS_MODULE_NS) { /* JS_PROP_WRITABLE is always true for variable references, but they are write protected in module name spaces. */ if (!js_same_value(ctx, val, *pr->u.var_ref->pvalue)) goto not_configurable; } else { /* update the reference */ set_value(ctx, pr->u.var_ref->pvalue, JS_DupValue(ctx, val)); } } /* if writable is set to false, no longer a reference (for mapped arguments) */ if ((flags & (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) == JS_PROP_HAS_WRITABLE) { JSValue val1; if (p->class_id == JS_CLASS_MODULE_NS) { return JS_ThrowTypeErrorOrFalse(ctx, flags, "module namespace properties have writable = false"); } if (js_shape_prepare_update(ctx, p, &prs)) return -1; val1 = JS_DupValue(ctx, *pr->u.var_ref->pvalue); free_var_ref(ctx->rt, pr->u.var_ref); pr->u.value = val1; prs->flags &= ~(JS_PROP_TMASK | JS_PROP_WRITABLE); } } else if (prs->flags & JS_PROP_LENGTH) { if (flags & JS_PROP_HAS_VALUE) { /* Note: no JS code is executable because 'val' is guaranted to be a Uint32 */ res = set_array_length(ctx, p, JS_DupValue(ctx, val), flags); } else { res = TRUE; } /* still need to reset the writable flag if needed. The JS_PROP_LENGTH is kept because the Uint32 test is still done if the length property is read-only. */ if ((flags & (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) == JS_PROP_HAS_WRITABLE) { prs = get_shape_prop(p->shape); if (js_update_property_flags(ctx, p, &prs, prs->flags & ~JS_PROP_WRITABLE)) return -1; } return res; } else { if (flags & JS_PROP_HAS_VALUE) { JS_FreeValue(ctx, pr->u.value); pr->u.value = JS_DupValue(ctx, val); } if (flags & JS_PROP_HAS_WRITABLE) { if (js_update_property_flags(ctx, p, &prs, (prs->flags & ~JS_PROP_WRITABLE) | (flags & JS_PROP_WRITABLE))) return -1; } } } } mask = 0; if (flags & JS_PROP_HAS_CONFIGURABLE) mask |= JS_PROP_CONFIGURABLE; if (flags & JS_PROP_HAS_ENUMERABLE) mask |= JS_PROP_ENUMERABLE; if (js_update_property_flags(ctx, p, &prs, (prs->flags & ~mask) | (flags & mask))) return -1; return TRUE; } /* handle modification of fast array elements */ if (p->fast_array) { uint32_t idx; uint32_t prop_flags; if (p->class_id == JS_CLASS_ARRAY) { if (__JS_AtomIsTaggedInt(prop)) { idx = __JS_AtomToUInt32(prop); if (idx < p->u.array.count) { prop_flags = get_prop_flags(flags, JS_PROP_C_W_E); if (prop_flags != JS_PROP_C_W_E) goto convert_to_slow_array; if (flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET)) { convert_to_slow_array: if (convert_fast_array_to_array(ctx, p)) return -1; else goto redo_prop_update; } if (flags & JS_PROP_HAS_VALUE) { set_value(ctx, &p->u.array.u.values[idx], JS_DupValue(ctx, val)); } return TRUE; } } } else if (p->class_id >= JS_CLASS_UINT8C_ARRAY && p->class_id <= JS_CLASS_FLOAT64_ARRAY) { JSValue num; int ret; if (!__JS_AtomIsTaggedInt(prop)) { /* slow path with to handle all numeric indexes */ num = JS_AtomIsNumericIndex1(ctx, prop); if (JS_IsUndefined(num)) goto typed_array_done; if (JS_IsException(num)) return -1; ret = JS_NumberIsInteger(ctx, num); if (ret < 0) { JS_FreeValue(ctx, num); return -1; } if (!ret) { JS_FreeValue(ctx, num); return JS_ThrowTypeErrorOrFalse(ctx, flags, "non integer index in typed array"); } ret = JS_NumberIsNegativeOrMinusZero(ctx, num); JS_FreeValue(ctx, num); if (ret) { return JS_ThrowTypeErrorOrFalse(ctx, flags, "negative index in typed array"); } if (!__JS_AtomIsTaggedInt(prop)) goto typed_array_oob; } idx = __JS_AtomToUInt32(prop); /* if the typed array is detached, p->u.array.count = 0 */ if (idx >= p->u.array.count) { typed_array_oob: return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound index in typed array"); } prop_flags = get_prop_flags(flags, JS_PROP_ENUMERABLE | JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); if (flags & (JS_PROP_HAS_GET | JS_PROP_HAS_SET) || prop_flags != (JS_PROP_ENUMERABLE | JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE)) { return JS_ThrowTypeErrorOrFalse(ctx, flags, "invalid descriptor flags"); } if (flags & JS_PROP_HAS_VALUE) { return JS_SetPropertyValue(ctx, this_obj, JS_NewInt32(ctx, idx), JS_DupValue(ctx, val), flags); } return TRUE; typed_array_done: ; } } return JS_CreateProperty(ctx, p, prop, val, getter, setter, flags); } static int JS_DefineAutoInitProperty(JSContext *ctx, JSValueConst this_obj, JSAtom prop, JSAutoInitIDEnum id, void *opaque, int flags) { JSObject *p; JSProperty *pr; if (JS_VALUE_GET_TAG(this_obj) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(this_obj); if (find_own_property(&pr, p, prop)) { /* property already exists */ abort(); return FALSE; } /* Specialized CreateProperty */ pr = add_property(ctx, p, prop, (flags & JS_PROP_C_W_E) | JS_PROP_AUTOINIT); if (unlikely(!pr)) return -1; pr->u.init.realm_and_id = (uintptr_t)JS_DupContext(ctx); assert((pr->u.init.realm_and_id & 3) == 0); assert(id <= 3); pr->u.init.realm_and_id |= id; pr->u.init.opaque = opaque; return TRUE; } /* shortcut to add or redefine a new property value */ int JS_DefinePropertyValue(JSContext *ctx, JSValueConst this_obj, JSAtom prop, JSValue val, int flags) { int ret; ret = JS_DefineProperty(ctx, this_obj, prop, val, JS_UNDEFINED, JS_UNDEFINED, flags | JS_PROP_HAS_VALUE | JS_PROP_HAS_CONFIGURABLE | JS_PROP_HAS_WRITABLE | JS_PROP_HAS_ENUMERABLE); JS_FreeValue(ctx, val); return ret; } int JS_DefinePropertyValueValue(JSContext *ctx, JSValueConst this_obj, JSValue prop, JSValue val, int flags) { JSAtom atom; int ret; atom = JS_ValueToAtom(ctx, prop); JS_FreeValue(ctx, prop); if (unlikely(atom == JS_ATOM_NULL)) { JS_FreeValue(ctx, val); return -1; } ret = JS_DefinePropertyValue(ctx, this_obj, atom, val, flags); JS_FreeAtom(ctx, atom); return ret; } int JS_DefinePropertyValueUint32(JSContext *ctx, JSValueConst this_obj, uint32_t idx, JSValue val, int flags) { return JS_DefinePropertyValueValue(ctx, this_obj, JS_NewUint32(ctx, idx), val, flags); } int JS_DefinePropertyValueInt64(JSContext *ctx, JSValueConst this_obj, int64_t idx, JSValue val, int flags) { return JS_DefinePropertyValueValue(ctx, this_obj, JS_NewInt64(ctx, idx), val, flags); } int JS_DefinePropertyValueStr(JSContext *ctx, JSValueConst this_obj, const char *prop, JSValue val, int flags) { JSAtom atom; int ret; atom = JS_NewAtom(ctx, prop); ret = JS_DefinePropertyValue(ctx, this_obj, atom, val, flags); JS_FreeAtom(ctx, atom); return ret; } /* shortcut to add getter & setter */ int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj, JSAtom prop, JSValue getter, JSValue setter, int flags) { int ret; ret = JS_DefineProperty(ctx, this_obj, prop, JS_UNDEFINED, getter, setter, flags | JS_PROP_HAS_GET | JS_PROP_HAS_SET | JS_PROP_HAS_CONFIGURABLE | JS_PROP_HAS_ENUMERABLE); JS_FreeValue(ctx, getter); JS_FreeValue(ctx, setter); return ret; } static int JS_CreateDataPropertyUint32(JSContext *ctx, JSValueConst this_obj, int64_t idx, JSValue val, int flags) { return JS_DefinePropertyValueValue(ctx, this_obj, JS_NewInt64(ctx, idx), val, flags | JS_PROP_CONFIGURABLE | JS_PROP_ENUMERABLE | JS_PROP_WRITABLE); } /* return TRUE if 'obj' has a non empty 'name' string */ static BOOL js_object_has_name(JSContext *ctx, JSValueConst obj) { JSProperty *pr; JSShapeProperty *prs; JSValueConst val; JSString *p; prs = find_own_property(&pr, JS_VALUE_GET_OBJ(obj), JS_ATOM_name); if (!prs) return FALSE; if ((prs->flags & JS_PROP_TMASK) != JS_PROP_NORMAL) return TRUE; val = pr->u.value; if (JS_VALUE_GET_TAG(val) != JS_TAG_STRING) return TRUE; p = JS_VALUE_GET_STRING(val); return (p->len != 0); } static int JS_DefineObjectName(JSContext *ctx, JSValueConst obj, JSAtom name, int flags) { if (name != JS_ATOM_NULL && JS_IsObject(obj) && !js_object_has_name(ctx, obj) && JS_DefinePropertyValue(ctx, obj, JS_ATOM_name, JS_AtomToString(ctx, name), flags) < 0) { return -1; } return 0; } static int JS_DefineObjectNameComputed(JSContext *ctx, JSValueConst obj, JSValueConst str, int flags) { if (JS_IsObject(obj) && !js_object_has_name(ctx, obj)) { JSAtom prop; JSValue name_str; prop = JS_ValueToAtom(ctx, str); if (prop == JS_ATOM_NULL) return -1; name_str = js_get_function_name(ctx, prop); JS_FreeAtom(ctx, prop); if (JS_IsException(name_str)) return -1; if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_name, name_str, flags) < 0) return -1; } return 0; } #define DEFINE_GLOBAL_LEX_VAR (1 << 7) #define DEFINE_GLOBAL_FUNC_VAR (1 << 6) static JSValue JS_ThrowSyntaxErrorVarRedeclaration(JSContext *ctx, JSAtom prop) { return JS_ThrowSyntaxErrorAtom(ctx, "redeclaration of '%s'", prop); } /* flags is 0, DEFINE_GLOBAL_LEX_VAR or DEFINE_GLOBAL_FUNC_VAR */ /* XXX: could support exotic global object. */ static int JS_CheckDefineGlobalVar(JSContext *ctx, JSAtom prop, int flags) { JSObject *p; JSShapeProperty *prs; p = JS_VALUE_GET_OBJ(ctx->global_obj); prs = find_own_property1(p, prop); /* XXX: should handle JS_PROP_AUTOINIT */ if (flags & DEFINE_GLOBAL_LEX_VAR) { if (prs && !(prs->flags & JS_PROP_CONFIGURABLE)) goto fail_redeclaration; } else { if (!prs && !p->extensible) goto define_error; if (flags & DEFINE_GLOBAL_FUNC_VAR) { if (prs) { if (!(prs->flags & JS_PROP_CONFIGURABLE) && ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET || ((prs->flags & (JS_PROP_WRITABLE | JS_PROP_ENUMERABLE)) != (JS_PROP_WRITABLE | JS_PROP_ENUMERABLE)))) { define_error: JS_ThrowTypeErrorAtom(ctx, "cannot define variable '%s'", prop); return -1; } } } } /* check if there already is a lexical declaration */ p = JS_VALUE_GET_OBJ(ctx->global_var_obj); prs = find_own_property1(p, prop); if (prs) { fail_redeclaration: JS_ThrowSyntaxErrorVarRedeclaration(ctx, prop); return -1; } return 0; } /* def_flags is (0, DEFINE_GLOBAL_LEX_VAR) | JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE */ /* XXX: could support exotic global object. */ static int JS_DefineGlobalVar(JSContext *ctx, JSAtom prop, int def_flags) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; JSValue val; int flags; if (def_flags & DEFINE_GLOBAL_LEX_VAR) { p = JS_VALUE_GET_OBJ(ctx->global_var_obj); flags = JS_PROP_ENUMERABLE | (def_flags & JS_PROP_WRITABLE) | JS_PROP_CONFIGURABLE; val = JS_UNINITIALIZED; } else { p = JS_VALUE_GET_OBJ(ctx->global_obj); flags = JS_PROP_ENUMERABLE | JS_PROP_WRITABLE | (def_flags & JS_PROP_CONFIGURABLE); val = JS_UNDEFINED; } prs = find_own_property1(p, prop); if (prs) return 0; if (!p->extensible) return 0; pr = add_property(ctx, p, prop, flags); if (unlikely(!pr)) return -1; pr->u.value = val; return 0; } /* 'def_flags' is 0 or JS_PROP_CONFIGURABLE. */ /* XXX: could support exotic global object. */ static int JS_DefineGlobalFunction(JSContext *ctx, JSAtom prop, JSValueConst func, int def_flags) { JSObject *p; JSShapeProperty *prs; int flags; p = JS_VALUE_GET_OBJ(ctx->global_obj); prs = find_own_property1(p, prop); flags = JS_PROP_HAS_VALUE | JS_PROP_THROW; if (!prs || (prs->flags & JS_PROP_CONFIGURABLE)) { flags |= JS_PROP_ENUMERABLE | JS_PROP_WRITABLE | def_flags | JS_PROP_HAS_CONFIGURABLE | JS_PROP_HAS_WRITABLE | JS_PROP_HAS_ENUMERABLE; } if (JS_DefineProperty(ctx, ctx->global_obj, prop, func, JS_UNDEFINED, JS_UNDEFINED, flags) < 0) return -1; return 0; } static JSValue JS_GetGlobalVar(JSContext *ctx, JSAtom prop, BOOL throw_ref_error) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; /* no exotic behavior is possible in global_var_obj */ p = JS_VALUE_GET_OBJ(ctx->global_var_obj); prs = find_own_property(&pr, p, prop); if (prs) { /* XXX: should handle JS_PROP_TMASK properties */ if (unlikely(JS_IsUninitialized(pr->u.value))) return JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return JS_DupValue(ctx, pr->u.value); } return JS_GetPropertyInternal(ctx, ctx->global_obj, prop, ctx->global_obj, throw_ref_error); } /* construct a reference to a global variable */ static int JS_GetGlobalVarRef(JSContext *ctx, JSAtom prop, JSValue *sp) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; /* no exotic behavior is possible in global_var_obj */ p = JS_VALUE_GET_OBJ(ctx->global_var_obj); prs = find_own_property(&pr, p, prop); if (prs) { /* XXX: should handle JS_PROP_AUTOINIT properties? */ /* XXX: conformance: do these tests in OP_put_var_ref/OP_get_var_ref ? */ if (unlikely(JS_IsUninitialized(pr->u.value))) { JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return -1; } if (unlikely(!(prs->flags & JS_PROP_WRITABLE))) { return JS_ThrowTypeErrorReadOnly(ctx, JS_PROP_THROW, prop); } sp[0] = JS_DupValue(ctx, ctx->global_var_obj); } else { int ret; ret = JS_HasProperty(ctx, ctx->global_obj, prop); if (ret < 0) return -1; if (ret) { sp[0] = JS_DupValue(ctx, ctx->global_obj); } else { sp[0] = JS_UNDEFINED; } } sp[1] = JS_AtomToValue(ctx, prop); return 0; } /* use for strict variable access: test if the variable exists */ static int JS_CheckGlobalVar(JSContext *ctx, JSAtom prop) { JSObject *p; JSShapeProperty *prs; int ret; /* no exotic behavior is possible in global_var_obj */ p = JS_VALUE_GET_OBJ(ctx->global_var_obj); prs = find_own_property1(p, prop); if (prs) { ret = TRUE; } else { ret = JS_HasProperty(ctx, ctx->global_obj, prop); if (ret < 0) return -1; } return ret; } /* flag = 0: normal variable write flag = 1: initialize lexical variable flag = 2: normal variable write, strict check was done before */ static int JS_SetGlobalVar(JSContext *ctx, JSAtom prop, JSValue val, int flag) { JSObject *p; JSShapeProperty *prs; JSProperty *pr; int flags; /* no exotic behavior is possible in global_var_obj */ p = JS_VALUE_GET_OBJ(ctx->global_var_obj); prs = find_own_property(&pr, p, prop); if (prs) { /* XXX: should handle JS_PROP_AUTOINIT properties? */ if (flag != 1) { if (unlikely(JS_IsUninitialized(pr->u.value))) { JS_FreeValue(ctx, val); JS_ThrowReferenceErrorUninitialized(ctx, prs->atom); return -1; } if (unlikely(!(prs->flags & JS_PROP_WRITABLE))) { JS_FreeValue(ctx, val); return JS_ThrowTypeErrorReadOnly(ctx, JS_PROP_THROW, prop); } } set_value(ctx, &pr->u.value, val); return 0; } flags = JS_PROP_THROW_STRICT; if (is_strict_mode(ctx)) flags |= JS_PROP_NO_ADD; return JS_SetPropertyInternal(ctx, ctx->global_obj, prop, val, ctx->global_obj, flags); } /* return -1, FALSE or TRUE. return FALSE if not configurable or invalid object. return -1 in case of exception. flags can be 0, JS_PROP_THROW or JS_PROP_THROW_STRICT */ int JS_DeleteProperty(JSContext *ctx, JSValueConst obj, JSAtom prop, int flags) { JSValue obj1; JSObject *p; int res; obj1 = JS_ToObject(ctx, obj); if (JS_IsException(obj1)) return -1; p = JS_VALUE_GET_OBJ(obj1); res = delete_property(ctx, p, prop); JS_FreeValue(ctx, obj1); if (res != FALSE) return res; if ((flags & JS_PROP_THROW) || ((flags & JS_PROP_THROW_STRICT) && is_strict_mode(ctx))) { JS_ThrowTypeError(ctx, "could not delete property"); return -1; } return FALSE; } int JS_DeletePropertyInt64(JSContext *ctx, JSValueConst obj, int64_t idx, int flags) { JSAtom prop; int res; if ((uint64_t)idx <= JS_ATOM_MAX_INT) { /* fast path for fast arrays */ return JS_DeleteProperty(ctx, obj, __JS_AtomFromUInt32(idx), flags); } prop = JS_NewAtomInt64(ctx, idx); if (prop == JS_ATOM_NULL) return -1; res = JS_DeleteProperty(ctx, obj, prop, flags); JS_FreeAtom(ctx, prop); return res; } BOOL JS_IsFunction(JSContext *ctx, JSValueConst val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(val); switch(p->class_id) { case JS_CLASS_BYTECODE_FUNCTION: return TRUE; case JS_CLASS_PROXY: return p->u.proxy_data->is_func; default: return (ctx->rt->class_array[p->class_id].call != NULL); } } BOOL JS_IsCFunction(JSContext *ctx, JSValueConst val, JSCFunction *func, int magic) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(val); if (p->class_id == JS_CLASS_C_FUNCTION) return (p->u.cfunc.c_function.generic == func && p->u.cfunc.magic == magic); else return FALSE; } BOOL JS_IsConstructor(JSContext *ctx, JSValueConst val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(val); return p->is_constructor; } BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, BOOL val) { JSObject *p; if (JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(func_obj); p->is_constructor = val; return TRUE; } BOOL JS_IsError(JSContext *ctx, JSValueConst val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(val); return (p->class_id == JS_CLASS_ERROR); } /* used to avoid catching interrupt exceptions */ BOOL JS_IsUncatchableError(JSContext *ctx, JSValueConst val) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(val); return p->class_id == JS_CLASS_ERROR && p->is_uncatchable_error; } void JS_SetUncatchableError(JSContext *ctx, JSValueConst val, BOOL flag) { JSObject *p; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return; p = JS_VALUE_GET_OBJ(val); if (p->class_id == JS_CLASS_ERROR) p->is_uncatchable_error = flag; } void JS_ResetUncatchableError(JSContext *ctx) { JS_SetUncatchableError(ctx, ctx->rt->current_exception, FALSE); } void JS_SetOpaque(JSValue obj, void *opaque) { JSObject *p; if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { p = JS_VALUE_GET_OBJ(obj); p->u.opaque = opaque; } } /* return NULL if not an object of class class_id */ void *JS_GetOpaque(JSValueConst obj, JSClassID class_id) { JSObject *p; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return NULL; p = JS_VALUE_GET_OBJ(obj); if (p->class_id != class_id) return NULL; return p->u.opaque; } void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id) { void *p = JS_GetOpaque(obj, class_id); if (unlikely(!p)) { JS_ThrowTypeErrorInvalidClass(ctx, class_id); } return p; } #define HINT_STRING 0 #define HINT_NUMBER 1 #define HINT_NONE 2 /* don't try Symbol.toPrimitive */ #define HINT_FORCE_ORDINARY (1 << 4) static JSValue JS_ToPrimitiveFree(JSContext *ctx, JSValue val, int hint) { int i; BOOL force_ordinary; JSAtom method_name; JSValue method, ret; if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) return val; force_ordinary = hint & HINT_FORCE_ORDINARY; hint &= ~HINT_FORCE_ORDINARY; if (!force_ordinary) { method = JS_GetProperty(ctx, val, JS_ATOM_Symbol_toPrimitive); if (JS_IsException(method)) goto exception; /* ECMA says *If exoticToPrim is not undefined* but tests in test262 use null as a non callable converter */ if (!JS_IsUndefined(method) && !JS_IsNull(method)) { JSAtom atom; JSValue arg; switch(hint) { case HINT_STRING: atom = JS_ATOM_string; break; case HINT_NUMBER: atom = JS_ATOM_number; break; default: case HINT_NONE: atom = JS_ATOM_default; break; } arg = JS_AtomToString(ctx, atom); ret = JS_CallFree(ctx, method, val, 1, (JSValueConst *)&arg); JS_FreeValue(ctx, arg); if (JS_IsException(ret)) goto exception; JS_FreeValue(ctx, val); if (JS_VALUE_GET_TAG(ret) != JS_TAG_OBJECT) return ret; JS_FreeValue(ctx, ret); return JS_ThrowTypeError(ctx, "toPrimitive"); } } if (hint != HINT_STRING) hint = HINT_NUMBER; for(i = 0; i < 2; i++) { if ((i ^ hint) == 0) { method_name = JS_ATOM_toString; } else { method_name = JS_ATOM_valueOf; } method = JS_GetProperty(ctx, val, method_name); if (JS_IsException(method)) goto exception; if (JS_IsFunction(ctx, method)) { ret = JS_CallFree(ctx, method, val, 0, NULL); if (JS_IsException(ret)) goto exception; if (JS_VALUE_GET_TAG(ret) != JS_TAG_OBJECT) { JS_FreeValue(ctx, val); return ret; } JS_FreeValue(ctx, ret); } else { JS_FreeValue(ctx, method); } } JS_ThrowTypeError(ctx, "toPrimitive"); exception: JS_FreeValue(ctx, val); return JS_EXCEPTION; } static JSValue JS_ToPrimitive(JSContext *ctx, JSValueConst val, int hint) { return JS_ToPrimitiveFree(ctx, JS_DupValue(ctx, val), hint); } void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj) { JSObject *p; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return; p = JS_VALUE_GET_OBJ(obj); p->is_HTMLDDA = TRUE; } static inline BOOL JS_IsHTMLDDA(JSContext *ctx, JSValueConst obj) { JSObject *p; if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return FALSE; p = JS_VALUE_GET_OBJ(obj); return p->is_HTMLDDA; } static int JS_ToBoolFree(JSContext *ctx, JSValue val) { uint32_t tag = JS_VALUE_GET_TAG(val); switch(tag) { case JS_TAG_INT: return JS_VALUE_GET_INT(val) != 0; case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: return JS_VALUE_GET_INT(val); case JS_TAG_EXCEPTION: return -1; case JS_TAG_STRING: { BOOL ret = JS_VALUE_GET_STRING(val)->len != 0; JS_FreeValue(ctx, val); return ret; } case JS_TAG_BIG_INT: #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: #endif { JSBigFloat *p = JS_VALUE_GET_PTR(val); BOOL ret; ret = p->num.expn != BF_EXP_ZERO && p->num.expn != BF_EXP_NAN; JS_FreeValue(ctx, val); return ret; } #ifdef CONFIG_BIGNUM case JS_TAG_BIG_DECIMAL: { JSBigDecimal *p = JS_VALUE_GET_PTR(val); BOOL ret; ret = p->num.expn != BF_EXP_ZERO && p->num.expn != BF_EXP_NAN; JS_FreeValue(ctx, val); return ret; } #endif case JS_TAG_OBJECT: { JSObject *p = JS_VALUE_GET_OBJ(val); BOOL ret; ret = !p->is_HTMLDDA; JS_FreeValue(ctx, val); return ret; } break; default: if (JS_TAG_IS_FLOAT64(tag)) { double d = JS_VALUE_GET_FLOAT64(val); return !isnan(d) && d != 0; } else { JS_FreeValue(ctx, val); return TRUE; } } } int JS_ToBool(JSContext *ctx, JSValueConst val) { return JS_ToBoolFree(ctx, JS_DupValue(ctx, val)); } static int skip_spaces(const char *pc) { const uint8_t *p, *p_next, *p_start; uint32_t c; p = p_start = (const uint8_t *)pc; for (;;) { c = *p; if (c < 128) { if (!((c >= 0x09 && c <= 0x0d) || (c == 0x20))) break; p++; } else { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p_next); if (!lre_is_space(c)) break; p = p_next; } } return p - p_start; } static inline int to_digit(int c) { if (c >= '0' && c <= '9') return c - '0'; else if (c >= 'A' && c <= 'Z') return c - 'A' + 10; else if (c >= 'a' && c <= 'z') return c - 'a' + 10; else return 36; } /* XXX: remove */ static double js_strtod(const char *str, int radix, BOOL is_float) { double d; int c; if (!is_float || radix != 10) { const char *p = str; uint64_t n_max, n; int int_exp, is_neg; is_neg = 0; if (*p == '-') { is_neg = 1; p++; } /* skip leading zeros */ while (*p == '0') p++; n = 0; if (radix == 10) n_max = ((uint64_t)-1 - 9) / 10; /* most common case */ else n_max = ((uint64_t)-1 - (radix - 1)) / radix; /* XXX: could be more precise */ int_exp = 0; while (*p != '\0') { c = to_digit((uint8_t)*p); if (c >= radix) break; if (n <= n_max) { n = n * radix + c; } else { if (radix == 10) goto strtod_case; int_exp++; } p++; } d = n; if (int_exp != 0) { d *= pow(radix, int_exp); } if (is_neg) d = -d; } else { strtod_case: d = strtod(str, NULL); } return d; } #define ATOD_INT_ONLY (1 << 0) /* accept Oo and Ob prefixes in addition to 0x prefix if radix = 0 */ #define ATOD_ACCEPT_BIN_OCT (1 << 2) /* accept O prefix as octal if radix == 0 and properly formed (Annex B) */ #define ATOD_ACCEPT_LEGACY_OCTAL (1 << 4) /* accept _ between digits as a digit separator */ #define ATOD_ACCEPT_UNDERSCORES (1 << 5) /* allow a suffix to override the type */ #define ATOD_ACCEPT_SUFFIX (1 << 6) /* default type */ #define ATOD_TYPE_MASK (3 << 7) #define ATOD_TYPE_FLOAT64 (0 << 7) #define ATOD_TYPE_BIG_INT (1 << 7) #ifdef CONFIG_BIGNUM #define ATOD_TYPE_BIG_FLOAT (2 << 7) #define ATOD_TYPE_BIG_DECIMAL (3 << 7) /* assume bigint mode: floats are parsed as integers if no decimal point nor exponent */ #define ATOD_MODE_BIGINT (1 << 9) #endif /* accept -0x1 */ #define ATOD_ACCEPT_PREFIX_AFTER_SIGN (1 << 10) static JSValue js_string_to_bigint(JSContext *ctx, const char *buf, int radix, int flags, slimb_t *pexponent) { bf_t a_s, *a = &a_s; int ret; JSValue val; val = JS_NewBigInt(ctx); if (JS_IsException(val)) return val; a = JS_GetBigInt(val); ret = bf_atof(a, buf, NULL, radix, BF_PREC_INF, BF_RNDZ); if (ret & BF_ST_MEM_ERROR) { JS_FreeValue(ctx, val); return JS_ThrowOutOfMemory(ctx); } #ifdef CONFIG_BIGNUM val = JS_CompactBigInt1(ctx, val, (flags & ATOD_MODE_BIGINT) != 0); #else val = JS_CompactBigInt1(ctx, val, FALSE); #endif return val; } #ifdef CONFIG_BIGNUM static JSValue js_string_to_bigfloat(JSContext *ctx, const char *buf, int radix, int flags, slimb_t *pexponent) { bf_t *a; int ret; JSValue val; val = JS_NewBigFloat(ctx); if (JS_IsException(val)) return val; a = JS_GetBigFloat(val); if (flags & ATOD_ACCEPT_SUFFIX) { /* return the exponent to get infinite precision */ ret = bf_atof2(a, pexponent, buf, NULL, radix, BF_PREC_INF, BF_RNDZ | BF_ATOF_EXPONENT); } else { ret = bf_atof(a, buf, NULL, radix, ctx->fp_env.prec, ctx->fp_env.flags); } if (ret & BF_ST_MEM_ERROR) { JS_FreeValue(ctx, val); return JS_ThrowOutOfMemory(ctx); } return val; } static JSValue js_string_to_bigdecimal(JSContext *ctx, const char *buf, int radix, int flags, slimb_t *pexponent) { bfdec_t *a; int ret; JSValue val; val = JS_NewBigDecimal(ctx); if (JS_IsException(val)) return val; a = JS_GetBigDecimal(val); ret = bfdec_atof(a, buf, NULL, BF_PREC_INF, BF_RNDZ | BF_ATOF_NO_NAN_INF); if (ret & BF_ST_MEM_ERROR) { JS_FreeValue(ctx, val); return JS_ThrowOutOfMemory(ctx); } return val; } #endif /* return an exception in case of memory error. Return JS_NAN if invalid syntax */ #ifdef CONFIG_BIGNUM static JSValue js_atof2(JSContext *ctx, const char *str, const char **pp, int radix, int flags, slimb_t *pexponent) #else static JSValue js_atof(JSContext *ctx, const char *str, const char **pp, int radix, int flags) #endif { const char *p, *p_start; int sep, is_neg; BOOL is_float, has_legacy_octal; int atod_type = flags & ATOD_TYPE_MASK; char buf1[64], *buf; int i, j, len; BOOL buf_allocated = FALSE; JSValue val; /* optional separator between digits */ sep = (flags & ATOD_ACCEPT_UNDERSCORES) ? '_' : 256; has_legacy_octal = FALSE; p = str; p_start = p; is_neg = 0; if (p[0] == '+') { p++; p_start++; if (!(flags & ATOD_ACCEPT_PREFIX_AFTER_SIGN)) goto no_radix_prefix; } else if (p[0] == '-') { p++; p_start++; is_neg = 1; if (!(flags & ATOD_ACCEPT_PREFIX_AFTER_SIGN)) goto no_radix_prefix; } if (p[0] == '0') { if ((p[1] == 'x' || p[1] == 'X') && (radix == 0 || radix == 16)) { p += 2; radix = 16; } else if ((p[1] == 'o' || p[1] == 'O') && radix == 0 && (flags & ATOD_ACCEPT_BIN_OCT)) { p += 2; radix = 8; } else if ((p[1] == 'b' || p[1] == 'B') && radix == 0 && (flags & ATOD_ACCEPT_BIN_OCT)) { p += 2; radix = 2; } else if ((p[1] >= '0' && p[1] <= '9') && radix == 0 && (flags & ATOD_ACCEPT_LEGACY_OCTAL)) { int i; has_legacy_octal = TRUE; sep = 256; for (i = 1; (p[i] >= '0' && p[i] <= '7'); i++) continue; if (p[i] == '8' || p[i] == '9') goto no_prefix; p += 1; radix = 8; } else { goto no_prefix; } /* there must be a digit after the prefix */ if (to_digit((uint8_t)*p) >= radix) goto fail; no_prefix: ; } else { no_radix_prefix: if (!(flags & ATOD_INT_ONLY) && (atod_type == ATOD_TYPE_FLOAT64 #ifdef CONFIG_BIGNUM || atod_type == ATOD_TYPE_BIG_FLOAT #endif ) && strstart(p, "Infinity", &p)) { #ifdef CONFIG_BIGNUM if (atod_type == ATOD_TYPE_BIG_FLOAT) { bf_t *a; val = JS_NewBigFloat(ctx); if (JS_IsException(val)) goto done; a = JS_GetBigFloat(val); bf_set_inf(a, is_neg); } else #endif { double d = 1.0 / 0.0; if (is_neg) d = -d; val = JS_NewFloat64(ctx, d); } goto done; } } if (radix == 0) radix = 10; is_float = FALSE; p_start = p; while (to_digit((uint8_t)*p) < radix || (*p == sep && (radix != 10 || p != p_start + 1 || p[-1] != '0') && to_digit((uint8_t)p[1]) < radix)) { p++; } if (!(flags & ATOD_INT_ONLY)) { if (*p == '.' && (p > p_start || to_digit((uint8_t)p[1]) < radix)) { is_float = TRUE; p++; if (*p == sep) goto fail; while (to_digit((uint8_t)*p) < radix || (*p == sep && to_digit((uint8_t)p[1]) < radix)) p++; } if (p > p_start && (((*p == 'e' || *p == 'E') && radix == 10) || ((*p == 'p' || *p == 'P') && (radix == 2 || radix == 8 || radix == 16)))) { const char *p1 = p + 1; is_float = TRUE; if (*p1 == '+') { p1++; } else if (*p1 == '-') { p1++; } if (is_digit((uint8_t)*p1)) { p = p1 + 1; while (is_digit((uint8_t)*p) || (*p == sep && is_digit((uint8_t)p[1]))) p++; } } } if (p == p_start) goto fail; buf = buf1; buf_allocated = FALSE; len = p - p_start; if (unlikely((len + 2) > sizeof(buf1))) { buf = js_malloc_rt(ctx->rt, len + 2); /* no exception raised */ if (!buf) goto mem_error; buf_allocated = TRUE; } /* remove the separators and the radix prefixes */ j = 0; if (is_neg) buf[j++] = '-'; for (i = 0; i < len; i++) { if (p_start[i] != '_') buf[j++] = p_start[i]; } buf[j] = '\0'; if (flags & ATOD_ACCEPT_SUFFIX) { if (*p == 'n') { p++; atod_type = ATOD_TYPE_BIG_INT; } else #ifdef CONFIG_BIGNUM if (*p == 'l') { p++; atod_type = ATOD_TYPE_BIG_FLOAT; } else if (*p == 'm') { p++; atod_type = ATOD_TYPE_BIG_DECIMAL; } else if (flags & ATOD_MODE_BIGINT) { if (!is_float) atod_type = ATOD_TYPE_BIG_INT; if (has_legacy_octal) goto fail; } else #endif { if (is_float && radix != 10) goto fail; } } else { if (atod_type == ATOD_TYPE_FLOAT64) { #ifdef CONFIG_BIGNUM if (flags & ATOD_MODE_BIGINT) { if (!is_float) atod_type = ATOD_TYPE_BIG_INT; if (has_legacy_octal) goto fail; } else #endif { if (is_float && radix != 10) goto fail; } } } switch(atod_type) { case ATOD_TYPE_FLOAT64: { double d; d = js_strtod(buf, radix, is_float); /* return int or float64 */ val = JS_NewFloat64(ctx, d); } break; case ATOD_TYPE_BIG_INT: if (has_legacy_octal || is_float) goto fail; val = ctx->rt->bigint_ops.from_string(ctx, buf, radix, flags, NULL); break; #ifdef CONFIG_BIGNUM case ATOD_TYPE_BIG_FLOAT: if (has_legacy_octal) goto fail; val = ctx->rt->bigfloat_ops.from_string(ctx, buf, radix, flags, pexponent); break; case ATOD_TYPE_BIG_DECIMAL: if (radix != 10) goto fail; val = ctx->rt->bigdecimal_ops.from_string(ctx, buf, radix, flags, NULL); break; #endif default: abort(); } done: if (buf_allocated) js_free_rt(ctx->rt, buf); if (pp) *pp = p; return val; fail: val = JS_NAN; goto done; mem_error: val = JS_ThrowOutOfMemory(ctx); goto done; } #ifdef CONFIG_BIGNUM static JSValue js_atof(JSContext *ctx, const char *str, const char **pp, int radix, int flags) { return js_atof2(ctx, str, pp, radix, flags, NULL); } #endif typedef enum JSToNumberHintEnum { TON_FLAG_NUMBER, TON_FLAG_NUMERIC, } JSToNumberHintEnum; static JSValue JS_ToNumberHintFree(JSContext *ctx, JSValue val, JSToNumberHintEnum flag) { uint32_t tag; JSValue ret; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_BIG_INT: if (flag != TON_FLAG_NUMERIC) { JS_FreeValue(ctx, val); return JS_ThrowTypeError(ctx, "cannot convert bigint to number"); } ret = val; break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_DECIMAL: if (flag != TON_FLAG_NUMERIC) { JS_FreeValue(ctx, val); return JS_ThrowTypeError(ctx, "cannot convert bigdecimal to number"); } ret = val; break; case JS_TAG_BIG_FLOAT: if (flag != TON_FLAG_NUMERIC) { JS_FreeValue(ctx, val); return JS_ThrowTypeError(ctx, "cannot convert bigfloat to number"); } ret = val; break; #endif case JS_TAG_FLOAT64: case JS_TAG_INT: case JS_TAG_EXCEPTION: ret = val; break; case JS_TAG_BOOL: case JS_TAG_NULL: ret = JS_NewInt32(ctx, JS_VALUE_GET_INT(val)); break; case JS_TAG_UNDEFINED: ret = JS_NAN; break; case JS_TAG_OBJECT: val = JS_ToPrimitiveFree(ctx, val, HINT_NUMBER); if (JS_IsException(val)) return JS_EXCEPTION; goto redo; case JS_TAG_STRING: { const char *str; const char *p; size_t len; str = JS_ToCStringLen(ctx, &len, val); JS_FreeValue(ctx, val); if (!str) return JS_EXCEPTION; p = str; p += skip_spaces(p); if ((p - str) == len) { ret = JS_NewInt32(ctx, 0); } else { int flags = ATOD_ACCEPT_BIN_OCT; ret = js_atof(ctx, p, &p, 0, flags); if (!JS_IsException(ret)) { p += skip_spaces(p); if ((p - str) != len) { JS_FreeValue(ctx, ret); ret = JS_NAN; } } } JS_FreeCString(ctx, str); } break; case JS_TAG_SYMBOL: JS_FreeValue(ctx, val); return JS_ThrowTypeError(ctx, "cannot convert symbol to number"); default: JS_FreeValue(ctx, val); ret = JS_NAN; break; } return ret; } static JSValue JS_ToNumberFree(JSContext *ctx, JSValue val) { return JS_ToNumberHintFree(ctx, val, TON_FLAG_NUMBER); } static JSValue JS_ToNumericFree(JSContext *ctx, JSValue val) { return JS_ToNumberHintFree(ctx, val, TON_FLAG_NUMERIC); } static JSValue JS_ToNumeric(JSContext *ctx, JSValueConst val) { return JS_ToNumericFree(ctx, JS_DupValue(ctx, val)); } static __exception int __JS_ToFloat64Free(JSContext *ctx, double *pres, JSValue val) { double d; uint32_t tag; val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) { *pres = JS_FLOAT64_NAN; return -1; } tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: d = JS_VALUE_GET_INT(val); break; case JS_TAG_FLOAT64: d = JS_VALUE_GET_FLOAT64(val); break; case JS_TAG_BIG_INT: #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: #endif { JSBigFloat *p = JS_VALUE_GET_PTR(val); /* XXX: there can be a double rounding issue with some primitives (such as JS_ToUint8ClampFree()), but it is not critical to fix it. */ bf_get_float64(&p->num, &d, BF_RNDN); JS_FreeValue(ctx, val); } break; default: abort(); } *pres = d; return 0; } static inline int JS_ToFloat64Free(JSContext *ctx, double *pres, JSValue val) { uint32_t tag; tag = JS_VALUE_GET_TAG(val); if (tag <= JS_TAG_NULL) { *pres = JS_VALUE_GET_INT(val); return 0; } else if (JS_TAG_IS_FLOAT64(tag)) { *pres = JS_VALUE_GET_FLOAT64(val); return 0; } else { return __JS_ToFloat64Free(ctx, pres, val); } } int JS_ToFloat64(JSContext *ctx, double *pres, JSValueConst val) { return JS_ToFloat64Free(ctx, pres, JS_DupValue(ctx, val)); } static JSValue JS_ToNumber(JSContext *ctx, JSValueConst val) { return JS_ToNumberFree(ctx, JS_DupValue(ctx, val)); } /* same as JS_ToNumber() but return 0 in case of NaN/Undefined */ static __maybe_unused JSValue JS_ToIntegerFree(JSContext *ctx, JSValue val) { uint32_t tag; JSValue ret; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: ret = JS_NewInt32(ctx, JS_VALUE_GET_INT(val)); break; case JS_TAG_FLOAT64: { double d = JS_VALUE_GET_FLOAT64(val); if (isnan(d)) { ret = JS_NewInt32(ctx, 0); } else { /* convert -0 to +0 */ d = trunc(d) + 0.0; ret = JS_NewFloat64(ctx, d); } } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { bf_t a_s, *a, r_s, *r = &r_s; BOOL is_nan; a = JS_ToBigFloat(ctx, &a_s, val); if (!a) { JS_FreeValue(ctx, val); return JS_EXCEPTION; } if (!bf_is_finite(a)) { is_nan = bf_is_nan(a); if (is_nan) ret = JS_NewInt32(ctx, 0); else ret = JS_DupValue(ctx, val); } else { ret = JS_NewBigInt(ctx); if (!JS_IsException(ret)) { r = JS_GetBigInt(ret); bf_set(r, a); bf_rint(r, BF_RNDZ); ret = JS_CompactBigInt(ctx, ret); } } if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, val); } break; #endif default: val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) return val; goto redo; } return ret; } /* Note: the integer value is satured to 32 bits */ static int JS_ToInt32SatFree(JSContext *ctx, int *pres, JSValue val) { uint32_t tag; int ret; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: ret = JS_VALUE_GET_INT(val); break; case JS_TAG_EXCEPTION: *pres = 0; return -1; case JS_TAG_FLOAT64: { double d = JS_VALUE_GET_FLOAT64(val); if (isnan(d)) { ret = 0; } else { if (d < INT32_MIN) ret = INT32_MIN; else if (d > INT32_MAX) ret = INT32_MAX; else ret = (int)d; } } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); bf_get_int32(&ret, &p->num, 0); JS_FreeValue(ctx, val); } break; #endif default: val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) { *pres = 0; return -1; } goto redo; } *pres = ret; return 0; } int JS_ToInt32Sat(JSContext *ctx, int *pres, JSValueConst val) { return JS_ToInt32SatFree(ctx, pres, JS_DupValue(ctx, val)); } int JS_ToInt32Clamp(JSContext *ctx, int *pres, JSValueConst val, int min, int max, int min_offset) { int res = JS_ToInt32SatFree(ctx, pres, JS_DupValue(ctx, val)); if (res == 0) { if (*pres < min) { *pres += min_offset; if (*pres < min) *pres = min; } else { if (*pres > max) *pres = max; } } return res; } static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val) { uint32_t tag; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: *pres = JS_VALUE_GET_INT(val); return 0; case JS_TAG_EXCEPTION: *pres = 0; return -1; case JS_TAG_FLOAT64: { double d = JS_VALUE_GET_FLOAT64(val); if (isnan(d)) { *pres = 0; } else { if (d < INT64_MIN) *pres = INT64_MIN; else if (d > INT64_MAX) *pres = INT64_MAX; else *pres = (int64_t)d; } } return 0; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); bf_get_int64(pres, &p->num, 0); JS_FreeValue(ctx, val); } return 0; #endif default: val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) { *pres = 0; return -1; } goto redo; } } int JS_ToInt64Sat(JSContext *ctx, int64_t *pres, JSValueConst val) { return JS_ToInt64SatFree(ctx, pres, JS_DupValue(ctx, val)); } int JS_ToInt64Clamp(JSContext *ctx, int64_t *pres, JSValueConst val, int64_t min, int64_t max, int64_t neg_offset) { int res = JS_ToInt64SatFree(ctx, pres, JS_DupValue(ctx, val)); if (res == 0) { if (*pres < 0) *pres += neg_offset; if (*pres < min) *pres = min; else if (*pres > max) *pres = max; } return res; } /* Same as JS_ToInt32Free() but with a 64 bit result. Return (<0, 0) in case of exception */ static int JS_ToInt64Free(JSContext *ctx, int64_t *pres, JSValue val) { uint32_t tag; int64_t ret; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: ret = JS_VALUE_GET_INT(val); break; case JS_TAG_FLOAT64: { JSFloat64Union u; double d; int e; d = JS_VALUE_GET_FLOAT64(val); u.d = d; /* we avoid doing fmod(x, 2^64) */ e = (u.u64 >> 52) & 0x7ff; if (likely(e <= (1023 + 62))) { /* fast case */ ret = (int64_t)d; } else if (e <= (1023 + 62 + 53)) { uint64_t v; /* remainder modulo 2^64 */ v = (u.u64 & (((uint64_t)1 << 52) - 1)) | ((uint64_t)1 << 52); ret = v << ((e - 1023) - 52); /* take the sign into account */ if (u.u64 >> 63) ret = -ret; } else { ret = 0; /* also handles NaN and +inf */ } } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); bf_get_int64(&ret, &p->num, BF_GET_INT_MOD); JS_FreeValue(ctx, val); } break; #endif default: val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) { *pres = 0; return -1; } goto redo; } *pres = ret; return 0; } int JS_ToInt64(JSContext *ctx, int64_t *pres, JSValueConst val) { return JS_ToInt64Free(ctx, pres, JS_DupValue(ctx, val)); } int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValueConst val) { if (JS_IsBigInt(ctx, val)) return JS_ToBigInt64(ctx, pres, val); else return JS_ToInt64(ctx, pres, val); } /* return (<0, 0) in case of exception */ static int JS_ToInt32Free(JSContext *ctx, int32_t *pres, JSValue val) { uint32_t tag; int32_t ret; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: ret = JS_VALUE_GET_INT(val); break; case JS_TAG_FLOAT64: { JSFloat64Union u; double d; int e; d = JS_VALUE_GET_FLOAT64(val); u.d = d; /* we avoid doing fmod(x, 2^32) */ e = (u.u64 >> 52) & 0x7ff; if (likely(e <= (1023 + 30))) { /* fast case */ ret = (int32_t)d; } else if (e <= (1023 + 30 + 53)) { uint64_t v; /* remainder modulo 2^32 */ v = (u.u64 & (((uint64_t)1 << 52) - 1)) | ((uint64_t)1 << 52); v = v << ((e - 1023) - 52 + 32); ret = v >> 32; /* take the sign into account */ if (u.u64 >> 63) ret = -ret; } else { ret = 0; /* also handles NaN and +inf */ } } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); bf_get_int32(&ret, &p->num, BF_GET_INT_MOD); JS_FreeValue(ctx, val); } break; #endif default: val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) { *pres = 0; return -1; } goto redo; } *pres = ret; return 0; } int JS_ToInt32(JSContext *ctx, int32_t *pres, JSValueConst val) { return JS_ToInt32Free(ctx, pres, JS_DupValue(ctx, val)); } static inline int JS_ToUint32Free(JSContext *ctx, uint32_t *pres, JSValue val) { return JS_ToInt32Free(ctx, (int32_t *)pres, val); } static int JS_ToUint8ClampFree(JSContext *ctx, int32_t *pres, JSValue val) { uint32_t tag; int res; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: case JS_TAG_UNDEFINED: res = JS_VALUE_GET_INT(val); #ifdef CONFIG_BIGNUM int_clamp: #endif res = max_int(0, min_int(255, res)); break; case JS_TAG_FLOAT64: { double d = JS_VALUE_GET_FLOAT64(val); if (isnan(d)) { res = 0; } else { if (d < 0) res = 0; else if (d > 255) res = 255; else res = lrint(d); } } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); bf_t r_s, *r = &r_s; bf_init(ctx->bf_ctx, r); bf_set(r, &p->num); bf_rint(r, BF_RNDN); bf_get_int32(&res, r, 0); bf_delete(r); JS_FreeValue(ctx, val); } goto int_clamp; #endif default: val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) { *pres = 0; return -1; } goto redo; } *pres = res; return 0; } static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, JSValue val, BOOL is_array_ctor) { uint32_t tag, len; tag = JS_VALUE_GET_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: { int v; v = JS_VALUE_GET_INT(val); if (v < 0) goto fail; len = v; } break; case JS_TAG_BIG_INT: #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: #endif { JSBigFloat *p = JS_VALUE_GET_PTR(val); bf_t a; BOOL res; bf_get_int32((int32_t *)&len, &p->num, BF_GET_INT_MOD); bf_init(ctx->bf_ctx, &a); bf_set_ui(&a, len); res = bf_cmp_eq(&a, &p->num); bf_delete(&a); JS_FreeValue(ctx, val); if (!res) goto fail; } break; default: if (JS_TAG_IS_FLOAT64(tag)) { double d; d = JS_VALUE_GET_FLOAT64(val); len = (uint32_t)d; if (len != d) goto fail; } else { uint32_t len1; if (is_array_ctor) { val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) return -1; /* cannot recurse because val is a number */ if (JS_ToArrayLengthFree(ctx, &len, val, TRUE)) return -1; } else { /* legacy behavior: must do the conversion twice and compare */ if (JS_ToUint32(ctx, &len, val)) { JS_FreeValue(ctx, val); return -1; } val = JS_ToNumberFree(ctx, val); if (JS_IsException(val)) return -1; /* cannot recurse because val is a number */ if (JS_ToArrayLengthFree(ctx, &len1, val, FALSE)) return -1; if (len1 != len) { fail: JS_ThrowRangeError(ctx, "invalid array length"); return -1; } } } break; } *plen = len; return 0; } #define MAX_SAFE_INTEGER (((int64_t)1 << 53) - 1) static BOOL is_safe_integer(double d) { return isfinite(d) && floor(d) == d && fabs(d) <= (double)MAX_SAFE_INTEGER; } int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValueConst val) { int64_t v; if (JS_ToInt64Sat(ctx, &v, val)) return -1; if (v < 0 || v > MAX_SAFE_INTEGER) { JS_ThrowRangeError(ctx, "invalid array index"); *plen = 0; return -1; } *plen = v; return 0; } /* convert a value to a length between 0 and MAX_SAFE_INTEGER. return -1 for exception */ static __exception int JS_ToLengthFree(JSContext *ctx, int64_t *plen, JSValue val) { int res = JS_ToInt64Clamp(ctx, plen, val, 0, MAX_SAFE_INTEGER, 0); JS_FreeValue(ctx, val); return res; } /* Note: can return an exception */ static int JS_NumberIsInteger(JSContext *ctx, JSValueConst val) { double d; if (!JS_IsNumber(val)) return FALSE; if (unlikely(JS_ToFloat64(ctx, &d, val))) return -1; return isfinite(d) && floor(d) == d; } static BOOL JS_NumberIsNegativeOrMinusZero(JSContext *ctx, JSValueConst val) { uint32_t tag; tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: { int v; v = JS_VALUE_GET_INT(val); return (v < 0); } case JS_TAG_FLOAT64: { JSFloat64Union u; u.d = JS_VALUE_GET_FLOAT64(val); return (u.u64 >> 63); } case JS_TAG_BIG_INT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); /* Note: integer zeros are not necessarily positive */ return p->num.sign && !bf_is_zero(&p->num); } #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); return p->num.sign; } break; case JS_TAG_BIG_DECIMAL: { JSBigDecimal *p = JS_VALUE_GET_PTR(val); return p->num.sign; } break; #endif default: return FALSE; } } static JSValue js_bigint_to_string1(JSContext *ctx, JSValueConst val, int radix) { JSValue ret; bf_t a_s, *a; char *str; int saved_sign; a = JS_ToBigInt(ctx, &a_s, val); if (!a) return JS_EXCEPTION; saved_sign = a->sign; if (a->expn == BF_EXP_ZERO) a->sign = 0; str = bf_ftoa(NULL, a, radix, 0, BF_RNDZ | BF_FTOA_FORMAT_FRAC | BF_FTOA_JS_QUIRKS); a->sign = saved_sign; JS_FreeBigInt(ctx, a, &a_s); if (!str) return JS_ThrowOutOfMemory(ctx); ret = JS_NewString(ctx, str); bf_free(ctx->bf_ctx, str); return ret; } static JSValue js_bigint_to_string(JSContext *ctx, JSValueConst val) { return js_bigint_to_string1(ctx, val, 10); } #ifdef CONFIG_BIGNUM static JSValue js_ftoa(JSContext *ctx, JSValueConst val1, int radix, limb_t prec, bf_flags_t flags) { JSValue val, ret; bf_t a_s, *a; char *str; int saved_sign; val = JS_ToNumeric(ctx, val1); if (JS_IsException(val)) return val; a = JS_ToBigFloat(ctx, &a_s, val); if (!a) { JS_FreeValue(ctx, val); return JS_EXCEPTION; } saved_sign = a->sign; if (a->expn == BF_EXP_ZERO) a->sign = 0; flags |= BF_FTOA_JS_QUIRKS; if ((flags & BF_FTOA_FORMAT_MASK) == BF_FTOA_FORMAT_FREE_MIN) { /* Note: for floating point numbers with a radix which is not a power of two, the current precision is used to compute the number of digits. */ if ((radix & (radix - 1)) != 0) { bf_t r_s, *r = &r_s; int prec, flags1; /* must round first */ if (JS_VALUE_GET_TAG(val) == JS_TAG_BIG_FLOAT) { prec = ctx->fp_env.prec; flags1 = ctx->fp_env.flags & (BF_FLAG_SUBNORMAL | (BF_EXP_BITS_MASK << BF_EXP_BITS_SHIFT)); } else { prec = 53; flags1 = bf_set_exp_bits(11) | BF_FLAG_SUBNORMAL; } bf_init(ctx->bf_ctx, r); bf_set(r, a); bf_round(r, prec, flags1 | BF_RNDN); str = bf_ftoa(NULL, r, radix, prec, flags1 | flags); bf_delete(r); } else { str = bf_ftoa(NULL, a, radix, BF_PREC_INF, flags); } } else { str = bf_ftoa(NULL, a, radix, prec, flags); } a->sign = saved_sign; if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, val); if (!str) return JS_ThrowOutOfMemory(ctx); ret = JS_NewString(ctx, str); bf_free(ctx->bf_ctx, str); return ret; } static JSValue js_bigfloat_to_string(JSContext *ctx, JSValueConst val) { return js_ftoa(ctx, val, 10, 0, BF_RNDN | BF_FTOA_FORMAT_FREE_MIN); } static JSValue js_bigdecimal_to_string1(JSContext *ctx, JSValueConst val, limb_t prec, int flags) { JSValue ret; bfdec_t *a; char *str; int saved_sign; a = JS_ToBigDecimal(ctx, val); if (!a) return JS_EXCEPTION; saved_sign = a->sign; if (a->expn == BF_EXP_ZERO) a->sign = 0; str = bfdec_ftoa(NULL, a, prec, flags | BF_FTOA_JS_QUIRKS); a->sign = saved_sign; if (!str) return JS_ThrowOutOfMemory(ctx); ret = JS_NewString(ctx, str); bf_free(ctx->bf_ctx, str); return ret; } static JSValue js_bigdecimal_to_string(JSContext *ctx, JSValueConst val) { return js_bigdecimal_to_string1(ctx, val, 0, BF_RNDZ | BF_FTOA_FORMAT_FREE); } #endif /* CONFIG_BIGNUM */ /* 2 <= base <= 36 */ static char *i64toa(char *buf_end, int64_t n, unsigned int base) { char *q = buf_end; int digit, is_neg; is_neg = 0; if (n < 0) { is_neg = 1; n = -n; } *--q = '\0'; do { digit = (uint64_t)n % base; n = (uint64_t)n / base; if (digit < 10) digit += '0'; else digit += 'a' - 10; *--q = digit; } while (n != 0); if (is_neg) *--q = '-'; return q; } /* buf1 contains the printf result */ static void js_ecvt1(double d, int n_digits, int *decpt, int *sign, char *buf, int rounding_mode, char *buf1, int buf1_size) { if (rounding_mode != FE_TONEAREST) fesetround(rounding_mode); snprintf(buf1, buf1_size, "%+.*e", n_digits - 1, d); if (rounding_mode != FE_TONEAREST) fesetround(FE_TONEAREST); *sign = (buf1[0] == '-'); /* mantissa */ buf[0] = buf1[1]; if (n_digits > 1) memcpy(buf + 1, buf1 + 3, n_digits - 1); buf[n_digits] = '\0'; /* exponent */ *decpt = atoi(buf1 + n_digits + 2 + (n_digits > 1)) + 1; } /* maximum buffer size for js_dtoa */ #define JS_DTOA_BUF_SIZE 128 /* needed because ecvt usually limits the number of digits to 17. Return the number of digits. */ static int js_ecvt(double d, int n_digits, int *decpt, int *sign, char *buf, BOOL is_fixed) { int rounding_mode; char buf_tmp[JS_DTOA_BUF_SIZE]; if (!is_fixed) { unsigned int n_digits_min, n_digits_max; /* find the minimum amount of digits (XXX: inefficient but simple) */ n_digits_min = 1; n_digits_max = 17; while (n_digits_min < n_digits_max) { n_digits = (n_digits_min + n_digits_max) / 2; js_ecvt1(d, n_digits, decpt, sign, buf, FE_TONEAREST, buf_tmp, sizeof(buf_tmp)); if (strtod(buf_tmp, NULL) == d) { /* no need to keep the trailing zeros */ while (n_digits >= 2 && buf[n_digits - 1] == '0') n_digits--; n_digits_max = n_digits; } else { n_digits_min = n_digits + 1; } } n_digits = n_digits_max; rounding_mode = FE_TONEAREST; } else { rounding_mode = FE_TONEAREST; #ifdef CONFIG_PRINTF_RNDN { char buf1[JS_DTOA_BUF_SIZE], buf2[JS_DTOA_BUF_SIZE]; int decpt1, sign1, decpt2, sign2; /* The JS rounding is specified as round to nearest ties away from zero (RNDNA), but in printf the "ties" case is not specified (for example it is RNDN for glibc, RNDNA for Windows), so we must round manually. */ js_ecvt1(d, n_digits + 1, &decpt1, &sign1, buf1, FE_TONEAREST, buf_tmp, sizeof(buf_tmp)); /* XXX: could use 2 digits to reduce the average running time */ if (buf1[n_digits] == '5') { js_ecvt1(d, n_digits + 1, &decpt1, &sign1, buf1, FE_DOWNWARD, buf_tmp, sizeof(buf_tmp)); js_ecvt1(d, n_digits + 1, &decpt2, &sign2, buf2, FE_UPWARD, buf_tmp, sizeof(buf_tmp)); if (memcmp(buf1, buf2, n_digits + 1) == 0 && decpt1 == decpt2) { /* exact result: round away from zero */ if (sign1) rounding_mode = FE_DOWNWARD; else rounding_mode = FE_UPWARD; } } } #endif /* CONFIG_PRINTF_RNDN */ } js_ecvt1(d, n_digits, decpt, sign, buf, rounding_mode, buf_tmp, sizeof(buf_tmp)); return n_digits; } static int js_fcvt1(char *buf, int buf_size, double d, int n_digits, int rounding_mode) { int n; if (rounding_mode != FE_TONEAREST) fesetround(rounding_mode); n = snprintf(buf, buf_size, "%.*f", n_digits, d); if (rounding_mode != FE_TONEAREST) fesetround(FE_TONEAREST); assert(n < buf_size); return n; } static void js_fcvt(char *buf, int buf_size, double d, int n_digits) { int rounding_mode; rounding_mode = FE_TONEAREST; #ifdef CONFIG_PRINTF_RNDN { int n1, n2; char buf1[JS_DTOA_BUF_SIZE]; char buf2[JS_DTOA_BUF_SIZE]; /* The JS rounding is specified as round to nearest ties away from zero (RNDNA), but in printf the "ties" case is not specified (for example it is RNDN for glibc, RNDNA for Windows), so we must round manually. */ n1 = js_fcvt1(buf1, sizeof(buf1), d, n_digits + 1, FE_TONEAREST); rounding_mode = FE_TONEAREST; /* XXX: could use 2 digits to reduce the average running time */ if (buf1[n1 - 1] == '5') { n1 = js_fcvt1(buf1, sizeof(buf1), d, n_digits + 1, FE_DOWNWARD); n2 = js_fcvt1(buf2, sizeof(buf2), d, n_digits + 1, FE_UPWARD); if (n1 == n2 && memcmp(buf1, buf2, n1) == 0) { /* exact result: round away from zero */ if (buf1[0] == '-') rounding_mode = FE_DOWNWARD; else rounding_mode = FE_UPWARD; } } } #endif /* CONFIG_PRINTF_RNDN */ js_fcvt1(buf, buf_size, d, n_digits, rounding_mode); } /* radix != 10 is only supported with flags = JS_DTOA_VAR_FORMAT */ /* use as many digits as necessary */ #define JS_DTOA_VAR_FORMAT (0 << 0) /* use n_digits significant digits (1 <= n_digits <= 101) */ #define JS_DTOA_FIXED_FORMAT (1 << 0) /* force fractional format: [-]dd.dd with n_digits fractional digits */ #define JS_DTOA_FRAC_FORMAT (2 << 0) /* force exponential notation either in fixed or variable format */ #define JS_DTOA_FORCE_EXP (1 << 2) /* XXX: slow and maybe not fully correct. Use libbf when it is fast enough. XXX: radix != 10 is only supported for small integers */ static void js_dtoa1(char *buf, double d, int radix, int n_digits, int flags) { char *q; if (!isfinite(d)) { if (isnan(d)) { strcpy(buf, "NaN"); } else { q = buf; if (d < 0) *q++ = '-'; strcpy(q, "Infinity"); } } else if (flags == JS_DTOA_VAR_FORMAT) { int64_t i64; char buf1[70], *ptr; i64 = (int64_t)d; if (d != i64 || i64 > MAX_SAFE_INTEGER || i64 < -MAX_SAFE_INTEGER) goto generic_conv; /* fast path for integers */ ptr = i64toa(buf1 + sizeof(buf1), i64, radix); strcpy(buf, ptr); } else { if (d == 0.0) d = 0.0; /* convert -0 to 0 */ if (flags == JS_DTOA_FRAC_FORMAT) { js_fcvt(buf, JS_DTOA_BUF_SIZE, d, n_digits); } else { char buf1[JS_DTOA_BUF_SIZE]; int sign, decpt, k, n, i, p, n_max; BOOL is_fixed; generic_conv: is_fixed = ((flags & 3) == JS_DTOA_FIXED_FORMAT); if (is_fixed) { n_max = n_digits; } else { n_max = 21; } /* the number has k digits (k >= 1) */ k = js_ecvt(d, n_digits, &decpt, &sign, buf1, is_fixed); n = decpt; /* d=10^(n-k)*(buf1) i.e. d= < x.yyyy 10^(n-1) */ q = buf; if (sign) *q++ = '-'; if (flags & JS_DTOA_FORCE_EXP) goto force_exp; if (n >= 1 && n <= n_max) { if (k <= n) { memcpy(q, buf1, k); q += k; for(i = 0; i < (n - k); i++) *q++ = '0'; *q = '\0'; } else { /* k > n */ memcpy(q, buf1, n); q += n; *q++ = '.'; for(i = 0; i < (k - n); i++) *q++ = buf1[n + i]; *q = '\0'; } } else if (n >= -5 && n <= 0) { *q++ = '0'; *q++ = '.'; for(i = 0; i < -n; i++) *q++ = '0'; memcpy(q, buf1, k); q += k; *q = '\0'; } else { force_exp: /* exponential notation */ *q++ = buf1[0]; if (k > 1) { *q++ = '.'; for(i = 1; i < k; i++) *q++ = buf1[i]; } *q++ = 'e'; p = n - 1; if (p >= 0) *q++ = '+'; sprintf(q, "%d", p); } } } } static JSValue js_dtoa(JSContext *ctx, double d, int radix, int n_digits, int flags) { char buf[JS_DTOA_BUF_SIZE]; js_dtoa1(buf, d, radix, n_digits, flags); return JS_NewString(ctx, buf); } JSValue JS_ToStringInternal(JSContext *ctx, JSValueConst val, BOOL is_ToPropertyKey) { uint32_t tag; const char *str; char buf[32]; tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_STRING: return JS_DupValue(ctx, val); case JS_TAG_INT: snprintf(buf, sizeof(buf), "%d", JS_VALUE_GET_INT(val)); str = buf; goto new_string; case JS_TAG_BOOL: return JS_AtomToString(ctx, JS_VALUE_GET_BOOL(val) ? JS_ATOM_true : JS_ATOM_false); case JS_TAG_NULL: return JS_AtomToString(ctx, JS_ATOM_null); case JS_TAG_UNDEFINED: return JS_AtomToString(ctx, JS_ATOM_undefined); case JS_TAG_EXCEPTION: return JS_EXCEPTION; case JS_TAG_OBJECT: { JSValue val1, ret; val1 = JS_ToPrimitive(ctx, val, HINT_STRING); if (JS_IsException(val1)) return val1; ret = JS_ToStringInternal(ctx, val1, is_ToPropertyKey); JS_FreeValue(ctx, val1); return ret; } break; case JS_TAG_FUNCTION_BYTECODE: str = "[function bytecode]"; goto new_string; case JS_TAG_SYMBOL: if (is_ToPropertyKey) { return JS_DupValue(ctx, val); } else { return JS_ThrowTypeError(ctx, "cannot convert symbol to string"); } case JS_TAG_FLOAT64: return js_dtoa(ctx, JS_VALUE_GET_FLOAT64(val), 10, 0, JS_DTOA_VAR_FORMAT); case JS_TAG_BIG_INT: return ctx->rt->bigint_ops.to_string(ctx, val); #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: return ctx->rt->bigfloat_ops.to_string(ctx, val); case JS_TAG_BIG_DECIMAL: return ctx->rt->bigdecimal_ops.to_string(ctx, val); #endif default: str = "[unsupported type]"; new_string: return JS_NewString(ctx, str); } } JSValue JS_ToString(JSContext *ctx, JSValueConst val) { return JS_ToStringInternal(ctx, val, FALSE); } static JSValue JS_ToStringFree(JSContext *ctx, JSValue val) { JSValue ret; ret = JS_ToString(ctx, val); JS_FreeValue(ctx, val); return ret; } static JSValue JS_ToLocaleStringFree(JSContext *ctx, JSValue val) { if (JS_IsUndefined(val) || JS_IsNull(val)) return JS_ToStringFree(ctx, val); return JS_InvokeFree(ctx, val, JS_ATOM_toLocaleString, 0, NULL); } JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val) { return JS_ToStringInternal(ctx, val, TRUE); } static JSValue JS_ToStringCheckObject(JSContext *ctx, JSValueConst val) { uint32_t tag = JS_VALUE_GET_TAG(val); if (tag == JS_TAG_NULL || tag == JS_TAG_UNDEFINED) return JS_ThrowTypeError(ctx, "null or undefined are forbidden"); return JS_ToString(ctx, val); } static JSValue JS_ToQuotedString(JSContext *ctx, JSValueConst val1) { JSValue val; JSString *p; int i; uint32_t c; StringBuffer b_s, *b = &b_s; char buf[16]; val = JS_ToStringCheckObject(ctx, val1); if (JS_IsException(val)) return val; p = JS_VALUE_GET_STRING(val); if (string_buffer_init(ctx, b, p->len + 2)) goto fail; if (string_buffer_putc8(b, '\"')) goto fail; for(i = 0; i < p->len; ) { c = string_getc(p, &i); switch(c) { case '\t': c = 't'; goto quote; case '\r': c = 'r'; goto quote; case '\n': c = 'n'; goto quote; case '\b': c = 'b'; goto quote; case '\f': c = 'f'; goto quote; case '\"': case '\\': quote: if (string_buffer_putc8(b, '\\')) goto fail; if (string_buffer_putc8(b, c)) goto fail; break; default: if (c < 32 || (c >= 0xd800 && c < 0xe000)) { snprintf(buf, sizeof(buf), "\\u%04x", c); if (string_buffer_puts8(b, buf)) goto fail; } else { if (string_buffer_putc(b, c)) goto fail; } break; } } if (string_buffer_putc8(b, '\"')) goto fail; JS_FreeValue(ctx, val); return string_buffer_end(b); fail: JS_FreeValue(ctx, val); string_buffer_free(b); return JS_EXCEPTION; } static __maybe_unused void JS_DumpObjectHeader(JSRuntime *rt) { printf("%14s %4s %4s %14s %10s %s\n", "ADDRESS", "REFS", "SHRF", "PROTO", "CLASS", "PROPS"); } /* for debug only: dump an object without side effect */ static __maybe_unused void JS_DumpObject(JSRuntime *rt, JSObject *p) { uint32_t i; char atom_buf[ATOM_GET_STR_BUF_SIZE]; JSShape *sh; JSShapeProperty *prs; JSProperty *pr; BOOL is_first = TRUE; /* XXX: should encode atoms with special characters */ sh = p->shape; /* the shape can be NULL while freeing an object */ printf("%14p %4d ", (void *)p, p->header.ref_count); if (sh) { printf("%3d%c %14p ", sh->header.ref_count, " *"[sh->is_hashed], (void *)sh->proto); } else { printf("%3s %14s ", "-", "-"); } printf("%10s ", JS_AtomGetStrRT(rt, atom_buf, sizeof(atom_buf), rt->class_array[p->class_id].class_name)); if (p->is_exotic && p->fast_array) { printf("[ "); for(i = 0; i < p->u.array.count; i++) { if (i != 0) printf(", "); switch (p->class_id) { case JS_CLASS_ARRAY: case JS_CLASS_ARGUMENTS: JS_DumpValueShort(rt, p->u.array.u.values[i]); break; case JS_CLASS_UINT8C_ARRAY: case JS_CLASS_INT8_ARRAY: case JS_CLASS_UINT8_ARRAY: case JS_CLASS_INT16_ARRAY: case JS_CLASS_UINT16_ARRAY: case JS_CLASS_INT32_ARRAY: case JS_CLASS_UINT32_ARRAY: case JS_CLASS_BIG_INT64_ARRAY: case JS_CLASS_BIG_UINT64_ARRAY: case JS_CLASS_FLOAT32_ARRAY: case JS_CLASS_FLOAT64_ARRAY: { int size = 1 << typed_array_size_log2(p->class_id); const uint8_t *b = p->u.array.u.uint8_ptr + i * size; while (size-- > 0) printf("%02X", *b++); } break; } } printf(" ] "); } if (sh) { printf("{ "); for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { if (prs->atom != JS_ATOM_NULL) { pr = &p->prop[i]; if (!is_first) printf(", "); printf("%s: ", JS_AtomGetStrRT(rt, atom_buf, sizeof(atom_buf), prs->atom)); if ((prs->flags & JS_PROP_TMASK) == JS_PROP_GETSET) { printf("[getset %p %p]", (void *)pr->u.getset.getter, (void *)pr->u.getset.setter); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_VARREF) { printf("[varref %p]", (void *)pr->u.var_ref); } else if ((prs->flags & JS_PROP_TMASK) == JS_PROP_AUTOINIT) { printf("[autoinit %p %d %p]", (void *)js_autoinit_get_realm(pr), js_autoinit_get_id(pr), (void *)pr->u.init.opaque); } else { JS_DumpValueShort(rt, pr->u.value); } is_first = FALSE; } } printf(" }"); } if (js_class_has_bytecode(p->class_id)) { JSFunctionBytecode *b = p->u.func.function_bytecode; JSVarRef **var_refs; if (b->closure_var_count) { var_refs = p->u.func.var_refs; printf(" Closure:"); for(i = 0; i < b->closure_var_count; i++) { printf(" "); JS_DumpValueShort(rt, var_refs[i]->value); } if (p->u.func.home_object) { printf(" HomeObject: "); JS_DumpValueShort(rt, JS_MKPTR(JS_TAG_OBJECT, p->u.func.home_object)); } } } printf("\n"); } static __maybe_unused void JS_DumpGCObject(JSRuntime *rt, JSGCObjectHeader *p) { if (p->gc_obj_type == JS_GC_OBJ_TYPE_JS_OBJECT) { JS_DumpObject(rt, (JSObject *)p); } else { printf("%14p %4d ", (void *)p, p->ref_count); switch(p->gc_obj_type) { case JS_GC_OBJ_TYPE_FUNCTION_BYTECODE: printf("[function bytecode]"); break; case JS_GC_OBJ_TYPE_SHAPE: printf("[shape]"); break; case JS_GC_OBJ_TYPE_VAR_REF: printf("[var_ref]"); break; case JS_GC_OBJ_TYPE_ASYNC_FUNCTION: printf("[async_function]"); break; case JS_GC_OBJ_TYPE_JS_CONTEXT: printf("[js_context]"); break; default: printf("[unknown %d]", p->gc_obj_type); break; } printf("\n"); } } static __maybe_unused void JS_DumpValueShort(JSRuntime *rt, JSValueConst val) { uint32_t tag = JS_VALUE_GET_NORM_TAG(val); const char *str; switch(tag) { case JS_TAG_INT: printf("%d", JS_VALUE_GET_INT(val)); break; case JS_TAG_BOOL: if (JS_VALUE_GET_BOOL(val)) str = "true"; else str = "false"; goto print_str; case JS_TAG_NULL: str = "null"; goto print_str; case JS_TAG_EXCEPTION: str = "exception"; goto print_str; case JS_TAG_UNINITIALIZED: str = "uninitialized"; goto print_str; case JS_TAG_UNDEFINED: str = "undefined"; print_str: printf("%s", str); break; case JS_TAG_FLOAT64: printf("%.14g", JS_VALUE_GET_FLOAT64(val)); break; case JS_TAG_BIG_INT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); char *str; str = bf_ftoa(NULL, &p->num, 10, 0, BF_RNDZ | BF_FTOA_FORMAT_FRAC); printf("%sn", str); bf_realloc(&rt->bf_ctx, str, 0); } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p = JS_VALUE_GET_PTR(val); char *str; str = bf_ftoa(NULL, &p->num, 16, BF_PREC_INF, BF_RNDZ | BF_FTOA_FORMAT_FREE | BF_FTOA_ADD_PREFIX); printf("%sl", str); bf_free(&rt->bf_ctx, str); } break; case JS_TAG_BIG_DECIMAL: { JSBigDecimal *p = JS_VALUE_GET_PTR(val); char *str; str = bfdec_ftoa(NULL, &p->num, BF_PREC_INF, BF_RNDZ | BF_FTOA_FORMAT_FREE); printf("%sm", str); bf_free(&rt->bf_ctx, str); } break; #endif case JS_TAG_STRING: { JSString *p; p = JS_VALUE_GET_STRING(val); JS_DumpString(rt, p); } break; case JS_TAG_FUNCTION_BYTECODE: { JSFunctionBytecode *b = JS_VALUE_GET_PTR(val); char buf[ATOM_GET_STR_BUF_SIZE]; printf("[bytecode %s]", JS_AtomGetStrRT(rt, buf, sizeof(buf), b->func_name)); } break; case JS_TAG_OBJECT: { JSObject *p = JS_VALUE_GET_OBJ(val); JSAtom atom = rt->class_array[p->class_id].class_name; char atom_buf[ATOM_GET_STR_BUF_SIZE]; printf("[%s %p]", JS_AtomGetStrRT(rt, atom_buf, sizeof(atom_buf), atom), (void *)p); } break; case JS_TAG_SYMBOL: { JSAtomStruct *p = JS_VALUE_GET_PTR(val); char atom_buf[ATOM_GET_STR_BUF_SIZE]; printf("Symbol(%s)", JS_AtomGetStrRT(rt, atom_buf, sizeof(atom_buf), js_get_atom_index(rt, p))); } break; case JS_TAG_MODULE: printf("[module]"); break; default: printf("[unknown tag %d]", tag); break; } } static __maybe_unused void JS_DumpValue(JSContext *ctx, JSValueConst val) { JS_DumpValueShort(ctx->rt, val); } static __maybe_unused void JS_PrintValue(JSContext *ctx, const char *str, JSValueConst val) { printf("%s=", str); JS_DumpValueShort(ctx->rt, val); printf("\n"); } /* return -1 if exception (proxy case) or TRUE/FALSE */ int JS_IsArray(JSContext *ctx, JSValueConst val) { JSObject *p; if (JS_VALUE_GET_TAG(val) == JS_TAG_OBJECT) { p = JS_VALUE_GET_OBJ(val); if (unlikely(p->class_id == JS_CLASS_PROXY)) return js_proxy_isArray(ctx, val); else return p->class_id == JS_CLASS_ARRAY; } else { return FALSE; } } static double js_pow(double a, double b) { if (unlikely(!isfinite(b)) && fabs(a) == 1) { /* not compatible with IEEE 754 */ return JS_FLOAT64_NAN; } else { return pow(a, b); } } JSValue JS_NewBigInt64_1(JSContext *ctx, int64_t v) { JSValue val; bf_t *a; val = JS_NewBigInt(ctx); if (JS_IsException(val)) return val; a = JS_GetBigInt(val); if (bf_set_si(a, v)) { JS_FreeValue(ctx, val); return JS_ThrowOutOfMemory(ctx); } return val; } JSValue JS_NewBigInt64(JSContext *ctx, int64_t v) { if (is_math_mode(ctx) && v >= -MAX_SAFE_INTEGER && v <= MAX_SAFE_INTEGER) { return JS_NewInt64(ctx, v); } else { return JS_NewBigInt64_1(ctx, v); } } JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v) { JSValue val; if (is_math_mode(ctx) && v <= MAX_SAFE_INTEGER) { val = JS_NewInt64(ctx, v); } else { bf_t *a; val = JS_NewBigInt(ctx); if (JS_IsException(val)) return val; a = JS_GetBigInt(val); if (bf_set_ui(a, v)) { JS_FreeValue(ctx, val); return JS_ThrowOutOfMemory(ctx); } } return val; } /* return NaN if bad bigint literal */ static JSValue JS_StringToBigInt(JSContext *ctx, JSValue val) { const char *str, *p; size_t len; int flags; str = JS_ToCStringLen(ctx, &len, val); JS_FreeValue(ctx, val); if (!str) return JS_EXCEPTION; p = str; p += skip_spaces(p); if ((p - str) == len) { val = JS_NewBigInt64(ctx, 0); } else { flags = ATOD_INT_ONLY | ATOD_ACCEPT_BIN_OCT | ATOD_TYPE_BIG_INT; #ifdef CONFIG_BIGNUM if (is_math_mode(ctx)) flags |= ATOD_MODE_BIGINT; #endif val = js_atof(ctx, p, &p, 0, flags); p += skip_spaces(p); if (!JS_IsException(val)) { if ((p - str) != len) { JS_FreeValue(ctx, val); val = JS_NAN; } } } JS_FreeCString(ctx, str); return val; } static JSValue JS_StringToBigIntErr(JSContext *ctx, JSValue val) { val = JS_StringToBigInt(ctx, val); if (JS_VALUE_IS_NAN(val)) return JS_ThrowSyntaxError(ctx, "invalid bigint literal"); return val; } /* if the returned bigfloat is allocated it is equal to 'buf'. Otherwise it is a pointer to the bigfloat in 'val'. */ static bf_t *JS_ToBigIntFree(JSContext *ctx, bf_t *buf, JSValue val) { uint32_t tag; bf_t *r; JSBigFloat *p; redo: tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_NULL: case JS_TAG_UNDEFINED: if (!is_math_mode(ctx)) goto fail; /* fall tru */ case JS_TAG_BOOL: r = buf; bf_init(ctx->bf_ctx, r); bf_set_si(r, JS_VALUE_GET_INT(val)); break; case JS_TAG_FLOAT64: { double d = JS_VALUE_GET_FLOAT64(val); if (!is_math_mode(ctx)) goto fail; if (!isfinite(d)) goto fail; r = buf; bf_init(ctx->bf_ctx, r); d = trunc(d); bf_set_float64(r, d); } break; case JS_TAG_BIG_INT: p = JS_VALUE_GET_PTR(val); r = &p->num; break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: if (!is_math_mode(ctx)) goto fail; p = JS_VALUE_GET_PTR(val); if (!bf_is_finite(&p->num)) goto fail; r = buf; bf_init(ctx->bf_ctx, r); bf_set(r, &p->num); bf_rint(r, BF_RNDZ); JS_FreeValue(ctx, val); break; #endif case JS_TAG_STRING: val = JS_StringToBigIntErr(ctx, val); if (JS_IsException(val)) return NULL; goto redo; case JS_TAG_OBJECT: val = JS_ToPrimitiveFree(ctx, val, HINT_NUMBER); if (JS_IsException(val)) return NULL; goto redo; default: fail: JS_FreeValue(ctx, val); JS_ThrowTypeError(ctx, "cannot convert to bigint"); return NULL; } return r; } static bf_t *JS_ToBigInt(JSContext *ctx, bf_t *buf, JSValueConst val) { return JS_ToBigIntFree(ctx, buf, JS_DupValue(ctx, val)); } static __maybe_unused JSValue JS_ToBigIntValueFree(JSContext *ctx, JSValue val) { if (JS_VALUE_GET_TAG(val) == JS_TAG_BIG_INT) { return val; } else { bf_t a_s, *a, *r; int ret; JSValue res; res = JS_NewBigInt(ctx); if (JS_IsException(res)) return JS_EXCEPTION; a = JS_ToBigIntFree(ctx, &a_s, val); if (!a) { JS_FreeValue(ctx, res); return JS_EXCEPTION; } r = JS_GetBigInt(res); ret = bf_set(r, a); JS_FreeBigInt(ctx, a, &a_s); if (ret) { JS_FreeValue(ctx, res); return JS_ThrowOutOfMemory(ctx); } return JS_CompactBigInt(ctx, res); } } /* free the bf_t allocated by JS_ToBigInt */ static void JS_FreeBigInt(JSContext *ctx, bf_t *a, bf_t *buf) { if (a == buf) { bf_delete(a); } else { JSBigFloat *p = (JSBigFloat *)((uint8_t *)a - offsetof(JSBigFloat, num)); JS_FreeValue(ctx, JS_MKPTR(JS_TAG_BIG_INT, p)); } } /* XXX: merge with JS_ToInt64Free with a specific flag */ static int JS_ToBigInt64Free(JSContext *ctx, int64_t *pres, JSValue val) { bf_t a_s, *a; a = JS_ToBigIntFree(ctx, &a_s, val); if (!a) { *pres = 0; return -1; } bf_get_int64(pres, a, BF_GET_INT_MOD); JS_FreeBigInt(ctx, a, &a_s); return 0; } int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val) { return JS_ToBigInt64Free(ctx, pres, JS_DupValue(ctx, val)); } static JSBigFloat *js_new_bf(JSContext *ctx) { JSBigFloat *p; p = js_malloc(ctx, sizeof(*p)); if (!p) return NULL; p->header.ref_count = 1; bf_init(ctx->bf_ctx, &p->num); return p; } static JSValue JS_NewBigInt(JSContext *ctx) { JSBigFloat *p; p = js_malloc(ctx, sizeof(*p)); if (!p) return JS_EXCEPTION; p->header.ref_count = 1; bf_init(ctx->bf_ctx, &p->num); return JS_MKPTR(JS_TAG_BIG_INT, p); } static JSValue JS_CompactBigInt1(JSContext *ctx, JSValue val, BOOL convert_to_safe_integer) { int64_t v; bf_t *a; if (JS_VALUE_GET_TAG(val) != JS_TAG_BIG_INT) return val; /* fail safe */ a = JS_GetBigInt(val); if (convert_to_safe_integer && bf_get_int64(&v, a, 0) == 0 && v >= -MAX_SAFE_INTEGER && v <= MAX_SAFE_INTEGER) { JS_FreeValue(ctx, val); return JS_NewInt64(ctx, v); } else if (a->expn == BF_EXP_ZERO && a->sign) { JSBigFloat *p = JS_VALUE_GET_PTR(val); assert(p->header.ref_count == 1); a->sign = 0; } return val; } /* Convert the big int to a safe integer if in math mode. normalize the zero representation. Could also be used to convert the bigint to a short bigint value. The reference count of the value must be 1. Cannot fail */ static JSValue JS_CompactBigInt(JSContext *ctx, JSValue val) { return JS_CompactBigInt1(ctx, val, is_math_mode(ctx)); } static JSValue throw_bf_exception(JSContext *ctx, int status) { const char *str; if (status & BF_ST_MEM_ERROR) return JS_ThrowOutOfMemory(ctx); if (status & BF_ST_DIVIDE_ZERO) { str = "division by zero"; } else if (status & BF_ST_INVALID_OP) { str = "invalid operation"; } else { str = "integer overflow"; } return JS_ThrowRangeError(ctx, "%s", str); } /* if the returned bigfloat is allocated it is equal to 'buf'. Otherwise it is a pointer to the bigfloat in 'val'. Return NULL in case of error. */ static bf_t *JS_ToBigFloat(JSContext *ctx, bf_t *buf, JSValueConst val) { uint32_t tag; bf_t *r; JSBigFloat *p; tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_INT: case JS_TAG_BOOL: case JS_TAG_NULL: r = buf; bf_init(ctx->bf_ctx, r); if (bf_set_si(r, JS_VALUE_GET_INT(val))) goto fail; break; case JS_TAG_FLOAT64: r = buf; bf_init(ctx->bf_ctx, r); if (bf_set_float64(r, JS_VALUE_GET_FLOAT64(val))) { fail: bf_delete(r); return NULL; } break; case JS_TAG_BIG_INT: #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: #endif p = JS_VALUE_GET_PTR(val); r = &p->num; break; case JS_TAG_UNDEFINED: default: r = buf; bf_init(ctx->bf_ctx, r); bf_set_nan(r); break; } return r; } #ifdef CONFIG_BIGNUM /* return NULL if invalid type */ static bfdec_t *JS_ToBigDecimal(JSContext *ctx, JSValueConst val) { uint32_t tag; JSBigDecimal *p; bfdec_t *r; tag = JS_VALUE_GET_NORM_TAG(val); switch(tag) { case JS_TAG_BIG_DECIMAL: p = JS_VALUE_GET_PTR(val); r = &p->num; break; default: JS_ThrowTypeError(ctx, "bigdecimal expected"); r = NULL; break; } return r; } static JSValue JS_NewBigFloat(JSContext *ctx) { JSBigFloat *p; p = js_malloc(ctx, sizeof(*p)); if (!p) return JS_EXCEPTION; p->header.ref_count = 1; bf_init(ctx->bf_ctx, &p->num); return JS_MKPTR(JS_TAG_BIG_FLOAT, p); } static JSValue JS_NewBigDecimal(JSContext *ctx) { JSBigDecimal *p; p = js_malloc(ctx, sizeof(*p)); if (!p) return JS_EXCEPTION; p->header.ref_count = 1; bfdec_init(ctx->bf_ctx, &p->num); return JS_MKPTR(JS_TAG_BIG_DECIMAL, p); } /* must be kept in sync with JSOverloadableOperatorEnum */ /* XXX: use atoms ? */ static const char js_overloadable_operator_names[JS_OVOP_COUNT][4] = { "+", "-", "*", "/", "%", "**", "|", "&", "^", "<<", ">>", ">>>", "==", "<", "pos", "neg", "++", "--", "~", }; static int get_ovop_from_opcode(OPCodeEnum op) { switch(op) { case OP_add: return JS_OVOP_ADD; case OP_sub: return JS_OVOP_SUB; case OP_mul: return JS_OVOP_MUL; case OP_div: return JS_OVOP_DIV; case OP_mod: case OP_math_mod: return JS_OVOP_MOD; case OP_pow: return JS_OVOP_POW; case OP_or: return JS_OVOP_OR; case OP_and: return JS_OVOP_AND; case OP_xor: return JS_OVOP_XOR; case OP_shl: return JS_OVOP_SHL; case OP_sar: return JS_OVOP_SAR; case OP_shr: return JS_OVOP_SHR; case OP_eq: case OP_neq: return JS_OVOP_EQ; case OP_lt: case OP_lte: case OP_gt: case OP_gte: return JS_OVOP_LESS; case OP_plus: return JS_OVOP_POS; case OP_neg: return JS_OVOP_NEG; case OP_inc: return JS_OVOP_INC; case OP_dec: return JS_OVOP_DEC; default: abort(); } } /* return NULL if not present */ static JSObject *find_binary_op(JSBinaryOperatorDef *def, uint32_t operator_index, JSOverloadableOperatorEnum op) { JSBinaryOperatorDefEntry *ent; int i; for(i = 0; i < def->count; i++) { ent = &def->tab[i]; if (ent->operator_index == operator_index) return ent->ops[op]; } return NULL; } /* return -1 if exception, 0 if no operator overloading, 1 if overloaded operator called */ static __exception int js_call_binary_op_fallback(JSContext *ctx, JSValue *pret, JSValueConst op1, JSValueConst op2, OPCodeEnum op, BOOL is_numeric, int hint) { JSValue opset1_obj, opset2_obj, method, ret, new_op1, new_op2; JSOperatorSetData *opset1, *opset2; JSOverloadableOperatorEnum ovop; JSObject *p; JSValueConst args[2]; if (!ctx->allow_operator_overloading) return 0; opset2_obj = JS_UNDEFINED; opset1_obj = JS_GetProperty(ctx, op1, JS_ATOM_Symbol_operatorSet); if (JS_IsException(opset1_obj)) goto exception; if (JS_IsUndefined(opset1_obj)) return 0; opset1 = JS_GetOpaque2(ctx, opset1_obj, JS_CLASS_OPERATOR_SET); if (!opset1) goto exception; opset2_obj = JS_GetProperty(ctx, op2, JS_ATOM_Symbol_operatorSet); if (JS_IsException(opset2_obj)) goto exception; if (JS_IsUndefined(opset2_obj)) { JS_FreeValue(ctx, opset1_obj); return 0; } opset2 = JS_GetOpaque2(ctx, opset2_obj, JS_CLASS_OPERATOR_SET); if (!opset2) goto exception; if (opset1->is_primitive && opset2->is_primitive) { JS_FreeValue(ctx, opset1_obj); JS_FreeValue(ctx, opset2_obj); return 0; } ovop = get_ovop_from_opcode(op); if (opset1->operator_counter == opset2->operator_counter) { p = opset1->self_ops[ovop]; } else if (opset1->operator_counter > opset2->operator_counter) { p = find_binary_op(&opset1->left, opset2->operator_counter, ovop); } else { p = find_binary_op(&opset2->right, opset1->operator_counter, ovop); } if (!p) { JS_ThrowTypeError(ctx, "operator %s: no function defined", js_overloadable_operator_names[ovop]); goto exception; } if (opset1->is_primitive) { if (is_numeric) { new_op1 = JS_ToNumeric(ctx, op1); } else { new_op1 = JS_ToPrimitive(ctx, op1, hint); } if (JS_IsException(new_op1)) goto exception; } else { new_op1 = JS_DupValue(ctx, op1); } if (opset2->is_primitive) { if (is_numeric) { new_op2 = JS_ToNumeric(ctx, op2); } else { new_op2 = JS_ToPrimitive(ctx, op2, hint); } if (JS_IsException(new_op2)) { JS_FreeValue(ctx, new_op1); goto exception; } } else { new_op2 = JS_DupValue(ctx, op2); } /* XXX: could apply JS_ToPrimitive() if primitive type so that the operator function does not get a value object */ method = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); if (ovop == JS_OVOP_LESS && (op == OP_lte || op == OP_gt)) { args[0] = new_op2; args[1] = new_op1; } else { args[0] = new_op1; args[1] = new_op2; } ret = JS_CallFree(ctx, method, JS_UNDEFINED, 2, args); JS_FreeValue(ctx, new_op1); JS_FreeValue(ctx, new_op2); if (JS_IsException(ret)) goto exception; if (ovop == JS_OVOP_EQ) { BOOL res = JS_ToBoolFree(ctx, ret); if (op == OP_neq) res ^= 1; ret = JS_NewBool(ctx, res); } else if (ovop == JS_OVOP_LESS) { if (JS_IsUndefined(ret)) { ret = JS_FALSE; } else { BOOL res = JS_ToBoolFree(ctx, ret); if (op == OP_lte || op == OP_gte) res ^= 1; ret = JS_NewBool(ctx, res); } } JS_FreeValue(ctx, opset1_obj); JS_FreeValue(ctx, opset2_obj); *pret = ret; return 1; exception: JS_FreeValue(ctx, opset1_obj); JS_FreeValue(ctx, opset2_obj); *pret = JS_UNDEFINED; return -1; } /* try to call the operation on the operatorSet field of 'obj'. Only used for "/" and "**" on the BigInt prototype in math mode */ static __exception int js_call_binary_op_simple(JSContext *ctx, JSValue *pret, JSValueConst obj, JSValueConst op1, JSValueConst op2, OPCodeEnum op) { JSValue opset1_obj, method, ret, new_op1, new_op2; JSOperatorSetData *opset1; JSOverloadableOperatorEnum ovop; JSObject *p; JSValueConst args[2]; opset1_obj = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_operatorSet); if (JS_IsException(opset1_obj)) goto exception; if (JS_IsUndefined(opset1_obj)) return 0; opset1 = JS_GetOpaque2(ctx, opset1_obj, JS_CLASS_OPERATOR_SET); if (!opset1) goto exception; ovop = get_ovop_from_opcode(op); p = opset1->self_ops[ovop]; if (!p) { JS_FreeValue(ctx, opset1_obj); return 0; } new_op1 = JS_ToNumeric(ctx, op1); if (JS_IsException(new_op1)) goto exception; new_op2 = JS_ToNumeric(ctx, op2); if (JS_IsException(new_op2)) { JS_FreeValue(ctx, new_op1); goto exception; } method = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); args[0] = new_op1; args[1] = new_op2; ret = JS_CallFree(ctx, method, JS_UNDEFINED, 2, args); JS_FreeValue(ctx, new_op1); JS_FreeValue(ctx, new_op2); if (JS_IsException(ret)) goto exception; JS_FreeValue(ctx, opset1_obj); *pret = ret; return 1; exception: JS_FreeValue(ctx, opset1_obj); *pret = JS_UNDEFINED; return -1; } /* return -1 if exception, 0 if no operator overloading, 1 if overloaded operator called */ static __exception int js_call_unary_op_fallback(JSContext *ctx, JSValue *pret, JSValueConst op1, OPCodeEnum op) { JSValue opset1_obj, method, ret; JSOperatorSetData *opset1; JSOverloadableOperatorEnum ovop; JSObject *p; if (!ctx->allow_operator_overloading) return 0; opset1_obj = JS_GetProperty(ctx, op1, JS_ATOM_Symbol_operatorSet); if (JS_IsException(opset1_obj)) goto exception; if (JS_IsUndefined(opset1_obj)) return 0; opset1 = JS_GetOpaque2(ctx, opset1_obj, JS_CLASS_OPERATOR_SET); if (!opset1) goto exception; if (opset1->is_primitive) { JS_FreeValue(ctx, opset1_obj); return 0; } ovop = get_ovop_from_opcode(op); p = opset1->self_ops[ovop]; if (!p) { JS_ThrowTypeError(ctx, "no overloaded operator %s", js_overloadable_operator_names[ovop]); goto exception; } method = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p)); ret = JS_CallFree(ctx, method, JS_UNDEFINED, 1, &op1); if (JS_IsException(ret)) goto exception; JS_FreeValue(ctx, opset1_obj); *pret = ret; return 1; exception: JS_FreeValue(ctx, opset1_obj); *pret = JS_UNDEFINED; return -1; } static int js_unary_arith_bigfloat(JSContext *ctx, JSValue *pres, OPCodeEnum op, JSValue op1) { bf_t a_s, *r, *a; int ret, v; JSValue res; if (op == OP_plus && !is_math_mode(ctx)) { JS_ThrowTypeError(ctx, "bigfloat argument with unary +"); JS_FreeValue(ctx, op1); return -1; } res = JS_NewBigFloat(ctx); if (JS_IsException(res)) { JS_FreeValue(ctx, op1); return -1; } r = JS_GetBigFloat(res); a = JS_ToBigFloat(ctx, &a_s, op1); if (!a) { JS_FreeValue(ctx, res); JS_FreeValue(ctx, op1); return -1; } ret = 0; switch(op) { case OP_inc: case OP_dec: v = 2 * (op - OP_dec) - 1; ret = bf_add_si(r, a, v, ctx->fp_env.prec, ctx->fp_env.flags); break; case OP_plus: ret = bf_set(r, a); break; case OP_neg: ret = bf_set(r, a); bf_neg(r); break; default: abort(); } if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, op1); if (unlikely(ret & BF_ST_MEM_ERROR)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } *pres = res; return 0; } static int js_unary_arith_bigdecimal(JSContext *ctx, JSValue *pres, OPCodeEnum op, JSValue op1) { bfdec_t *r, *a; int ret, v; JSValue res; if (op == OP_plus && !is_math_mode(ctx)) { JS_ThrowTypeError(ctx, "bigdecimal argument with unary +"); JS_FreeValue(ctx, op1); return -1; } res = JS_NewBigDecimal(ctx); if (JS_IsException(res)) { JS_FreeValue(ctx, op1); return -1; } r = JS_GetBigDecimal(res); a = JS_ToBigDecimal(ctx, op1); if (!a) { JS_FreeValue(ctx, res); JS_FreeValue(ctx, op1); return -1; } ret = 0; switch(op) { case OP_inc: case OP_dec: v = 2 * (op - OP_dec) - 1; ret = bfdec_add_si(r, a, v, BF_PREC_INF, BF_RNDZ); break; case OP_plus: ret = bfdec_set(r, a); break; case OP_neg: ret = bfdec_set(r, a); bfdec_neg(r); break; default: abort(); } JS_FreeValue(ctx, op1); if (unlikely(ret)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } *pres = res; return 0; } #endif /* CONFIG_BIGNUM */ static int js_unary_arith_bigint(JSContext *ctx, JSValue *pres, OPCodeEnum op, JSValue op1) { bf_t a_s, *r, *a; int ret, v; JSValue res; if (op == OP_plus && !is_math_mode(ctx)) { JS_ThrowTypeError(ctx, "bigint argument with unary +"); JS_FreeValue(ctx, op1); return -1; } res = JS_NewBigInt(ctx); if (JS_IsException(res)) { JS_FreeValue(ctx, op1); return -1; } r = JS_GetBigInt(res); a = JS_ToBigInt(ctx, &a_s, op1); if (!a) { JS_FreeValue(ctx, res); JS_FreeValue(ctx, op1); return -1; } ret = 0; switch(op) { case OP_inc: case OP_dec: v = 2 * (op - OP_dec) - 1; ret = bf_add_si(r, a, v, BF_PREC_INF, BF_RNDZ); break; case OP_plus: ret = bf_set(r, a); break; case OP_neg: ret = bf_set(r, a); bf_neg(r); break; case OP_not: ret = bf_add_si(r, a, 1, BF_PREC_INF, BF_RNDZ); bf_neg(r); break; default: abort(); } JS_FreeBigInt(ctx, a, &a_s); JS_FreeValue(ctx, op1); if (unlikely(ret)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } res = JS_CompactBigInt(ctx, res); *pres = res; return 0; } static no_inline __exception int js_unary_arith_slow(JSContext *ctx, JSValue *sp, OPCodeEnum op) { JSValue op1; int v; uint32_t tag; op1 = sp[-1]; /* fast path for float64 */ if (JS_TAG_IS_FLOAT64(JS_VALUE_GET_TAG(op1))) goto handle_float64; #ifdef CONFIG_BIGNUM if (JS_IsObject(op1)) { JSValue val; int ret = js_call_unary_op_fallback(ctx, &val, op1, op); if (ret < 0) return -1; if (ret) { JS_FreeValue(ctx, op1); sp[-1] = val; return 0; } } #endif op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) goto exception; tag = JS_VALUE_GET_TAG(op1); switch(tag) { case JS_TAG_INT: { int64_t v64; v64 = JS_VALUE_GET_INT(op1); switch(op) { case OP_inc: case OP_dec: v = 2 * (op - OP_dec) - 1; v64 += v; break; case OP_plus: break; case OP_neg: if (v64 == 0) { sp[-1] = __JS_NewFloat64(ctx, -0.0); return 0; } else { v64 = -v64; } break; default: abort(); } sp[-1] = JS_NewInt64(ctx, v64); } break; case JS_TAG_BIG_INT: handle_bigint: if (ctx->rt->bigint_ops.unary_arith(ctx, sp - 1, op, op1)) goto exception; break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: if (ctx->rt->bigfloat_ops.unary_arith(ctx, sp - 1, op, op1)) goto exception; break; case JS_TAG_BIG_DECIMAL: if (ctx->rt->bigdecimal_ops.unary_arith(ctx, sp - 1, op, op1)) goto exception; break; #endif default: handle_float64: { double d; if (is_math_mode(ctx)) goto handle_bigint; d = JS_VALUE_GET_FLOAT64(op1); switch(op) { case OP_inc: case OP_dec: v = 2 * (op - OP_dec) - 1; d += v; break; case OP_plus: break; case OP_neg: d = -d; break; default: abort(); } sp[-1] = __JS_NewFloat64(ctx, d); } break; } return 0; exception: sp[-1] = JS_UNDEFINED; return -1; } static __exception int js_post_inc_slow(JSContext *ctx, JSValue *sp, OPCodeEnum op) { JSValue op1; /* XXX: allow custom operators */ op1 = sp[-1]; op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { sp[-1] = JS_UNDEFINED; return -1; } sp[-1] = op1; sp[0] = JS_DupValue(ctx, op1); return js_unary_arith_slow(ctx, sp + 1, op - OP_post_dec + OP_dec); } static no_inline int js_not_slow(JSContext *ctx, JSValue *sp) { JSValue op1; op1 = sp[-1]; #ifdef CONFIG_BIGNUM if (JS_IsObject(op1)) { JSValue val; int ret = js_call_unary_op_fallback(ctx, &val, op1, OP_not); if (ret < 0) return -1; if (ret) { JS_FreeValue(ctx, op1); sp[-1] = val; return 0; } } #endif op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) goto exception; if (is_math_mode(ctx) || JS_VALUE_GET_TAG(op1) == JS_TAG_BIG_INT) { if (ctx->rt->bigint_ops.unary_arith(ctx, sp - 1, OP_not, op1)) goto exception; } else { int32_t v1; if (unlikely(JS_ToInt32Free(ctx, &v1, op1))) goto exception; sp[-1] = JS_NewInt32(ctx, ~v1); } return 0; exception: sp[-1] = JS_UNDEFINED; return -1; } static int js_binary_arith_bigint(JSContext *ctx, OPCodeEnum op, JSValue *pres, JSValue op1, JSValue op2) { bf_t a_s, b_s, *r, *a, *b; int ret; JSValue res; res = JS_NewBigInt(ctx); if (JS_IsException(res)) goto fail; a = JS_ToBigInt(ctx, &a_s, op1); if (!a) goto fail; b = JS_ToBigInt(ctx, &b_s, op2); if (!b) { JS_FreeBigInt(ctx, a, &a_s); goto fail; } r = JS_GetBigInt(res); ret = 0; switch(op) { case OP_add: ret = bf_add(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_sub: ret = bf_sub(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_mul: ret = bf_mul(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_div: if (!is_math_mode(ctx)) { bf_t rem_s, *rem = &rem_s; bf_init(ctx->bf_ctx, rem); ret = bf_divrem(r, rem, a, b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); bf_delete(rem); } else { goto math_mode_div_pow; } break; #ifdef CONFIG_BIGNUM case OP_math_mod: /* Euclidian remainder */ ret = bf_rem(r, a, b, BF_PREC_INF, BF_RNDZ, BF_DIVREM_EUCLIDIAN) & BF_ST_INVALID_OP; break; #endif case OP_mod: ret = bf_rem(r, a, b, BF_PREC_INF, BF_RNDZ, BF_RNDZ) & BF_ST_INVALID_OP; break; case OP_pow: if (b->sign) { if (!is_math_mode(ctx)) { ret = BF_ST_INVALID_OP; } else { math_mode_div_pow: #ifdef CONFIG_BIGNUM JS_FreeValue(ctx, res); ret = js_call_binary_op_simple(ctx, &res, ctx->class_proto[JS_CLASS_BIG_INT], op1, op2, op); if (ret != 0) { JS_FreeBigInt(ctx, a, &a_s); JS_FreeBigInt(ctx, b, &b_s); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (ret < 0) { return -1; } else { *pres = res; return 0; } } /* if no BigInt power operator defined, return a bigfloat */ res = JS_NewBigFloat(ctx); if (JS_IsException(res)) { JS_FreeBigInt(ctx, a, &a_s); JS_FreeBigInt(ctx, b, &b_s); goto fail; } r = JS_GetBigFloat(res); if (op == OP_div) { ret = bf_div(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags) & BF_ST_MEM_ERROR; } else { ret = bf_pow(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags | BF_POW_JS_QUIRKS) & BF_ST_MEM_ERROR; } JS_FreeBigInt(ctx, a, &a_s); JS_FreeBigInt(ctx, b, &b_s); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (unlikely(ret)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } *pres = res; return 0; #else abort(); #endif } } else { ret = bf_pow(r, a, b, BF_PREC_INF, BF_RNDZ | BF_POW_JS_QUIRKS); } break; /* logical operations */ case OP_shl: case OP_sar: { slimb_t v2; #if LIMB_BITS == 32 bf_get_int32(&v2, b, 0); if (v2 == INT32_MIN) v2 = INT32_MIN + 1; #else bf_get_int64(&v2, b, 0); if (v2 == INT64_MIN) v2 = INT64_MIN + 1; #endif if (op == OP_sar) v2 = -v2; ret = bf_set(r, a); ret |= bf_mul_2exp(r, v2, BF_PREC_INF, BF_RNDZ); if (v2 < 0) { ret |= bf_rint(r, BF_RNDD) & (BF_ST_OVERFLOW | BF_ST_MEM_ERROR); } } break; case OP_and: ret = bf_logic_and(r, a, b); break; case OP_or: ret = bf_logic_or(r, a, b); break; case OP_xor: ret = bf_logic_xor(r, a, b); break; default: abort(); } JS_FreeBigInt(ctx, a, &a_s); JS_FreeBigInt(ctx, b, &b_s); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (unlikely(ret)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } *pres = JS_CompactBigInt(ctx, res); return 0; fail: JS_FreeValue(ctx, res); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); return -1; } #ifdef CONFIG_BIGNUM static int js_binary_arith_bigfloat(JSContext *ctx, OPCodeEnum op, JSValue *pres, JSValue op1, JSValue op2) { bf_t a_s, b_s, *r, *a, *b; int ret; JSValue res; res = JS_NewBigFloat(ctx); if (JS_IsException(res)) goto fail; r = JS_GetBigFloat(res); a = JS_ToBigFloat(ctx, &a_s, op1); if (!a) { JS_FreeValue(ctx, res); goto fail; } b = JS_ToBigFloat(ctx, &b_s, op2); if (!b) { if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, res); goto fail; } bf_init(ctx->bf_ctx, r); switch(op) { case OP_add: ret = bf_add(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags); break; case OP_sub: ret = bf_sub(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags); break; case OP_mul: ret = bf_mul(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags); break; case OP_div: ret = bf_div(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags); break; case OP_math_mod: /* Euclidian remainder */ ret = bf_rem(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags, BF_DIVREM_EUCLIDIAN); break; case OP_mod: ret = bf_rem(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags, BF_RNDZ); break; case OP_pow: ret = bf_pow(r, a, b, ctx->fp_env.prec, ctx->fp_env.flags | BF_POW_JS_QUIRKS); break; default: abort(); } if (a == &a_s) bf_delete(a); if (b == &b_s) bf_delete(b); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (unlikely(ret & BF_ST_MEM_ERROR)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } *pres = res; return 0; fail: JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); return -1; } /* b must be a positive integer */ static int js_bfdec_pow(bfdec_t *r, const bfdec_t *a, const bfdec_t *b) { bfdec_t b1; int32_t b2; int ret; bfdec_init(b->ctx, &b1); ret = bfdec_set(&b1, b); if (ret) { bfdec_delete(&b1); return ret; } ret = bfdec_rint(&b1, BF_RNDZ); if (ret) { bfdec_delete(&b1); return BF_ST_INVALID_OP; /* must be an integer */ } ret = bfdec_get_int32(&b2, &b1); bfdec_delete(&b1); if (ret) return ret; /* overflow */ if (b2 < 0) return BF_ST_INVALID_OP; /* must be positive */ return bfdec_pow_ui(r, a, b2); } static int js_binary_arith_bigdecimal(JSContext *ctx, OPCodeEnum op, JSValue *pres, JSValue op1, JSValue op2) { bfdec_t *r, *a, *b; int ret; JSValue res; res = JS_NewBigDecimal(ctx); if (JS_IsException(res)) goto fail; r = JS_GetBigDecimal(res); a = JS_ToBigDecimal(ctx, op1); if (!a) goto fail; b = JS_ToBigDecimal(ctx, op2); if (!b) goto fail; switch(op) { case OP_add: ret = bfdec_add(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_sub: ret = bfdec_sub(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_mul: ret = bfdec_mul(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_div: ret = bfdec_div(r, a, b, BF_PREC_INF, BF_RNDZ); break; case OP_math_mod: /* Euclidian remainder */ ret = bfdec_rem(r, a, b, BF_PREC_INF, BF_RNDZ, BF_DIVREM_EUCLIDIAN); break; case OP_mod: ret = bfdec_rem(r, a, b, BF_PREC_INF, BF_RNDZ, BF_RNDZ); break; case OP_pow: ret = js_bfdec_pow(r, a, b); break; default: abort(); } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (unlikely(ret)) { JS_FreeValue(ctx, res); throw_bf_exception(ctx, ret); return -1; } *pres = res; return 0; fail: JS_FreeValue(ctx, res); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); return -1; } #endif /* CONFIG_BIGNUM */ static no_inline __exception int js_binary_arith_slow(JSContext *ctx, JSValue *sp, OPCodeEnum op) { JSValue op1, op2; uint32_t tag1, tag2; double d1, d2; op1 = sp[-2]; op2 = sp[-1]; tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); /* fast path for float operations */ if (tag1 == JS_TAG_FLOAT64 && tag2 == JS_TAG_FLOAT64) { d1 = JS_VALUE_GET_FLOAT64(op1); d2 = JS_VALUE_GET_FLOAT64(op2); goto handle_float64; } #ifdef CONFIG_BIGNUM /* try to call an overloaded operator */ if ((tag1 == JS_TAG_OBJECT && (tag2 != JS_TAG_NULL && tag2 != JS_TAG_UNDEFINED)) || (tag2 == JS_TAG_OBJECT && (tag1 != JS_TAG_NULL && tag1 != JS_TAG_UNDEFINED))) { JSValue res; int ret = js_call_binary_op_fallback(ctx, &res, op1, op2, op, TRUE, 0); if (ret != 0) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (ret < 0) { goto exception; } else { sp[-2] = res; return 0; } } } #endif op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToNumericFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); if (tag1 == JS_TAG_INT && tag2 == JS_TAG_INT) { int32_t v1, v2; int64_t v; v1 = JS_VALUE_GET_INT(op1); v2 = JS_VALUE_GET_INT(op2); switch(op) { case OP_sub: v = (int64_t)v1 - (int64_t)v2; break; case OP_mul: v = (int64_t)v1 * (int64_t)v2; if (is_math_mode(ctx) && (v < -MAX_SAFE_INTEGER || v > MAX_SAFE_INTEGER)) goto handle_bigint; if (v == 0 && (v1 | v2) < 0) { sp[-2] = __JS_NewFloat64(ctx, -0.0); return 0; } break; case OP_div: if (is_math_mode(ctx)) goto handle_bigint; sp[-2] = __JS_NewFloat64(ctx, (double)v1 / (double)v2); return 0; #ifdef CONFIG_BIGNUM case OP_math_mod: if (unlikely(v2 == 0)) { throw_bf_exception(ctx, BF_ST_DIVIDE_ZERO); goto exception; } v = (int64_t)v1 % (int64_t)v2; if (v < 0) { if (v2 < 0) v -= v2; else v += v2; } break; #endif case OP_mod: if (v1 < 0 || v2 <= 0) { sp[-2] = JS_NewFloat64(ctx, fmod(v1, v2)); return 0; } else { v = (int64_t)v1 % (int64_t)v2; } break; case OP_pow: if (!is_math_mode(ctx)) { sp[-2] = JS_NewFloat64(ctx, js_pow(v1, v2)); return 0; } else { goto handle_bigint; } break; default: abort(); } sp[-2] = JS_NewInt64(ctx, v); } else #ifdef CONFIG_BIGNUM if (tag1 == JS_TAG_BIG_DECIMAL || tag2 == JS_TAG_BIG_DECIMAL) { if (ctx->rt->bigdecimal_ops.binary_arith(ctx, op, sp - 2, op1, op2)) goto exception; } else if (tag1 == JS_TAG_BIG_FLOAT || tag2 == JS_TAG_BIG_FLOAT) { if (ctx->rt->bigfloat_ops.binary_arith(ctx, op, sp - 2, op1, op2)) goto exception; } else #endif if (tag1 == JS_TAG_BIG_INT || tag2 == JS_TAG_BIG_INT) { handle_bigint: if (ctx->rt->bigint_ops.binary_arith(ctx, op, sp - 2, op1, op2)) goto exception; } else { double dr; /* float64 result */ if (JS_ToFloat64Free(ctx, &d1, op1)) { JS_FreeValue(ctx, op2); goto exception; } if (JS_ToFloat64Free(ctx, &d2, op2)) goto exception; handle_float64: if (is_math_mode(ctx) && is_safe_integer(d1) && is_safe_integer(d2)) goto handle_bigint; switch(op) { case OP_sub: dr = d1 - d2; break; case OP_mul: dr = d1 * d2; break; case OP_div: dr = d1 / d2; break; case OP_mod: dr = fmod(d1, d2); break; #ifdef CONFIG_BIGNUM case OP_math_mod: d2 = fabs(d2); dr = fmod(d1, d2); /* XXX: loss of accuracy if dr < 0 */ if (dr < 0) dr += d2; break; #endif case OP_pow: dr = js_pow(d1, d2); break; default: abort(); } sp[-2] = __JS_NewFloat64(ctx, dr); } return 0; exception: sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } static no_inline __exception int js_add_slow(JSContext *ctx, JSValue *sp) { JSValue op1, op2; uint32_t tag1, tag2; op1 = sp[-2]; op2 = sp[-1]; tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); /* fast path for float64 */ if (tag1 == JS_TAG_FLOAT64 && tag2 == JS_TAG_FLOAT64) { double d1, d2; d1 = JS_VALUE_GET_FLOAT64(op1); d2 = JS_VALUE_GET_FLOAT64(op2); sp[-2] = __JS_NewFloat64(ctx, d1 + d2); return 0; } if (tag1 == JS_TAG_OBJECT || tag2 == JS_TAG_OBJECT) { #ifdef CONFIG_BIGNUM /* try to call an overloaded operator */ if ((tag1 == JS_TAG_OBJECT && (tag2 != JS_TAG_NULL && tag2 != JS_TAG_UNDEFINED && tag2 != JS_TAG_STRING)) || (tag2 == JS_TAG_OBJECT && (tag1 != JS_TAG_NULL && tag1 != JS_TAG_UNDEFINED && tag1 != JS_TAG_STRING))) { JSValue res; int ret = js_call_binary_op_fallback(ctx, &res, op1, op2, OP_add, FALSE, HINT_NONE); if (ret != 0) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (ret < 0) { goto exception; } else { sp[-2] = res; return 0; } } } #endif op1 = JS_ToPrimitiveFree(ctx, op1, HINT_NONE); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToPrimitiveFree(ctx, op2, HINT_NONE); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); } if (tag1 == JS_TAG_STRING || tag2 == JS_TAG_STRING) { sp[-2] = JS_ConcatString(ctx, op1, op2); if (JS_IsException(sp[-2])) goto exception; return 0; } op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToNumericFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); if (tag1 == JS_TAG_INT && tag2 == JS_TAG_INT) { int32_t v1, v2; int64_t v; v1 = JS_VALUE_GET_INT(op1); v2 = JS_VALUE_GET_INT(op2); v = (int64_t)v1 + (int64_t)v2; sp[-2] = JS_NewInt64(ctx, v); } else #ifdef CONFIG_BIGNUM if (tag1 == JS_TAG_BIG_DECIMAL || tag2 == JS_TAG_BIG_DECIMAL) { if (ctx->rt->bigdecimal_ops.binary_arith(ctx, OP_add, sp - 2, op1, op2)) goto exception; } else if (tag1 == JS_TAG_BIG_FLOAT || tag2 == JS_TAG_BIG_FLOAT) { if (ctx->rt->bigfloat_ops.binary_arith(ctx, OP_add, sp - 2, op1, op2)) goto exception; } else #endif if (tag1 == JS_TAG_BIG_INT || tag2 == JS_TAG_BIG_INT) { handle_bigint: if (ctx->rt->bigint_ops.binary_arith(ctx, OP_add, sp - 2, op1, op2)) goto exception; } else { double d1, d2; /* float64 result */ if (JS_ToFloat64Free(ctx, &d1, op1)) { JS_FreeValue(ctx, op2); goto exception; } if (JS_ToFloat64Free(ctx, &d2, op2)) goto exception; if (is_math_mode(ctx) && is_safe_integer(d1) && is_safe_integer(d2)) goto handle_bigint; sp[-2] = __JS_NewFloat64(ctx, d1 + d2); } return 0; exception: sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } static no_inline __exception int js_binary_logic_slow(JSContext *ctx, JSValue *sp, OPCodeEnum op) { JSValue op1, op2; uint32_t tag1, tag2; uint32_t v1, v2, r; op1 = sp[-2]; op2 = sp[-1]; tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); #ifdef CONFIG_BIGNUM /* try to call an overloaded operator */ if ((tag1 == JS_TAG_OBJECT && (tag2 != JS_TAG_NULL && tag2 != JS_TAG_UNDEFINED)) || (tag2 == JS_TAG_OBJECT && (tag1 != JS_TAG_NULL && tag1 != JS_TAG_UNDEFINED))) { JSValue res; int ret = js_call_binary_op_fallback(ctx, &res, op1, op2, op, TRUE, 0); if (ret != 0) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (ret < 0) { goto exception; } else { sp[-2] = res; return 0; } } } #endif op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToNumericFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } if (is_math_mode(ctx)) goto bigint_op; tag1 = JS_VALUE_GET_TAG(op1); tag2 = JS_VALUE_GET_TAG(op2); if (tag1 == JS_TAG_BIG_INT || tag2 == JS_TAG_BIG_INT) { if (tag1 != tag2) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); JS_ThrowTypeError(ctx, "both operands must be bigint"); goto exception; } else { bigint_op: if (ctx->rt->bigint_ops.binary_arith(ctx, op, sp - 2, op1, op2)) goto exception; } } else { if (unlikely(JS_ToInt32Free(ctx, (int32_t *)&v1, op1))) { JS_FreeValue(ctx, op2); goto exception; } if (unlikely(JS_ToInt32Free(ctx, (int32_t *)&v2, op2))) goto exception; switch(op) { case OP_shl: r = v1 << (v2 & 0x1f); break; case OP_sar: r = (int)v1 >> (v2 & 0x1f); break; case OP_and: r = v1 & v2; break; case OP_or: r = v1 | v2; break; case OP_xor: r = v1 ^ v2; break; default: abort(); } sp[-2] = JS_NewInt32(ctx, r); } return 0; exception: sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } /* Note: also used for bigint */ static int js_compare_bigfloat(JSContext *ctx, OPCodeEnum op, JSValue op1, JSValue op2) { bf_t a_s, b_s, *a, *b; int res; a = JS_ToBigFloat(ctx, &a_s, op1); if (!a) { JS_FreeValue(ctx, op2); return -1; } b = JS_ToBigFloat(ctx, &b_s, op2); if (!b) { if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, op1); return -1; } switch(op) { case OP_lt: res = bf_cmp_lt(a, b); /* if NaN return false */ break; case OP_lte: res = bf_cmp_le(a, b); /* if NaN return false */ break; case OP_gt: res = bf_cmp_lt(b, a); /* if NaN return false */ break; case OP_gte: res = bf_cmp_le(b, a); /* if NaN return false */ break; case OP_eq: res = bf_cmp_eq(a, b); /* if NaN return false */ break; default: abort(); } if (a == &a_s) bf_delete(a); if (b == &b_s) bf_delete(b); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); return res; } #ifdef CONFIG_BIGNUM static int js_compare_bigdecimal(JSContext *ctx, OPCodeEnum op, JSValue op1, JSValue op2) { bfdec_t *a, *b; int res; /* Note: binary floats are converted to bigdecimal with toString(). It is not mathematically correct but is consistent with the BigDecimal() constructor behavior */ op1 = JS_ToBigDecimalFree(ctx, op1, TRUE); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); return -1; } op2 = JS_ToBigDecimalFree(ctx, op2, TRUE); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); return -1; } a = JS_ToBigDecimal(ctx, op1); /* cannot fail */ b = JS_ToBigDecimal(ctx, op2); /* cannot fail */ switch(op) { case OP_lt: res = bfdec_cmp_lt(a, b); /* if NaN return false */ break; case OP_lte: res = bfdec_cmp_le(a, b); /* if NaN return false */ break; case OP_gt: res = bfdec_cmp_lt(b, a); /* if NaN return false */ break; case OP_gte: res = bfdec_cmp_le(b, a); /* if NaN return false */ break; case OP_eq: res = bfdec_cmp_eq(a, b); /* if NaN return false */ break; default: abort(); } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); return res; } #endif /* !CONFIG_BIGNUM */ static no_inline int js_relational_slow(JSContext *ctx, JSValue *sp, OPCodeEnum op) { JSValue op1, op2; int res; uint32_t tag1, tag2; op1 = sp[-2]; op2 = sp[-1]; tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); #ifdef CONFIG_BIGNUM /* try to call an overloaded operator */ if ((tag1 == JS_TAG_OBJECT && (tag2 != JS_TAG_NULL && tag2 != JS_TAG_UNDEFINED)) || (tag2 == JS_TAG_OBJECT && (tag1 != JS_TAG_NULL && tag1 != JS_TAG_UNDEFINED))) { JSValue ret; res = js_call_binary_op_fallback(ctx, &ret, op1, op2, op, FALSE, HINT_NUMBER); if (res != 0) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (res < 0) { goto exception; } else { sp[-2] = ret; return 0; } } } #endif op1 = JS_ToPrimitiveFree(ctx, op1, HINT_NUMBER); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToPrimitiveFree(ctx, op2, HINT_NUMBER); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); if (tag1 == JS_TAG_STRING && tag2 == JS_TAG_STRING) { JSString *p1, *p2; p1 = JS_VALUE_GET_STRING(op1); p2 = JS_VALUE_GET_STRING(op2); res = js_string_compare(ctx, p1, p2); switch(op) { case OP_lt: res = (res < 0); break; case OP_lte: res = (res <= 0); break; case OP_gt: res = (res > 0); break; default: case OP_gte: res = (res >= 0); break; } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); } else if ((tag1 <= JS_TAG_NULL || tag1 == JS_TAG_FLOAT64) && (tag2 <= JS_TAG_NULL || tag2 == JS_TAG_FLOAT64)) { /* fast path for float64/int */ goto float64_compare; } else { if (((tag1 == JS_TAG_BIG_INT && tag2 == JS_TAG_STRING) || (tag2 == JS_TAG_BIG_INT && tag1 == JS_TAG_STRING)) && !is_math_mode(ctx)) { if (tag1 == JS_TAG_STRING) { op1 = JS_StringToBigInt(ctx, op1); if (JS_VALUE_GET_TAG(op1) != JS_TAG_BIG_INT) goto invalid_bigint_string; } if (tag2 == JS_TAG_STRING) { op2 = JS_StringToBigInt(ctx, op2); if (JS_VALUE_GET_TAG(op2) != JS_TAG_BIG_INT) { invalid_bigint_string: JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); res = FALSE; goto done; } } } else { op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToNumericFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } } tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); #ifdef CONFIG_BIGNUM if (tag1 == JS_TAG_BIG_DECIMAL || tag2 == JS_TAG_BIG_DECIMAL) { res = ctx->rt->bigdecimal_ops.compare(ctx, op, op1, op2); if (res < 0) goto exception; } else if (tag1 == JS_TAG_BIG_FLOAT || tag2 == JS_TAG_BIG_FLOAT) { res = ctx->rt->bigfloat_ops.compare(ctx, op, op1, op2); if (res < 0) goto exception; } else #endif if (tag1 == JS_TAG_BIG_INT || tag2 == JS_TAG_BIG_INT) { res = ctx->rt->bigint_ops.compare(ctx, op, op1, op2); if (res < 0) goto exception; } else { double d1, d2; float64_compare: /* can use floating point comparison */ if (tag1 == JS_TAG_FLOAT64) { d1 = JS_VALUE_GET_FLOAT64(op1); } else { d1 = JS_VALUE_GET_INT(op1); } if (tag2 == JS_TAG_FLOAT64) { d2 = JS_VALUE_GET_FLOAT64(op2); } else { d2 = JS_VALUE_GET_INT(op2); } switch(op) { case OP_lt: res = (d1 < d2); /* if NaN return false */ break; case OP_lte: res = (d1 <= d2); /* if NaN return false */ break; case OP_gt: res = (d1 > d2); /* if NaN return false */ break; default: case OP_gte: res = (d1 >= d2); /* if NaN return false */ break; } } } done: sp[-2] = JS_NewBool(ctx, res); return 0; exception: sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } static BOOL tag_is_number(uint32_t tag) { return (tag == JS_TAG_INT || tag == JS_TAG_BIG_INT || tag == JS_TAG_FLOAT64 #ifdef CONFIG_BIGNUM || tag == JS_TAG_BIG_FLOAT || tag == JS_TAG_BIG_DECIMAL #endif ); } static no_inline __exception int js_eq_slow(JSContext *ctx, JSValue *sp, BOOL is_neq) { JSValue op1, op2; #ifdef CONFIG_BIGNUM JSValue ret; #endif int res; uint32_t tag1, tag2; op1 = sp[-2]; op2 = sp[-1]; redo: tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); if (tag_is_number(tag1) && tag_is_number(tag2)) { if (tag1 == JS_TAG_INT && tag2 == JS_TAG_INT) { res = JS_VALUE_GET_INT(op1) == JS_VALUE_GET_INT(op2); } else if ((tag1 == JS_TAG_FLOAT64 && (tag2 == JS_TAG_INT || tag2 == JS_TAG_FLOAT64)) || (tag2 == JS_TAG_FLOAT64 && (tag1 == JS_TAG_INT || tag1 == JS_TAG_FLOAT64))) { double d1, d2; if (tag1 == JS_TAG_FLOAT64) { d1 = JS_VALUE_GET_FLOAT64(op1); } else { d1 = JS_VALUE_GET_INT(op1); } if (tag2 == JS_TAG_FLOAT64) { d2 = JS_VALUE_GET_FLOAT64(op2); } else { d2 = JS_VALUE_GET_INT(op2); } res = (d1 == d2); } else #ifdef CONFIG_BIGNUM if (tag1 == JS_TAG_BIG_DECIMAL || tag2 == JS_TAG_BIG_DECIMAL) { res = ctx->rt->bigdecimal_ops.compare(ctx, OP_eq, op1, op2); if (res < 0) goto exception; } else if (tag1 == JS_TAG_BIG_FLOAT || tag2 == JS_TAG_BIG_FLOAT) { res = ctx->rt->bigfloat_ops.compare(ctx, OP_eq, op1, op2); if (res < 0) goto exception; } else #endif { res = ctx->rt->bigint_ops.compare(ctx, OP_eq, op1, op2); if (res < 0) goto exception; } } else if (tag1 == tag2) { #ifdef CONFIG_BIGNUM if (tag1 == JS_TAG_OBJECT) { /* try the fallback operator */ res = js_call_binary_op_fallback(ctx, &ret, op1, op2, is_neq ? OP_neq : OP_eq, FALSE, HINT_NONE); if (res != 0) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (res < 0) { goto exception; } else { sp[-2] = ret; return 0; } } } #endif res = js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT); } else if ((tag1 == JS_TAG_NULL && tag2 == JS_TAG_UNDEFINED) || (tag2 == JS_TAG_NULL && tag1 == JS_TAG_UNDEFINED)) { res = TRUE; } else if ((tag1 == JS_TAG_STRING && tag_is_number(tag2)) || (tag2 == JS_TAG_STRING && tag_is_number(tag1))) { if ((tag1 == JS_TAG_BIG_INT || tag2 == JS_TAG_BIG_INT) && !is_math_mode(ctx)) { if (tag1 == JS_TAG_STRING) { op1 = JS_StringToBigInt(ctx, op1); if (JS_VALUE_GET_TAG(op1) != JS_TAG_BIG_INT) goto invalid_bigint_string; } if (tag2 == JS_TAG_STRING) { op2 = JS_StringToBigInt(ctx, op2); if (JS_VALUE_GET_TAG(op2) != JS_TAG_BIG_INT) { invalid_bigint_string: JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); res = FALSE; goto done; } } } else { op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToNumericFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } } res = js_strict_eq(ctx, op1, op2); } else if (tag1 == JS_TAG_BOOL) { op1 = JS_NewInt32(ctx, JS_VALUE_GET_INT(op1)); goto redo; } else if (tag2 == JS_TAG_BOOL) { op2 = JS_NewInt32(ctx, JS_VALUE_GET_INT(op2)); goto redo; } else if ((tag1 == JS_TAG_OBJECT && (tag_is_number(tag2) || tag2 == JS_TAG_STRING || tag2 == JS_TAG_SYMBOL)) || (tag2 == JS_TAG_OBJECT && (tag_is_number(tag1) || tag1 == JS_TAG_STRING || tag1 == JS_TAG_SYMBOL))) { #ifdef CONFIG_BIGNUM /* try the fallback operator */ res = js_call_binary_op_fallback(ctx, &ret, op1, op2, is_neq ? OP_neq : OP_eq, FALSE, HINT_NONE); if (res != 0) { JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); if (res < 0) { goto exception; } else { sp[-2] = ret; return 0; } } #endif op1 = JS_ToPrimitiveFree(ctx, op1, HINT_NONE); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToPrimitiveFree(ctx, op2, HINT_NONE); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } goto redo; } else { /* IsHTMLDDA object is equivalent to undefined for '==' and '!=' */ if ((JS_IsHTMLDDA(ctx, op1) && (tag2 == JS_TAG_NULL || tag2 == JS_TAG_UNDEFINED)) || (JS_IsHTMLDDA(ctx, op2) && (tag1 == JS_TAG_NULL || tag1 == JS_TAG_UNDEFINED))) { res = TRUE; } else { res = FALSE; } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); } done: sp[-2] = JS_NewBool(ctx, res ^ is_neq); return 0; exception: sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } static no_inline int js_shr_slow(JSContext *ctx, JSValue *sp) { JSValue op1, op2; uint32_t v1, v2, r; op1 = sp[-2]; op2 = sp[-1]; op1 = JS_ToNumericFree(ctx, op1); if (JS_IsException(op1)) { JS_FreeValue(ctx, op2); goto exception; } op2 = JS_ToNumericFree(ctx, op2); if (JS_IsException(op2)) { JS_FreeValue(ctx, op1); goto exception; } /* XXX: could forbid >>> in bignum mode */ if (!is_math_mode(ctx) && (JS_VALUE_GET_TAG(op1) == JS_TAG_BIG_INT || JS_VALUE_GET_TAG(op2) == JS_TAG_BIG_INT)) { JS_ThrowTypeError(ctx, "bigint operands are forbidden for >>>"); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); goto exception; } /* cannot give an exception */ JS_ToUint32Free(ctx, &v1, op1); JS_ToUint32Free(ctx, &v2, op2); r = v1 >> (v2 & 0x1f); sp[-2] = JS_NewUint32(ctx, r); return 0; exception: sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } #ifdef CONFIG_BIGNUM static JSValue js_mul_pow10_to_float64(JSContext *ctx, const bf_t *a, int64_t exponent) { bf_t r_s, *r = &r_s; double d; int ret; /* always convert to Float64 */ bf_init(ctx->bf_ctx, r); ret = bf_mul_pow_radix(r, a, 10, exponent, 53, bf_set_exp_bits(11) | BF_RNDN | BF_FLAG_SUBNORMAL); bf_get_float64(r, &d, BF_RNDN); bf_delete(r); if (ret & BF_ST_MEM_ERROR) return JS_ThrowOutOfMemory(ctx); else return __JS_NewFloat64(ctx, d); } static no_inline int js_mul_pow10(JSContext *ctx, JSValue *sp) { bf_t a_s, *a, *r; JSValue op1, op2, res; int64_t e; int ret; res = JS_NewBigFloat(ctx); if (JS_IsException(res)) return -1; r = JS_GetBigFloat(res); op1 = sp[-2]; op2 = sp[-1]; a = JS_ToBigFloat(ctx, &a_s, op1); if (!a) { JS_FreeValue(ctx, res); return -1; } if (JS_IsBigInt(ctx, op2)) { ret = JS_ToBigInt64(ctx, &e, op2); } else { ret = JS_ToInt64(ctx, &e, op2); } if (ret) { if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, res); return -1; } bf_mul_pow_radix(r, a, 10, e, ctx->fp_env.prec, ctx->fp_env.flags); if (a == &a_s) bf_delete(a); JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); sp[-2] = res; return 0; } #endif /* XXX: Should take JSValueConst arguments */ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2, JSStrictEqModeEnum eq_mode) { BOOL res; int tag1, tag2; double d1, d2; tag1 = JS_VALUE_GET_NORM_TAG(op1); tag2 = JS_VALUE_GET_NORM_TAG(op2); switch(tag1) { case JS_TAG_BOOL: if (tag1 != tag2) { res = FALSE; } else { res = JS_VALUE_GET_INT(op1) == JS_VALUE_GET_INT(op2); goto done_no_free; } break; case JS_TAG_NULL: case JS_TAG_UNDEFINED: res = (tag1 == tag2); break; case JS_TAG_STRING: { JSString *p1, *p2; if (tag1 != tag2) { res = FALSE; } else { p1 = JS_VALUE_GET_STRING(op1); p2 = JS_VALUE_GET_STRING(op2); res = (js_string_compare(ctx, p1, p2) == 0); } } break; case JS_TAG_SYMBOL: { JSAtomStruct *p1, *p2; if (tag1 != tag2) { res = FALSE; } else { p1 = JS_VALUE_GET_PTR(op1); p2 = JS_VALUE_GET_PTR(op2); res = (p1 == p2); } } break; case JS_TAG_OBJECT: if (tag1 != tag2) res = FALSE; else res = JS_VALUE_GET_OBJ(op1) == JS_VALUE_GET_OBJ(op2); break; case JS_TAG_INT: d1 = JS_VALUE_GET_INT(op1); if (tag2 == JS_TAG_INT) { d2 = JS_VALUE_GET_INT(op2); goto number_test; } else if (tag2 == JS_TAG_FLOAT64) { d2 = JS_VALUE_GET_FLOAT64(op2); goto number_test; } else { res = FALSE; } break; case JS_TAG_FLOAT64: d1 = JS_VALUE_GET_FLOAT64(op1); if (tag2 == JS_TAG_FLOAT64) { d2 = JS_VALUE_GET_FLOAT64(op2); } else if (tag2 == JS_TAG_INT) { d2 = JS_VALUE_GET_INT(op2); } else { res = FALSE; break; } number_test: if (unlikely(eq_mode >= JS_EQ_SAME_VALUE)) { JSFloat64Union u1, u2; /* NaN is not always normalized, so this test is necessary */ if (isnan(d1) || isnan(d2)) { res = isnan(d1) == isnan(d2); } else if (eq_mode == JS_EQ_SAME_VALUE_ZERO) { res = (d1 == d2); /* +0 == -0 */ } else { u1.d = d1; u2.d = d2; res = (u1.u64 == u2.u64); /* +0 != -0 */ } } else { res = (d1 == d2); /* if NaN return false and +0 == -0 */ } goto done_no_free; case JS_TAG_BIG_INT: { bf_t a_s, *a, b_s, *b; if (tag1 != tag2) { res = FALSE; break; } a = JS_ToBigFloat(ctx, &a_s, op1); /* cannot fail */ b = JS_ToBigFloat(ctx, &b_s, op2); /* cannot fail */ res = bf_cmp_eq(a, b); if (a == &a_s) bf_delete(a); if (b == &b_s) bf_delete(b); } break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: { JSBigFloat *p1, *p2; const bf_t *a, *b; if (tag1 != tag2) { res = FALSE; break; } p1 = JS_VALUE_GET_PTR(op1); p2 = JS_VALUE_GET_PTR(op2); a = &p1->num; b = &p2->num; if (unlikely(eq_mode >= JS_EQ_SAME_VALUE)) { if (eq_mode == JS_EQ_SAME_VALUE_ZERO && a->expn == BF_EXP_ZERO && b->expn == BF_EXP_ZERO) { res = TRUE; } else { res = (bf_cmp_full(a, b) == 0); } } else { res = bf_cmp_eq(a, b); } } break; case JS_TAG_BIG_DECIMAL: { JSBigDecimal *p1, *p2; const bfdec_t *a, *b; if (tag1 != tag2) { res = FALSE; break; } p1 = JS_VALUE_GET_PTR(op1); p2 = JS_VALUE_GET_PTR(op2); a = &p1->num; b = &p2->num; res = bfdec_cmp_eq(a, b); } break; #endif default: res = FALSE; break; } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); done_no_free: return res; } static BOOL js_strict_eq(JSContext *ctx, JSValue op1, JSValue op2) { return js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT); } static BOOL js_same_value(JSContext *ctx, JSValueConst op1, JSValueConst op2) { return js_strict_eq2(ctx, JS_DupValue(ctx, op1), JS_DupValue(ctx, op2), JS_EQ_SAME_VALUE); } static BOOL js_same_value_zero(JSContext *ctx, JSValueConst op1, JSValueConst op2) { return js_strict_eq2(ctx, JS_DupValue(ctx, op1), JS_DupValue(ctx, op2), JS_EQ_SAME_VALUE_ZERO); } static no_inline int js_strict_eq_slow(JSContext *ctx, JSValue *sp, BOOL is_neq) { BOOL res; res = js_strict_eq(ctx, sp[-2], sp[-1]); sp[-2] = JS_NewBool(ctx, res ^ is_neq); return 0; } static __exception int js_operator_in(JSContext *ctx, JSValue *sp) { JSValue op1, op2; JSAtom atom; int ret; op1 = sp[-2]; op2 = sp[-1]; if (JS_VALUE_GET_TAG(op2) != JS_TAG_OBJECT) { JS_ThrowTypeError(ctx, "invalid 'in' operand"); return -1; } atom = JS_ValueToAtom(ctx, op1); if (unlikely(atom == JS_ATOM_NULL)) return -1; ret = JS_HasProperty(ctx, op2, atom); JS_FreeAtom(ctx, atom); if (ret < 0) return -1; JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); sp[-2] = JS_NewBool(ctx, ret); return 0; } static __exception int js_operator_private_in(JSContext *ctx, JSValue *sp) { JSValue op1, op2; int ret; op1 = sp[-2]; /* object */ op2 = sp[-1]; /* field name or method function */ if (JS_VALUE_GET_TAG(op1) != JS_TAG_OBJECT) { JS_ThrowTypeError(ctx, "invalid 'in' operand"); return -1; } if (JS_IsObject(op2)) { /* method: use the brand */ ret = JS_CheckBrand(ctx, op1, op2); if (ret < 0) return -1; } else { JSAtom atom; JSObject *p; JSShapeProperty *prs; JSProperty *pr; /* field */ atom = JS_ValueToAtom(ctx, op2); if (unlikely(atom == JS_ATOM_NULL)) return -1; p = JS_VALUE_GET_OBJ(op1); prs = find_own_property(&pr, p, atom); JS_FreeAtom(ctx, atom); ret = (prs != NULL); } JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); sp[-2] = JS_NewBool(ctx, ret); return 0; } static __exception int js_has_unscopable(JSContext *ctx, JSValueConst obj, JSAtom atom) { JSValue arr, val; int ret; arr = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_unscopables); if (JS_IsException(arr)) return -1; ret = 0; if (JS_IsObject(arr)) { val = JS_GetProperty(ctx, arr, atom); ret = JS_ToBoolFree(ctx, val); } JS_FreeValue(ctx, arr); return ret; } static __exception int js_operator_instanceof(JSContext *ctx, JSValue *sp) { JSValue op1, op2; BOOL ret; op1 = sp[-2]; op2 = sp[-1]; ret = JS_IsInstanceOf(ctx, op1, op2); if (ret < 0) return ret; JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); sp[-2] = JS_NewBool(ctx, ret); return 0; } static __exception int js_operator_typeof(JSContext *ctx, JSValueConst op1) { JSAtom atom; uint32_t tag; tag = JS_VALUE_GET_NORM_TAG(op1); switch(tag) { case JS_TAG_BIG_INT: atom = JS_ATOM_bigint; break; #ifdef CONFIG_BIGNUM case JS_TAG_BIG_FLOAT: atom = JS_ATOM_bigfloat; break; case JS_TAG_BIG_DECIMAL: atom = JS_ATOM_bigdecimal; break; #endif case JS_TAG_INT: case JS_TAG_FLOAT64: atom = JS_ATOM_number; break; case JS_TAG_UNDEFINED: atom = JS_ATOM_undefined; break; case JS_TAG_BOOL: atom = JS_ATOM_boolean; break; case JS_TAG_STRING: atom = JS_ATOM_string; break; case JS_TAG_OBJECT: { JSObject *p; p = JS_VALUE_GET_OBJ(op1); if (unlikely(p->is_HTMLDDA)) atom = JS_ATOM_undefined; else if (JS_IsFunction(ctx, op1)) atom = JS_ATOM_function; else goto obj_type; } break; case JS_TAG_NULL: obj_type: atom = JS_ATOM_object; break; case JS_TAG_SYMBOL: atom = JS_ATOM_symbol; break; default: atom = JS_ATOM_unknown; break; } return atom; } static __exception int js_operator_delete(JSContext *ctx, JSValue *sp) { JSValue op1, op2; JSAtom atom; int ret; op1 = sp[-2]; op2 = sp[-1]; atom = JS_ValueToAtom(ctx, op2); if (unlikely(atom == JS_ATOM_NULL)) return -1; ret = JS_DeleteProperty(ctx, op1, atom, JS_PROP_THROW_STRICT); JS_FreeAtom(ctx, atom); if (unlikely(ret < 0)) return -1; JS_FreeValue(ctx, op1); JS_FreeValue(ctx, op2); sp[-2] = JS_NewBool(ctx, ret); return 0; } static JSValue js_throw_type_error(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { return JS_ThrowTypeError(ctx, "invalid property access"); } /* XXX: not 100% compatible, but mozilla seems to use a similar implementation to ensure that caller in non strict mode does not throw (ES5 compatibility) */ static JSValue js_function_proto_caller(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { JSFunctionBytecode *b = JS_GetFunctionBytecode(this_val); if (!b || (b->js_mode & JS_MODE_STRICT) || !b->has_prototype) { return js_throw_type_error(ctx, this_val, 0, NULL); } return JS_UNDEFINED; } static JSValue js_function_proto_fileName(JSContext *ctx, JSValueConst this_val) { JSFunctionBytecode *b = JS_GetFunctionBytecode(this_val); if (b && b->has_debug) { return JS_AtomToString(ctx, b->debug.filename); } return JS_UNDEFINED; } static JSValue js_function_proto_lineNumber(JSContext *ctx, JSValueConst this_val) { JSFunctionBytecode *b = JS_GetFunctionBytecode(this_val); if (b && b->has_debug) { return JS_NewInt32(ctx, b->debug.line_num); } return JS_UNDEFINED; } static int js_arguments_define_own_property(JSContext *ctx, JSValueConst this_obj, JSAtom prop, JSValueConst val, JSValueConst getter, JSValueConst setter, int flags) { JSObject *p; uint32_t idx; p = JS_VALUE_GET_OBJ(this_obj); /* convert to normal array when redefining an existing numeric field */ if (p->fast_array && JS_AtomIsArrayIndex(ctx, &idx, prop) && idx < p->u.array.count) { if (convert_fast_array_to_array(ctx, p)) return -1; } /* run the default define own property */ return JS_DefineProperty(ctx, this_obj, prop, val, getter, setter, flags | JS_PROP_NO_EXOTIC); } static const JSClassExoticMethods js_arguments_exotic_methods = { .define_own_property = js_arguments_define_own_property, }; static JSValue js_build_arguments(JSContext *ctx, int argc, JSValueConst *argv) { JSValue val, *tab; JSProperty *pr; JSObject *p; int i; val = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], JS_CLASS_ARGUMENTS); if (JS_IsException(val)) return val; p = JS_VALUE_GET_OBJ(val); /* add the length field (cannot fail) */ pr = add_property(ctx, p, JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); pr->u.value = JS_NewInt32(ctx, argc); /* initialize the fast array part */ tab = NULL; if (argc > 0) { tab = js_malloc(ctx, sizeof(tab[0]) * argc); if (!tab) { JS_FreeValue(ctx, val); return JS_EXCEPTION; } for(i = 0; i < argc; i++) { tab[i] = JS_DupValue(ctx, argv[i]); } } p->u.array.u.values = tab; p->u.array.count = argc; JS_DefinePropertyValue(ctx, val, JS_ATOM_Symbol_iterator, JS_DupValue(ctx, ctx->array_proto_values), JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE); /* add callee property to throw a TypeError in strict mode */ JS_DefineProperty(ctx, val, JS_ATOM_callee, JS_UNDEFINED, ctx->throw_type_error, ctx->throw_type_error, JS_PROP_HAS_GET | JS_PROP_HAS_SET); return val; } #define GLOBAL_VAR_OFFSET 0x40000000 #define ARGUMENT_VAR_OFFSET 0x20000000 /* legacy arguments object: add references to the function arguments */ static JSValue js_build_mapped_arguments(JSContext *ctx, int argc, JSValueConst *argv, JSStackFrame *sf, int arg_count) { JSValue val; JSProperty *pr; JSObject *p; int i; val = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_OBJECT], JS_CLASS_MAPPED_ARGUMENTS); if (JS_IsException(val)) return val; p = JS_VALUE_GET_OBJ(val); /* add the length field (cannot fail) */ pr = add_property(ctx, p, JS_ATOM_length, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); pr->u.value = JS_NewInt32(ctx, argc); for(i = 0; i < arg_count; i++) { JSVarRef *var_ref; var_ref = get_var_ref(ctx, sf, i, TRUE); if (!var_ref) goto fail; pr = add_property(ctx, p, __JS_AtomFromUInt32(i), JS_PROP_C_W_E | JS_PROP_VARREF); if (!pr) { free_var_ref(ctx->rt, var_ref); goto fail; } pr->u.var_ref = var_ref; } /* the arguments not mapped to the arguments of the function can be normal properties */ for(i = arg_count; i < argc; i++) { if (JS_DefinePropertyValueUint32(ctx, val, i, JS_DupValue(ctx, argv[i]), JS_PROP_C_W_E) < 0) goto fail; } JS_DefinePropertyValue(ctx, val, JS_ATOM_Symbol_iterator, JS_DupValue(ctx, ctx->array_proto_values), JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE); /* callee returns this function in non strict mode */ JS_DefinePropertyValue(ctx, val, JS_ATOM_callee, JS_DupValue(ctx, ctx->rt->current_stack_frame->cur_func), JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE); return val; fail: JS_FreeValue(ctx, val); return JS_EXCEPTION; } static JSValue js_build_rest(JSContext *ctx, int first, int argc, JSValueConst *argv) { JSValue val; int i, ret; val = JS_NewArray(ctx); if (JS_IsException(val)) return val; for (i = first; i < argc; i++) { ret = JS_DefinePropertyValueUint32(ctx, val, i - first, JS_DupValue(ctx, argv[i]), JS_PROP_C_W_E); if (ret < 0) { JS_FreeValue(ctx, val); return JS_EXCEPTION; } } return val; } static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj) { JSObject *p, *p1; JSPropertyEnum *tab_atom; int i; JSValue enum_obj; JSForInIterator *it; uint32_t tag, tab_atom_count; tag = JS_VALUE_GET_TAG(obj); if (tag != JS_TAG_OBJECT && tag != JS_TAG_NULL && tag != JS_TAG_UNDEFINED) { obj = JS_ToObjectFree(ctx, obj); } it = js_malloc(ctx, sizeof(*it)); if (!it) { JS_FreeValue(ctx, obj); return JS_EXCEPTION; } enum_obj = JS_NewObjectProtoClass(ctx, JS_NULL, JS_CLASS_FOR_IN_ITERATOR); if (JS_IsException(enum_obj)) { js_free(ctx, it); JS_FreeValue(ctx, obj); return JS_EXCEPTION; } it->is_array = FALSE; it->obj = obj; it->idx = 0; it->tab_atom = NULL; it->atom_count = 0; it->in_prototype_chain = FALSE; p1 = JS_VALUE_GET_OBJ(enum_obj); p1->u.for_in_iterator = it; if (tag == JS_TAG_NULL || tag == JS_TAG_UNDEFINED) return enum_obj; p = JS_VALUE_GET_OBJ(obj); if (p->fast_array) { JSShape *sh; JSShapeProperty *prs; /* check that there are no enumerable normal fields */ sh = p->shape; for(i = 0, prs = get_shape_prop(sh); i < sh->prop_count; i++, prs++) { if (prs->flags & JS_PROP_ENUMERABLE) goto normal_case; } /* for fast arrays, we only store the number of elements */ it->is_array = TRUE; it->atom_count = p->u.array.count; } else { normal_case: if (JS_GetOwnPropertyNamesInternal(ctx, &tab_atom, &tab_atom_count, p, JS_GPN_STRING_MASK | JS_GPN_SET_ENUM)) { JS_FreeValue(ctx, enum_obj); return JS_EXCEPTION; } it->tab_atom = tab_atom; it->atom_count = tab_atom_count; } return enum_obj; } /* obj -> enum_obj */ static __exception int js_for_in_start(JSContext *ctx, JSValue *sp) { sp[-1] = build_for_in_iterator(ctx, sp[-1]); if (JS_IsException(sp[-1])) return -1; return 0; } /* return -1 if exception, 0 if slow case, 1 if the enumeration is finished */ static __exception int js_for_in_prepare_prototype_chain_enum(JSContext *ctx, JSValueConst enum_obj) { JSObject *p; JSForInIterator *it; JSPropertyEnum *tab_atom; uint32_t tab_atom_count, i; JSValue obj1; p = JS_VALUE_GET_OBJ(enum_obj); it = p->u.for_in_iterator; /* check if there are enumerable properties in the prototype chain (fast path) */ obj1 = JS_DupValue(ctx, it->obj); for(;;) { obj1 = JS_GetPrototypeFree(ctx, obj1); if (JS_IsNull(obj1)) break; if (JS_IsException(obj1)) goto fail; if (JS_GetOwnPropertyNamesInternal(ctx, &tab_atom, &tab_atom_count, JS_VALUE_GET_OBJ(obj1), JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY)) { JS_FreeValue(ctx, obj1); goto fail; } js_free_prop_enum(ctx, tab_atom, tab_atom_count); if (tab_atom_count != 0) { JS_FreeValue(ctx, obj1); goto slow_path; } /* must check for timeout to avoid infinite loop */ if (js_poll_interrupts(ctx)) { JS_FreeValue(ctx, obj1); goto fail; } } JS_FreeValue(ctx, obj1); return 1; slow_path: /* add the visited properties, even if they are not enumerable */ if (it->is_array) { if (JS_GetOwnPropertyNamesInternal(ctx, &tab_atom, &tab_atom_count, JS_VALUE_GET_OBJ(it->obj), JS_GPN_STRING_MASK | JS_GPN_SET_ENUM)) { goto fail; } it->is_array = FALSE; it->tab_atom = tab_atom; it->atom_count = tab_atom_count; } for(i = 0; i < it->atom_count; i++) { if (JS_DefinePropertyValue(ctx, enum_obj, it->tab_atom[i].atom, JS_NULL, JS_PROP_ENUMERABLE) < 0) goto fail; } return 0; fail: return -1; } /* enum_obj -> enum_obj value done */ static __exception int js_for_in_next(JSContext *ctx, JSValue *sp) { JSValueConst enum_obj; JSObject *p; JSAtom prop; JSForInIterator *it; JSPropertyEnum *tab_atom; uint32_t tab_atom_count; int ret; enum_obj = sp[-1]; /* fail safe */ if (JS_VALUE_GET_TAG(enum_obj) != JS_TAG_OBJECT) goto done; p = JS_VALUE_GET_OBJ(enum_obj); if (p->class_id != JS_CLASS_FOR_IN_ITERATOR) goto done; it = p->u.for_in_iterator; for(;;) { if (it->idx >= it->atom_count) { if (JS_IsNull(it->obj) || JS_IsUndefined(it->obj)) goto done; /* not an object */ /* no more property in the current object: look in the prototype */ if (!it->in_prototype_chain) { ret = js_for_in_prepare_prototype_chain_enum(ctx, enum_obj); if (ret < 0) return -1; if (ret) goto done; it->in_prototype_chain = TRUE; } it->obj = JS_GetPrototypeFree(ctx, it->obj); if (JS_IsException(it->obj)) return -1; if (JS_IsNull(it->obj)) goto done; /* no more prototype */ /* must check for timeout to avoid infinite loop */ if (js_poll_interrupts(ctx)) return -1; if (JS_GetOwnPropertyNamesInternal(ctx, &tab_atom, &tab_atom_count, JS_VALUE_GET_OBJ(it->obj), JS_GPN_STRING_MASK | JS_GPN_SET_ENUM)) { return -1; } js_free_prop_enum(ctx, it->tab_atom, it->atom_count); it->tab_atom = tab_atom; it->atom_count = tab_atom_count; it->idx = 0; } else { if (it->is_array) { prop = __JS_AtomFromUInt32(it->idx); it->idx++; } else { BOOL is_enumerable; prop = it->tab_atom[it->idx].atom; is_enumerable = it->tab_atom[it->idx].is_enumerable; it->idx++; if (it->in_prototype_chain) { /* slow case: we are in the prototype chain */ ret = JS_GetOwnPropertyInternal(ctx, NULL, JS_VALUE_GET_OBJ(enum_obj), prop); if (ret < 0) return ret; if (ret) continue; /* already visited */ /* add to the visited property list */ if (JS_DefinePropertyValue(ctx, enum_obj, prop, JS_NULL, JS_PROP_ENUMERABLE) < 0) return -1; } if (!is_enumerable) continue; } /* check if the property was deleted */ ret = JS_GetOwnPropertyInternal(ctx, NULL, JS_VALUE_GET_OBJ(it->obj), prop); if (ret < 0) return ret; if (ret) break; } } /* return the property */ sp[0] = JS_AtomToValue(ctx, prop); sp[1] = JS_FALSE; return 0; done: /* return the end */ sp[0] = JS_UNDEFINED; sp[1] = JS_TRUE; return 0; } static JSValue JS_GetIterator2(JSContext *ctx, JSValueConst obj, JSValueConst method) { JSValue enum_obj; enum_obj = JS_Call(ctx, method, obj, 0, NULL); if (JS_IsException(enum_obj)) return enum_obj; if (!JS_IsObject(enum_obj)) { JS_FreeValue(ctx, enum_obj); return JS_ThrowTypeErrorNotAnObject(ctx); } return enum_obj; } static JSValue JS_GetIterator(JSContext *ctx, JSValueConst obj, BOOL is_async) { JSValue method, ret, sync_iter; if (is_async) { method = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_asyncIterator); if (JS_IsException(method)) return method; if (JS_IsUndefined(method) || JS_IsNull(method)) { method = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_iterator); if (JS_IsException(method)) return method; sync_iter = JS_GetIterator2(ctx, obj, method); JS_FreeValue(ctx, method); if (JS_IsException(sync_iter)) return sync_iter; ret = JS_CreateAsyncFromSyncIterator(ctx, sync_iter); JS_FreeValue(ctx, sync_iter); return ret; } } else { method = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_iterator); if (JS_IsException(method)) return method; } if (!JS_IsFunction(ctx, method)) { JS_FreeValue(ctx, method); return JS_ThrowTypeError(ctx, "value is not iterable"); } ret = JS_GetIterator2(ctx, obj, method); JS_FreeValue(ctx, method); return ret; } /* return *pdone = 2 if the iterator object is not parsed */ static JSValue JS_IteratorNext2(JSContext *ctx, JSValueConst enum_obj, JSValueConst method, int argc, JSValueConst *argv, int *pdone) { JSValue obj; /* fast path for the built-in iterators (avoid creating the intermediate result object) */ if (JS_IsObject(method)) { JSObject *p = JS_VALUE_GET_OBJ(method); if (p->class_id == JS_CLASS_C_FUNCTION && p->u.cfunc.cproto == JS_CFUNC_iterator_next) { JSCFunctionType func; JSValueConst args[1]; /* in case the function expects one argument */ if (argc == 0) { args[0] = JS_UNDEFINED; argv = args; } func = p->u.cfunc.c_function; return func.iterator_next(ctx, enum_obj, argc, argv, pdone, p->u.cfunc.magic); } } obj = JS_Call(ctx, method, enum_obj, argc, argv); if (JS_IsException(obj)) goto fail; if (!JS_IsObject(obj)) { JS_FreeValue(ctx, obj); JS_ThrowTypeError(ctx, "iterator must return an object"); goto fail; } *pdone = 2; return obj; fail: *pdone = FALSE; return JS_EXCEPTION; } static JSValue JS_IteratorNext(JSContext *ctx, JSValueConst enum_obj, JSValueConst method, int argc, JSValueConst *argv, BOOL *pdone) { JSValue obj, value, done_val; int done; obj = JS_IteratorNext2(ctx, enum_obj, method, argc, argv, &done); if (JS_IsException(obj)) goto fail; if (done != 2) { *pdone = done; return obj; } else { done_val = JS_GetProperty(ctx, obj, JS_ATOM_done); if (JS_IsException(done_val)) goto fail; *pdone = JS_ToBoolFree(ctx, done_val); value = JS_UNDEFINED; if (!*pdone) { value = JS_GetProperty(ctx, obj, JS_ATOM_value); } JS_FreeValue(ctx, obj); return value; } fail: JS_FreeValue(ctx, obj); *pdone = FALSE; return JS_EXCEPTION; } /* return < 0 in case of exception */ static int JS_IteratorClose(JSContext *ctx, JSValueConst enum_obj, BOOL is_exception_pending) { JSValue method, ret, ex_obj; int res; if (is_exception_pending) { ex_obj = ctx->rt->current_exception; ctx->rt->current_exception = JS_NULL; res = -1; } else { ex_obj = JS_UNDEFINED; res = 0; } method = JS_GetProperty(ctx, enum_obj, JS_ATOM_return); if (JS_IsException(method)) { res = -1; goto done; } if (JS_IsUndefined(method) || JS_IsNull(method)) { goto done; } ret = JS_CallFree(ctx, method, enum_obj, 0, NULL); if (!is_exception_pending) { if (JS_IsException(ret)) { res = -1; } else if (!JS_IsObject(ret)) { JS_ThrowTypeErrorNotAnObject(ctx); res = -1; } } JS_FreeValue(ctx, ret); done: if (is_exception_pending) { JS_Throw(ctx, ex_obj); } return res; } /* obj -> enum_rec (3 slots) */ static __exception int js_for_of_start(JSContext *ctx, JSValue *sp, BOOL is_async) { JSValue op1, obj, method; op1 = sp[-1]; obj = JS_GetIterator(ctx, op1, is_async); if (JS_IsException(obj)) return -1; JS_FreeValue(ctx, op1); sp[-1] = obj; method = JS_GetProperty(ctx, obj, JS_ATOM_next); if (JS_IsException(method)) return -1; sp[0] = method; return 0; } /* enum_rec [objs] -> enum_rec [objs] value done. There are 'offset' objs. If 'done' is true or in case of exception, 'enum_rec' is set to undefined. If 'done' is true, 'value' is always set to undefined. */ static __exception int js_for_of_next(JSContext *ctx, JSValue *sp, int offset) { JSValue value = JS_UNDEFINED; int done = 1; if (likely(!JS_IsUndefined(sp[offset]))) { value = JS_IteratorNext(ctx, sp[offset], sp[offset + 1], 0, NULL, &done); if (JS_IsException(value)) done = -1; if (done) { /* value is JS_UNDEFINED or JS_EXCEPTION */ /* replace the iteration object with undefined */ JS_FreeValue(ctx, sp[offset]); sp[offset] = JS_UNDEFINED; if (done < 0) { return -1; } else { JS_FreeValue(ctx, value); value = JS_UNDEFINED; } } } sp[0] = value; sp[1] = JS_NewBool(ctx, done); return 0; } static JSValue JS_IteratorGetCompleteValue(JSContext *ctx, JSValueConst obj, BOOL *pdone) { JSValue done_val, value; BOOL done; done_val = JS_GetProperty(ctx, obj, JS_ATOM_done); if (JS_IsException(done_val)) goto fail; done = JS_ToBoolFree(ctx, done_val); value = JS_GetProperty(ctx, obj, JS_ATOM_value); if (JS_IsException(value)) goto fail; *pdone = done; return value; fail: *pdone = FALSE; return JS_EXCEPTION; } static __exception int js_iterator_get_value_done(JSContext *ctx, JSValue *sp) { JSValue obj, value; BOOL done; obj = sp[-1]; if (!JS_IsObject(obj)) { JS_ThrowTypeError(ctx, "iterator must return an object"); return -1; } value = JS_IteratorGetCompleteValue(ctx, obj, &done); if (JS_IsException(value)) return -1; JS_FreeValue(ctx, obj); sp[-1] = value; sp[0] = JS_NewBool(ctx, done); return 0; } static JSValue js_create_iterator_result(JSContext *ctx, JSValue val, BOOL done) { JSValue obj; obj = JS_NewObject(ctx); if (JS_IsException(obj)) { JS_FreeValue(ctx, val); return obj; } if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_value, val, JS_PROP_C_W_E) < 0) { goto fail; } if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_done, JS_NewBool(ctx, done), JS_PROP_C_W_E) < 0) { fail: JS_FreeValue(ctx, obj); return JS_EXCEPTION; } return obj; } static JSValue js_array_iterator_next(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, BOOL *pdone, int magic); static JSValue js_create_array_iterator(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic); static BOOL js_is_fast_array(JSContext *ctx, JSValueConst obj) { /* Try and handle fast arrays explicitly */ if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { JSObject *p = JS_VALUE_GET_OBJ(obj); if (p->class_id == JS_CLASS_ARRAY && p->fast_array) { return TRUE; } } return FALSE; } /* Access an Array's internal JSValue array if available */ static BOOL js_get_fast_array(JSContext *ctx, JSValueConst obj, JSValue **arrpp, uint32_t *countp) { /* Try and handle fast arrays explicitly */ if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) { JSObject *p = JS_VALUE_GET_OBJ(obj); if (p->class_id == JS_CLASS_ARRAY && p->fast_array) { *countp = p->u.array.count; *arrpp = p->u.array.u.values; return TRUE; } } return FALSE; } static __exception int js_append_enumerate(JSContext *ctx, JSValue *sp) { JSValue iterator, enumobj, method, value; int is_array_iterator; JSValue *arrp; uint32_t i, count32, pos; if (JS_VALUE_GET_TAG(sp[-2]) != JS_TAG_INT) { JS_ThrowInternalError(ctx, "invalid index for append"); return -1; } pos = JS_VALUE_GET_INT(sp[-2]); /* XXX: further optimisations: - use ctx->array_proto_values? - check if array_iterator_prototype next method is built-in and avoid constructing actual iterator object? - build this into js_for_of_start and use in all `for (x of o)` loops */ iterator = JS_GetProperty(ctx, sp[-1], JS_ATOM_Symbol_iterator); if (JS_IsException(iterator)) return -1; is_array_iterator = JS_IsCFunction(ctx, iterator, (JSCFunction *)js_create_array_iterator, JS_ITERATOR_KIND_VALUE); JS_FreeValue(ctx, iterator); enumobj = JS_GetIterator(ctx, sp[-1], FALSE); if (JS_IsException(enumobj)) return -1; method = JS_GetProperty(ctx, enumobj, JS_ATOM_next); if (JS_IsException(method)) { JS_FreeValue(ctx, enumobj); return -1; } if (is_array_iterator && JS_IsCFunction(ctx, method, (JSCFunction *)js_array_iterator_next, 0) && js_get_fast_array(ctx, sp[-1], &arrp, &count32)) { uint32_t len; if (js_get_length32(ctx, &len, sp[-1])) goto exception; /* if len > count32, the elements >= count32 might be read in the prototypes and might have side effects */ if (len != count32) goto general_case; /* Handle fast arrays explicitly */ for (i = 0; i < count32; i++) { if (JS_DefinePropertyValueUint32(ctx, sp[-3], pos++, JS_DupValue(ctx, arrp[i]), JS_PROP_C_W_E) < 0) goto exception; } } else { general_case: for (;;) { BOOL done; value = JS_IteratorNext(ctx, enumobj, method, 0, NULL, &done); if (JS_IsException(value)) goto exception; if (done) { /* value is JS_UNDEFINED */ break; } if (JS_DefinePropertyValueUint32(ctx, sp[-3], pos++, value, JS_PROP_C_W_E) < 0) goto exception; } } /* Note: could raise an error if too many elements */ sp[-2] = JS_NewInt32(ctx, pos); JS_FreeValue(ctx, enumobj); JS_FreeValue(ctx, method); return 0; exception: JS_IteratorClose(ctx, enumobj, TRUE); JS_FreeValue(ctx, enumobj); JS_FreeValue(ctx, method); return -1; } static __exception int JS_CopyDataProperties(JSContext *ctx, JSValueConst target, JSValueConst source, JSValueConst excluded, BOOL setprop) { JSPropertyEnum *tab_atom; JSValue val; uint32_t i, tab_atom_count; JSObject *p; JSObject *pexcl = NULL; int ret, gpn_flags; JSPropertyDescriptor desc; BOOL is_enumerable; if (JS_VALUE_GET_TAG(source) != JS_TAG_OBJECT) return 0; if (JS_VALUE_GET_TAG(excluded) == JS_TAG_OBJECT) pexcl = JS_VALUE_GET_OBJ(excluded); p = JS_VALUE_GET_OBJ(source); gpn_flags = JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK | JS_GPN_ENUM_ONLY; if (p->is_exotic) { const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic; /* cannot use JS_GPN_ENUM_ONLY with e.g. proxies because it introduces a visible change */ if (em && em->get_own_property_names) { gpn_flags &= ~JS_GPN_ENUM_ONLY; } } if (JS_GetOwnPropertyNamesInternal(ctx, &tab_atom, &tab_atom_count, p, gpn_flags)) return -1; for (i = 0; i < tab_atom_count; i++) { if (pexcl) { ret = JS_GetOwnPropertyInternal(ctx, NULL, pexcl, tab_atom[i].atom); if (ret) { if (ret < 0) goto exception; continue; } } if (!(gpn_flags & JS_GPN_ENUM_ONLY)) { /* test if the property is enumerable */ ret = JS_GetOwnPropertyInternal(ctx, &desc, p, tab_atom[i].atom); if (ret < 0) goto exception; if (!ret) continue; is_enumerable = (desc.flags & JS_PROP_ENUMERABLE) != 0; js_free_desc(ctx, &desc); if (!is_enumerable) continue; } val = JS_GetProperty(ctx, source, tab_atom[i].atom); if (JS_IsException(val)) goto exception; if (setprop) ret = JS_SetProperty(ctx, target, tab_atom[i].atom, val); else ret = JS_DefinePropertyValue(ctx, target, tab_atom[i].atom, val, JS_PROP_C_W_E); if (ret < 0) goto exception; } js_free_prop_enum(ctx, tab_atom, tab_atom_count); return 0; exception: js_free_prop_enum(ctx, tab_atom, tab_atom_count); return -1; } /* only valid inside C functions */ static JSValueConst JS_GetActiveFunction(JSContext *ctx) { return ctx->rt->current_stack_frame->cur_func; } static JSVarRef *get_var_ref(JSContext *ctx, JSStackFrame *sf, int var_idx, BOOL is_arg) { JSVarRef *var_ref; struct list_head *el; list_for_each(el, &sf->var_ref_list) { var_ref = list_entry(el, JSVarRef, var_ref_link); if (var_ref->var_idx == var_idx && var_ref->is_arg == is_arg) { var_ref->header.ref_count++; return var_ref; } } /* create a new one */ var_ref = js_malloc(ctx, sizeof(JSVarRef)); if (!var_ref) return NULL; var_ref->header.ref_count = 1; add_gc_object(ctx->rt, &var_ref->header, JS_GC_OBJ_TYPE_VAR_REF); var_ref->is_detached = FALSE; var_ref->is_arg = is_arg; var_ref->var_idx = var_idx; list_add_tail(&var_ref->var_ref_link, &sf->var_ref_list); if (sf->js_mode & JS_MODE_ASYNC) { /* The stack frame is detached and may be destroyed at any time so its reference count must be increased. Calling close_var_refs() when destroying the stack frame is not possible because it would change the graph between the GC objects. Another solution could be to temporarily detach the JSVarRef of async functions during the GC. It would have the advantage of allowing the release of unused stack frames in a cycle. */ var_ref->async_func = container_of(sf, JSAsyncFunctionState, frame); var_ref->async_func->header.ref_count++; } else { var_ref->async_func = NULL; } if (is_arg) var_ref->pvalue = &sf->arg_buf[var_idx]; else var_ref->pvalue = &sf->var_buf[var_idx]; return var_ref; } static JSValue js_closure2(JSContext *ctx, JSValue func_obj, JSFunctionBytecode *b, JSVarRef **cur_var_refs, JSStackFrame *sf) { JSObject *p; JSVarRef **var_refs; int i; p = JS_VALUE_GET_OBJ(func_obj); p->u.func.function_bytecode = b; p->u.func.home_object = NULL; p->u.func.var_refs = NULL; if (b->closure_var_count) { var_refs = js_mallocz(ctx, sizeof(var_refs[0]) * b->closure_var_count); if (!var_refs) goto fail; p->u.func.var_refs = var_refs; for(i = 0; i < b->closure_var_count; i++) { JSClosureVar *cv = &b->closure_var[i]; JSVarRef *var_ref; if (cv->is_local) { /* reuse the existing variable reference if it already exists */ var_ref = get_var_ref(ctx, sf, cv->var_idx, cv->is_arg); if (!var_ref) goto fail; } else { var_ref = cur_var_refs[cv->var_idx]; var_ref->header.ref_count++; } var_refs[i] = var_ref; } } return func_obj; fail: /* bfunc is freed when func_obj is freed */ JS_FreeValue(ctx, func_obj); return JS_EXCEPTION; } static JSValue js_instantiate_prototype(JSContext *ctx, JSObject *p, JSAtom atom, void *opaque) { JSValue obj, this_val; int ret; this_val = JS_MKPTR(JS_TAG_OBJECT, p); obj = JS_NewObject(ctx); if (JS_IsException(obj)) return JS_EXCEPTION; set_cycle_flag(ctx, obj); set_cycle_flag(ctx, this_val); ret = JS_DefinePropertyValue(ctx, obj, JS_ATOM_constructor, JS_DupValue(ctx, this_val), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); if (ret < 0) { JS_FreeValue(ctx, obj); return JS_EXCEPTION; } return obj; } static const uint16_t func_kind_to_class_id[] = { [JS_FUNC_NORMAL] = JS_CLASS_BYTECODE_FUNCTION, [JS_FUNC_GENERATOR] = JS_CLASS_GENERATOR_FUNCTION, [JS_FUNC_ASYNC] = JS_CLASS_ASYNC_FUNCTION, [JS_FUNC_ASYNC_GENERATOR] = JS_CLASS_ASYNC_GENERATOR_FUNCTION, }; static JSValue js_closure(JSContext *ctx, JSValue bfunc, JSVarRef **cur_var_refs, JSStackFrame *sf) { JSFunctionBytecode *b; JSValue func_obj; JSAtom name_atom; b = JS_VALUE_GET_PTR(bfunc); func_obj = JS_NewObjectClass(ctx, func_kind_to_class_id[b->func_kind]); if (JS_IsException(func_obj)) { JS_FreeValue(ctx, bfunc); return JS_EXCEPTION; } func_obj = js_closure2(ctx, func_obj, b, cur_var_refs, sf); if (JS_IsException(func_obj)) { /* bfunc has been freed */ goto fail; } name_atom = b->func_name; if (name_atom == JS_ATOM_NULL) name_atom = JS_ATOM_empty_string; js_function_set_properties(ctx, func_obj, name_atom, b->defined_arg_count); if (b->func_kind & JS_FUNC_GENERATOR) { JSValue proto; int proto_class_id; /* generators have a prototype field which is used as prototype for the generator object */ if (b->func_kind == JS_FUNC_ASYNC_GENERATOR) proto_class_id = JS_CLASS_ASYNC_GENERATOR; else proto_class_id = JS_CLASS_GENERATOR; proto = JS_NewObjectProto(ctx, ctx->class_proto[proto_class_id]); if (JS_IsException(proto)) goto fail; JS_DefinePropertyValue(ctx, func_obj, JS_ATOM_prototype, proto, JS_PROP_WRITABLE); } else if (b->has_prototype) { /* add the 'prototype' property: delay instantiation to avoid creating cycles for every javascript function. The prototype object is created on the fly when first accessed */ JS_SetConstructorBit(ctx, func_obj, TRUE); JS_DefineAutoInitProperty(ctx, func_obj, JS_ATOM_prototype, JS_AUTOINIT_ID_PROTOTYPE, NULL, JS_PROP_WRITABLE); } return func_obj; fail: /* bfunc is freed when func_obj is freed */ JS_FreeValue(ctx, func_obj); return JS_EXCEPTION; } #define JS_DEFINE_CLASS_HAS_HERITAGE (1 << 0) static int js_op_define_class(JSContext *ctx, JSValue *sp, JSAtom class_name, int class_flags, JSVarRef **cur_var_refs, JSStackFrame *sf, BOOL is_computed_name) { JSValue bfunc, parent_class, proto = JS_UNDEFINED; JSValue ctor = JS_UNDEFINED, parent_proto = JS_UNDEFINED; JSFunctionBytecode *b; parent_class = sp[-2]; bfunc = sp[-1]; if (class_flags & JS_DEFINE_CLASS_HAS_HERITAGE) { if (JS_IsNull(parent_class)) { parent_proto = JS_NULL; parent_class = JS_DupValue(ctx, ctx->function_proto); } else { if (!JS_IsConstructor(ctx, parent_class)) { JS_ThrowTypeError(ctx, "parent class must be constructor"); goto fail; } parent_proto = JS_GetProperty(ctx, parent_class, JS_ATOM_prototype); if (JS_IsException(parent_proto)) goto fail; if (!JS_IsNull(parent_proto) && !JS_IsObject(parent_proto)) { JS_ThrowTypeError(ctx, "parent prototype must be an object or null"); goto fail; } } } else { /* parent_class is JS_UNDEFINED in this case */ parent_proto = JS_DupValue(ctx, ctx->class_proto[JS_CLASS_OBJECT]); parent_class = JS_DupValue(ctx, ctx->function_proto); } proto = JS_NewObjectProto(ctx, parent_proto); if (JS_IsException(proto)) goto fail; b = JS_VALUE_GET_PTR(bfunc); assert(b->func_kind == JS_FUNC_NORMAL); ctor = JS_NewObjectProtoClass(ctx, parent_class, JS_CLASS_BYTECODE_FUNCTION); if (JS_IsException(ctor)) goto fail; ctor = js_closure2(ctx, ctor, b, cur_var_refs, sf); bfunc = JS_UNDEFINED; if (JS_IsException(ctor)) goto fail; js_method_set_home_object(ctx, ctor, proto); JS_SetConstructorBit(ctx, ctor, TRUE); JS_DefinePropertyValue(ctx, ctor, JS_ATOM_length, JS_NewInt32(ctx, b->defined_arg_count), JS_PROP_CONFIGURABLE); if (is_computed_name) { if (JS_DefineObjectNameComputed(ctx, ctor, sp[-3], JS_PROP_CONFIGURABLE) < 0) goto fail; } else { if (JS_DefineObjectName(ctx, ctor, class_name, JS_PROP_CONFIGURABLE) < 0) goto fail; } /* the constructor property must be first. It can be overriden by computed property names */ if (JS_DefinePropertyValue(ctx, proto, JS_ATOM_constructor, JS_DupValue(ctx, ctor), JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE | JS_PROP_THROW) < 0) goto fail; /* set the prototype property */ if (JS_DefinePropertyValue(ctx, ctor, JS_ATOM_prototype, JS_DupValue(ctx, proto), JS_PROP_THROW) < 0) goto fail; set_cycle_flag(ctx, ctor); set_cycle_flag(ctx, proto); JS_FreeValue(ctx, parent_proto); JS_FreeValue(ctx, parent_class); sp[-2] = ctor; sp[-1] = proto; return 0; fail: JS_FreeValue(ctx, parent_class); JS_FreeValue(ctx, parent_proto); JS_FreeValue(ctx, bfunc); JS_FreeValue(ctx, proto); JS_FreeValue(ctx, ctor); sp[-2] = JS_UNDEFINED; sp[-1] = JS_UNDEFINED; return -1; } static void close_var_refs(JSRuntime *rt, JSStackFrame *sf) { struct list_head *el, *el1; JSVarRef *var_ref; int var_idx; list_for_each_safe(el, el1, &sf->var_ref_list) { var_ref = list_entry(el, JSVarRef, var_ref_link); /* no need to unlink var_ref->var_ref_link as the list is never used afterwards */ if (var_ref->async_func) async_func_free(rt, var_ref->async_func); var_idx = var_ref->var_idx; if (var_ref->is_arg) var_ref->value = JS_DupValueRT(rt, sf->arg_buf[var_idx]); else var_ref->value = JS_DupValueRT(rt, sf->var_buf[var_idx]); var_ref->pvalue = &var_ref->value; /* the reference is no longer to a local variable */ var_ref->is_detached = TRUE; } } static void close_lexical_var(JSContext *ctx, JSStackFrame *sf, int idx, int is_arg) { 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, var_ref_link); if (var_idx == var_ref->var_idx && var_ref->is_arg == is_arg) { list_del(&var_ref->var_ref_link); if (var_ref->async_func) async_func_free(ctx->rt, var_ref->async_func); var_ref->value = JS_DupValue(ctx, sf->var_buf[var_idx]); var_ref->pvalue = &var_ref->value; /* the reference is no longer to a local variable */ var_ref->is_detached = TRUE; } } } #define JS_CALL_FLAG_COPY_ARGV (1 << 1) #define JS_CALL_FLAG_GENERATOR (1 << 2) static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags) { JSRuntime *rt = ctx->rt; JSCFunctionType func; JSObject *p; JSStackFrame sf_s, *sf = &sf_s, *prev_sf; JSValue ret_val; JSValueConst *arg_buf; int arg_count, i; JSCFunctionEnum cproto; p = JS_VALUE_GET_OBJ(func_obj); cproto = p->u.cfunc.cproto; arg_count = p->u.cfunc.length; /* better to always check stack overflow */ if (js_check_stack_overflow(rt, sizeof(arg_buf[0]) * arg_count)) return JS_ThrowStackOverflow(ctx); prev_sf = rt->current_stack_frame; sf->prev_frame = prev_sf; rt->current_stack_frame = sf; ctx = p->u.cfunc.realm; /* change the current realm */ #ifdef CONFIG_BIGNUM /* we only propagate the bignum mode as some runtime functions test it */ if (prev_sf) sf->js_mode = prev_sf->js_mode & JS_MODE_MATH; else sf->js_mode = 0; #else sf->js_mode = 0; #endif sf->cur_func = (JSValue)func_obj; sf->arg_count = argc; arg_buf = argv; if (unlikely(argc < arg_count)) { /* ensure that at least argc_count arguments are readable */ arg_buf = alloca(sizeof(arg_buf[0]) * arg_count); for(i = 0; i < argc; i++) arg_buf[i] = argv[i]; for(i = argc; i < arg_count; i++) arg_buf[i] = JS_UNDEFINED; sf->arg_count = arg_count; } sf->arg_buf = (JSValue*)arg_buf; func = p->u.cfunc.c_function; switch(cproto) { case JS_CFUNC_constructor: case JS_CFUNC_constructor_or_func: if (!(flags & JS_CALL_FLAG_CONSTRUCTOR)) { if (cproto == JS_CFUNC_constructor) { not_a_constructor: ret_val = JS_ThrowTypeError(ctx, "must be called with new"); break; } else { this_obj = JS_UNDEFINED; } } /* here this_obj is new_target */ /* fall thru */ case JS_CFUNC_generic: ret_val = func.generic(ctx, this_obj, argc, arg_buf); break; case JS_CFUNC_constructor_magic: case JS_CFUNC_constructor_or_func_magic: if (!(flags & JS_CALL_FLAG_CONSTRUCTOR)) { if (cproto == JS_CFUNC_constructor_magic) { goto not_a_constructor; } else { this_obj = JS_UNDEFINED; } } /* fall thru */ case JS_CFUNC_generic_magic: ret_val = func.generic_magic(ctx, this_obj, argc, arg_buf, p->u.cfunc.magic); break; case JS_CFUNC_getter: ret_val = func.getter(ctx, this_obj); break; case JS_CFUNC_setter: ret_val = func.setter(ctx, this_obj, arg_buf[0]); break; case JS_CFUNC_getter_magic: ret_val = func.getter_magic(ctx, this_obj, p->u.cfunc.magic); break; case JS_CFUNC_setter_magic: ret_val = func.setter_magic(ctx, this_obj, arg_buf[0], p->u.cfunc.magic); break; case JS_CFUNC_f_f: { double d1; if (unlikely(JS_ToFloat64(ctx, &d1, arg_buf[0]))) { ret_val = JS_EXCEPTION; break; } ret_val = JS_NewFloat64(ctx, func.f_f(d1)); } break; case JS_CFUNC_f_f_f: { double d1, d2; if (unlikely(JS_ToFloat64(ctx, &d1, arg_buf[0]))) { ret_val = JS_EXCEPTION; break; } if (unlikely(JS_ToFloat64(ctx, &d2, arg_buf[1]))) { ret_val = JS_EXCEPTION; break; } ret_val = JS_NewFloat64(ctx, func.f_f_f(d1, d2)); } break; case JS_CFUNC_iterator_next: { int done; ret_val = func.iterator_next(ctx, this_obj, argc, arg_buf, &done, p->u.cfunc.magic); if (!JS_IsException(ret_val) && done != 2) { ret_val = js_create_iterator_result(ctx, ret_val, done); } } break; default: abort(); } rt->current_stack_frame = sf->prev_frame; return ret_val; } static JSValue js_call_bound_function(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags) { JSObject *p; JSBoundFunction *bf; JSValueConst *arg_buf, new_target; int arg_count, i; p = JS_VALUE_GET_OBJ(func_obj); bf = p->u.bound_function; arg_count = bf->argc + argc; if (js_check_stack_overflow(ctx->rt, sizeof(JSValue) * arg_count)) return JS_ThrowStackOverflow(ctx); arg_buf = alloca(sizeof(JSValue) * arg_count); for(i = 0; i < bf->argc; i++) { arg_buf[i] = bf->argv[i]; } for(i = 0; i < argc; i++) { arg_buf[bf->argc + i] = argv[i]; } if (flags & JS_CALL_FLAG_CONSTRUCTOR) { new_target = this_obj; if (js_same_value(ctx, func_obj, new_target)) new_target = bf->func_obj; return JS_CallConstructor2(ctx, bf->func_obj, new_target, arg_count, arg_buf); } else { return JS_Call(ctx, bf->func_obj, bf->this_val, arg_count, arg_buf); } } /* argument of OP_special_object */ typedef enum { OP_SPECIAL_OBJECT_ARGUMENTS, OP_SPECIAL_OBJECT_MAPPED_ARGUMENTS, OP_SPECIAL_OBJECT_THIS_FUNC, OP_SPECIAL_OBJECT_NEW_TARGET, OP_SPECIAL_OBJECT_HOME_OBJECT, OP_SPECIAL_OBJECT_VAR_OBJECT, OP_SPECIAL_OBJECT_IMPORT_META, } OPSpecialObjectEnum; #define FUNC_RET_AWAIT 0 #define FUNC_RET_YIELD 1 #define FUNC_RET_YIELD_STAR 2 #define FUNC_RET_INITIAL_YIELD 3 /* argv[] is modified if (flags & JS_CALL_FLAG_COPY_ARGV) = 0. */ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj, JSValueConst this_obj, JSValueConst new_target, int argc, JSValue *argv, int flags) { JSRuntime *rt = caller_ctx->rt; JSContext *ctx; JSObject *p; JSFunctionBytecode *b; JSStackFrame sf_s, *sf = &sf_s; const uint8_t *pc; int opcode, arg_allocated_size, i; JSValue *local_buf, *stack_buf, *var_buf, *arg_buf, *sp, ret_val, *pval; JSVarRef **var_refs; size_t alloca_size; #if !DIRECT_DISPATCH #define SWITCH(pc) switch (opcode = *pc++) #define CASE(op) case op #define DEFAULT default #define BREAK break #else static const void * const dispatch_table[256] = { #define DEF(id, size, n_pop, n_push, f) && case_OP_ ## id, #if SHORT_OPCODES #define def(id, size, n_pop, n_push, f) #else #define def(id, size, n_pop, n_push, f) && case_default, #endif #include "quickjs-opcode.h" [ OP_COUNT ... 255 ] = &&case_default }; #define SWITCH(pc) goto *dispatch_table[opcode = *pc++]; #define CASE(op) case_ ## op #define DEFAULT case_default #define BREAK SWITCH(pc) #endif if (js_poll_interrupts(caller_ctx)) return JS_EXCEPTION; if (unlikely(JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT)) { if (flags & JS_CALL_FLAG_GENERATOR) { JSAsyncFunctionState *s = JS_VALUE_GET_PTR(func_obj); /* func_obj get contains a pointer to JSFuncAsyncState */ /* the stack frame is already allocated */ sf = &s->frame; p = JS_VALUE_GET_OBJ(sf->cur_func); b = p->u.func.function_bytecode; ctx = b->realm; var_refs = p->u.func.var_refs; local_buf = arg_buf = sf->arg_buf; var_buf = sf->var_buf; stack_buf = sf->var_buf + b->var_count; sp = sf->cur_sp; sf->cur_sp = NULL; /* cur_sp is NULL if the function is running */ pc = sf->cur_pc; sf->prev_frame = rt->current_stack_frame; rt->current_stack_frame = sf; if (s->throw_flag) goto exception; else goto restart; } else { goto not_a_function; } } p = JS_VALUE_GET_OBJ(func_obj); if (unlikely(p->class_id != JS_CLASS_BYTECODE_FUNCTION)) { JSClassCall *call_func; call_func = rt->class_array[p->class_id].call; if (!call_func) { not_a_function: return JS_ThrowTypeError(caller_ctx, "not a function"); } return call_func(caller_ctx, func_obj, this_obj, argc, (JSValueConst *)argv, flags); } b = p->u.func.function_bytecode; if (unlikely(argc < b->arg_count || (flags & JS_CALL_FLAG_COPY_ARGV))) { arg_allocated_size = b->arg_count; } else { arg_allocated_size = 0; } alloca_size = sizeof(JSValue) * (arg_allocated_size + b->var_count + b->stack_size); if (js_check_stack_overflow(rt, alloca_size)) return JS_ThrowStackOverflow(caller_ctx); sf->js_mode = b->js_mode; arg_buf = argv; sf->arg_count = argc; sf->cur_func = (JSValue)func_obj; init_list_head(&sf->var_ref_list); var_refs = p->u.func.var_refs; local_buf = alloca(alloca_size); if (unlikely(arg_allocated_size)) { int n = min_int(argc, b->arg_count); arg_buf = local_buf; for(i = 0; i < n; i++) arg_buf[i] = JS_DupValue(caller_ctx, argv[i]); for(; i < b->arg_count; i++) arg_buf[i] = JS_UNDEFINED; sf->arg_count = b->arg_count; } var_buf = local_buf + arg_allocated_size; sf->var_buf = var_buf; sf->arg_buf = arg_buf; for(i = 0; i < b->var_count; i++) var_buf[i] = JS_UNDEFINED; stack_buf = var_buf + b->var_count; sp = stack_buf; pc = b->byte_code_buf; sf->prev_frame = rt->current_stack_frame; rt->current_stack_frame = sf; ctx = b->realm; /* set the current realm */ restart: for(;;) { int call_argc; JSValue *call_argv; SWITCH(pc) { CASE(OP_push_i32): *sp++ = JS_NewInt32(ctx, get_u32(pc)); pc += 4; BREAK; CASE(OP_push_const): *sp++ = JS_DupValue(ctx, b->cpool[get_u32(pc)]); pc += 4; BREAK; #if SHORT_OPCODES CASE(OP_push_minus1): CASE(OP_push_0): CASE(OP_push_1): CASE(OP_push_2): CASE(OP_push_3): CASE(OP_push_4): CASE(OP_push_5): CASE(OP_push_6): CASE(OP_push_7): *sp++ = JS_NewInt32(ctx, opcode - OP_push_0); BREAK; CASE(OP_push_i8): *sp++ = JS_NewInt32(ctx, get_i8(pc)); pc += 1; BREAK; CASE(OP_push_i16): *sp++ = JS_NewInt32(ctx, get_i16(pc)); pc += 2; BREAK; CASE(OP_push_const8): *sp++ = JS_DupValue(ctx, b->cpool[*pc++]); BREAK; CASE(OP_fclosure8): *sp++ = js_closure(ctx, JS_DupValue(ctx, b->cpool[*pc++]), var_refs, sf); if (unlikely(JS_IsException(sp[-1]))) goto exception; BREAK; CASE(OP_push_empty_string): *sp++ = JS_AtomToString(ctx, JS_ATOM_empty_string); BREAK; CASE(OP_get_length): { JSValue val; val = JS_GetProperty(ctx, sp[-1], JS_ATOM_length); if (unlikely(JS_IsException(val))) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = val; } BREAK; #endif CASE(OP_push_atom_value): *sp++ = JS_AtomToValue(ctx, get_u32(pc)); pc += 4; BREAK; CASE(OP_undefined): *sp++ = JS_UNDEFINED; BREAK; CASE(OP_null): *sp++ = JS_NULL; BREAK; CASE(OP_push_this): /* OP_push_this is only called at the start of a function */ { JSValue val; if (!(b->js_mode & JS_MODE_STRICT)) { uint32_t tag = JS_VALUE_GET_TAG(this_obj); if (likely(tag == JS_TAG_OBJECT)) goto normal_this; if (tag == JS_TAG_NULL || tag == JS_TAG_UNDEFINED) { val = JS_DupValue(ctx, ctx->global_obj); } else { val = JS_ToObject(ctx, this_obj); if (JS_IsException(val)) goto exception; } } else { normal_this: val = JS_DupValue(ctx, this_obj); } *sp++ = val; } BREAK; CASE(OP_push_false): *sp++ = JS_FALSE; BREAK; CASE(OP_push_true): *sp++ = JS_TRUE; BREAK; CASE(OP_object): *sp++ = JS_NewObject(ctx); if (unlikely(JS_IsException(sp[-1]))) goto exception; BREAK; CASE(OP_special_object): { int arg = *pc++; switch(arg) { case OP_SPECIAL_OBJECT_ARGUMENTS: *sp++ = js_build_arguments(ctx, argc, (JSValueConst *)argv); if (unlikely(JS_IsException(sp[-1]))) goto exception; break; case OP_SPECIAL_OBJECT_MAPPED_ARGUMENTS: *sp++ = js_build_mapped_arguments(ctx, argc, (JSValueConst *)argv, sf, min_int(argc, b->arg_count)); if (unlikely(JS_IsException(sp[-1]))) goto exception; break; case OP_SPECIAL_OBJECT_THIS_FUNC: *sp++ = JS_DupValue(ctx, sf->cur_func); break; case OP_SPECIAL_OBJECT_NEW_TARGET: *sp++ = JS_DupValue(ctx, new_target); break; case OP_SPECIAL_OBJECT_HOME_OBJECT: { JSObject *p1; p1 = p->u.func.home_object; if (unlikely(!p1)) *sp++ = JS_UNDEFINED; else *sp++ = JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, p1)); } break; case OP_SPECIAL_OBJECT_VAR_OBJECT: *sp++ = JS_NewObjectProto(ctx, JS_NULL); if (unlikely(JS_IsException(sp[-1]))) goto exception; break; case OP_SPECIAL_OBJECT_IMPORT_META: *sp++ = js_import_meta(ctx); if (unlikely(JS_IsException(sp[-1]))) goto exception; break; default: abort(); } } BREAK; CASE(OP_rest): { int first = get_u16(pc); pc += 2; *sp++ = js_build_rest(ctx, first, argc, (JSValueConst *)argv); if (unlikely(JS_IsException(sp[-1]))) goto exception; } BREAK; CASE(OP_drop): JS_FreeValue(ctx, sp[-1]); sp--; BREAK; CASE(OP_nip): JS_FreeValue(ctx, sp[-2]); sp[-2] = sp[-1]; sp--; BREAK; CASE(OP_nip1): /* a b c -> b c */ JS_FreeValue(ctx, sp[-3]); sp[-3] = sp[-2]; sp[-2] = sp[-1]; sp--; BREAK; CASE(OP_dup): sp[0] = JS_DupValue(ctx, sp[-1]); sp++; BREAK; CASE(OP_dup2): /* a b -> a b a b */ sp[0] = JS_DupValue(ctx, sp[-2]); sp[1] = JS_DupValue(ctx, sp[-1]); sp += 2; BREAK; CASE(OP_dup3): /* a b c -> a b c a b c */ sp[0] = JS_DupValue(ctx, sp[-3]); sp[1] = JS_DupValue(ctx, sp[-2]); sp[2] = JS_DupValue(ctx, sp[-1]); sp += 3; BREAK; CASE(OP_dup1): /* a b -> a a b */ sp[0] = sp[-1]; sp[-1] = JS_DupValue(ctx, sp[-2]); sp++; BREAK; CASE(OP_insert2): /* obj a -> a obj a (dup_x1) */ sp[0] = sp[-1]; sp[-1] = sp[-2]; sp[-2] = JS_DupValue(ctx, sp[0]); sp++; BREAK; CASE(OP_insert3): /* obj prop a -> a obj prop a (dup_x2) */ sp[0] = sp[-1]; sp[-1] = sp[-2]; sp[-2] = sp[-3]; sp[-3] = JS_DupValue(ctx, sp[0]); sp++; BREAK; CASE(OP_insert4): /* this obj prop a -> a this obj prop a */ sp[0] = sp[-1]; sp[-1] = sp[-2]; sp[-2] = sp[-3]; sp[-3] = sp[-4]; sp[-4] = JS_DupValue(ctx, sp[0]); sp++; BREAK; CASE(OP_perm3): /* obj a b -> a obj b (213) */ { JSValue tmp; tmp = sp[-2]; sp[-2] = sp[-3]; sp[-3] = tmp; } BREAK; CASE(OP_rot3l): /* x a b -> a b x (231) */ { JSValue tmp; tmp = sp[-3]; sp[-3] = sp[-2]; sp[-2] = sp[-1]; sp[-1] = tmp; } BREAK; CASE(OP_rot4l): /* x a b c -> a b c x */ { JSValue tmp; tmp = sp[-4]; sp[-4] = sp[-3]; sp[-3] = sp[-2]; sp[-2] = sp[-1]; sp[-1] = tmp; } BREAK; CASE(OP_rot5l): /* x a b c d -> a b c d x */ { JSValue tmp; tmp = sp[-5]; sp[-5] = sp[-4]; sp[-4] = sp[-3]; sp[-3] = sp[-2]; sp[-2] = sp[-1]; sp[-1] = tmp; } BREAK; CASE(OP_rot3r): /* a b x -> x a b (312) */ { JSValue tmp; tmp = sp[-1]; sp[-1] = sp[-2]; sp[-2] = sp[-3]; sp[-3] = tmp; } BREAK; CASE(OP_perm4): /* obj prop a b -> a obj prop b */ { JSValue tmp; tmp = sp[-2]; sp[-2] = sp[-3]; sp[-3] = sp[-4]; sp[-4] = tmp; } BREAK; CASE(OP_perm5): /* this obj prop a b -> a this obj prop b */ { JSValue tmp; tmp = sp[-2]; sp[-2] = sp[-3]; sp[-3] = sp[-4]; sp[-4] = sp[-5]; sp[-5] = tmp; } BREAK; CASE(OP_swap): /* a b -> b a */ { JSValue tmp; tmp = sp[-2]; sp[-2] = sp[-1]; sp[-1] = tmp; } BREAK; CASE(OP_swap2): /* a b c d -> c d a b */ { JSValue tmp1, tmp2; tmp1 = sp[-4]; tmp2 = sp[-3]; sp[-4] = sp[-2]; sp[-3] = sp[-1]; sp[-2] = tmp1; sp[-1] = tmp2; } BREAK; CASE(OP_fclosure): { JSValue bfunc = JS_DupValue(ctx, b->cpool[get_u32(pc)]); pc += 4; *sp++ = js_closure(ctx, bfunc, var_refs, sf); if (unlikely(JS_IsException(sp[-1]))) goto exception; } BREAK; #if SHORT_OPCODES CASE(OP_call0): CASE(OP_call1): CASE(OP_call2): CASE(OP_call3): call_argc = opcode - OP_call0; goto has_call_argc; #endif CASE(OP_call): CASE(OP_tail_call): { call_argc = get_u16(pc); pc += 2; goto has_call_argc; has_call_argc: call_argv = sp - call_argc; sf->cur_pc = pc; ret_val = JS_CallInternal(ctx, call_argv[-1], JS_UNDEFINED, JS_UNDEFINED, call_argc, call_argv, 0); if (unlikely(JS_IsException(ret_val))) goto exception; if (opcode == OP_tail_call) goto done; for(i = -1; i < call_argc; i++) JS_FreeValue(ctx, call_argv[i]); sp -= call_argc + 1; *sp++ = ret_val; } BREAK; CASE(OP_call_constructor): { call_argc = get_u16(pc); pc += 2; call_argv = sp - call_argc; sf->cur_pc = pc; ret_val = JS_CallConstructorInternal(ctx, call_argv[-2], call_argv[-1], call_argc, call_argv, 0); if (unlikely(JS_IsException(ret_val))) goto exception; for(i = -2; i < call_argc; i++) JS_FreeValue(ctx, call_argv[i]); sp -= call_argc + 2; *sp++ = ret_val; } BREAK; CASE(OP_call_method): CASE(OP_tail_call_method): { call_argc = get_u16(pc); pc += 2; call_argv = sp - call_argc; sf->cur_pc = pc; ret_val = JS_CallInternal(ctx, call_argv[-1], call_argv[-2], JS_UNDEFINED, call_argc, call_argv, 0); if (unlikely(JS_IsException(ret_val))) goto exception; if (opcode == OP_tail_call_method) goto done; for(i = -2; i < call_argc; i++) JS_FreeValue(ctx, call_argv[i]); sp -= call_argc + 2; *sp++ = ret_val; } BREAK; CASE(OP_array_from): { int i, ret; call_argc = get_u16(pc); pc += 2; ret_val = JS_NewArray(ctx); if (unlikely(JS_IsException(ret_val))) goto exception; call_argv = sp - call_argc; for(i = 0; i < call_argc; i++) { ret = JS_DefinePropertyValue(ctx, ret_val, __JS_AtomFromUInt32(i), call_argv[i], JS_PROP_C_W_E | JS_PROP_THROW); call_argv[i] = JS_UNDEFINED; if (ret < 0) { JS_FreeValue(ctx, ret_val); goto exception; } } sp -= call_argc; *sp++ = ret_val; } BREAK; CASE(OP_apply): { int magic; magic = get_u16(pc); pc += 2; ret_val = js_function_apply(ctx, sp[-3], 2, (JSValueConst *)&sp[-2], magic); if (unlikely(JS_IsException(ret_val))) goto exception; JS_FreeValue(ctx, sp[-3]); JS_FreeValue(ctx, sp[-2]); JS_FreeValue(ctx, sp[-1]); sp -= 3; *sp++ = ret_val; } BREAK; CASE(OP_return): ret_val = *--sp; goto done; CASE(OP_return_undef): ret_val = JS_UNDEFINED; goto done; CASE(OP_check_ctor_return): /* return TRUE if 'this' should be returned */ if (!JS_IsObject(sp[-1])) { if (!JS_IsUndefined(sp[-1])) { JS_ThrowTypeError(caller_ctx, "derived class constructor must return an object or undefined"); goto exception; } sp[0] = JS_TRUE; } else { sp[0] = JS_FALSE; } sp++; BREAK; CASE(OP_check_ctor): if (JS_IsUndefined(new_target)) { JS_ThrowTypeError(ctx, "class constructors must be invoked with 'new'"); goto exception; } BREAK; CASE(OP_check_brand): { int ret = JS_CheckBrand(ctx, sp[-2], sp[-1]); if (ret < 0) goto exception; if (!ret) { JS_ThrowTypeError(ctx, "invalid brand on object"); goto exception; } } BREAK; CASE(OP_add_brand): if (JS_AddBrand(ctx, sp[-2], sp[-1]) < 0) goto exception; JS_FreeValue(ctx, sp[-2]); JS_FreeValue(ctx, sp[-1]); sp -= 2; BREAK; CASE(OP_throw): JS_Throw(ctx, *--sp); goto exception; CASE(OP_throw_error): #define JS_THROW_VAR_RO 0 #define JS_THROW_VAR_REDECL 1 #define JS_THROW_VAR_UNINITIALIZED 2 #define JS_THROW_ERROR_DELETE_SUPER 3 #define JS_THROW_ERROR_ITERATOR_THROW 4 { JSAtom atom; int type; atom = get_u32(pc); type = pc[4]; pc += 5; if (type == JS_THROW_VAR_RO) JS_ThrowTypeErrorReadOnly(ctx, JS_PROP_THROW, atom); else if (type == JS_THROW_VAR_REDECL) JS_ThrowSyntaxErrorVarRedeclaration(ctx, atom); else if (type == JS_THROW_VAR_UNINITIALIZED) JS_ThrowReferenceErrorUninitialized(ctx, atom); else if (type == JS_THROW_ERROR_DELETE_SUPER) JS_ThrowReferenceError(ctx, "unsupported reference to 'super'"); else if (type == JS_THROW_ERROR_ITERATOR_THROW) JS_ThrowTypeError(ctx, "iterator does not have a throw method"); else JS_ThrowInternalError(ctx, "invalid throw var type %d", type); } goto exception; CASE(OP_eval): { JSValueConst obj; int scope_idx; call_argc = get_u16(pc); scope_idx = get_u16(pc + 2) - 1; pc += 4; call_argv = sp - call_argc; sf->cur_pc = pc; if (js_same_value(ctx, call_argv[-1], ctx->eval_obj)) { if (call_argc >= 1) obj = call_argv[0]; else obj = JS_UNDEFINED; ret_val = JS_EvalObject(ctx, JS_UNDEFINED, obj, JS_EVAL_TYPE_DIRECT, scope_idx); } else { ret_val = JS_CallInternal(ctx, call_argv[-1], JS_UNDEFINED, JS_UNDEFINED, call_argc, call_argv, 0); } if (unlikely(JS_IsException(ret_val))) goto exception; for(i = -1; i < call_argc; i++) JS_FreeValue(ctx, call_argv[i]); sp -= call_argc + 1; *sp++ = ret_val; } BREAK; /* could merge with OP_apply */ CASE(OP_apply_eval): { int scope_idx; uint32_t len; JSValue *tab; JSValueConst obj; scope_idx = get_u16(pc) - 1; pc += 2; tab = build_arg_list(ctx, &len, sp[-1]); if (!tab) goto exception; if (js_same_value(ctx, sp[-2], ctx->eval_obj)) { if (len >= 1) obj = tab[0]; else obj = JS_UNDEFINED; ret_val = JS_EvalObject(ctx, JS_UNDEFINED, obj, JS_EVAL_TYPE_DIRECT, scope_idx); } else { ret_val = JS_Call(ctx, sp[-2], JS_UNDEFINED, len, (JSValueConst *)tab); } free_arg_list(ctx, tab, len); if (unlikely(JS_IsException(ret_val))) goto exception; JS_FreeValue(ctx, sp[-2]); JS_FreeValue(ctx, sp[-1]); sp -= 2; *sp++ = ret_val; } BREAK; CASE(OP_regexp): { sp[-2] = js_regexp_constructor_internal(ctx, JS_UNDEFINED, sp[-2], sp[-1]); sp--; } BREAK; CASE(OP_get_super): { JSValue proto; proto = JS_GetPrototype(ctx, sp[-1]); if (JS_IsException(proto)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = proto; } BREAK; CASE(OP_import): { JSValue val; val = js_dynamic_import(ctx, sp[-1]); if (JS_IsException(val)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = val; } BREAK; CASE(OP_check_var): { int ret; JSAtom atom; atom = get_u32(pc); pc += 4; ret = JS_CheckGlobalVar(ctx, atom); if (ret < 0) goto exception; *sp++ = JS_NewBool(ctx, ret); } BREAK; CASE(OP_get_var_undef): CASE(OP_get_var): { JSValue val; JSAtom atom; atom = get_u32(pc); pc += 4; val = JS_GetGlobalVar(ctx, atom, opcode - OP_get_var_undef); if (unlikely(JS_IsException(val))) goto exception; *sp++ = val; } BREAK; CASE(OP_put_var): CASE(OP_put_var_init): { int ret; JSAtom atom; atom = get_u32(pc); pc += 4; ret = JS_SetGlobalVar(ctx, atom, sp[-1], opcode - OP_put_var); sp--; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_put_var_strict): { int ret; JSAtom atom; atom = get_u32(pc); pc += 4; /* sp[-2] is JS_TRUE or JS_FALSE */ if (unlikely(!JS_VALUE_GET_INT(sp[-2]))) { JS_ThrowReferenceErrorNotDefined(ctx, atom); goto exception; } ret = JS_SetGlobalVar(ctx, atom, sp[-1], 2); sp -= 2; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_check_define_var): { JSAtom atom; int flags; atom = get_u32(pc); flags = pc[4]; pc += 5; if (JS_CheckDefineGlobalVar(ctx, atom, flags)) goto exception; } BREAK; CASE(OP_define_var): { JSAtom atom; int flags; atom = get_u32(pc); flags = pc[4]; pc += 5; if (JS_DefineGlobalVar(ctx, atom, flags)) goto exception; } BREAK; CASE(OP_define_func): { JSAtom atom; int flags; atom = get_u32(pc); flags = pc[4]; pc += 5; if (JS_DefineGlobalFunction(ctx, atom, sp[-1], flags)) goto exception; JS_FreeValue(ctx, sp[-1]); sp--; } BREAK; CASE(OP_get_loc): { int idx; idx = get_u16(pc); pc += 2; sp[0] = JS_DupValue(ctx, var_buf[idx]); sp++; } BREAK; CASE(OP_put_loc): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, &var_buf[idx], sp[-1]); sp--; } BREAK; CASE(OP_set_loc): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, &var_buf[idx], JS_DupValue(ctx, sp[-1])); } BREAK; CASE(OP_get_arg): { int idx; idx = get_u16(pc); pc += 2; sp[0] = JS_DupValue(ctx, arg_buf[idx]); sp++; } BREAK; CASE(OP_put_arg): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, &arg_buf[idx], sp[-1]); sp--; } BREAK; CASE(OP_set_arg): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, &arg_buf[idx], JS_DupValue(ctx, sp[-1])); } BREAK; #if SHORT_OPCODES CASE(OP_get_loc8): *sp++ = JS_DupValue(ctx, var_buf[*pc++]); BREAK; CASE(OP_put_loc8): set_value(ctx, &var_buf[*pc++], *--sp); BREAK; CASE(OP_set_loc8): set_value(ctx, &var_buf[*pc++], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_get_loc0): *sp++ = JS_DupValue(ctx, var_buf[0]); BREAK; CASE(OP_get_loc1): *sp++ = JS_DupValue(ctx, var_buf[1]); BREAK; CASE(OP_get_loc2): *sp++ = JS_DupValue(ctx, var_buf[2]); BREAK; CASE(OP_get_loc3): *sp++ = JS_DupValue(ctx, var_buf[3]); BREAK; CASE(OP_put_loc0): set_value(ctx, &var_buf[0], *--sp); BREAK; CASE(OP_put_loc1): set_value(ctx, &var_buf[1], *--sp); BREAK; CASE(OP_put_loc2): set_value(ctx, &var_buf[2], *--sp); BREAK; CASE(OP_put_loc3): set_value(ctx, &var_buf[3], *--sp); BREAK; CASE(OP_set_loc0): set_value(ctx, &var_buf[0], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_loc1): set_value(ctx, &var_buf[1], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_loc2): set_value(ctx, &var_buf[2], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_loc3): set_value(ctx, &var_buf[3], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_get_arg0): *sp++ = JS_DupValue(ctx, arg_buf[0]); BREAK; CASE(OP_get_arg1): *sp++ = JS_DupValue(ctx, arg_buf[1]); BREAK; CASE(OP_get_arg2): *sp++ = JS_DupValue(ctx, arg_buf[2]); BREAK; CASE(OP_get_arg3): *sp++ = JS_DupValue(ctx, arg_buf[3]); BREAK; CASE(OP_put_arg0): set_value(ctx, &arg_buf[0], *--sp); BREAK; CASE(OP_put_arg1): set_value(ctx, &arg_buf[1], *--sp); BREAK; CASE(OP_put_arg2): set_value(ctx, &arg_buf[2], *--sp); BREAK; CASE(OP_put_arg3): set_value(ctx, &arg_buf[3], *--sp); BREAK; CASE(OP_set_arg0): set_value(ctx, &arg_buf[0], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_arg1): set_value(ctx, &arg_buf[1], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_arg2): set_value(ctx, &arg_buf[2], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_arg3): set_value(ctx, &arg_buf[3], JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_get_var_ref0): *sp++ = JS_DupValue(ctx, *var_refs[0]->pvalue); BREAK; CASE(OP_get_var_ref1): *sp++ = JS_DupValue(ctx, *var_refs[1]->pvalue); BREAK; CASE(OP_get_var_ref2): *sp++ = JS_DupValue(ctx, *var_refs[2]->pvalue); BREAK; CASE(OP_get_var_ref3): *sp++ = JS_DupValue(ctx, *var_refs[3]->pvalue); BREAK; CASE(OP_put_var_ref0): set_value(ctx, var_refs[0]->pvalue, *--sp); BREAK; CASE(OP_put_var_ref1): set_value(ctx, var_refs[1]->pvalue, *--sp); BREAK; CASE(OP_put_var_ref2): set_value(ctx, var_refs[2]->pvalue, *--sp); BREAK; CASE(OP_put_var_ref3): set_value(ctx, var_refs[3]->pvalue, *--sp); BREAK; CASE(OP_set_var_ref0): set_value(ctx, var_refs[0]->pvalue, JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_var_ref1): set_value(ctx, var_refs[1]->pvalue, JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_var_ref2): set_value(ctx, var_refs[2]->pvalue, JS_DupValue(ctx, sp[-1])); BREAK; CASE(OP_set_var_ref3): set_value(ctx, var_refs[3]->pvalue, JS_DupValue(ctx, sp[-1])); BREAK; #endif CASE(OP_get_var_ref): { int idx; JSValue val; idx = get_u16(pc); pc += 2; val = *var_refs[idx]->pvalue; sp[0] = JS_DupValue(ctx, val); sp++; } BREAK; CASE(OP_put_var_ref): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, var_refs[idx]->pvalue, sp[-1]); sp--; } BREAK; CASE(OP_set_var_ref): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, var_refs[idx]->pvalue, JS_DupValue(ctx, sp[-1])); } BREAK; CASE(OP_get_var_ref_check): { int idx; JSValue val; idx = get_u16(pc); pc += 2; val = *var_refs[idx]->pvalue; if (unlikely(JS_IsUninitialized(val))) { JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, TRUE); goto exception; } sp[0] = JS_DupValue(ctx, val); sp++; } BREAK; CASE(OP_put_var_ref_check): { int idx; idx = get_u16(pc); pc += 2; if (unlikely(JS_IsUninitialized(*var_refs[idx]->pvalue))) { JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, TRUE); goto exception; } set_value(ctx, var_refs[idx]->pvalue, sp[-1]); sp--; } BREAK; CASE(OP_put_var_ref_check_init): { int idx; idx = get_u16(pc); pc += 2; if (unlikely(!JS_IsUninitialized(*var_refs[idx]->pvalue))) { JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, TRUE); goto exception; } set_value(ctx, var_refs[idx]->pvalue, sp[-1]); sp--; } BREAK; CASE(OP_set_loc_uninitialized): { int idx; idx = get_u16(pc); pc += 2; set_value(ctx, &var_buf[idx], JS_UNINITIALIZED); } BREAK; CASE(OP_get_loc_check): { int idx; idx = get_u16(pc); pc += 2; if (unlikely(JS_IsUninitialized(var_buf[idx]))) { JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE); goto exception; } sp[0] = JS_DupValue(ctx, var_buf[idx]); sp++; } BREAK; CASE(OP_get_loc_checkthis): { int idx; idx = get_u16(pc); pc += 2; if (unlikely(JS_IsUninitialized(var_buf[idx]))) { JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx, FALSE); goto exception; } sp[0] = JS_DupValue(ctx, var_buf[idx]); sp++; } BREAK; CASE(OP_put_loc_check): { int idx; idx = get_u16(pc); pc += 2; if (unlikely(JS_IsUninitialized(var_buf[idx]))) { JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE); goto exception; } set_value(ctx, &var_buf[idx], sp[-1]); sp--; } BREAK; CASE(OP_put_loc_check_init): { int idx; idx = get_u16(pc); pc += 2; if (unlikely(!JS_IsUninitialized(var_buf[idx]))) { JS_ThrowReferenceError(ctx, "'this' can be initialized only once"); goto exception; } set_value(ctx, &var_buf[idx], sp[-1]); sp--; } BREAK; CASE(OP_close_loc): { int idx; idx = get_u16(pc); pc += 2; close_lexical_var(ctx, sf, idx, FALSE); } BREAK; CASE(OP_make_loc_ref): CASE(OP_make_arg_ref): CASE(OP_make_var_ref_ref): { JSVarRef *var_ref; JSProperty *pr; JSAtom atom; int idx; atom = get_u32(pc); idx = get_u16(pc + 4); pc += 6; *sp++ = JS_NewObjectProto(ctx, JS_NULL); if (unlikely(JS_IsException(sp[-1]))) goto exception; if (opcode == OP_make_var_ref_ref) { var_ref = var_refs[idx]; var_ref->header.ref_count++; } else { var_ref = get_var_ref(ctx, sf, idx, opcode == OP_make_arg_ref); if (!var_ref) goto exception; } pr = add_property(ctx, JS_VALUE_GET_OBJ(sp[-1]), atom, JS_PROP_WRITABLE | JS_PROP_VARREF); if (!pr) { free_var_ref(rt, var_ref); goto exception; } pr->u.var_ref = var_ref; *sp++ = JS_AtomToValue(ctx, atom); } BREAK; CASE(OP_make_var_ref): { JSAtom atom; atom = get_u32(pc); pc += 4; if (JS_GetGlobalVarRef(ctx, atom, sp)) goto exception; sp += 2; } BREAK; CASE(OP_goto): pc += (int32_t)get_u32(pc); if (unlikely(js_poll_interrupts(ctx))) goto exception; BREAK; #if SHORT_OPCODES CASE(OP_goto16): pc += (int16_t)get_u16(pc); if (unlikely(js_poll_interrupts(ctx))) goto exception; BREAK; CASE(OP_goto8): pc += (int8_t)pc[0]; if (unlikely(js_poll_interrupts(ctx))) goto exception; BREAK; #endif CASE(OP_if_true): { int res; JSValue op1; op1 = sp[-1]; pc += 4; if ((uint32_t)JS_VALUE_GET_TAG(op1) <= JS_TAG_UNDEFINED) { res = JS_VALUE_GET_INT(op1); } else { res = JS_ToBoolFree(ctx, op1); } sp--; if (res) { pc += (int32_t)get_u32(pc - 4) - 4; } if (unlikely(js_poll_interrupts(ctx))) goto exception; } BREAK; CASE(OP_if_false): { int res; JSValue op1; op1 = sp[-1]; pc += 4; if ((uint32_t)JS_VALUE_GET_TAG(op1) <= JS_TAG_UNDEFINED) { res = JS_VALUE_GET_INT(op1); } else { res = JS_ToBoolFree(ctx, op1); } sp--; if (!res) { pc += (int32_t)get_u32(pc - 4) - 4; } if (unlikely(js_poll_interrupts(ctx))) goto exception; } BREAK; #if SHORT_OPCODES CASE(OP_if_true8): { int res; JSValue op1; op1 = sp[-1]; pc += 1; if ((uint32_t)JS_VALUE_GET_TAG(op1) <= JS_TAG_UNDEFINED) { res = JS_VALUE_GET_INT(op1); } else { res = JS_ToBoolFree(ctx, op1); } sp--; if (res) { pc += (int8_t)pc[-1] - 1; } if (unlikely(js_poll_interrupts(ctx))) goto exception; } BREAK; CASE(OP_if_false8): { int res; JSValue op1; op1 = sp[-1]; pc += 1; if ((uint32_t)JS_VALUE_GET_TAG(op1) <= JS_TAG_UNDEFINED) { res = JS_VALUE_GET_INT(op1); } else { res = JS_ToBoolFree(ctx, op1); } sp--; if (!res) { pc += (int8_t)pc[-1] - 1; } if (unlikely(js_poll_interrupts(ctx))) goto exception; } BREAK; #endif CASE(OP_catch): { int32_t diff; diff = get_u32(pc); sp[0] = JS_NewCatchOffset(ctx, pc + diff - b->byte_code_buf); sp++; pc += 4; } BREAK; CASE(OP_gosub): { int32_t diff; diff = get_u32(pc); /* XXX: should have a different tag to avoid security flaw */ sp[0] = JS_NewInt32(ctx, pc + 4 - b->byte_code_buf); sp++; pc += diff; } BREAK; CASE(OP_ret): { JSValue op1; uint32_t pos; op1 = sp[-1]; if (unlikely(JS_VALUE_GET_TAG(op1) != JS_TAG_INT)) goto ret_fail; pos = JS_VALUE_GET_INT(op1); if (unlikely(pos >= b->byte_code_len)) { ret_fail: JS_ThrowInternalError(ctx, "invalid ret value"); goto exception; } sp--; pc = b->byte_code_buf + pos; } BREAK; CASE(OP_for_in_start): if (js_for_in_start(ctx, sp)) goto exception; BREAK; CASE(OP_for_in_next): if (js_for_in_next(ctx, sp)) goto exception; sp += 2; BREAK; CASE(OP_for_of_start): if (js_for_of_start(ctx, sp, FALSE)) goto exception; sp += 1; *sp++ = JS_NewCatchOffset(ctx, 0); BREAK; CASE(OP_for_of_next): { int offset = -3 - pc[0]; pc += 1; if (js_for_of_next(ctx, sp, offset)) goto exception; sp += 2; } BREAK; CASE(OP_for_await_of_start): if (js_for_of_start(ctx, sp, TRUE)) goto exception; sp += 1; *sp++ = JS_NewCatchOffset(ctx, 0); BREAK; CASE(OP_iterator_get_value_done): if (js_iterator_get_value_done(ctx, sp)) goto exception; sp += 1; BREAK; CASE(OP_iterator_check_object): if (unlikely(!JS_IsObject(sp[-1]))) { JS_ThrowTypeError(ctx, "iterator must return an object"); goto exception; } BREAK; CASE(OP_iterator_close): /* iter_obj next catch_offset -> */ sp--; /* drop the catch offset to avoid getting caught by exception */ JS_FreeValue(ctx, sp[-1]); /* drop the next method */ sp--; if (!JS_IsUndefined(sp[-1])) { if (JS_IteratorClose(ctx, sp[-1], FALSE)) goto exception; JS_FreeValue(ctx, sp[-1]); } sp--; BREAK; CASE(OP_nip_catch): { JSValue ret_val; /* catch_offset ... ret_val -> ret_eval */ ret_val = *--sp; while (sp > stack_buf && JS_VALUE_GET_TAG(sp[-1]) != JS_TAG_CATCH_OFFSET) { JS_FreeValue(ctx, *--sp); } if (unlikely(sp == stack_buf)) { JS_ThrowInternalError(ctx, "nip_catch"); JS_FreeValue(ctx, ret_val); goto exception; } sp[-1] = ret_val; } BREAK; CASE(OP_iterator_next): /* stack: iter_obj next catch_offset val */ { JSValue ret; ret = JS_Call(ctx, sp[-3], sp[-4], 1, (JSValueConst *)(sp - 1)); if (JS_IsException(ret)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret; } BREAK; CASE(OP_iterator_call): /* stack: iter_obj next catch_offset val */ { JSValue method, ret; BOOL ret_flag; int flags; flags = *pc++; method = JS_GetProperty(ctx, sp[-4], (flags & 1) ? JS_ATOM_throw : JS_ATOM_return); if (JS_IsException(method)) goto exception; if (JS_IsUndefined(method) || JS_IsNull(method)) { ret_flag = TRUE; } else { if (flags & 2) { /* no argument */ ret = JS_CallFree(ctx, method, sp[-4], 0, NULL); } else { ret = JS_CallFree(ctx, method, sp[-4], 1, (JSValueConst *)(sp - 1)); } if (JS_IsException(ret)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret; ret_flag = FALSE; } sp[0] = JS_NewBool(ctx, ret_flag); sp += 1; } BREAK; CASE(OP_lnot): { int res; JSValue op1; op1 = sp[-1]; if ((uint32_t)JS_VALUE_GET_TAG(op1) <= JS_TAG_UNDEFINED) { res = JS_VALUE_GET_INT(op1) != 0; } else { res = JS_ToBoolFree(ctx, op1); } sp[-1] = JS_NewBool(ctx, !res); } BREAK; CASE(OP_get_field): { JSValue val; JSAtom atom; atom = get_u32(pc); pc += 4; val = JS_GetProperty(ctx, sp[-1], atom); if (unlikely(JS_IsException(val))) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = val; } BREAK; CASE(OP_get_field2): { JSValue val; JSAtom atom; atom = get_u32(pc); pc += 4; val = JS_GetProperty(ctx, sp[-1], atom); if (unlikely(JS_IsException(val))) goto exception; *sp++ = val; } BREAK; CASE(OP_put_field): { int ret; JSAtom atom; atom = get_u32(pc); pc += 4; ret = JS_SetPropertyInternal(ctx, sp[-2], atom, sp[-1], sp[-2], JS_PROP_THROW_STRICT); JS_FreeValue(ctx, sp[-2]); sp -= 2; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_private_symbol): { JSAtom atom; JSValue val; atom = get_u32(pc); pc += 4; val = JS_NewSymbolFromAtom(ctx, atom, JS_ATOM_TYPE_PRIVATE); if (JS_IsException(val)) goto exception; *sp++ = val; } BREAK; CASE(OP_get_private_field): { JSValue val; val = JS_GetPrivateField(ctx, sp[-2], sp[-1]); JS_FreeValue(ctx, sp[-1]); JS_FreeValue(ctx, sp[-2]); sp[-2] = val; sp--; if (unlikely(JS_IsException(val))) goto exception; } BREAK; CASE(OP_put_private_field): { int ret; ret = JS_SetPrivateField(ctx, sp[-3], sp[-1], sp[-2]); JS_FreeValue(ctx, sp[-3]); JS_FreeValue(ctx, sp[-1]); sp -= 3; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_define_private_field): { int ret; ret = JS_DefinePrivateField(ctx, sp[-3], sp[-2], sp[-1]); JS_FreeValue(ctx, sp[-2]); sp -= 2; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_define_field): { int ret; JSAtom atom; atom = get_u32(pc); pc += 4; ret = JS_DefinePropertyValue(ctx, sp[-2], atom, sp[-1], JS_PROP_C_W_E | JS_PROP_THROW); sp--; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_set_name): { int ret; JSAtom atom; atom = get_u32(pc); pc += 4; ret = JS_DefineObjectName(ctx, sp[-1], atom, JS_PROP_CONFIGURABLE); if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_set_name_computed): { int ret; ret = JS_DefineObjectNameComputed(ctx, sp[-1], sp[-2], JS_PROP_CONFIGURABLE); if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_set_proto): { JSValue proto; proto = sp[-1]; if (JS_IsObject(proto) || JS_IsNull(proto)) { if (JS_SetPrototypeInternal(ctx, sp[-2], proto, TRUE) < 0) goto exception; } JS_FreeValue(ctx, proto); sp--; } BREAK; CASE(OP_set_home_object): js_method_set_home_object(ctx, sp[-1], sp[-2]); BREAK; CASE(OP_define_method): CASE(OP_define_method_computed): { JSValue getter, setter, value; JSValueConst obj; JSAtom atom; int flags, ret, op_flags; BOOL is_computed; #define OP_DEFINE_METHOD_METHOD 0 #define OP_DEFINE_METHOD_GETTER 1 #define OP_DEFINE_METHOD_SETTER 2 #define OP_DEFINE_METHOD_ENUMERABLE 4 is_computed = (opcode == OP_define_method_computed); if (is_computed) { atom = JS_ValueToAtom(ctx, sp[-2]); if (unlikely(atom == JS_ATOM_NULL)) goto exception; opcode += OP_define_method - OP_define_method_computed; } else { atom = get_u32(pc); pc += 4; } op_flags = *pc++; obj = sp[-2 - is_computed]; flags = JS_PROP_HAS_CONFIGURABLE | JS_PROP_CONFIGURABLE | JS_PROP_HAS_ENUMERABLE | JS_PROP_THROW; if (op_flags & OP_DEFINE_METHOD_ENUMERABLE) flags |= JS_PROP_ENUMERABLE; op_flags &= 3; value = JS_UNDEFINED; getter = JS_UNDEFINED; setter = JS_UNDEFINED; if (op_flags == OP_DEFINE_METHOD_METHOD) { value = sp[-1]; flags |= JS_PROP_HAS_VALUE | JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE; } else if (op_flags == OP_DEFINE_METHOD_GETTER) { getter = sp[-1]; flags |= JS_PROP_HAS_GET; } else { setter = sp[-1]; flags |= JS_PROP_HAS_SET; } ret = js_method_set_properties(ctx, sp[-1], atom, flags, obj); if (ret >= 0) { ret = JS_DefineProperty(ctx, obj, atom, value, getter, setter, flags); } JS_FreeValue(ctx, sp[-1]); if (is_computed) { JS_FreeAtom(ctx, atom); JS_FreeValue(ctx, sp[-2]); } sp -= 1 + is_computed; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_define_class): CASE(OP_define_class_computed): { int class_flags; JSAtom atom; atom = get_u32(pc); class_flags = pc[4]; pc += 5; if (js_op_define_class(ctx, sp, atom, class_flags, var_refs, sf, (opcode == OP_define_class_computed)) < 0) goto exception; } BREAK; CASE(OP_get_array_el): { JSValue val; val = JS_GetPropertyValue(ctx, sp[-2], sp[-1]); JS_FreeValue(ctx, sp[-2]); sp[-2] = val; sp--; if (unlikely(JS_IsException(val))) goto exception; } BREAK; CASE(OP_get_array_el2): { JSValue val; val = JS_GetPropertyValue(ctx, sp[-2], sp[-1]); sp[-1] = val; if (unlikely(JS_IsException(val))) goto exception; } BREAK; CASE(OP_get_ref_value): { JSValue val; if (unlikely(JS_IsUndefined(sp[-2]))) { JSAtom atom = JS_ValueToAtom(ctx, sp[-1]); if (atom != JS_ATOM_NULL) { JS_ThrowReferenceErrorNotDefined(ctx, atom); JS_FreeAtom(ctx, atom); } goto exception; } val = JS_GetPropertyValue(ctx, sp[-2], JS_DupValue(ctx, sp[-1])); if (unlikely(JS_IsException(val))) goto exception; sp[0] = val; sp++; } BREAK; CASE(OP_get_super_value): { JSValue val; JSAtom atom; atom = JS_ValueToAtom(ctx, sp[-1]); if (unlikely(atom == JS_ATOM_NULL)) goto exception; val = JS_GetPropertyInternal(ctx, sp[-2], atom, sp[-3], FALSE); JS_FreeAtom(ctx, atom); if (unlikely(JS_IsException(val))) goto exception; JS_FreeValue(ctx, sp[-1]); JS_FreeValue(ctx, sp[-2]); JS_FreeValue(ctx, sp[-3]); sp[-3] = val; sp -= 2; } BREAK; CASE(OP_put_array_el): { int ret; ret = JS_SetPropertyValue(ctx, sp[-3], sp[-2], sp[-1], JS_PROP_THROW_STRICT); JS_FreeValue(ctx, sp[-3]); sp -= 3; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_put_ref_value): { int ret, flags; flags = JS_PROP_THROW_STRICT; if (unlikely(JS_IsUndefined(sp[-3]))) { if (is_strict_mode(ctx)) { JSAtom atom = JS_ValueToAtom(ctx, sp[-2]); if (atom != JS_ATOM_NULL) { JS_ThrowReferenceErrorNotDefined(ctx, atom); JS_FreeAtom(ctx, atom); } goto exception; } else { sp[-3] = JS_DupValue(ctx, ctx->global_obj); } } else { if (is_strict_mode(ctx)) flags |= JS_PROP_NO_ADD; } ret = JS_SetPropertyValue(ctx, sp[-3], sp[-2], sp[-1], flags); JS_FreeValue(ctx, sp[-3]); sp -= 3; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_put_super_value): { int ret; JSAtom atom; if (JS_VALUE_GET_TAG(sp[-3]) != JS_TAG_OBJECT) { JS_ThrowTypeErrorNotAnObject(ctx); goto exception; } atom = JS_ValueToAtom(ctx, sp[-2]); if (unlikely(atom == JS_ATOM_NULL)) goto exception; ret = JS_SetPropertyInternal(ctx, sp[-3], atom, sp[-1], sp[-4], JS_PROP_THROW_STRICT); JS_FreeAtom(ctx, atom); JS_FreeValue(ctx, sp[-4]); JS_FreeValue(ctx, sp[-3]); JS_FreeValue(ctx, sp[-2]); sp -= 4; if (ret < 0) goto exception; } BREAK; CASE(OP_define_array_el): { int ret; ret = JS_DefinePropertyValueValue(ctx, sp[-3], JS_DupValue(ctx, sp[-2]), sp[-1], JS_PROP_C_W_E | JS_PROP_THROW); sp -= 1; if (unlikely(ret < 0)) goto exception; } BREAK; CASE(OP_append): /* array pos enumobj -- array pos */ { if (js_append_enumerate(ctx, sp)) goto exception; JS_FreeValue(ctx, *--sp); } BREAK; CASE(OP_copy_data_properties): /* target source excludeList */ { /* stack offsets (-1 based): 2 bits for target, 3 bits for source, 2 bits for exclusionList */ int mask; mask = *pc++; if (JS_CopyDataProperties(ctx, sp[-1 - (mask & 3)], sp[-1 - ((mask >> 2) & 7)], sp[-1 - ((mask >> 5) & 7)], 0)) goto exception; } BREAK; CASE(OP_add): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { int64_t r; r = (int64_t)JS_VALUE_GET_INT(op1) + JS_VALUE_GET_INT(op2); if (unlikely((int)r != r)) goto add_slow; sp[-2] = JS_NewInt32(ctx, r); sp--; } else if (JS_VALUE_IS_BOTH_FLOAT(op1, op2)) { sp[-2] = __JS_NewFloat64(ctx, JS_VALUE_GET_FLOAT64(op1) + JS_VALUE_GET_FLOAT64(op2)); sp--; } else { add_slow: if (js_add_slow(ctx, sp)) goto exception; sp--; } } BREAK; CASE(OP_add_loc): { JSValue *pv; int idx; idx = *pc; pc += 1; pv = &var_buf[idx]; if (likely(JS_VALUE_IS_BOTH_INT(*pv, sp[-1]))) { int64_t r; r = (int64_t)JS_VALUE_GET_INT(*pv) + JS_VALUE_GET_INT(sp[-1]); if (unlikely((int)r != r)) goto add_loc_slow; *pv = JS_NewInt32(ctx, r); sp--; } else if (JS_VALUE_GET_TAG(*pv) == JS_TAG_STRING) { JSValue op1; op1 = sp[-1]; sp--; op1 = JS_ToPrimitiveFree(ctx, op1, HINT_NONE); if (JS_IsException(op1)) goto exception; op1 = JS_ConcatString(ctx, JS_DupValue(ctx, *pv), op1); if (JS_IsException(op1)) goto exception; set_value(ctx, pv, op1); } else { JSValue ops[2]; add_loc_slow: /* In case of exception, js_add_slow frees ops[0] and ops[1], so we must duplicate *pv */ ops[0] = JS_DupValue(ctx, *pv); ops[1] = sp[-1]; sp--; if (js_add_slow(ctx, ops + 2)) goto exception; set_value(ctx, pv, ops[0]); } } BREAK; CASE(OP_sub): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { int64_t r; r = (int64_t)JS_VALUE_GET_INT(op1) - JS_VALUE_GET_INT(op2); if (unlikely((int)r != r)) goto binary_arith_slow; sp[-2] = JS_NewInt32(ctx, r); sp--; } else if (JS_VALUE_IS_BOTH_FLOAT(op1, op2)) { sp[-2] = __JS_NewFloat64(ctx, JS_VALUE_GET_FLOAT64(op1) - JS_VALUE_GET_FLOAT64(op2)); sp--; } else { goto binary_arith_slow; } } BREAK; CASE(OP_mul): { JSValue op1, op2; double d; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { int32_t v1, v2; int64_t r; v1 = JS_VALUE_GET_INT(op1); v2 = JS_VALUE_GET_INT(op2); r = (int64_t)v1 * v2; if (unlikely((int)r != r)) { #ifdef CONFIG_BIGNUM if (unlikely(sf->js_mode & JS_MODE_MATH) && (r < -MAX_SAFE_INTEGER || r > MAX_SAFE_INTEGER)) goto binary_arith_slow; #endif d = (double)r; goto mul_fp_res; } /* need to test zero case for -0 result */ if (unlikely(r == 0 && (v1 | v2) < 0)) { d = -0.0; goto mul_fp_res; } sp[-2] = JS_NewInt32(ctx, r); sp--; } else if (JS_VALUE_IS_BOTH_FLOAT(op1, op2)) { #ifdef CONFIG_BIGNUM if (unlikely(sf->js_mode & JS_MODE_MATH)) goto binary_arith_slow; #endif d = JS_VALUE_GET_FLOAT64(op1) * JS_VALUE_GET_FLOAT64(op2); mul_fp_res: sp[-2] = __JS_NewFloat64(ctx, d); sp--; } else { goto binary_arith_slow; } } BREAK; CASE(OP_div): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { int v1, v2; if (unlikely(sf->js_mode & JS_MODE_MATH)) goto binary_arith_slow; v1 = JS_VALUE_GET_INT(op1); v2 = JS_VALUE_GET_INT(op2); sp[-2] = JS_NewFloat64(ctx, (double)v1 / (double)v2); sp--; } else { goto binary_arith_slow; } } BREAK; CASE(OP_mod): #ifdef CONFIG_BIGNUM CASE(OP_math_mod): #endif { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { int v1, v2, r; v1 = JS_VALUE_GET_INT(op1); v2 = JS_VALUE_GET_INT(op2); /* We must avoid v2 = 0, v1 = INT32_MIN and v2 = -1 and the cases where the result is -0. */ if (unlikely(v1 < 0 || v2 <= 0)) goto binary_arith_slow; r = v1 % v2; sp[-2] = JS_NewInt32(ctx, r); sp--; } else { goto binary_arith_slow; } } BREAK; CASE(OP_pow): binary_arith_slow: if (js_binary_arith_slow(ctx, sp, opcode)) goto exception; sp--; BREAK; CASE(OP_plus): { JSValue op1; uint32_t tag; op1 = sp[-1]; tag = JS_VALUE_GET_TAG(op1); if (tag == JS_TAG_INT || JS_TAG_IS_FLOAT64(tag)) { } else { if (js_unary_arith_slow(ctx, sp, opcode)) goto exception; } } BREAK; CASE(OP_neg): { JSValue op1; uint32_t tag; int val; double d; op1 = sp[-1]; tag = JS_VALUE_GET_TAG(op1); if (tag == JS_TAG_INT) { val = JS_VALUE_GET_INT(op1); /* Note: -0 cannot be expressed as integer */ if (unlikely(val == 0)) { d = -0.0; goto neg_fp_res; } if (unlikely(val == INT32_MIN)) { d = -(double)val; goto neg_fp_res; } sp[-1] = JS_NewInt32(ctx, -val); } else if (JS_TAG_IS_FLOAT64(tag)) { d = -JS_VALUE_GET_FLOAT64(op1); neg_fp_res: sp[-1] = __JS_NewFloat64(ctx, d); } else { if (js_unary_arith_slow(ctx, sp, opcode)) goto exception; } } BREAK; CASE(OP_inc): { JSValue op1; int val; op1 = sp[-1]; if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { val = JS_VALUE_GET_INT(op1); if (unlikely(val == INT32_MAX)) goto inc_slow; sp[-1] = JS_NewInt32(ctx, val + 1); } else { inc_slow: if (js_unary_arith_slow(ctx, sp, opcode)) goto exception; } } BREAK; CASE(OP_dec): { JSValue op1; int val; op1 = sp[-1]; if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { val = JS_VALUE_GET_INT(op1); if (unlikely(val == INT32_MIN)) goto dec_slow; sp[-1] = JS_NewInt32(ctx, val - 1); } else { dec_slow: if (js_unary_arith_slow(ctx, sp, opcode)) goto exception; } } BREAK; CASE(OP_post_inc): CASE(OP_post_dec): if (js_post_inc_slow(ctx, sp, opcode)) goto exception; sp++; BREAK; CASE(OP_inc_loc): { JSValue op1; int val; int idx; idx = *pc; pc += 1; op1 = var_buf[idx]; if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { val = JS_VALUE_GET_INT(op1); if (unlikely(val == INT32_MAX)) goto inc_loc_slow; var_buf[idx] = JS_NewInt32(ctx, val + 1); } else { inc_loc_slow: /* must duplicate otherwise the variable value may be destroyed before JS code accesses it */ op1 = JS_DupValue(ctx, op1); if (js_unary_arith_slow(ctx, &op1 + 1, OP_inc)) goto exception; set_value(ctx, &var_buf[idx], op1); } } BREAK; CASE(OP_dec_loc): { JSValue op1; int val; int idx; idx = *pc; pc += 1; op1 = var_buf[idx]; if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { val = JS_VALUE_GET_INT(op1); if (unlikely(val == INT32_MIN)) goto dec_loc_slow; var_buf[idx] = JS_NewInt32(ctx, val - 1); } else { dec_loc_slow: /* must duplicate otherwise the variable value may be destroyed before JS code accesses it */ op1 = JS_DupValue(ctx, op1); if (js_unary_arith_slow(ctx, &op1 + 1, OP_dec)) goto exception; set_value(ctx, &var_buf[idx], op1); } } BREAK; CASE(OP_not): { JSValue op1; op1 = sp[-1]; if (JS_VALUE_GET_TAG(op1) == JS_TAG_INT) { sp[-1] = JS_NewInt32(ctx, ~JS_VALUE_GET_INT(op1)); } else { if (js_not_slow(ctx, sp)) goto exception; } } BREAK; CASE(OP_shl): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { uint32_t v1, v2; v1 = JS_VALUE_GET_INT(op1); v2 = JS_VALUE_GET_INT(op2); #ifdef CONFIG_BIGNUM { int64_t r; if (unlikely(sf->js_mode & JS_MODE_MATH)) { if (v2 > 0x1f) goto shl_slow; r = (int64_t)v1 << v2; if ((int)r != r) goto shl_slow; } else { v2 &= 0x1f; } } #else v2 &= 0x1f; #endif sp[-2] = JS_NewInt32(ctx, v1 << v2); sp--; } else { #ifdef CONFIG_BIGNUM shl_slow: #endif if (js_binary_logic_slow(ctx, sp, opcode)) goto exception; sp--; } } BREAK; CASE(OP_shr): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { uint32_t v2; v2 = JS_VALUE_GET_INT(op2); /* v1 >>> v2 retains its JS semantics if CONFIG_BIGNUM */ v2 &= 0x1f; sp[-2] = JS_NewUint32(ctx, (uint32_t)JS_VALUE_GET_INT(op1) >> v2); sp--; } else { if (js_shr_slow(ctx, sp)) goto exception; sp--; } } BREAK; CASE(OP_sar): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { uint32_t v2; v2 = JS_VALUE_GET_INT(op2); #ifdef CONFIG_BIGNUM if (unlikely(v2 > 0x1f)) { if (unlikely(sf->js_mode & JS_MODE_MATH)) goto sar_slow; else v2 &= 0x1f; } #else v2 &= 0x1f; #endif sp[-2] = JS_NewInt32(ctx, (int)JS_VALUE_GET_INT(op1) >> v2); sp--; } else { #ifdef CONFIG_BIGNUM sar_slow: #endif if (js_binary_logic_slow(ctx, sp, opcode)) goto exception; sp--; } } BREAK; CASE(OP_and): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { sp[-2] = JS_NewInt32(ctx, JS_VALUE_GET_INT(op1) & JS_VALUE_GET_INT(op2)); sp--; } else { if (js_binary_logic_slow(ctx, sp, opcode)) goto exception; sp--; } } BREAK; CASE(OP_or): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { sp[-2] = JS_NewInt32(ctx, JS_VALUE_GET_INT(op1) | JS_VALUE_GET_INT(op2)); sp--; } else { if (js_binary_logic_slow(ctx, sp, opcode)) goto exception; sp--; } } BREAK; CASE(OP_xor): { JSValue op1, op2; op1 = sp[-2]; op2 = sp[-1]; if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { sp[-2] = JS_NewInt32(ctx, JS_VALUE_GET_INT(op1) ^ JS_VALUE_GET_INT(op2)); sp--; } else { if (js_binary_logic_slow(ctx, sp, opcode)) goto exception; sp--; } } BREAK; #define OP_CMP(opcode, binary_op, slow_call) \ CASE(opcode): \ { \ JSValue op1, op2; \ op1 = sp[-2]; \ op2 = sp[-1]; \ if (likely(JS_VALUE_IS_BOTH_INT(op1, op2))) { \ sp[-2] = JS_NewBool(ctx, JS_VALUE_GET_INT(op1) binary_op JS_VALUE_GET_INT(op2)); \ sp--; \ } else { \ if (slow_call) \ goto exception; \ sp--; \ } \ } \ BREAK OP_CMP(OP_lt, <, js_relational_slow(ctx, sp, opcode)); OP_CMP(OP_lte, <=, js_relational_slow(ctx, sp, opcode)); OP_CMP(OP_gt, >, js_relational_slow(ctx, sp, opcode)); OP_CMP(OP_gte, >=, js_relational_slow(ctx, sp, opcode)); OP_CMP(OP_eq, ==, js_eq_slow(ctx, sp, 0)); OP_CMP(OP_neq, !=, js_eq_slow(ctx, sp, 1)); OP_CMP(OP_strict_eq, ==, js_strict_eq_slow(ctx, sp, 0)); OP_CMP(OP_strict_neq, !=, js_strict_eq_slow(ctx, sp, 1)); #ifdef CONFIG_BIGNUM CASE(OP_mul_pow10): if (rt->bigfloat_ops.mul_pow10(ctx, sp)) goto exception; sp--; BREAK; #endif CASE(OP_in): if (js_operator_in(ctx, sp)) goto exception; sp--; BREAK; CASE(OP_private_in): if (js_operator_private_in(ctx, sp)) goto exception; sp--; BREAK; CASE(OP_instanceof): if (js_operator_instanceof(ctx, sp)) goto exception; sp--; BREAK; CASE(OP_typeof): { JSValue op1; JSAtom atom; op1 = sp[-1]; atom = js_operator_typeof(ctx, op1); JS_FreeValue(ctx, op1); sp[-1] = JS_AtomToString(ctx, atom); } BREAK; CASE(OP_delete): if (js_operator_delete(ctx, sp)) goto exception; sp--; BREAK; CASE(OP_delete_var): { JSAtom atom; int ret; atom = get_u32(pc); pc += 4; ret = JS_DeleteProperty(ctx, ctx->global_obj, atom, 0); if (unlikely(ret < 0)) goto exception; *sp++ = JS_NewBool(ctx, ret); } BREAK; CASE(OP_to_object): if (JS_VALUE_GET_TAG(sp[-1]) != JS_TAG_OBJECT) { ret_val = JS_ToObject(ctx, sp[-1]); if (JS_IsException(ret_val)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret_val; } BREAK; CASE(OP_to_propkey): switch (JS_VALUE_GET_TAG(sp[-1])) { case JS_TAG_INT: case JS_TAG_STRING: case JS_TAG_SYMBOL: break; default: ret_val = JS_ToPropertyKey(ctx, sp[-1]); if (JS_IsException(ret_val)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret_val; break; } BREAK; CASE(OP_to_propkey2): /* must be tested first */ if (unlikely(JS_IsUndefined(sp[-2]) || JS_IsNull(sp[-2]))) { JS_ThrowTypeError(ctx, "value has no property"); goto exception; } switch (JS_VALUE_GET_TAG(sp[-1])) { case JS_TAG_INT: case JS_TAG_STRING: case JS_TAG_SYMBOL: break; default: ret_val = JS_ToPropertyKey(ctx, sp[-1]); if (JS_IsException(ret_val)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret_val; break; } BREAK; #if 0 CASE(OP_to_string): if (JS_VALUE_GET_TAG(sp[-1]) != JS_TAG_STRING) { ret_val = JS_ToString(ctx, sp[-1]); if (JS_IsException(ret_val)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = ret_val; } BREAK; #endif CASE(OP_with_get_var): CASE(OP_with_put_var): CASE(OP_with_delete_var): CASE(OP_with_make_ref): CASE(OP_with_get_ref): CASE(OP_with_get_ref_undef): { JSAtom atom; int32_t diff; JSValue obj, val; int ret, is_with; atom = get_u32(pc); diff = get_u32(pc + 4); is_with = pc[8]; pc += 9; obj = sp[-1]; ret = JS_HasProperty(ctx, obj, atom); if (unlikely(ret < 0)) goto exception; if (ret) { if (is_with) { ret = js_has_unscopable(ctx, obj, atom); if (unlikely(ret < 0)) goto exception; if (ret) goto no_with; } switch (opcode) { case OP_with_get_var: val = JS_GetProperty(ctx, obj, atom); if (unlikely(JS_IsException(val))) goto exception; set_value(ctx, &sp[-1], val); break; case OP_with_put_var: /* XXX: check if strict mode */ ret = JS_SetPropertyInternal(ctx, obj, atom, sp[-2], obj, JS_PROP_THROW_STRICT); JS_FreeValue(ctx, sp[-1]); sp -= 2; if (unlikely(ret < 0)) goto exception; break; case OP_with_delete_var: ret = JS_DeleteProperty(ctx, obj, atom, 0); if (unlikely(ret < 0)) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = JS_NewBool(ctx, ret); break; case OP_with_make_ref: /* produce a pair object/propname on the stack */ *sp++ = JS_AtomToValue(ctx, atom); break; case OP_with_get_ref: /* produce a pair object/method on the stack */ val = JS_GetProperty(ctx, obj, atom); if (unlikely(JS_IsException(val))) goto exception; *sp++ = val; break; case OP_with_get_ref_undef: /* produce a pair undefined/function on the stack */ val = JS_GetProperty(ctx, obj, atom); if (unlikely(JS_IsException(val))) goto exception; JS_FreeValue(ctx, sp[-1]); sp[-1] = JS_UNDEFINED; *sp++ = val; break; } pc += diff - 5; } else { no_with: /* if not jumping, drop the object argument */ JS_FreeValue(ctx, sp[-1]); sp--; } } BREAK; CASE(OP_await): ret_val = JS_NewInt32(ctx, FUNC_RET_AWAIT); goto done_generator; CASE(OP_yield): ret_val = JS_NewInt32(ctx, FUNC_RET_YIELD); goto done_generator; CASE(OP_yield_star): CASE(OP_async_yield_star): ret_val = JS_NewInt32(ctx, FUNC_RET_YIELD_STAR); goto done_generator; CASE(OP_return_async): ret_val = JS_UNDEFINED; goto done_generator; CASE(OP_initial_yield): ret_val = JS_NewInt32(ctx, FUNC_RET_INITIAL_YIELD); goto done_generator; CASE(OP_nop): BREAK; CASE(OP_is_undefined_or_null): if (JS_VALUE_GET_TAG(sp[-1]) == JS_TAG_UNDEFINED || JS_VALUE_GET_TAG(sp[-1]) == JS_TAG_NULL) { goto set_true; } else { goto free_and_set_false; } #if SHORT_OPCODES CASE(OP_is_undefined): if (JS_VALUE_GET_TAG(sp[-1]) == JS_TAG_UNDEFINED) { goto set_true; } else { goto free_and_set_false; } CASE(OP_is_null): if (JS_VALUE_GET_TAG(sp[-1]) == JS_TAG_NULL) { goto set_true; } else { goto free_and_set_false; } /* XXX: could merge to a single opcode */ CASE(OP_typeof_is_undefined): /* different from OP_is_undefined because of isHTMLDDA */ if (js_operator_typeof(ctx, sp[-1]) == JS_ATOM_undefined) { goto free_and_set_true; } else { goto free_and_set_false; } CASE(OP_typeof_is_function): if (js_operator_typeof(ctx, sp[-1]) == JS_ATOM_function) { goto free_and_set_true; } else { goto free_and_set_false; } free_and_set_true: JS_FreeValue(ctx, sp[-1]); #endif set_true: sp[-1] = JS_TRUE; BREAK; free_and_set_false: JS_FreeValue(ctx, sp[-1]); sp[-1] = JS_FALSE; BREAK; CASE(OP_invalid): DEFAULT: JS_ThrowInternalError(ctx, "invalid opcode: pc=%u opcode=0x%02x", (int)(pc - b->byte_code_buf - 1), opcode); goto exception; } } exception: if (is_backtrace_needed(ctx, rt->current_exception)) { /* add the backtrace information now (it is not done before if the exception happens in a bytecode operation */ sf->cur_pc = pc; build_backtrace(ctx, rt->current_exception, NULL, 0, 0); } if (!JS_IsUncatchableError(ctx, rt->current_exception)) { while (sp > stack_buf) { JSValue val = *--sp; JS_FreeValue(ctx, val); if (JS_VALUE_GET_TAG(val) == JS_TAG_CATCH_OFFSET) { int pos = JS_VALUE_GET_INT(val); if (pos == 0) { /* enumerator: close it with a throw */ JS_FreeValue(ctx, sp[-1]); /* drop the next method */ sp--; JS_IteratorClose(ctx, sp[-1], TRUE); } else { *sp++ = rt->current_exception; rt->current_exception = JS_NULL; pc = b->byte_code_buf + pos; goto restart; } } } } ret_val = JS_EXCEPTION; /* the local variables are freed by the caller in the generator case. Hence the label 'done' should never be reached in a generator function. */ if (b->func_kind != JS_FUNC_NORMAL) { done_generator: sf->cur_pc = pc; sf->cur_sp = sp; } else { done: if (unlikely(!list_empty(&sf->var_ref_list))) { /* variable references reference the stack: must close them */ close_var_refs(rt, sf); } /* free the local variables and stack */ for(pval = local_buf; pval < sp; pval++) { JS_FreeValue(ctx, *pval); } } rt->current_stack_frame = sf->prev_frame; return ret_val; } JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv) { return JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED, argc, (JSValue *)argv, JS_CALL_FLAG_COPY_ARGV); } static JSValue JS_CallFree(JSContext *ctx, JSValue func_obj, JSValueConst this_obj, int argc, JSValueConst *argv) { JSValue res = JS_CallInternal(ctx, func_obj, this_obj, JS_UNDEFINED, argc, (JSValue *)argv, JS_CALL_FLAG_COPY_ARGV); JS_FreeValue(ctx, func_obj); return res; } /* warning: the refcount of the context is not incremented. Return NULL in case of exception (case of revoked proxy only) */ static JSContext *JS_GetFunctionRealm(JSContext *ctx, JSValueConst func_obj) { JSObject *p; JSContext *realm; if (JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT) return ctx; p = JS_VALUE_GET_OBJ(func_obj); switch(p->class_id) { case JS_CLASS_C_FUNCTION: realm = p->u.cfunc.realm; break; case JS_CLASS_BYTECODE_FUNCTION: case JS_CLASS_GENERATOR_FUNCTION: case JS_CLASS_ASYNC_FUNCTION: case JS_CLASS_ASYNC_GENERATOR_FUNCTION: { JSFunctionBytecode *b; b = p->u.func.function_bytecode; realm = b->realm; } break; case JS_CLASS_PROXY: { JSProxyData *s = p->u.opaque; if (!s) return ctx; if (s->is_revoked) { JS_ThrowTypeErrorRevokedProxy(ctx); return NULL; } else { realm = JS_GetFunctionRealm(ctx, s->target); } } break; case JS_CLASS_BOUND_FUNCTION: { JSBoundFunction *bf = p->u.bound_function; realm = JS_GetFunctionRealm(ctx, bf->func_obj); } break; default: realm = ctx; break; } return realm; } static JSValue js_create_from_ctor(JSContext *ctx, JSValueConst ctor, int class_id) { JSValue proto, obj; JSContext *realm; if (JS_IsUndefined(ctor)) { proto = JS_DupValue(ctx, ctx->class_proto[class_id]); } else { proto = JS_GetProperty(ctx, ctor, JS_ATOM_prototype); if (JS_IsException(proto)) return proto; if (!JS_IsObject(proto)) { JS_FreeValue(ctx, proto); realm = JS_GetFunctionRealm(ctx, ctor); if (!realm) return JS_EXCEPTION; proto = JS_DupValue(ctx, realm->class_proto[class_id]); } } obj = JS_NewObjectProtoClass(ctx, proto, class_id); JS_FreeValue(ctx, proto); return obj; } /* argv[] is modified if (flags & JS_CALL_FLAG_COPY_ARGV) = 0. */ static JSValue JS_CallConstructorInternal(JSContext *ctx, JSValueConst func_obj, JSValueConst new_target, int argc, JSValue *argv, int flags) { JSObject *p; JSFunctionBytecode *b; if (js_poll_interrupts(ctx)) return JS_EXCEPTION; flags |= JS_CALL_FLAG_CONSTRUCTOR; if (unlikely(JS_VALUE_GET_TAG(func_obj) != JS_TAG_OBJECT)) goto not_a_function; p = JS_VALUE_GET_OBJ(func_obj); if (unlikely(!p->is_constructor)) return JS_ThrowTypeError(ctx, "not a constructor"); if (unlikely(p->class_id != JS_CLASS_BYTECODE_FUNCTION)) { JSClassCall *call_func; call_func = ctx->rt->class_array[p->class_id].call; if (!call_func) { not_a_function: return JS_ThrowTypeError(ctx, "not a function"); } return call_func(ctx, func_obj, new_target, argc, (JSValueConst *)argv, flags); } b = p->u.func.function_bytecode; if (b->is_derived_class_constructor) { return JS_CallInternal(ctx, func_obj, JS_UNDEFINED, new_target, argc, argv, flags); } else { JSValue obj, ret; /* legacy constructor behavior */ obj = js_create_from_ctor(ctx, new_target, JS_CLASS_OBJECT); if (JS_IsException(obj)) return JS_EXCEPTION; ret = JS_CallInternal(ctx, func_obj, obj, new_target, argc, argv, flags); if (JS_VALUE_GET_TAG(ret) == JS_TAG_OBJECT || JS_IsException(ret)) { JS_FreeValue(ctx, obj); return ret; } else { JS_FreeValue(ctx, ret); return obj; } } } JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj, JSValueConst new_target, int argc, JSValueConst *argv) { return JS_CallConstructorInternal(ctx, func_obj, new_target, argc, (JSValue *)argv, JS_CALL_FLAG_COPY_ARGV); } JSValue JS_CallConstructor(JSContext *ctx, JSValueConst func_obj, int argc, JSValueConst *argv) { return JS_CallConstructorInternal(ctx, func_obj, func_obj, argc, (JSValue *)argv, JS_CALL_FLAG_COPY_ARGV); } JSValue JS_Invoke(JSContext *ctx, JSValueConst this_val, JSAtom atom, int argc, JSValueConst *argv) { JSValue func_obj; func_obj = JS_GetProperty(ctx, this_val, atom); if (JS_IsException(func_obj)) return func_obj; return JS_CallFree(ctx, func_obj, this_val, argc, argv); } static JSValue JS_InvokeFree(JSContext *ctx, JSValue this_val, JSAtom atom, int argc, JSValueConst *argv) { JSValue res = JS_Invoke(ctx, this_val, atom, argc, argv); JS_FreeValue(ctx, this_val); return res; } /* JSAsyncFunctionState (used by generator and async functions) */ static JSAsyncFunctionState *async_func_init(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv) { JSAsyncFunctionState *s; JSObject *p; JSFunctionBytecode *b; JSStackFrame *sf; int local_count, i, arg_buf_len, n; s = js_mallocz(ctx, sizeof(*s)); if (!s) return NULL; s->header.ref_count = 1; add_gc_object(ctx->rt, &s->header, JS_GC_OBJ_TYPE_ASYNC_FUNCTION); sf = &s->frame; init_list_head(&sf->var_ref_list); p = JS_VALUE_GET_OBJ(func_obj); b = p->u.func.function_bytecode; sf->js_mode = b->js_mode | JS_MODE_ASYNC; sf->cur_pc = b->byte_code_buf; arg_buf_len = max_int(b->arg_count, argc); local_count = arg_buf_len + b->var_count + b->stack_size; sf->arg_buf = js_malloc(ctx, sizeof(JSValue) * max_int(local_count, 1)); if (!sf->arg_buf) { js_free(ctx, s); return NULL; } sf->cur_func = JS_DupValue(ctx, func_obj); s->this_val = JS_DupValue(ctx, this_obj); s->argc = argc; sf->arg_count = arg_buf_len; sf->var_buf = sf->arg_buf + arg_buf_len; sf->cur_sp = sf->var_buf + b->var_count; for(i = 0; i < argc; i++) sf->arg_buf[i] = JS_DupValue(ctx, argv[i]); n = arg_buf_len + b->var_count; for(i = argc; i < n; i++) sf->arg_buf[i] = JS_UNDEFINED; s->resolving_funcs[0] = JS_UNDEFINED; s->resolving_funcs[1] = JS_UNDEFINED; s->is_completed = FALSE; return s; } static void async_func_free_frame(JSRuntime *rt, JSAsyncFunctionState *s) { JSStackFrame *sf = &s->frame; JSValue *sp; if (sf->arg_buf) { /* cannot free the function if it is running */ assert(sf->cur_sp != NULL); for(sp = sf->arg_buf; sp < sf->cur_sp; sp++) { JS_FreeValueRT(rt, *sp); } js_free_rt(rt, sf->arg_buf); sf->arg_buf = NULL; } JS_FreeValueRT(rt, sf->cur_func); JS_FreeValueRT(rt, s->this_val); } static JSValue async_func_resume(JSContext *ctx, JSAsyncFunctionState *s) { JSRuntime *rt = ctx->rt; JSStackFrame *sf = &s->frame; JSValue func_obj, ret; assert(!s->is_completed); if (js_check_stack_overflow(ctx->rt, 0)) { ret = JS_ThrowStackOverflow(ctx); } else { /* the tag does not matter provided it is not an object */ func_obj = JS_MKPTR(JS_TAG_INT, s); ret = JS_CallInternal(ctx, func_obj, s->this_val, JS_UNDEFINED, s->argc, sf->arg_buf, JS_CALL_FLAG_GENERATOR); } if (JS_IsException(ret) || JS_IsUndefined(ret)) { if (JS_IsUndefined(ret)) { ret = sf->cur_sp[-1]; sf->cur_sp[-1] = JS_UNDEFINED; } /* end of execution */ s->is_completed = TRUE; /* close the closure variables. */ close_var_refs(rt, sf); async_func_free_frame(rt, s); } return ret; } static void __async_func_free(JSRuntime *rt, JSAsyncFunctionState *s) { /* cannot close the closure variables here because it would potentially modify the object graph */ if (!s->is_completed) { async_func_free_frame(rt, s); } JS_FreeValueRT(rt, s->resolving_funcs[0]); JS_FreeValueRT(rt, s->resolving_funcs[1]); remove_gc_object(&s->header); if (rt->gc_phase == JS_GC_PHASE_REMOVE_CYCLES && s->header.ref_count != 0) { list_add_tail(&s->header.link, &rt->gc_zero_ref_count_list); } else { js_free_rt(rt, s); } } static void async_func_free(JSRuntime *rt, JSAsyncFunctionState *s) { if (--s->header.ref_count == 0) { if (rt->gc_phase != JS_GC_PHASE_REMOVE_CYCLES) { list_del(&s->header.link); list_add(&s->header.link, &rt->gc_zero_ref_count_list); if (rt->gc_phase == JS_GC_PHASE_NONE) { free_zero_refcount(rt); } } } } /* Generators */ typedef enum JSGeneratorStateEnum { JS_GENERATOR_STATE_SUSPENDED_START, JS_GENERATOR_STATE_SUSPENDED_YIELD, JS_GENERATOR_STATE_SUSPENDED_YIELD_STAR, JS_GENERATOR_STATE_EXECUTING, JS_GENERATOR_STATE_COMPLETED, } JSGeneratorStateEnum; typedef struct JSGeneratorData { JSGeneratorStateEnum state; JSAsyncFunctionState *func_state; } JSGeneratorData; static void free_generator_stack_rt(JSRuntime *rt, JSGeneratorData *s) { if (s->state == JS_GENERATOR_STATE_COMPLETED) return; if (s->func_state) { async_func_free(rt, s->func_state); s->func_state = NULL; } s->state = JS_GENERATOR_STATE_COMPLETED; } static void js_generator_finalizer(JSRuntime *rt, JSValue obj) { JSGeneratorData *s = JS_GetOpaque(obj, JS_CLASS_GENERATOR); if (s) { free_generator_stack_rt(rt, s); js_free_rt(rt, s); } } static void free_generator_stack(JSContext *ctx, JSGeneratorData *s) { free_generator_stack_rt(ctx->rt, s); } static void js_generator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); JSGeneratorData *s = p->u.generator_data; if (!s || !s->func_state) return; mark_func(rt, &s->func_state->header); } /* XXX: use enum */ #define GEN_MAGIC_NEXT 0 #define GEN_MAGIC_RETURN 1 #define GEN_MAGIC_THROW 2 static JSValue js_generator_next(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, BOOL *pdone, int magic) { JSGeneratorData *s = JS_GetOpaque(this_val, JS_CLASS_GENERATOR); JSStackFrame *sf; JSValue ret, func_ret; *pdone = TRUE; if (!s) return JS_ThrowTypeError(ctx, "not a generator"); sf = &s->func_state->frame; switch(s->state) { default: case JS_GENERATOR_STATE_SUSPENDED_START: if (magic == GEN_MAGIC_NEXT) { goto exec_no_arg; } else { free_generator_stack(ctx, s); goto done; } break; case JS_GENERATOR_STATE_SUSPENDED_YIELD_STAR: case JS_GENERATOR_STATE_SUSPENDED_YIELD: /* cur_sp[-1] was set to JS_UNDEFINED in the previous call */ ret = JS_DupValue(ctx, argv[0]); if (magic == GEN_MAGIC_THROW && s->state == JS_GENERATOR_STATE_SUSPENDED_YIELD) { JS_Throw(ctx, ret); s->func_state->throw_flag = TRUE; } else { sf->cur_sp[-1] = ret; sf->cur_sp[0] = JS_NewInt32(ctx, magic); sf->cur_sp++; exec_no_arg: s->func_state->throw_flag = FALSE; } s->state = JS_GENERATOR_STATE_EXECUTING; func_ret = async_func_resume(ctx, s->func_state); s->state = JS_GENERATOR_STATE_SUSPENDED_YIELD; if (s->func_state->is_completed) { /* finalize the execution in case of exception or normal return */ free_generator_stack(ctx, s); return func_ret; } else { assert(JS_VALUE_GET_TAG(func_ret) == JS_TAG_INT); /* get the returned yield value at the top of the stack */ ret = sf->cur_sp[-1]; sf->cur_sp[-1] = JS_UNDEFINED; if (JS_VALUE_GET_INT(func_ret) == FUNC_RET_YIELD_STAR) { s->state = JS_GENERATOR_STATE_SUSPENDED_YIELD_STAR; /* return (value, done) object */ *pdone = 2; } else { *pdone = FALSE; } } break; case JS_GENERATOR_STATE_COMPLETED: done: /* execution is finished */ switch(magic) { default: case GEN_MAGIC_NEXT: ret = JS_UNDEFINED; break; case GEN_MAGIC_RETURN: ret = JS_DupValue(ctx, argv[0]); break; case GEN_MAGIC_THROW: ret = JS_Throw(ctx, JS_DupValue(ctx, argv[0])); break; } break; case JS_GENERATOR_STATE_EXECUTING: ret = JS_ThrowTypeError(ctx, "cannot invoke a running generator"); break; } return ret; } static JSValue js_generator_function_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags) { JSValue obj, func_ret; JSGeneratorData *s; s = js_mallocz(ctx, sizeof(*s)); if (!s) return JS_EXCEPTION; s->state = JS_GENERATOR_STATE_SUSPENDED_START; s->func_state = async_func_init(ctx, func_obj, this_obj, argc, argv); if (!s->func_state) { s->state = JS_GENERATOR_STATE_COMPLETED; goto fail; } /* execute the function up to 'OP_initial_yield' */ func_ret = async_func_resume(ctx, s->func_state); if (JS_IsException(func_ret)) goto fail; JS_FreeValue(ctx, func_ret); obj = js_create_from_ctor(ctx, func_obj, JS_CLASS_GENERATOR); if (JS_IsException(obj)) goto fail; JS_SetOpaque(obj, s); return obj; fail: free_generator_stack_rt(ctx->rt, s); js_free(ctx, s); return JS_EXCEPTION; } /* AsyncFunction */ static void js_async_function_resolve_finalizer(JSRuntime *rt, JSValue val) { JSObject *p = JS_VALUE_GET_OBJ(val); JSAsyncFunctionState *s = p->u.async_function_data; if (s) { async_func_free(rt, s); } } static void js_async_function_resolve_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSObject *p = JS_VALUE_GET_OBJ(val); JSAsyncFunctionState *s = p->u.async_function_data; if (s) { mark_func(rt, &s->header); } } static int js_async_function_resolve_create(JSContext *ctx, JSAsyncFunctionState *s, JSValue *resolving_funcs) { int i; JSObject *p; for(i = 0; i < 2; i++) { resolving_funcs[i] = JS_NewObjectProtoClass(ctx, ctx->function_proto, JS_CLASS_ASYNC_FUNCTION_RESOLVE + i); if (JS_IsException(resolving_funcs[i])) { if (i == 1) JS_FreeValue(ctx, resolving_funcs[0]); return -1; } p = JS_VALUE_GET_OBJ(resolving_funcs[i]); s->header.ref_count++; p->u.async_function_data = s; } return 0; } static void js_async_function_resume(JSContext *ctx, JSAsyncFunctionState *s) { JSValue func_ret, ret2; func_ret = async_func_resume(ctx, s); if (s->is_completed) { if (JS_IsException(func_ret)) { JSValue error; fail: error = JS_GetException(ctx); ret2 = JS_Call(ctx, s->resolving_funcs[1], JS_UNDEFINED, 1, (JSValueConst *)&error); JS_FreeValue(ctx, error); JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */ } else { /* normal return */ ret2 = JS_Call(ctx, s->resolving_funcs[0], JS_UNDEFINED, 1, (JSValueConst *)&func_ret); JS_FreeValue(ctx, func_ret); JS_FreeValue(ctx, ret2); /* XXX: what to do if exception ? */ } } else { JSValue value, promise, resolving_funcs[2], resolving_funcs1[2]; int i, res; value = s->frame.cur_sp[-1]; s->frame.cur_sp[-1] = JS_UNDEFINED; /* await */ JS_FreeValue(ctx, func_ret); /* not used */ promise = js_promise_resolve(ctx, ctx->promise_ctor, 1, (JSValueConst *)&value, 0); JS_FreeValue(ctx, value); if (JS_IsException(promise)) goto fail; if (js_async_function_resolve_create(ctx, s, resolving_funcs)) { JS_FreeValue(ctx, promise); goto fail; } /* Note: no need to create 'thrownawayCapability' as in the spec */ for(i = 0; i < 2; i++) resolving_funcs1[i] = JS_UNDEFINED; res = perform_promise_then(ctx, promise, (JSValueConst *)resolving_funcs, (JSValueConst *)resolving_funcs1); JS_FreeValue(ctx, promise); for(i = 0; i < 2; i++) JS_FreeValue(ctx, resolving_funcs[i]); if (res) goto fail; } } static JSValue js_async_function_resolve_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags) { JSObject *p = JS_VALUE_GET_OBJ(func_obj); JSAsyncFunctionState *s = p->u.async_function_data; BOOL is_reject = p->class_id - JS_CLASS_ASYNC_FUNCTION_RESOLVE; JSValueConst arg; if (argc > 0) arg = argv[0]; else arg = JS_UNDEFINED; s->throw_flag = is_reject; if (is_reject) { JS_Throw(ctx, JS_DupValue(ctx, arg)); } else { /* return value of await */ s->frame.cur_sp[-1] = JS_DupValue(ctx, arg); } js_async_function_resume(ctx, s); return JS_UNDEFINED; } static JSValue js_async_function_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags) { JSValue promise; JSAsyncFunctionState *s; s = async_func_init(ctx, func_obj, this_obj, argc, argv); if (!s) return JS_EXCEPTION; promise = JS_NewPromiseCapability(ctx, s->resolving_funcs); if (JS_IsException(promise)) { async_func_free(ctx->rt, s); return JS_EXCEPTION; } js_async_function_resume(ctx, s); async_func_free(ctx->rt, s); return promise; } /* AsyncGenerator */ typedef enum JSAsyncGeneratorStateEnum { JS_ASYNC_GENERATOR_STATE_SUSPENDED_START, JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD, JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD_STAR, JS_ASYNC_GENERATOR_STATE_EXECUTING, JS_ASYNC_GENERATOR_STATE_AWAITING_RETURN, JS_ASYNC_GENERATOR_STATE_COMPLETED, } JSAsyncGeneratorStateEnum; typedef struct JSAsyncGeneratorRequest { struct list_head link; /* completion */ int completion_type; /* GEN_MAGIC_x */ JSValue result; /* promise capability */ JSValue promise; JSValue resolving_funcs[2]; } JSAsyncGeneratorRequest; typedef struct JSAsyncGeneratorData { JSObject *generator; /* back pointer to the object (const) */ JSAsyncGeneratorStateEnum state; /* func_state is NULL is state AWAITING_RETURN and COMPLETED */ JSAsyncFunctionState *func_state; struct list_head queue; /* list of JSAsyncGeneratorRequest.link */ } JSAsyncGeneratorData; static void js_async_generator_free(JSRuntime *rt, JSAsyncGeneratorData *s) { struct list_head *el, *el1; JSAsyncGeneratorRequest *req; list_for_each_safe(el, el1, &s->queue) { req = list_entry(el, JSAsyncGeneratorRequest, link); JS_FreeValueRT(rt, req->result); JS_FreeValueRT(rt, req->promise); JS_FreeValueRT(rt, req->resolving_funcs[0]); JS_FreeValueRT(rt, req->resolving_funcs[1]); js_free_rt(rt, req); } if (s->func_state) async_func_free(rt, s->func_state); js_free_rt(rt, s); } static void js_async_generator_finalizer(JSRuntime *rt, JSValue obj) { JSAsyncGeneratorData *s = JS_GetOpaque(obj, JS_CLASS_ASYNC_GENERATOR); if (s) { js_async_generator_free(rt, s); } } static void js_async_generator_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { JSAsyncGeneratorData *s = JS_GetOpaque(val, JS_CLASS_ASYNC_GENERATOR); struct list_head *el; JSAsyncGeneratorRequest *req; if (s) { list_for_each(el, &s->queue) { req = list_entry(el, JSAsyncGeneratorRequest, link); JS_MarkValue(rt, req->result, mark_func); JS_MarkValue(rt, req->promise, mark_func); JS_MarkValue(rt, req->resolving_funcs[0], mark_func); JS_MarkValue(rt, req->resolving_funcs[1], mark_func); } if (s->func_state) { mark_func(rt, &s->func_state->header); } } } static JSValue js_async_generator_resolve_function(JSContext *ctx, JSValueConst this_obj, int argc, JSValueConst *argv, int magic, JSValue *func_data); static int js_async_generator_resolve_function_create(JSContext *ctx, JSValueConst generator, JSValue *resolving_funcs, BOOL is_resume_next) { int i; JSValue func; for(i = 0; i < 2; i++) { func = JS_NewCFunctionData(ctx, js_async_generator_resolve_function, 1, i + is_resume_next * 2, 1, &generator); if (JS_IsException(func)) { if (i == 1) JS_FreeValue(ctx, resolving_funcs[0]); return -1; } resolving_funcs[i] = func; } return 0; } static int js_async_generator_await(JSContext *ctx, JSAsyncGeneratorData *s, JSValueConst value) { JSValue promise, resolving_funcs[2], resolving_funcs1[2]; int i, res; promise = js_promise_resolve(ctx, ctx->promise_ctor, 1, &value, 0); if (JS_IsException(promise)) goto fail; if (js_async_generator_resolve_function_create(ctx, JS_MKPTR(JS_TAG_OBJECT, s->generator), resolving_funcs, FALSE)) { JS_FreeValue(ctx, promise); goto fail; } /* Note: no need to create 'thrownawayCapability' as in the spec */ for(i = 0; i < 2; i++) resolving_funcs1[i] = JS_UNDEFINED; res = perform_promise_then(ctx, promise, (JSValueConst *)resolving_funcs, (JSValueConst *)resolving_funcs1); JS_FreeValue(ctx, promise); for(i = 0; i < 2; i++) JS_FreeValue(ctx, resolving_funcs[i]); if (res) goto fail; return 0; fail: return -1; } static void js_async_generator_resolve_or_reject(JSContext *ctx, JSAsyncGeneratorData *s, JSValueConst result, int is_reject) { JSAsyncGeneratorRequest *next; JSValue ret; next = list_entry(s->queue.next, JSAsyncGeneratorRequest, link); list_del(&next->link); ret = JS_Call(ctx, next->resolving_funcs[is_reject], JS_UNDEFINED, 1, &result); JS_FreeValue(ctx, ret); JS_FreeValue(ctx, next->result); JS_FreeValue(ctx, next->promise); JS_FreeValue(ctx, next->resolving_funcs[0]); JS_FreeValue(ctx, next->resolving_funcs[1]); js_free(ctx, next); } static void js_async_generator_resolve(JSContext *ctx, JSAsyncGeneratorData *s, JSValueConst value, BOOL done) { JSValue result; result = js_create_iterator_result(ctx, JS_DupValue(ctx, value), done); /* XXX: better exception handling ? */ js_async_generator_resolve_or_reject(ctx, s, result, 0); JS_FreeValue(ctx, result); } static void js_async_generator_reject(JSContext *ctx, JSAsyncGeneratorData *s, JSValueConst exception) { js_async_generator_resolve_or_reject(ctx, s, exception, 1); } static void js_async_generator_complete(JSContext *ctx, JSAsyncGeneratorData *s) { if (s->state != JS_ASYNC_GENERATOR_STATE_COMPLETED) { s->state = JS_ASYNC_GENERATOR_STATE_COMPLETED; async_func_free(ctx->rt, s->func_state); s->func_state = NULL; } } static int js_async_generator_completed_return(JSContext *ctx, JSAsyncGeneratorData *s, JSValueConst value) { JSValue promise, resolving_funcs[2], resolving_funcs1[2]; int res; // Can fail looking up JS_ATOM_constructor when is_reject==0. promise = js_promise_resolve(ctx, ctx->promise_ctor, 1, &value, /*is_reject*/0); // A poisoned .constructor property is observable and the resulting // exception should be delivered to the catch handler. if (JS_IsException(promise)) { JSValue err = JS_GetException(ctx); promise = js_promise_resolve(ctx, ctx->promise_ctor, 1, (JSValueConst *)&err, /*is_reject*/1); JS_FreeValue(ctx, err); if (JS_IsException(promise)) return -1; } if (js_async_generator_resolve_function_create(ctx, JS_MKPTR(JS_TAG_OBJECT, s->generator), resolving_funcs1, TRUE)) { JS_FreeValue(ctx, promise); return -1; } resolving_funcs[0] = JS_UNDEFINED; resolving_funcs[1] = JS_UNDEFINED; res = perform_promise_then(ctx, promise, (JSValueConst *)resolving_funcs1, (JSValueConst *)resolving_funcs); JS_FreeValue(ctx, resolving_funcs1[0]); JS_FreeValue(ctx, resolving_funcs1[1]); JS_FreeValue(ctx, promise); return res; } static void js_async_generator_resume_next(JSContext *ctx, JSAsyncGeneratorData *s) { JSAsyncGeneratorRequest *next; JSValue func_ret, value; for(;;) { if (list_empty(&s->queue)) break; next = list_entry(s->queue.next, JSAsyncGeneratorRequest, link); switch(s->state) { case JS_ASYNC_GENERATOR_STATE_EXECUTING: /* only happens when restarting execution after await() */ goto resume_exec; case JS_ASYNC_GENERATOR_STATE_AWAITING_RETURN: goto done; case JS_ASYNC_GENERATOR_STATE_SUSPENDED_START: if (next->completion_type == GEN_MAGIC_NEXT) { goto exec_no_arg; } else { js_async_generator_complete(ctx, s); } break; case JS_ASYNC_GENERATOR_STATE_COMPLETED: if (next->completion_type == GEN_MAGIC_NEXT) { js_async_generator_resolve(ctx, s, JS_UNDEFINED, TRUE); } else if (next->completion_type == GEN_MAGIC_RETURN) { s->state = JS_ASYNC_GENERATOR_STATE_AWAITING_RETURN; js_async_generator_completed_return(ctx, s, next->result); } else { js_async_generator_reject(ctx, s, next->result); } goto done; case JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD: case JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD_STAR: value = JS_DupValue(ctx, next->result); if (next->completion_type == GEN_MAGIC_THROW && s->state == JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD) { JS_Throw(ctx, value); s->func_state->throw_flag = TRUE; } else { /* 'yield' returns a value. 'yield *' also returns a value in case the 'throw' method is called */ s->func_state->frame.cur_sp[-1] = value; s->func_state->frame.cur_sp[0] = JS_NewInt32(ctx, next->completion_type); s->func_state->frame.cur_sp++; exec_no_arg: s->func_state->throw_flag = FALSE; } s->state = JS_ASYNC_GENERATOR_STATE_EXECUTING; resume_exec: func_ret = async_func_resume(ctx, s->func_state); if (s->func_state->is_completed) { if (JS_IsException(func_ret)) { value = JS_GetException(ctx); js_async_generator_complete(ctx, s); js_async_generator_reject(ctx, s, value); JS_FreeValue(ctx, value); } else { /* end of function */ js_async_generator_complete(ctx, s); js_async_generator_resolve(ctx, s, func_ret, TRUE); JS_FreeValue(ctx, func_ret); } } else { int func_ret_code, ret; assert(JS_VALUE_GET_TAG(func_ret) == JS_TAG_INT); func_ret_code = JS_VALUE_GET_INT(func_ret); value = s->func_state->frame.cur_sp[-1]; s->func_state->frame.cur_sp[-1] = JS_UNDEFINED; switch(func_ret_code) { case FUNC_RET_YIELD: case FUNC_RET_YIELD_STAR: if (func_ret_code == FUNC_RET_YIELD_STAR) s->state = JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD_STAR; else s->state = JS_ASYNC_GENERATOR_STATE_SUSPENDED_YIELD; js_async_generator_resolve(ctx, s, value, FALSE); JS_FreeValue(ctx, value); break; case FUNC_RET_AWAIT: ret = js_async_generator_await(ctx, s, value); JS_FreeValue(ctx, value); if (ret < 0) { /* exception: throw it */ s->func_state->throw_flag = TRUE; goto resume_exec; } goto done; default: abort(); } } break; default: abort(); } } done: ; } static JSValue js_async_generator_resolve_function(JSContext *ctx, JSValueConst this_obj, int argc, JSValueConst *argv, int magic, JSValue *func_data) { BOOL is_reject = magic & 1; JSAsyncGeneratorData *s = JS_GetOpaque(func_data[0], JS_CLASS_ASYNC_GENERATOR); JSValueConst arg = argv[0]; /* XXX: what if s == NULL */ if (magic >= 2) { /* resume next case in AWAITING_RETURN state */ assert(s->state == JS_ASYNC_GENERATOR_STATE_AWAITING_RETURN || s->state == JS_ASYNC_GENERATOR_STATE_COMPLETED); s->state = JS_ASYNC_GENERATOR_STATE_COMPLETED; if (is_reject) { js_async_generator_reject(ctx, s, arg); } else { js_async_generator_resolve(ctx, s, arg, TRUE); } } else { /* restart function execution after await() */ assert(s->state == JS_ASYNC_GENERATOR_STATE_EXECUTING); s->func_state->throw_flag = is_reject; if (is_reject) { JS_Throw(ctx, JS_DupValue(ctx, arg)); } else { /* return value of await */ s->func_state->frame.cur_sp[-1] = JS_DupValue(ctx, arg); } js_async_generator_resume_next(ctx, s); } return JS_UNDEFINED; } /* magic = GEN_MAGIC_x */ static JSValue js_async_generator_next(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) { JSAsyncGeneratorData *s = JS_GetOpaque(this_val, JS_CLASS_ASYNC_GENERATOR); JSValue promise, resolving_funcs[2]; JSAsyncGeneratorRequest *req; promise = JS_NewPromiseCapability(ctx, resolving_funcs); if (JS_IsException(promise)) return JS_EXCEPTION; if (!s) { JSValue err, res2; JS_ThrowTypeError(ctx, "not an AsyncGenerator object"); err = JS_GetException(ctx); res2 = JS_Call(ctx, resolving_funcs[1], JS_UNDEFINED, 1, (JSValueConst *)&err); JS_FreeValue(ctx, err); JS_FreeValue(ctx, res2); JS_FreeValue(ctx, resolving_funcs[0]); JS_FreeValue(ctx, resolving_funcs[1]); return promise; } req = js_mallocz(ctx, sizeof(*req)); if (!req) goto fail; req->completion_type = magic; req->result = JS_DupValue(ctx, argv[0]); req->promise = JS_DupValue(ctx, promise); req->resolving_funcs[0] = resolving_funcs[0]; req->resolving_funcs[1] = resolving_funcs[1]; list_add_tail(&req->link, &s->queue); if (s->state != JS_ASYNC_GENERATOR_STATE_EXECUTING) { js_async_generator_resume_next(ctx, s); } return promise; fail: JS_FreeValue(ctx, resolving_funcs[0]); JS_FreeValue(ctx, resolving_funcs[1]); JS_FreeValue(ctx, promise); return JS_EXCEPTION; } static JSValue js_async_generator_function_call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj, int argc, JSValueConst *argv, int flags) { JSValue obj, func_ret; JSAsyncGeneratorData *s; s = js_mallocz(ctx, sizeof(*s)); if (!s) return JS_EXCEPTION; s->state = JS_ASYNC_GENERATOR_STATE_SUSPENDED_START; init_list_head(&s->queue); s->func_state = async_func_init(ctx, func_obj, this_obj, argc, argv); if (!s->func_state) goto fail; /* execute the function up to 'OP_initial_yield' (no yield nor await are possible) */ func_ret = async_func_resume(ctx, s->func_state); if (JS_IsException(func_ret)) goto fail; JS_FreeValue(ctx, func_ret); obj = js_create_from_ctor(ctx, func_obj, JS_CLASS_ASYNC_GENERATOR); if (JS_IsException(obj)) goto fail; s->generator = JS_VALUE_GET_OBJ(obj); JS_SetOpaque(obj, s); return obj; fail: js_async_generator_free(ctx->rt, s); return JS_EXCEPTION; } /* JS parser */ enum { TOK_NUMBER = -128, TOK_STRING, TOK_TEMPLATE, TOK_IDENT, TOK_REGEXP, /* warning: order matters (see js_parse_assign_expr) */ TOK_MUL_ASSIGN, TOK_DIV_ASSIGN, TOK_MOD_ASSIGN, TOK_PLUS_ASSIGN, TOK_MINUS_ASSIGN, TOK_SHL_ASSIGN, TOK_SAR_ASSIGN, TOK_SHR_ASSIGN, TOK_AND_ASSIGN, TOK_XOR_ASSIGN, TOK_OR_ASSIGN, #ifdef CONFIG_BIGNUM TOK_MATH_POW_ASSIGN, #endif TOK_POW_ASSIGN, TOK_LAND_ASSIGN, TOK_LOR_ASSIGN, TOK_DOUBLE_QUESTION_MARK_ASSIGN, TOK_DEC, TOK_INC, TOK_SHL, TOK_SAR, TOK_SHR, TOK_LT, TOK_LTE, TOK_GT, TOK_GTE, TOK_EQ, TOK_STRICT_EQ, TOK_NEQ, TOK_STRICT_NEQ, TOK_LAND, TOK_LOR, #ifdef CONFIG_BIGNUM TOK_MATH_POW, #endif TOK_POW, TOK_ARROW, TOK_ELLIPSIS, TOK_DOUBLE_QUESTION_MARK, TOK_QUESTION_MARK_DOT, TOK_ERROR, TOK_PRIVATE_NAME, TOK_EOF, /* keywords: WARNING: same order as atoms */ TOK_NULL, /* must be first */ TOK_FALSE, TOK_TRUE, TOK_IF, TOK_ELSE, TOK_RETURN, TOK_VAR, TOK_THIS, TOK_DELETE, TOK_VOID, TOK_TYPEOF, TOK_NEW, TOK_IN, TOK_INSTANCEOF, TOK_DO, TOK_WHILE, TOK_FOR, TOK_BREAK, TOK_CONTINUE, TOK_SWITCH, TOK_CASE, TOK_DEFAULT, TOK_THROW, TOK_TRY, TOK_CATCH, TOK_FINALLY, TOK_FUNCTION, TOK_DEBUGGER, TOK_WITH, /* FutureReservedWord */ TOK_CLASS, TOK_CONST, TOK_ENUM, TOK_EXPORT, TOK_EXTENDS, TOK_IMPORT, TOK_SUPER, /* FutureReservedWords when parsing strict mode code */ TOK_IMPLEMENTS, TOK_INTERFACE, TOK_LET, TOK_PACKAGE, TOK_PRIVATE, TOK_PROTECTED, TOK_PUBLIC, TOK_STATIC, TOK_YIELD, TOK_AWAIT, /* must be last */ TOK_OF, /* only used for js_parse_skip_parens_token() */ }; #define TOK_FIRST_KEYWORD TOK_NULL #define TOK_LAST_KEYWORD TOK_AWAIT /* unicode code points */ #define CP_NBSP 0x00a0 #define CP_BOM 0xfeff #define CP_LS 0x2028 #define CP_PS 0x2029 typedef struct BlockEnv { struct BlockEnv *prev; JSAtom label_name; /* JS_ATOM_NULL if none */ int label_break; /* -1 if none */ int label_cont; /* -1 if none */ int drop_count; /* number of stack elements to drop */ int label_finally; /* -1 if none */ int scope_level; int has_iterator; } BlockEnv; typedef struct JSGlobalVar { int cpool_idx; /* if >= 0, index in the constant pool for hoisted function defintion*/ uint8_t force_init : 1; /* force initialization to undefined */ uint8_t is_lexical : 1; /* global let/const definition */ uint8_t is_const : 1; /* const definition */ int scope_level; /* scope of definition */ JSAtom var_name; /* variable name */ } JSGlobalVar; typedef struct RelocEntry { struct RelocEntry *next; uint32_t addr; /* address to patch */ int size; /* address size: 1, 2 or 4 bytes */ } RelocEntry; typedef struct JumpSlot { int op; int size; int pos; int label; } JumpSlot; typedef struct LabelSlot { int ref_count; int pos; /* phase 1 address, -1 means not resolved yet */ int pos2; /* phase 2 address, -1 means not resolved yet */ int addr; /* phase 3 address, -1 means not resolved yet */ RelocEntry *first_reloc; } LabelSlot; typedef struct LineNumberSlot { uint32_t pc; int line_num; } LineNumberSlot; typedef enum JSParseFunctionEnum { JS_PARSE_FUNC_STATEMENT, JS_PARSE_FUNC_VAR, JS_PARSE_FUNC_EXPR, JS_PARSE_FUNC_ARROW, JS_PARSE_FUNC_GETTER, JS_PARSE_FUNC_SETTER, JS_PARSE_FUNC_METHOD, JS_PARSE_FUNC_CLASS_STATIC_INIT, JS_PARSE_FUNC_CLASS_CONSTRUCTOR, JS_PARSE_FUNC_DERIVED_CLASS_CONSTRUCTOR, } JSParseFunctionEnum; typedef enum JSParseExportEnum { JS_PARSE_EXPORT_NONE, JS_PARSE_EXPORT_NAMED, JS_PARSE_EXPORT_DEFAULT, } JSParseExportEnum; typedef struct JSFunctionDef { JSContext *ctx; struct JSFunctionDef *parent; int parent_cpool_idx; /* index in the constant pool of the parent or -1 if none */ int parent_scope_level; /* scope level in parent at point of definition */ struct list_head child_list; /* list of JSFunctionDef.link */ struct list_head link; BOOL is_eval; /* TRUE if eval code */ int eval_type; /* only valid if is_eval = TRUE */ BOOL is_global_var; /* TRUE if variables are not defined locally: eval global, eval module or non strict eval */ BOOL is_func_expr; /* TRUE if function expression */ BOOL has_home_object; /* TRUE if the home object is available */ BOOL has_prototype; /* true if a prototype field is necessary */ BOOL has_simple_parameter_list; BOOL has_parameter_expressions; /* if true, an argument scope is created */ BOOL has_use_strict; /* to reject directive in special cases */ BOOL has_eval_call; /* true if the function contains a call to eval() */ BOOL has_arguments_binding; /* true if the 'arguments' binding is available in the function */ BOOL has_this_binding; /* true if the 'this' and new.target binding are available in the function */ BOOL new_target_allowed; /* true if the 'new.target' does not throw a syntax error */ BOOL super_call_allowed; /* true if super() is allowed */ BOOL super_allowed; /* true if super. or super[] is allowed */ BOOL arguments_allowed; /* true if the 'arguments' identifier is allowed */ BOOL is_derived_class_constructor; BOOL in_function_body; BOOL backtrace_barrier; JSFunctionKindEnum func_kind : 8; JSParseFunctionEnum func_type : 8; uint8_t js_mode; /* bitmap of JS_MODE_x */ JSAtom func_name; /* JS_ATOM_NULL if no name */ JSVarDef *vars; int var_size; /* allocated size for vars[] */ int var_count; JSVarDef *args; int arg_size; /* allocated size for args[] */ int arg_count; /* number of arguments */ int defined_arg_count; int var_object_idx; /* -1 if none */ int arg_var_object_idx; /* -1 if none (var object for the argument scope) */ int arguments_var_idx; /* -1 if none */ int arguments_arg_idx; /* argument variable definition in argument scope, -1 if none */ int func_var_idx; /* variable containing the current function (-1 if none, only used if is_func_expr is true) */ int eval_ret_idx; /* variable containing the return value of the eval, -1 if none */ int this_var_idx; /* variable containg the 'this' value, -1 if none */ int new_target_var_idx; /* variable containg the 'new.target' value, -1 if none */ int this_active_func_var_idx; /* variable containg the 'this.active_func' value, -1 if none */ int home_object_var_idx; BOOL need_home_object; int scope_level; /* index into fd->scopes if the current lexical scope */ int scope_first; /* index into vd->vars of first lexically scoped variable */ int scope_size; /* allocated size of fd->scopes array */ int scope_count; /* number of entries used in the fd->scopes array */ JSVarScope *scopes; JSVarScope def_scope_array[4]; int body_scope; /* scope of the body of the function or eval */ int global_var_count; int global_var_size; JSGlobalVar *global_vars; DynBuf byte_code; int last_opcode_pos; /* -1 if no last opcode */ int last_opcode_line_num; BOOL use_short_opcodes; /* true if short opcodes are used in byte_code */ LabelSlot *label_slots; int label_size; /* allocated size for label_slots[] */ int label_count; BlockEnv *top_break; /* break/continue label stack */ /* constant pool (strings, functions, numbers) */ JSValue *cpool; int cpool_count; int cpool_size; /* list of variables in the closure */ int closure_var_count; int closure_var_size; JSClosureVar *closure_var; JumpSlot *jump_slots; int jump_size; int jump_count; LineNumberSlot *line_number_slots; int line_number_size; int line_number_count; int line_number_last; int line_number_last_pc; /* pc2line table */ JSAtom filename; int line_num; DynBuf pc2line; char *source; /* raw source, utf-8 encoded */ int source_len; JSModuleDef *module; /* != NULL when parsing a module */ BOOL has_await; /* TRUE if await is used (used in module eval) */ } JSFunctionDef; typedef struct JSToken { int val; int line_num; /* line number of token start */ const uint8_t *ptr; union { struct { JSValue str; int sep; } str; struct { JSValue val; #ifdef CONFIG_BIGNUM slimb_t exponent; /* may be != 0 only if val is a float */ #endif } num; struct { JSAtom atom; BOOL has_escape; BOOL is_reserved; } ident; struct { JSValue body; JSValue flags; } regexp; } u; } JSToken; typedef struct JSParseState { JSContext *ctx; int last_line_num; /* line number of last token */ int line_num; /* line number of current offset */ const char *filename; JSToken token; BOOL got_lf; /* true if got line feed before the current token */ const uint8_t *last_ptr; const uint8_t *buf_ptr; const uint8_t *buf_end; /* current function code */ JSFunctionDef *cur_func; BOOL is_module; /* parsing a module */ BOOL allow_html_comments; BOOL ext_json; /* true if accepting JSON superset */ } JSParseState; typedef struct JSOpCode { #ifdef DUMP_BYTECODE const char *name; #endif uint8_t size; /* in bytes */ /* the opcodes remove n_pop items from the top of the stack, then pushes n_push items */ uint8_t n_pop; uint8_t n_push; uint8_t fmt; } JSOpCode; static const JSOpCode opcode_info[OP_COUNT + (OP_TEMP_END - OP_TEMP_START)] = { #define FMT(f) #ifdef DUMP_BYTECODE #define DEF(id, size, n_pop, n_push, f) { #id, size, n_pop, n_push, OP_FMT_ ## f }, #else #define DEF(id, size, n_pop, n_push, f) { size, n_pop, n_push, OP_FMT_ ## f }, #endif #include "quickjs-opcode.h" #undef DEF #undef FMT }; #if SHORT_OPCODES /* After the final compilation pass, short opcodes are used. Their opcodes overlap with the temporary opcodes which cannot appear in the final bytecode. Their description is after the temporary opcodes in opcode_info[]. */ #define short_opcode_info(op) \ opcode_info[(op) >= OP_TEMP_START ? \ (op) + (OP_TEMP_END - OP_TEMP_START) : (op)] #else #define short_opcode_info(op) opcode_info[op] #endif static __exception int next_token(JSParseState *s); static void free_token(JSParseState *s, JSToken *token) { switch(token->val) { case TOK_NUMBER: JS_FreeValue(s->ctx, token->u.num.val); break; case TOK_STRING: case TOK_TEMPLATE: JS_FreeValue(s->ctx, token->u.str.str); break; case TOK_REGEXP: JS_FreeValue(s->ctx, token->u.regexp.body); JS_FreeValue(s->ctx, token->u.regexp.flags); break; case TOK_IDENT: case TOK_PRIVATE_NAME: JS_FreeAtom(s->ctx, token->u.ident.atom); break; default: if (token->val >= TOK_FIRST_KEYWORD && token->val <= TOK_LAST_KEYWORD) { JS_FreeAtom(s->ctx, token->u.ident.atom); } break; } } static void __attribute((unused)) dump_token(JSParseState *s, const JSToken *token) { switch(token->val) { case TOK_NUMBER: { double d; JS_ToFloat64(s->ctx, &d, token->u.num.val); /* no exception possible */ printf("number: %.14g\n", d); } break; case TOK_IDENT: dump_atom: { char buf[ATOM_GET_STR_BUF_SIZE]; printf("ident: '%s'\n", JS_AtomGetStr(s->ctx, buf, sizeof(buf), token->u.ident.atom)); } break; case TOK_STRING: { const char *str; /* XXX: quote the string */ str = JS_ToCString(s->ctx, token->u.str.str); printf("string: '%s'\n", str); JS_FreeCString(s->ctx, str); } break; case TOK_TEMPLATE: { const char *str; str = JS_ToCString(s->ctx, token->u.str.str); printf("template: `%s`\n", str); JS_FreeCString(s->ctx, str); } break; case TOK_REGEXP: { const char *str, *str2; str = JS_ToCString(s->ctx, token->u.regexp.body); str2 = JS_ToCString(s->ctx, token->u.regexp.flags); printf("regexp: '%s' '%s'\n", str, str2); JS_FreeCString(s->ctx, str); JS_FreeCString(s->ctx, str2); } break; case TOK_EOF: printf("eof\n"); break; default: if (s->token.val >= TOK_NULL && s->token.val <= TOK_LAST_KEYWORD) { goto dump_atom; } else if (s->token.val >= 256) { printf("token: %d\n", token->val); } else { printf("token: '%c'\n", token->val); } break; } } int __attribute__((format(printf, 2, 3))) js_parse_error(JSParseState *s, const char *fmt, ...) { JSContext *ctx = s->ctx; va_list ap; int backtrace_flags; va_start(ap, fmt); JS_ThrowError2(ctx, JS_SYNTAX_ERROR, fmt, ap, FALSE); va_end(ap); backtrace_flags = 0; if (s->cur_func && s->cur_func->backtrace_barrier) backtrace_flags = JS_BACKTRACE_FLAG_SINGLE_LEVEL; build_backtrace(ctx, ctx->rt->current_exception, s->filename, s->line_num, backtrace_flags); return -1; } static int js_parse_expect(JSParseState *s, int tok) { if (s->token.val != tok) { /* XXX: dump token correctly in all cases */ return js_parse_error(s, "expecting '%c'", tok); } return next_token(s); } static int js_parse_expect_semi(JSParseState *s) { if (s->token.val != ';') { /* automatic insertion of ';' */ if (s->token.val == TOK_EOF || s->token.val == '}' || s->got_lf) { return 0; } return js_parse_error(s, "expecting '%c'", ';'); } return next_token(s); } static int js_parse_error_reserved_identifier(JSParseState *s) { char buf1[ATOM_GET_STR_BUF_SIZE]; return js_parse_error(s, "'%s' is a reserved identifier", JS_AtomGetStr(s->ctx, buf1, sizeof(buf1), s->token.u.ident.atom)); } static __exception int js_parse_template_part(JSParseState *s, const uint8_t *p) { uint32_t c; StringBuffer b_s, *b = &b_s; /* p points to the first byte of the template part */ if (string_buffer_init(s->ctx, b, 32)) goto fail; for(;;) { if (p >= s->buf_end) goto unexpected_eof; c = *p++; if (c == '`') { /* template end part */ break; } if (c == '$' && *p == '{') { /* template start or middle part */ p++; break; } if (c == '\\') { if (string_buffer_putc8(b, c)) goto fail; if (p >= s->buf_end) goto unexpected_eof; c = *p++; } /* newline sequences are normalized as single '\n' bytes */ if (c == '\r') { if (*p == '\n') p++; c = '\n'; } if (c == '\n') { s->line_num++; } else if (c >= 0x80) { const uint8_t *p_next; c = unicode_from_utf8(p - 1, UTF8_CHAR_LEN_MAX, &p_next); if (c > 0x10FFFF) { js_parse_error(s, "invalid UTF-8 sequence"); goto fail; } p = p_next; } if (string_buffer_putc(b, c)) goto fail; } s->token.val = TOK_TEMPLATE; s->token.u.str.sep = c; s->token.u.str.str = string_buffer_end(b); s->buf_ptr = p; return 0; unexpected_eof: js_parse_error(s, "unexpected end of string"); fail: string_buffer_free(b); return -1; } static __exception int js_parse_string(JSParseState *s, int sep, BOOL do_throw, const uint8_t *p, JSToken *token, const uint8_t **pp) { int ret; uint32_t c; StringBuffer b_s, *b = &b_s; /* string */ if (string_buffer_init(s->ctx, b, 32)) goto fail; for(;;) { if (p >= s->buf_end) goto invalid_char; c = *p; if (c < 0x20) { if (!s->cur_func) { if (do_throw) js_parse_error(s, "invalid character in a JSON string"); goto fail; } if (sep == '`') { if (c == '\r') { if (p[1] == '\n') p++; c = '\n'; } /* do not update s->line_num */ } else if (c == '\n' || c == '\r') goto invalid_char; } p++; if (c == sep) break; if (c == '$' && *p == '{' && sep == '`') { /* template start or middle part */ p++; break; } if (c == '\\') { c = *p; /* XXX: need a specific JSON case to avoid accepting invalid escapes */ switch(c) { case '\0': if (p >= s->buf_end) goto invalid_char; p++; break; case '\'': case '\"': case '\\': p++; break; case '\r': /* accept DOS and MAC newline sequences */ if (p[1] == '\n') { p++; } /* fall thru */ case '\n': /* ignore escaped newline sequence */ p++; if (sep != '`') s->line_num++; continue; default: if (c >= '0' && c <= '9') { if (!s->cur_func) goto invalid_escape; /* JSON case */ if (!(s->cur_func->js_mode & JS_MODE_STRICT) && sep != '`') goto parse_escape; if (c == '0' && !(p[1] >= '0' && p[1] <= '9')) { p++; c = '\0'; } else { if (c >= '8' || sep == '`') { /* Note: according to ES2021, \8 and \9 are not accepted in strict mode or in templates. */ goto invalid_escape; } else { if (do_throw) js_parse_error(s, "octal escape sequences are not allowed in strict mode"); } goto fail; } } else if (c >= 0x80) { const uint8_t *p_next; c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p_next); if (c > 0x10FFFF) { goto invalid_utf8; } p = p_next; /* LS or PS are skipped */ if (c == CP_LS || c == CP_PS) continue; } else { parse_escape: ret = lre_parse_escape(&p, TRUE); if (ret == -1) { invalid_escape: if (do_throw) js_parse_error(s, "malformed escape sequence in string literal"); goto fail; } else if (ret < 0) { /* ignore the '\' (could output a warning) */ p++; } else { c = ret; } } break; } } else if (c >= 0x80) { const uint8_t *p_next; c = unicode_from_utf8(p - 1, UTF8_CHAR_LEN_MAX, &p_next); if (c > 0x10FFFF) goto invalid_utf8; p = p_next; } if (string_buffer_putc(b, c)) goto fail; } token->val = TOK_STRING; token->u.str.sep = c; token->u.str.str = string_buffer_end(b); *pp = p; return 0; invalid_utf8: if (do_throw) js_parse_error(s, "invalid UTF-8 sequence"); goto fail; invalid_char: if (do_throw) js_parse_error(s, "unexpected end of string"); fail: string_buffer_free(b); return -1; } static inline BOOL token_is_pseudo_keyword(JSParseState *s, JSAtom atom) { return s->token.val == TOK_IDENT && s->token.u.ident.atom == atom && !s->token.u.ident.has_escape; } static __exception int js_parse_regexp(JSParseState *s) { const uint8_t *p; BOOL in_class; StringBuffer b_s, *b = &b_s; StringBuffer b2_s, *b2 = &b2_s; uint32_t c; p = s->buf_ptr; p++; in_class = FALSE; if (string_buffer_init(s->ctx, b, 32)) return -1; if (string_buffer_init(s->ctx, b2, 1)) goto fail; for(;;) { if (p >= s->buf_end) { eof_error: js_parse_error(s, "unexpected end of regexp"); goto fail; } c = *p++; if (c == '\n' || c == '\r') { goto eol_error; } else if (c == '/') { if (!in_class) break; } else if (c == '[') { in_class = TRUE; } else if (c == ']') { /* XXX: incorrect as the first character in a class */ in_class = FALSE; } else if (c == '\\') { if (string_buffer_putc8(b, c)) goto fail; c = *p++; if (c == '\n' || c == '\r') goto eol_error; else if (c == '\0' && p >= s->buf_end) goto eof_error; else if (c >= 0x80) { const uint8_t *p_next; c = unicode_from_utf8(p - 1, UTF8_CHAR_LEN_MAX, &p_next); if (c > 0x10FFFF) { goto invalid_utf8; } p = p_next; if (c == CP_LS || c == CP_PS) goto eol_error; } } else if (c >= 0x80) { const uint8_t *p_next; c = unicode_from_utf8(p - 1, UTF8_CHAR_LEN_MAX, &p_next); if (c > 0x10FFFF) { invalid_utf8: js_parse_error(s, "invalid UTF-8 sequence"); goto fail; } p = p_next; /* LS or PS are considered as line terminator */ if (c == CP_LS || c == CP_PS) { eol_error: js_parse_error(s, "unexpected line terminator in regexp"); goto fail; } } if (string_buffer_putc(b, c)) goto fail; } /* flags */ for(;;) { const uint8_t *p_next = p; c = *p_next++; if (c >= 0x80) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p_next); if (c > 0x10FFFF) { goto invalid_utf8; } } if (!lre_js_is_ident_next(c)) break; if (string_buffer_putc(b2, c)) goto fail; p = p_next; } s->token.val = TOK_REGEXP; s->token.u.regexp.body = string_buffer_end(b); s->token.u.regexp.flags = string_buffer_end(b2); s->buf_ptr = p; return 0; fail: string_buffer_free(b); string_buffer_free(b2); return -1; } static __exception int ident_realloc(JSContext *ctx, char **pbuf, size_t *psize, char *static_buf) { char *buf, *new_buf; size_t size, new_size; buf = *pbuf; size = *psize; if (size >= (SIZE_MAX / 3) * 2) new_size = SIZE_MAX; else new_size = size + (size >> 1); if (buf == static_buf) { new_buf = js_malloc(ctx, new_size); if (!new_buf) return -1; memcpy(new_buf, buf, size); } else { new_buf = js_realloc(ctx, buf, new_size); if (!new_buf) return -1; } *pbuf = new_buf; *psize = new_size; return 0; } /* convert a TOK_IDENT to a keyword when needed */ static void update_token_ident(JSParseState *s) { if (s->token.u.ident.atom <= JS_ATOM_LAST_KEYWORD || (s->token.u.ident.atom <= JS_ATOM_LAST_STRICT_KEYWORD && (s->cur_func->js_mode & JS_MODE_STRICT)) || (s->token.u.ident.atom == JS_ATOM_yield && ((s->cur_func->func_kind & JS_FUNC_GENERATOR) || (s->cur_func->func_type == JS_PARSE_FUNC_ARROW && !s->cur_func->in_function_body && s->cur_func->parent && (s->cur_func->parent->func_kind & JS_FUNC_GENERATOR)))) || (s->token.u.ident.atom == JS_ATOM_await && (s->is_module || (s->cur_func->func_kind & JS_FUNC_ASYNC) || s->cur_func->func_type == JS_PARSE_FUNC_CLASS_STATIC_INIT || (s->cur_func->func_type == JS_PARSE_FUNC_ARROW && !s->cur_func->in_function_body && s->cur_func->parent && ((s->cur_func->parent->func_kind & JS_FUNC_ASYNC) || s->cur_func->parent->func_type == JS_PARSE_FUNC_CLASS_STATIC_INIT))))) { if (s->token.u.ident.has_escape) { s->token.u.ident.is_reserved = TRUE; s->token.val = TOK_IDENT; } else { /* The keywords atoms are pre allocated */ s->token.val = s->token.u.ident.atom - 1 + TOK_FIRST_KEYWORD; } } } /* if the current token is an identifier or keyword, reparse it according to the current function type */ static void reparse_ident_token(JSParseState *s) { if (s->token.val == TOK_IDENT || (s->token.val >= TOK_FIRST_KEYWORD && s->token.val <= TOK_LAST_KEYWORD)) { s->token.val = TOK_IDENT; s->token.u.ident.is_reserved = FALSE; update_token_ident(s); } } /* 'c' is the first character. Return JS_ATOM_NULL in case of error */ static JSAtom parse_ident(JSParseState *s, const uint8_t **pp, BOOL *pident_has_escape, int c, BOOL is_private) { const uint8_t *p, *p1; char ident_buf[128], *buf; size_t ident_size, ident_pos; JSAtom atom; p = *pp; buf = ident_buf; ident_size = sizeof(ident_buf); ident_pos = 0; if (is_private) buf[ident_pos++] = '#'; for(;;) { p1 = p; if (c < 128) { buf[ident_pos++] = c; } else { ident_pos += unicode_to_utf8((uint8_t*)buf + ident_pos, c); } c = *p1++; if (c == '\\' && *p1 == 'u') { c = lre_parse_escape(&p1, TRUE); *pident_has_escape = TRUE; } else if (c >= 128) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p1); } if (!lre_js_is_ident_next(c)) break; p = p1; if (unlikely(ident_pos >= ident_size - UTF8_CHAR_LEN_MAX)) { if (ident_realloc(s->ctx, &buf, &ident_size, ident_buf)) { atom = JS_ATOM_NULL; goto done; } } } atom = JS_NewAtomLen(s->ctx, buf, ident_pos); done: if (unlikely(buf != ident_buf)) js_free(s->ctx, buf); *pp = p; return atom; } static __exception int next_token(JSParseState *s) { const uint8_t *p; int c; BOOL ident_has_escape; JSAtom atom; if (js_check_stack_overflow(s->ctx->rt, 0)) { return js_parse_error(s, "stack overflow"); } free_token(s, &s->token); p = s->last_ptr = s->buf_ptr; s->got_lf = FALSE; s->last_line_num = s->token.line_num; redo: s->token.line_num = s->line_num; s->token.ptr = p; c = *p; switch(c) { case 0: if (p >= s->buf_end) { s->token.val = TOK_EOF; } else { goto def_token; } break; case '`': if (js_parse_template_part(s, p + 1)) goto fail; p = s->buf_ptr; break; case '\'': case '\"': if (js_parse_string(s, c, TRUE, p + 1, &s->token, &p)) goto fail; break; case '\r': /* accept DOS and MAC newline sequences */ if (p[1] == '\n') { p++; } /* fall thru */ case '\n': p++; line_terminator: s->got_lf = TRUE; s->line_num++; goto redo; case '\f': case '\v': case ' ': case '\t': p++; goto redo; case '/': if (p[1] == '*') { /* comment */ p += 2; for(;;) { if (*p == '\0' && p >= s->buf_end) { js_parse_error(s, "unexpected end of comment"); goto fail; } if (p[0] == '*' && p[1] == '/') { p += 2; break; } if (*p == '\n') { s->line_num++; s->got_lf = TRUE; /* considered as LF for ASI */ p++; } else if (*p == '\r') { s->got_lf = TRUE; /* considered as LF for ASI */ p++; } else if (*p >= 0x80) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p); if (c == CP_LS || c == CP_PS) { s->got_lf = TRUE; /* considered as LF for ASI */ } else if (c == -1) { p++; /* skip invalid UTF-8 */ } } else { p++; } } goto redo; } else if (p[1] == '/') { /* line comment */ p += 2; skip_line_comment: for(;;) { if (*p == '\0' && p >= s->buf_end) break; if (*p == '\r' || *p == '\n') break; if (*p >= 0x80) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p); /* LS or PS are considered as line terminator */ if (c == CP_LS || c == CP_PS) { break; } else if (c == -1) { p++; /* skip invalid UTF-8 */ } } else { p++; } } goto redo; } else if (p[1] == '=') { p += 2; s->token.val = TOK_DIV_ASSIGN; } else { p++; s->token.val = c; } break; case '\\': if (p[1] == 'u') { const uint8_t *p1 = p + 1; int c1 = lre_parse_escape(&p1, TRUE); if (c1 >= 0 && lre_js_is_ident_first(c1)) { c = c1; p = p1; ident_has_escape = TRUE; goto has_ident; } else { /* XXX: syntax error? */ } } goto def_token; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case '$': /* identifier */ p++; ident_has_escape = FALSE; has_ident: atom = parse_ident(s, &p, &ident_has_escape, c, FALSE); if (atom == JS_ATOM_NULL) goto fail; s->token.u.ident.atom = atom; s->token.u.ident.has_escape = ident_has_escape; s->token.u.ident.is_reserved = FALSE; s->token.val = TOK_IDENT; update_token_ident(s); break; case '#': /* private name */ { const uint8_t *p1; p++; p1 = p; c = *p1++; if (c == '\\' && *p1 == 'u') { c = lre_parse_escape(&p1, TRUE); } else if (c >= 128) { c = unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p1); } if (!lre_js_is_ident_first(c)) { js_parse_error(s, "invalid first character of private name"); goto fail; } p = p1; ident_has_escape = FALSE; /* not used */ atom = parse_ident(s, &p, &ident_has_escape, c, TRUE); if (atom == JS_ATOM_NULL) goto fail; s->token.u.ident.atom = atom; s->token.val = TOK_PRIVATE_NAME; } break; case '.': if (p[1] == '.' && p[2] == '.') { p += 3; s->token.val = TOK_ELLIPSIS; break; } if (p[1] >= '0' && p[1] <= '9') { goto parse_number; } else { goto def_token; } break; case '0': /* in strict mode, octal literals are not accepted */ if (is_digit(p[1]) && (s->cur_func->js_mode & JS_MODE_STRICT)) { js_parse_error(s, "octal literals are deprecated in strict mode"); goto fail; } goto parse_number; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* number */ parse_number: { JSValue ret; const uint8_t *p1; int flags, radix; flags = ATOD_ACCEPT_BIN_OCT | ATOD_ACCEPT_LEGACY_OCTAL | ATOD_ACCEPT_UNDERSCORES; flags |= ATOD_ACCEPT_SUFFIX; #ifdef CONFIG_BIGNUM if (s->cur_func->js_mode & JS_MODE_MATH) { flags |= ATOD_MODE_BIGINT; if (s->cur_func->js_mode & JS_MODE_MATH) flags |= ATOD_TYPE_BIG_FLOAT; } #endif radix = 0; #ifdef CONFIG_BIGNUM s->token.u.num.exponent = 0; ret = js_atof2(s->ctx, (const char *)p, (const char **)&p, radix, flags, &s->token.u.num.exponent); #else ret = js_atof(s->ctx, (const char *)p, (const char **)&p, radix, flags); #endif if (JS_IsException(ret)) goto fail; /* reject `10instanceof Number` */ if (JS_VALUE_IS_NAN(ret) || lre_js_is_ident_next(unicode_from_utf8(p, UTF8_CHAR_LEN_MAX, &p1))) { JS_FreeValue(s->ctx, ret); js_parse_error(s, "invalid number literal"); goto fail; } s->token.val = TOK_NUMBER; s->token.u.num.val = ret; } break; case '*': if (p[1] == '=') { p += 2; s->token.val = TOK_MUL_ASSIGN; } else if (p[1] == '*') { if (p[2] == '=') { p += 3; s->token.val = TOK_POW_ASSIGN; } else { p += 2; s->token.val = TOK_POW; } } else { goto def_token; } break; case '%': if (p[1] == '=') { p += 2; s->token.val = TOK_MOD_ASSIGN; } else { goto def_token; } break; case '+': if (p[1] == '=') { p += 2; s->token.val = TOK_PLUS_ASSIGN; } else if (p[1] == '+') { p += 2; s->token.val = TOK_INC; } else { goto def_token; } break; case '-': if (p[1] == '=') { p += 2; s->token.val = TOK_MINUS_ASSIGN; } else if (p[1] == '-') { if (s->allow_html_comments && p[2] == '>' && s->last_line_num != s->line_num) { /* Annex B: `-->` at beginning of line is an html comment end. It extends to the end of the line. */ goto skip_line_comment; } p += 2; s->token.val = TOK_DEC; } else { goto def_token; } break; case '<': if (p[1] == '=') { p += 2; s->token.val = TOK_LTE; } else if (p[1] == '<') { if (p[2] == '=') { p += 3; s->token.val = TOK_SHL_ASSIGN; } else { p += 2; s->token.val = TOK_SHL; } } else if (s->allow_html_comments && p[1] == '!' && p[2] == '-' && p[3] == '-') { /* Annex B: handle `