remove unneeded object properties and if 0 code
This commit is contained in:
2
cell.md
2
cell.md
@@ -1,5 +1,7 @@
|
||||
JAVASCRIPT VISION
|
||||
|
||||
I see objects as being a sort of combination of a lisp cell and a record: symbols, which are used internally, and are private and non iterable, and record string values, which are iterable, readable, and writable; of course everything becomes locked in when stone.
|
||||
|
||||
CELLSCRIPT
|
||||
|
||||
Javascript to its core. Objects. What does the language need? It can be quite small, I think. The key is, ANYTHING that we want to be fast and JIT'd, must be present. So, record lookups. These are actually quicker in a jit'd language that have them as a feature. Most things should be libraries. Blobs need to be in the runtime.
|
||||
|
||||
385
source/quickjs.c
385
source/quickjs.c
@@ -884,7 +884,6 @@ static int js_string_compare(JSContext *ctx,
|
||||
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 JSValue JS_ToNumberFree(JSContext *ctx, JSValue val);
|
||||
static int JS_GetOwnPropertyInternal(JSContext *ctx, JSPropertyDescriptor *desc,
|
||||
JSObject *p, JSAtom prop);
|
||||
@@ -2104,9 +2103,6 @@ static JSAtom __JS_NewAtom(JSRuntime *rt, JSString *str, int atom_type)
|
||||
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) {
|
||||
@@ -2290,12 +2286,6 @@ static JSAtom __JS_FindAtom(JSRuntime *rt, const char *str, size_t len,
|
||||
|
||||
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;
|
||||
@@ -4537,25 +4527,6 @@ JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto_val,
|
||||
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:
|
||||
return JS_DupValue(ctx, p->u.object_data);
|
||||
}
|
||||
}
|
||||
return JS_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int JS_SetObjectData(JSContext *ctx, JSValueConst obj, JSValue val)
|
||||
{
|
||||
JSObject *p;
|
||||
@@ -7742,9 +7713,7 @@ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj,
|
||||
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) {
|
||||
@@ -9896,17 +9865,6 @@ static __exception int JS_ToLengthFree(JSContext *ctx, int64_t *plen,
|
||||
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 JSValue js_dtoa2(JSContext *ctx,
|
||||
double d, int radix, int n_digits, int flags)
|
||||
{
|
||||
@@ -14723,17 +14681,6 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
||||
}
|
||||
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_nop):
|
||||
BREAK;
|
||||
CASE(OP_is_null):
|
||||
@@ -23009,12 +22956,6 @@ static int skip_dead_code(JSFunctionDef *s, const uint8_t *bc_buf, int bc_len,
|
||||
label = get_u32(bc_buf + pos + 1);
|
||||
if (update_label(s, label, 0) > 0)
|
||||
break;
|
||||
#if 0
|
||||
if (s->label_slots[label].first_reloc) {
|
||||
printf("line %d: unreferenced label %d:%d has relocations\n",
|
||||
*linep, label, s->label_slots[label].pos2);
|
||||
}
|
||||
#endif
|
||||
assert(s->label_slots[label].first_reloc == NULL);
|
||||
} else {
|
||||
/* XXX: output a warning for unreachable code? */
|
||||
@@ -24917,13 +24858,6 @@ static void free_function_bytecode(JSRuntime *rt, JSFunctionBytecode *b)
|
||||
{
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
{
|
||||
char buf[ATOM_GET_STR_BUF_SIZE];
|
||||
printf("freeing %s\n",
|
||||
JS_AtomGetStrRT(rt, buf, sizeof(buf), b->func_name));
|
||||
}
|
||||
#endif
|
||||
free_bytecode_atoms(rt, b->byte_code_buf, b->byte_code_len, TRUE);
|
||||
|
||||
if (b->vardefs) {
|
||||
@@ -28478,39 +28412,6 @@ static JSValue js_object_fromEntries(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Note: corresponds to ECMA spec: CreateDataPropertyOrThrow() */
|
||||
static JSValue js_object___setOwnProperty(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
int ret;
|
||||
ret = JS_DefinePropertyValueValue(ctx, argv[0], JS_DupValue(ctx, argv[1]),
|
||||
JS_DupValue(ctx, argv[2]),
|
||||
JS_PROP_C_W_E | JS_PROP_THROW);
|
||||
if (ret < 0)
|
||||
return JS_EXCEPTION;
|
||||
else
|
||||
return JS_NewBool(ctx, ret);
|
||||
}
|
||||
|
||||
static JSValue js_object___toObject(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_ToObject(ctx, argv[0]);
|
||||
}
|
||||
|
||||
static JSValue js_object___toPrimitive(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
int hint = HINT_NONE;
|
||||
|
||||
if (JS_VALUE_GET_TAG(argv[1]) == JS_TAG_INT)
|
||||
hint = JS_VALUE_GET_INT(argv[1]);
|
||||
|
||||
return JS_ToPrimitive(ctx, argv[0], hint);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* return an empty string if not an object */
|
||||
static JSValue js_object___getClass(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
@@ -28539,46 +28440,6 @@ static JSValue js_object_is(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_NewBool(ctx, js_same_value(ctx, argv[0], argv[1]));
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_object___getObjectData(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_GetObjectData(ctx, argv[0]);
|
||||
}
|
||||
|
||||
static JSValue js_object___setObjectData(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
if (JS_SetObjectData(ctx, argv[0], JS_DupValue(ctx, argv[1])))
|
||||
return JS_EXCEPTION;
|
||||
return JS_DupValue(ctx, argv[1]);
|
||||
}
|
||||
|
||||
static JSValue js_object___toPropertyKey(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_ToPropertyKey(ctx, argv[0]);
|
||||
}
|
||||
|
||||
static JSValue js_object___isObject(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_NewBool(ctx, JS_IsObject(argv[0]));
|
||||
}
|
||||
|
||||
static JSValue js_object___isSameValueZero(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_NewBool(ctx, js_same_value_zero(ctx, argv[0], argv[1]));
|
||||
}
|
||||
|
||||
static JSValue js_object___isConstructor(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_NewBool(ctx, JS_IsConstructor(ctx, argv[0]));
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue JS_SpeciesConstructor(JSContext *ctx, JSValueConst obj,
|
||||
JSValueConst defaultConstructor)
|
||||
{
|
||||
@@ -28608,14 +28469,6 @@ static JSValue JS_SpeciesConstructor(JSContext *ctx, JSValueConst obj,
|
||||
return species;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_object___speciesConstructor(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_SpeciesConstructor(ctx, argv[0], argv[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue js_object_get___proto__(JSContext *ctx, JSValueConst this_val)
|
||||
{
|
||||
JSValue val, ret;
|
||||
@@ -28780,16 +28633,6 @@ static const JSCFunctionListEntry js_object_funcs[] = {
|
||||
JS_CFUNC_MAGIC_DEF("isSealed", 1, js_object_isSealed, 0 ),
|
||||
JS_CFUNC_MAGIC_DEF("isFrozen", 1, js_object_isSealed, 1 ),
|
||||
JS_CFUNC_DEF("__getClass", 1, js_object___getClass ),
|
||||
//JS_CFUNC_DEF("__isObject", 1, js_object___isObject ),
|
||||
//JS_CFUNC_DEF("__isConstructor", 1, js_object___isConstructor ),
|
||||
//JS_CFUNC_DEF("__toObject", 1, js_object___toObject ),
|
||||
//JS_CFUNC_DEF("__setOwnProperty", 3, js_object___setOwnProperty ),
|
||||
//JS_CFUNC_DEF("__toPrimitive", 2, js_object___toPrimitive ),
|
||||
//JS_CFUNC_DEF("__toPropertyKey", 1, js_object___toPropertyKey ),
|
||||
//JS_CFUNC_DEF("__speciesConstructor", 2, js_object___speciesConstructor ),
|
||||
//JS_CFUNC_DEF("__isSameValueZero", 2, js_object___isSameValueZero ),
|
||||
//JS_CFUNC_DEF("__getObjectData", 1, js_object___getObjectData ),
|
||||
//JS_CFUNC_DEF("__setObjectData", 2, js_object___setObjectData ),
|
||||
JS_CFUNC_DEF("fromEntries", 1, js_object_fromEntries ),
|
||||
JS_CFUNC_DEF("hasOwn", 2, js_object_hasOwn ),
|
||||
};
|
||||
@@ -31291,23 +31134,6 @@ static JSValue js_number_constructor(JSContext *ctx, JSValueConst new_target,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_number___toInteger(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_ToIntegerFree(ctx, JS_DupValue(ctx, argv[0]));
|
||||
}
|
||||
|
||||
static JSValue js_number___toLength(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
int64_t v;
|
||||
if (JS_ToLengthFree(ctx, &v, JS_DupValue(ctx, argv[0])))
|
||||
return JS_EXCEPTION;
|
||||
return JS_NewInt64(ctx, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue js_number_isNaN(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
@@ -31324,46 +31150,13 @@ static JSValue js_number_isFinite(JSContext *ctx, JSValueConst this_val,
|
||||
return js_global_isFinite(ctx, this_val, argc, argv);
|
||||
}
|
||||
|
||||
static JSValue js_number_isInteger(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
int ret;
|
||||
ret = JS_NumberIsInteger(ctx, argv[0]);
|
||||
if (ret < 0)
|
||||
return JS_EXCEPTION;
|
||||
else
|
||||
return JS_NewBool(ctx, ret);
|
||||
}
|
||||
|
||||
static JSValue js_number_isSafeInteger(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
double d;
|
||||
if (!JS_IsNumber(argv[0]))
|
||||
return JS_FALSE;
|
||||
if (unlikely(JS_ToFloat64(ctx, &d, argv[0])))
|
||||
return JS_EXCEPTION;
|
||||
return JS_NewBool(ctx, is_safe_integer(d));
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_number_funcs[] = {
|
||||
/* global ParseInt and parseFloat should be defined already or delayed */
|
||||
JS_ALIAS_BASE_DEF("parseInt", "parseInt", 0 ),
|
||||
JS_ALIAS_BASE_DEF("parseFloat", "parseFloat", 0 ),
|
||||
JS_CFUNC_DEF("isNaN", 1, js_number_isNaN ),
|
||||
JS_CFUNC_DEF("isFinite", 1, js_number_isFinite ),
|
||||
JS_CFUNC_DEF("isInteger", 1, js_number_isInteger ),
|
||||
JS_CFUNC_DEF("isSafeInteger", 1, js_number_isSafeInteger ),
|
||||
JS_PROP_DOUBLE_DEF("MAX_VALUE", 1.7976931348623157e+308, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("MIN_VALUE", 5e-324, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("NaN", NAN, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("NEGATIVE_INFINITY", -INFINITY, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("POSITIVE_INFINITY", INFINITY, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("EPSILON", 2.220446049250313e-16, 0 ), /* ES6 */
|
||||
JS_PROP_DOUBLE_DEF("MAX_SAFE_INTEGER", 9007199254740991.0, 0 ), /* ES6 */
|
||||
JS_PROP_DOUBLE_DEF("MIN_SAFE_INTEGER", -9007199254740991.0, 0 ), /* ES6 */
|
||||
//JS_CFUNC_DEF("__toInteger", 1, js_number___toInteger ),
|
||||
//JS_CFUNC_DEF("__toLength", 1, js_number___toLength ),
|
||||
};
|
||||
|
||||
static JSValue js_thisNumberValue(JSContext *ctx, JSValueConst this_val)
|
||||
@@ -31871,17 +31664,6 @@ JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
|
||||
return string_buffer_end(b);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_string___isSpace(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
int c;
|
||||
if (JS_ToInt32(ctx, &c, argv[0]))
|
||||
return JS_EXCEPTION;
|
||||
return JS_NewBool(ctx, lre_is_space(c));
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue js_string_charCodeAt(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
@@ -33165,47 +32947,6 @@ static JSValue js_string_toString(JSContext *ctx, JSValueConst this_val,
|
||||
return js_thisStringValue(ctx, this_val);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_string___toStringCheckObject(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_ToStringCheckObject(ctx, argv[0]);
|
||||
}
|
||||
|
||||
static JSValue js_string___toString(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_ToString(ctx, argv[0]);
|
||||
}
|
||||
|
||||
static JSValue js_string___advanceStringIndex(JSContext *ctx, JSValueConst
|
||||
this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
JSValue str;
|
||||
int idx;
|
||||
BOOL is_unicode;
|
||||
JSString *p;
|
||||
|
||||
str = JS_ToString(ctx, argv[0]);
|
||||
if (JS_IsException(str))
|
||||
return str;
|
||||
if (JS_ToInt32Sat(ctx, &idx, argv[1])) {
|
||||
JS_FreeValue(ctx, str);
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
is_unicode = JS_ToBool(ctx, argv[2]);
|
||||
p = JS_VALUE_GET_STRING(str);
|
||||
if (!is_unicode || (unsigned)idx >= p->len || !p->is_wide_char) {
|
||||
idx++;
|
||||
} else {
|
||||
string_getc(p, &idx);
|
||||
}
|
||||
JS_FreeValue(ctx, str);
|
||||
return JS_NewInt32(ctx, idx);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* String Iterator */
|
||||
|
||||
static JSValue js_string_iterator_next(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -33265,11 +33006,6 @@ static const JSCFunctionListEntry js_string_funcs[] = {
|
||||
JS_CFUNC_DEF("fromCharCode", 1, js_string_fromCharCode ),
|
||||
JS_CFUNC_DEF("fromCodePoint", 1, js_string_fromCodePoint ),
|
||||
JS_CFUNC_DEF("raw", 1, js_string_raw ),
|
||||
//JS_CFUNC_DEF("__toString", 1, js_string___toString ),
|
||||
//JS_CFUNC_DEF("__isSpace", 1, js_string___isSpace ),
|
||||
//JS_CFUNC_DEF("__toStringCheckObject", 1, js_string___toStringCheckObject ),
|
||||
//JS_CFUNC_DEF("__advanceStringIndex", 3, js_string___advanceStringIndex ),
|
||||
//JS_CFUNC_DEF("__GetSubstitution", 6, js_string___GetSubstitution ),
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry js_string_proto_funcs[] = {
|
||||
@@ -33308,8 +33044,6 @@ static const JSCFunctionListEntry js_string_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("__quote", 1, js_string___quote ),
|
||||
JS_CFUNC_MAGIC_DEF("toLowerCase", 0, js_string_toLowerCase, 1 ),
|
||||
JS_CFUNC_MAGIC_DEF("toUpperCase", 0, js_string_toLowerCase, 0 ),
|
||||
// JS_CFUNC_MAGIC_DEF("toLocaleLowerCase", 0, js_string_toLowerCase, 1 ),
|
||||
// JS_CFUNC_MAGIC_DEF("toLocaleUpperCase", 0, js_string_toLowerCase, 0 ),
|
||||
JS_CFUNC_MAGIC_DEF("[Symbol.iterator]", 0, js_create_array_iterator, JS_ITERATOR_KIND_VALUE | 4 ),
|
||||
};
|
||||
|
||||
@@ -33476,45 +33210,6 @@ static JSValue js_math_hypot(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_NewFloat64(ctx, r);
|
||||
}
|
||||
|
||||
static double js_math_f16round(double a)
|
||||
{
|
||||
return fromfp16(tofp16(a));
|
||||
}
|
||||
|
||||
static double js_math_fround(double a)
|
||||
{
|
||||
return (float)a;
|
||||
}
|
||||
|
||||
static JSValue js_math_imul(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
uint32_t a, b, c;
|
||||
int32_t d;
|
||||
|
||||
if (JS_ToUint32(ctx, &a, argv[0]))
|
||||
return JS_EXCEPTION;
|
||||
if (JS_ToUint32(ctx, &b, argv[1]))
|
||||
return JS_EXCEPTION;
|
||||
c = a * b;
|
||||
memcpy(&d, &c, sizeof(d));
|
||||
return JS_NewInt32(ctx, d);
|
||||
}
|
||||
|
||||
static JSValue js_math_clz32(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
uint32_t a, r;
|
||||
|
||||
if (JS_ToUint32(ctx, &a, argv[0]))
|
||||
return JS_EXCEPTION;
|
||||
if (a == 0)
|
||||
r = 32;
|
||||
else
|
||||
r = clz32(a);
|
||||
return JS_NewInt32(ctx, r);
|
||||
}
|
||||
|
||||
/* xorshift* random number generator by Marsaglia */
|
||||
static uint64_t xorshift64star(uint64_t *pstate)
|
||||
{
|
||||
@@ -33581,46 +33276,17 @@ static const JSCFunctionListEntry js_math_funcs[] = {
|
||||
JS_CFUNC_SPECIAL_DEF("log1p", 1, f_f, log1p ),
|
||||
JS_CFUNC_SPECIAL_DEF("log2", 1, f_f, log2 ),
|
||||
JS_CFUNC_SPECIAL_DEF("log10", 1, f_f, log10 ),
|
||||
JS_CFUNC_SPECIAL_DEF("cbrt", 1, f_f, cbrt ),
|
||||
JS_CFUNC_DEF("hypot", 2, js_math_hypot ),
|
||||
JS_CFUNC_DEF("random", 0, js_math_random ),
|
||||
JS_CFUNC_SPECIAL_DEF("f16round", 1, f_f, js_math_f16round ),
|
||||
JS_CFUNC_SPECIAL_DEF("fround", 1, f_f, js_math_fround ),
|
||||
JS_CFUNC_DEF("imul", 2, js_math_imul ),
|
||||
JS_CFUNC_DEF("clz32", 1, js_math_clz32 ),
|
||||
JS_PROP_STRING_DEF("[Symbol.toStringTag]", "Math", JS_PROP_CONFIGURABLE ),
|
||||
JS_PROP_DOUBLE_DEF("E", 2.718281828459045, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("LN10", 2.302585092994046, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("LN2", 0.6931471805599453, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("LOG2E", 1.4426950408889634, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("LOG10E", 0.4342944819032518, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("PI", 3.141592653589793, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("SQRT1_2", 0.7071067811865476, 0 ),
|
||||
JS_PROP_DOUBLE_DEF("SQRT2", 1.4142135623730951, 0 ),
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry js_math_obj[] = {
|
||||
JS_OBJECT_DEF("Math", js_math_funcs, countof(js_math_funcs), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
static JSValue js_get_prototype_from_ctor(JSContext *ctx, JSValueConst ctor,
|
||||
JSValueConst def_proto)
|
||||
{
|
||||
JSValue proto;
|
||||
proto = JS_GetProperty(ctx, ctor, JS_ATOM_prototype);
|
||||
if (JS_IsException(proto))
|
||||
return proto;
|
||||
if (!JS_IsObject(proto)) {
|
||||
JS_FreeValue(ctx, proto);
|
||||
proto = JS_DupValue(ctx, def_proto);
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* RegExp */
|
||||
|
||||
static void js_regexp_finalizer(JSRuntime *rt, JSValue val)
|
||||
@@ -33891,27 +33557,6 @@ static JSValue js_regexp_compile(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_regexp_get___source(JSContext *ctx, JSValueConst this_val)
|
||||
{
|
||||
JSRegExp *re = js_get_regexp(ctx, this_val, TRUE);
|
||||
if (!re)
|
||||
return JS_EXCEPTION;
|
||||
return JS_DupValue(ctx, JS_MKPTR(JS_TAG_STRING, re->pattern));
|
||||
}
|
||||
|
||||
static JSValue js_regexp_get___flags(JSContext *ctx, JSValueConst this_val)
|
||||
{
|
||||
JSRegExp *re = js_get_regexp(ctx, this_val, TRUE);
|
||||
int flags;
|
||||
|
||||
if (!re)
|
||||
return JS_EXCEPTION;
|
||||
flags = lre_get_flags(re->bytecode->u.str8);
|
||||
return JS_NewInt32(ctx, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue js_regexp_get_source(JSContext *ctx, JSValueConst this_val)
|
||||
{
|
||||
JSRegExp *re;
|
||||
@@ -34455,19 +34100,6 @@ static JSValue JS_RegExpExec(JSContext *ctx, JSValueConst r, JSValueConst s)
|
||||
return js_regexp_exec(ctx, r, 1, &s);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static JSValue js_regexp___RegExpExec(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_RegExpExec(ctx, argv[0], argv[1]);
|
||||
}
|
||||
static JSValue js_regexp___RegExpDelete(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
return JS_RegExpDelete(ctx, argv[0], argv[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue js_regexp_test(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
@@ -35177,8 +34809,6 @@ done:
|
||||
static const JSCFunctionListEntry js_regexp_funcs[] = {
|
||||
JS_CFUNC_DEF("escape", 1, js_regexp_escape ),
|
||||
JS_CGETSET_DEF("[Symbol.species]", js_get_this, NULL ),
|
||||
//JS_CFUNC_DEF("__RegExpExec", 2, js_regexp___RegExpExec ),
|
||||
//JS_CFUNC_DEF("__RegExpDelete", 2, js_regexp___RegExpDelete ),
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry js_regexp_proto_funcs[] = {
|
||||
@@ -35201,8 +34831,6 @@ static const JSCFunctionListEntry js_regexp_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("[Symbol.matchAll]", 1, js_regexp_Symbol_matchAll ),
|
||||
JS_CFUNC_DEF("[Symbol.search]", 1, js_regexp_Symbol_search ),
|
||||
JS_CFUNC_DEF("[Symbol.split]", 2, js_regexp_Symbol_split ),
|
||||
//JS_CGETSET_DEF("__source", js_regexp_get___source, NULL ),
|
||||
//JS_CGETSET_DEF("__flags", js_regexp_get___flags, NULL ),
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry js_regexp_string_iterator_proto_funcs[] = {
|
||||
@@ -38144,16 +37772,7 @@ static void JS_AddIntrinsicBasicObjects(JSContext *ctx)
|
||||
ctx->class_proto[JS_CLASS_OBJECT]);
|
||||
ctx->class_proto[JS_CLASS_BYTECODE_FUNCTION] = JS_DupValue(ctx, ctx->function_proto);
|
||||
ctx->class_proto[JS_CLASS_ERROR] = JS_NewObject(ctx);
|
||||
#if 0
|
||||
/* these are auto-initialized from js_error_proto_funcs,
|
||||
but delaying might be a problem */
|
||||
JS_DefinePropertyValue(ctx, ctx->class_proto[JS_CLASS_ERROR], JS_ATOM_name,
|
||||
JS_AtomToString(ctx, JS_ATOM_Error),
|
||||
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||
JS_DefinePropertyValue(ctx, ctx->class_proto[JS_CLASS_ERROR], JS_ATOM_message,
|
||||
JS_AtomToString(ctx, JS_ATOM_empty_string),
|
||||
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||
#endif
|
||||
|
||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ERROR],
|
||||
js_error_proto_funcs,
|
||||
countof(js_error_proto_funcs));
|
||||
|
||||
Reference in New Issue
Block a user