From 946ebe5cd77719b363053d82b9cf3c0f3f542037 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sat, 14 Jun 2025 18:04:27 -0500 Subject: [PATCH] remove date intrinsic --- source/quickjs.c | 1279 +--------------------------------------------- source/quickjs.h | 3 - 2 files changed, 1 insertion(+), 1281 deletions(-) diff --git a/source/quickjs.c b/source/quickjs.c index 01ab8aaa..d78fe3cb 100644 --- a/source/quickjs.c +++ b/source/quickjs.c @@ -127,7 +127,6 @@ enum { 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 */ @@ -1297,8 +1296,7 @@ static JSValue js_array_from_iterator(JSContext *ctx, uint32_t *plen, static int js_string_find_invalid_codepoint(JSString *p); static JSValue js_regexp_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv); -static JSValue get_date_string(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv, int magic); + static JSValue js_error_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv); @@ -1497,7 +1495,6 @@ static JSClassShortDef const js_std_class_def[] = { { 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 */ @@ -2124,7 +2121,6 @@ JSContext *JS_NewContext(JSRuntime *rt) return NULL; JS_AddIntrinsicBaseObjects(ctx); - JS_AddIntrinsicDate(ctx); JS_AddIntrinsicEval(ctx); JS_AddIntrinsicStringNormalize(ctx); JS_AddIntrinsicRegExp(ctx); @@ -5126,7 +5122,6 @@ static JSValue JS_NewObjectFromShape(JSContext *ctx, JSShape *sh, JSClassID clas case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: case JS_CLASS_SYMBOL: - case JS_CLASS_DATE: case JS_CLASS_BIG_INT: p->u.object_data = JS_UNDEFINED; goto set_exotic; @@ -5185,7 +5180,6 @@ static JSValue JS_GetObjectData(JSContext *ctx, JSValueConst obj) case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: case JS_CLASS_SYMBOL: - case JS_CLASS_DATE: case JS_CLASS_BIG_INT: return JS_DupValue(ctx, p->u.object_data); } @@ -5205,7 +5199,6 @@ static int JS_SetObjectData(JSContext *ctx, JSValueConst obj, JSValue val) case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: case JS_CLASS_SYMBOL: - case JS_CLASS_DATE: case JS_CLASS_BIG_INT: JS_FreeValue(ctx, p->u.object_data); p->u.object_data = val; /* for JS_CLASS_STRING, 'val' must @@ -6414,7 +6407,6 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s) 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 */ compute_value_size(p->u.object_data, hp); break; @@ -13363,13 +13355,6 @@ static void js_print_object(JSPrintValueState *s, JSObject *p) js_print_raw_string(s, str); JS_FreeValueRT(s->rt, str); comma_state = 2; - } else if (p->class_id == JS_CLASS_DATE && s->ctx && !s->options.raw_dump) { - JSValue str = get_date_string(s->ctx, JS_MKPTR(JS_TAG_OBJECT, p), 0, NULL, 0x23); /* toISOString() */ - if (JS_IsException(str)) - goto default_obj; - js_print_raw_string(s, str); - JS_FreeValueRT(s->rt, str); - comma_state = 2; } else if (p->class_id == JS_CLASS_ERROR && s->ctx && !s->options.raw_dump) { JSValue str = js_error_toString(s->ctx, JS_MKPTR(JS_TAG_OBJECT, p), 0, NULL); if (JS_IsException(str)) @@ -36009,7 +35994,6 @@ typedef enum BCTagEnum { BC_TAG_TYPED_ARRAY, BC_TAG_ARRAY_BUFFER, BC_TAG_SHARED_ARRAY_BUFFER, - BC_TAG_DATE, BC_TAG_OBJECT_VALUE, BC_TAG_OBJECT_REFERENCE, } BCTagEnum; @@ -36054,7 +36038,6 @@ static const char * const bc_tag_str[] = { "TypedArray", "ArrayBuffer", "SharedArrayBuffer", - "Date", "ObjectValue", "ObjectReference", }; @@ -36701,10 +36684,6 @@ static int JS_WriteObjectRec(BCWriterState *s, JSValueConst obj) goto invalid_tag; ret = JS_WriteSharedArrayBuffer(s, obj); break; - case JS_CLASS_DATE: - bc_put_u8(s, BC_TAG_DATE); - ret = JS_WriteObjectRec(s, p->u.object_data); - break; case JS_CLASS_NUMBER: case JS_CLASS_STRING: case JS_CLASS_BOOLEAN: @@ -37704,32 +37683,6 @@ static JSValue JS_ReadSharedArrayBuffer(BCReaderState *s) return JS_EXCEPTION; } -static JSValue JS_ReadDate(BCReaderState *s) -{ - JSContext *ctx = s->ctx; - JSValue val, obj = JS_UNDEFINED; - - val = JS_ReadObjectRec(s); - if (JS_IsException(val)) - goto fail; - if (!JS_IsNumber(val)) { - JS_ThrowTypeError(ctx, "Number tag expected for date"); - goto fail; - } - obj = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_DATE], - JS_CLASS_DATE); - if (JS_IsException(obj)) - goto fail; - if (BC_add_object_ref(s, obj)) - goto fail; - JS_SetObjectData(ctx, obj, val); - return obj; - fail: - JS_FreeValue(ctx, val); - JS_FreeValue(ctx, obj); - return JS_EXCEPTION; -} - static JSValue JS_ReadObjectValue(BCReaderState *s) { JSContext *ctx = s->ctx; @@ -37831,9 +37784,6 @@ static JSValue JS_ReadObjectRec(BCReaderState *s) goto invalid_tag; obj = JS_ReadSharedArrayBuffer(s); break; - case BC_TAG_DATE: - obj = JS_ReadDate(s); - break; case BC_TAG_OBJECT_VALUE: obj = JS_ReadObjectValue(s); break; @@ -38963,7 +38913,6 @@ static JSValue js_object_toString(JSContext *ctx, JSValueConst this_val, case JS_CLASS_ERROR: case JS_CLASS_BOOLEAN: case JS_CLASS_NUMBER: - case JS_CLASS_DATE: case JS_CLASS_REGEXP: atom = ctx->rt->class_array[p->class_id].class_name; break; @@ -44521,77 +44470,7 @@ static const JSCFunctionListEntry js_math_obj[] = { JS_OBJECT_DEF("Math", js_math_funcs, countof(js_math_funcs), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ), }; -/* Date */ - -/* OS dependent. d = argv[0] is in ms from 1970. Return the difference - between UTC time and local time 'd' in minutes */ -static int getTimezoneOffset(int64_t time) -{ - time_t ti; - int res; - - time /= 1000; /* convert to seconds */ - if (sizeof(time_t) == 4) { - /* on 32-bit systems, we need to clamp the time value to the - range of `time_t`. This is better than truncating values to - 32 bits and hopefully provides the same result as 64-bit - implementation of localtime_r. - */ - if ((time_t)-1 < 0) { - if (time < INT32_MIN) { - time = INT32_MIN; - } else if (time > INT32_MAX) { - time = INT32_MAX; - } - } else { - if (time < 0) { - time = 0; - } else if (time > UINT32_MAX) { - time = UINT32_MAX; - } - } - } - ti = time; -#if defined(_WIN32) - { - struct tm *tm; - time_t gm_ti, loc_ti; - - tm = gmtime(&ti); - if (!tm) - return 0; - gm_ti = mktime(tm); - - tm = localtime(&ti); - if (!tm) - return 0; - loc_ti = mktime(tm); - - res = (gm_ti - loc_ti) / 60; - } -#else - { - struct tm tm; - localtime_r(&ti, &tm); - res = -tm.tm_gmtoff / 60; - } -#endif - return res; -} - #if 0 -static JSValue js___date_getTimezoneOffset(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - double dd; - - if (JS_ToFloat64(ctx, &dd, argv[0])) - return JS_EXCEPTION; - if (isnan(dd)) - return __JS_NewFloat64(ctx, dd); - else - return JS_NewInt32(ctx, getTimezoneOffset((int64_t)dd)); -} static JSValue js_get_prototype_from_ctor(JSContext *ctx, JSValueConst ctor, JSValueConst def_proto) @@ -44607,20 +44486,6 @@ static JSValue js_get_prototype_from_ctor(JSContext *ctx, JSValueConst ctor, return proto; } -/* create a new date object */ -static JSValue js___date_create(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - JSValue obj, proto; - proto = js_get_prototype_from_ctor(ctx, argv[0], argv[1]); - if (JS_IsException(proto)) - return proto; - obj = JS_NewObjectProtoClass(ctx, proto, JS_CLASS_DATE); - JS_FreeValue(ctx, proto); - if (!JS_IsException(obj)) - JS_SetObjectData(ctx, obj, JS_DupValue(ctx, argv[2])); - return obj; -} #endif /* RegExp */ @@ -50874,1148 +50739,6 @@ static const JSCFunctionListEntry js_global_funcs[] = { JS_PROP_STRING_DEF("[Symbol.toStringTag]", "global", JS_PROP_CONFIGURABLE ), }; -/* Date */ - -static int64_t math_mod(int64_t a, int64_t b) { - /* return positive modulo */ - int64_t m = a % b; - return m + (m < 0) * b; -} - -static int64_t floor_div(int64_t a, int64_t b) { - /* integer division rounding toward -Infinity */ - int64_t m = a % b; - return (a - (m + (m < 0) * b)) / b; -} - -static JSValue js_Date_parse(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv); - -static __exception int JS_ThisTimeValue(JSContext *ctx, double *valp, JSValueConst this_val) -{ - if (JS_VALUE_GET_TAG(this_val) == JS_TAG_OBJECT) { - JSObject *p = JS_VALUE_GET_OBJ(this_val); - if (p->class_id == JS_CLASS_DATE && JS_IsNumber(p->u.object_data)) - return JS_ToFloat64(ctx, valp, p->u.object_data); - } - JS_ThrowTypeError(ctx, "not a Date object"); - return -1; -} - -static JSValue JS_SetThisTimeValue(JSContext *ctx, JSValueConst this_val, double v) -{ - if (JS_VALUE_GET_TAG(this_val) == JS_TAG_OBJECT) { - JSObject *p = JS_VALUE_GET_OBJ(this_val); - if (p->class_id == JS_CLASS_DATE) { - JS_FreeValue(ctx, p->u.object_data); - p->u.object_data = JS_NewFloat64(ctx, v); - return JS_DupValue(ctx, p->u.object_data); - } - } - return JS_ThrowTypeError(ctx, "not a Date object"); -} - -static int64_t days_from_year(int64_t y) { - return 365 * (y - 1970) + floor_div(y - 1969, 4) - - floor_div(y - 1901, 100) + floor_div(y - 1601, 400); -} - -static int64_t days_in_year(int64_t y) { - return 365 + !(y % 4) - !(y % 100) + !(y % 400); -} - -/* return the year, update days */ -static int64_t year_from_days(int64_t *days) { - int64_t y, d1, nd, d = *days; - y = floor_div(d * 10000, 3652425) + 1970; - /* the initial approximation is very good, so only a few - iterations are necessary */ - for(;;) { - d1 = d - days_from_year(y); - if (d1 < 0) { - y--; - d1 += days_in_year(y); - } else { - nd = days_in_year(y); - if (d1 < nd) - break; - d1 -= nd; - y++; - } - } - *days = d1; - return y; -} - -static int const month_days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -static char const month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; -static char const day_names[] = "SunMonTueWedThuFriSat"; - -static __exception int get_date_fields(JSContext *ctx, JSValueConst obj, - double fields[minimum_length(9)], int is_local, int force) -{ - double dval; - int64_t d, days, wd, y, i, md, h, m, s, ms, tz = 0; - - if (JS_ThisTimeValue(ctx, &dval, obj)) - return -1; - - if (isnan(dval)) { - if (!force) - return FALSE; /* NaN */ - d = 0; /* initialize all fields to 0 */ - } else { - d = dval; /* assuming -8.64e15 <= dval <= -8.64e15 */ - if (is_local) { - tz = -getTimezoneOffset(d); - d += tz * 60000; - } - } - - /* result is >= 0, we can use % */ - h = math_mod(d, 86400000); - days = (d - h) / 86400000; - ms = h % 1000; - h = (h - ms) / 1000; - s = h % 60; - h = (h - s) / 60; - m = h % 60; - h = (h - m) / 60; - wd = math_mod(days + 4, 7); /* week day */ - y = year_from_days(&days); - - for(i = 0; i < 11; i++) { - md = month_days[i]; - if (i == 1) - md += days_in_year(y) - 365; - if (days < md) - break; - days -= md; - } - fields[0] = y; - fields[1] = i; - fields[2] = days + 1; - fields[3] = h; - fields[4] = m; - fields[5] = s; - fields[6] = ms; - fields[7] = wd; - fields[8] = tz; - return TRUE; -} - -static double time_clip(double t) { - if (t >= -8.64e15 && t <= 8.64e15) - return trunc(t) + 0.0; /* convert -0 to +0 */ - else - return NAN; -} - -/* The spec mandates the use of 'double' and it specifies the order - of the operations */ -static double set_date_fields(double fields[minimum_length(7)], int is_local) { - double y, m, dt, ym, mn, day, h, s, milli, time, tv; - int yi, mi, i; - int64_t days; - volatile double temp; /* enforce evaluation order */ - - /* emulate 21.4.1.15 MakeDay ( year, month, date ) */ - y = fields[0]; - m = fields[1]; - dt = fields[2]; - ym = y + floor(m / 12); - mn = fmod(m, 12); - if (mn < 0) - mn += 12; - if (ym < -271821 || ym > 275760) - return NAN; - - yi = ym; - mi = mn; - days = days_from_year(yi); - for(i = 0; i < mi; i++) { - days += month_days[i]; - if (i == 1) - days += days_in_year(yi) - 365; - } - day = days + dt - 1; - - /* emulate 21.4.1.14 MakeTime ( hour, min, sec, ms ) */ - h = fields[3]; - m = fields[4]; - s = fields[5]; - milli = fields[6]; - /* Use a volatile intermediary variable to ensure order of evaluation - * as specified in ECMA. This fixes a test262 error on - * test262/test/built-ins/Date/UTC/fp-evaluation-order.js. - * Without the volatile qualifier, the compile can generate code - * that performs the computation in a different order or with instructions - * that produce a different result such as FMA (float multiply and add). - */ - time = h * 3600000; - time += (temp = m * 60000); - time += (temp = s * 1000); - time += milli; - - /* emulate 21.4.1.16 MakeDate ( day, time ) */ - tv = (temp = day * 86400000) + time; /* prevent generation of FMA */ - if (!isfinite(tv)) - return NAN; - - /* adjust for local time and clip */ - if (is_local) { - int64_t ti = tv < INT64_MIN ? INT64_MIN : tv >= 0x1p63 ? INT64_MAX : (int64_t)tv; - tv += getTimezoneOffset(ti) * 60000; - } - return time_clip(tv); -} - -static JSValue get_date_field(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv, int magic) -{ - // get_date_field(obj, n, is_local) - double fields[9]; - int res, n, is_local; - - is_local = magic & 0x0F; - n = (magic >> 4) & 0x0F; - res = get_date_fields(ctx, this_val, fields, is_local, 0); - if (res < 0) - return JS_EXCEPTION; - if (!res) - return JS_NAN; - - if (magic & 0x100) { // getYear - fields[0] -= 1900; - } - return JS_NewFloat64(ctx, fields[n]); -} - -static JSValue set_date_field(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv, int magic) -{ - // _field(obj, first_field, end_field, args, is_local) - double fields[9]; - int res, first_field, end_field, is_local, i, n, res1; - double d, a; - - d = NAN; - first_field = (magic >> 8) & 0x0F; - end_field = (magic >> 4) & 0x0F; - is_local = magic & 0x0F; - - res = get_date_fields(ctx, this_val, fields, is_local, first_field == 0); - if (res < 0) - return JS_EXCEPTION; - res1 = res; - - // Argument coercion is observable and must be done unconditionally. - n = min_int(argc, end_field - first_field); - for(i = 0; i < n; i++) { - if (JS_ToFloat64(ctx, &a, argv[i])) - return JS_EXCEPTION; - if (!isfinite(a)) - res = FALSE; - fields[first_field + i] = trunc(a); - } - - if (!res1) - return JS_NAN; /* thisTimeValue is NaN */ - - if (res && argc > 0) - d = set_date_fields(fields, is_local); - - return JS_SetThisTimeValue(ctx, this_val, d); -} - -/* fmt: - 0: toUTCString: "Tue, 02 Jan 2018 23:04:46 GMT" - 1: toString: "Wed Jan 03 2018 00:05:22 GMT+0100 (CET)" - 2: toISOString: "2018-01-02T23:02:56.927Z" - 3: toLocaleString: "1/2/2018, 11:40:40 PM" - part: 1=date, 2=time 3=all - XXX: should use a variant of strftime(). - */ -static JSValue get_date_string(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv, int magic) -{ - // _string(obj, fmt, part) - char buf[64]; - double fields[9]; - int res, fmt, part, pos; - int y, mon, d, h, m, s, ms, wd, tz; - - fmt = (magic >> 4) & 0x0F; - part = magic & 0x0F; - - res = get_date_fields(ctx, this_val, fields, fmt & 1, 0); - if (res < 0) - return JS_EXCEPTION; - if (!res) { - if (fmt == 2) - return JS_ThrowRangeError(ctx, "Date value is NaN"); - else - return js_new_string8(ctx, "Invalid Date"); - } - - y = fields[0]; - mon = fields[1]; - d = fields[2]; - h = fields[3]; - m = fields[4]; - s = fields[5]; - ms = fields[6]; - wd = fields[7]; - tz = fields[8]; - - pos = 0; - - if (part & 1) { /* date part */ - switch(fmt) { - case 0: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%.3s, %02d %.3s %0*d ", - day_names + wd * 3, d, - month_names + mon * 3, 4 + (y < 0), y); - break; - case 1: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%.3s %.3s %02d %0*d", - day_names + wd * 3, - month_names + mon * 3, d, 4 + (y < 0), y); - if (part == 3) { - buf[pos++] = ' '; - } - break; - case 2: - if (y >= 0 && y <= 9999) { - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%04d", y); - } else { - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%+07d", y); - } - pos += snprintf(buf + pos, sizeof(buf) - pos, - "-%02d-%02dT", mon + 1, d); - break; - case 3: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%02d/%02d/%0*d", mon + 1, d, 4 + (y < 0), y); - if (part == 3) { - buf[pos++] = ','; - buf[pos++] = ' '; - } - break; - } - } - if (part & 2) { /* time part */ - switch(fmt) { - case 0: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%02d:%02d:%02d GMT", h, m, s); - break; - case 1: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%02d:%02d:%02d GMT", h, m, s); - if (tz < 0) { - buf[pos++] = '-'; - tz = -tz; - } else { - buf[pos++] = '+'; - } - /* tz is >= 0, can use % */ - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%02d%02d", tz / 60, tz % 60); - /* XXX: tack the time zone code? */ - break; - case 2: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%02d:%02d:%02d.%03dZ", h, m, s, ms); - break; - case 3: - pos += snprintf(buf + pos, sizeof(buf) - pos, - "%02d:%02d:%02d %cM", (h + 11) % 12 + 1, m, s, - (h < 12) ? 'A' : 'P'); - break; - } - } - return JS_NewStringLen(ctx, buf, pos); -} - -/* OS dependent: return the UTC time in ms since 1970. */ -static int64_t date_now(void) { - struct timeval tv; - gettimeofday(&tv, NULL); - return (int64_t)tv.tv_sec * 1000 + (tv.tv_usec / 1000); -} - -static JSValue js_date_constructor(JSContext *ctx, JSValueConst new_target, - int argc, JSValueConst *argv) -{ - // Date(y, mon, d, h, m, s, ms) - JSValue rv; - int i, n; - double a, val; - - if (JS_IsUndefined(new_target)) { - /* invoked as function */ - argc = 0; - } - n = argc; - if (n == 0) { - val = date_now(); - } else if (n == 1) { - JSValue v, dv; - if (JS_VALUE_GET_TAG(argv[0]) == JS_TAG_OBJECT) { - JSObject *p = JS_VALUE_GET_OBJ(argv[0]); - if (p->class_id == JS_CLASS_DATE && JS_IsNumber(p->u.object_data)) { - if (JS_ToFloat64(ctx, &val, p->u.object_data)) - return JS_EXCEPTION; - val = time_clip(val); - goto has_val; - } - } - v = JS_ToPrimitive(ctx, argv[0], HINT_NONE); - if (JS_IsString(v)) { - dv = js_Date_parse(ctx, JS_UNDEFINED, 1, (JSValueConst *)&v); - JS_FreeValue(ctx, v); - if (JS_IsException(dv)) - return JS_EXCEPTION; - if (JS_ToFloat64Free(ctx, &val, dv)) - return JS_EXCEPTION; - } else { - if (JS_ToFloat64Free(ctx, &val, v)) - return JS_EXCEPTION; - } - val = time_clip(val); - } else { - double fields[] = { 0, 0, 1, 0, 0, 0, 0 }; - if (n > 7) - n = 7; - for(i = 0; i < n; i++) { - if (JS_ToFloat64(ctx, &a, argv[i])) - return JS_EXCEPTION; - if (!isfinite(a)) - break; - fields[i] = trunc(a); - if (i == 0 && fields[0] >= 0 && fields[0] < 100) - fields[0] += 1900; - } - val = (i == n) ? set_date_fields(fields, 1) : NAN; - } -has_val: -#if 0 - JSValueConst args[3]; - args[0] = new_target; - args[1] = ctx->class_proto[JS_CLASS_DATE]; - args[2] = JS_NewFloat64(ctx, val); - rv = js___date_create(ctx, JS_UNDEFINED, 3, args); -#else - rv = js_create_from_ctor(ctx, new_target, JS_CLASS_DATE); - if (!JS_IsException(rv)) - JS_SetObjectData(ctx, rv, JS_NewFloat64(ctx, val)); -#endif - if (!JS_IsException(rv) && JS_IsUndefined(new_target)) { - /* invoked as a function, return (new Date()).toString(); */ - JSValue s; - s = get_date_string(ctx, rv, 0, NULL, 0x13); - JS_FreeValue(ctx, rv); - rv = s; - } - return rv; -} - -static JSValue js_Date_UTC(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // UTC(y, mon, d, h, m, s, ms) - double fields[] = { 0, 0, 1, 0, 0, 0, 0 }; - int i, n; - double a; - - n = argc; - if (n == 0) - return JS_NAN; - if (n > 7) - n = 7; - for(i = 0; i < n; i++) { - if (JS_ToFloat64(ctx, &a, argv[i])) - return JS_EXCEPTION; - if (!isfinite(a)) - return JS_NAN; - fields[i] = trunc(a); - if (i == 0 && fields[0] >= 0 && fields[0] < 100) - fields[0] += 1900; - } - return JS_NewFloat64(ctx, set_date_fields(fields, 0)); -} - -/* Date string parsing */ - -static BOOL string_skip_char(const uint8_t *sp, int *pp, int c) { - if (sp[*pp] == c) { - *pp += 1; - return TRUE; - } else { - return FALSE; - } -} - -/* skip spaces, update offset, return next char */ -static int string_skip_spaces(const uint8_t *sp, int *pp) { - int c; - while ((c = sp[*pp]) == ' ') - *pp += 1; - return c; -} - -/* skip dashes dots and commas */ -static int string_skip_separators(const uint8_t *sp, int *pp) { - int c; - while ((c = sp[*pp]) == '-' || c == '/' || c == '.' || c == ',') - *pp += 1; - return c; -} - -/* skip a word, stop on spaces, digits and separators, update offset */ -static int string_skip_until(const uint8_t *sp, int *pp, const char *stoplist) { - int c; - while (!strchr(stoplist, c = sp[*pp])) - *pp += 1; - return c; -} - -/* parse a numeric field (max_digits = 0 -> no maximum) */ -static BOOL string_get_digits(const uint8_t *sp, int *pp, int *pval, - int min_digits, int max_digits) -{ - int v = 0; - int c, p = *pp, p_start; - - p_start = p; - while ((c = sp[p]) >= '0' && c <= '9') { - /* arbitrary limit to 9 digits */ - if (v >= 100000000) - return FALSE; - v = v * 10 + c - '0'; - p++; - if (p - p_start == max_digits) - break; - } - if (p - p_start < min_digits) - return FALSE; - *pval = v; - *pp = p; - return TRUE; -} - -static BOOL string_get_milliseconds(const uint8_t *sp, int *pp, int *pval) { - /* parse optional fractional part as milliseconds and truncate. */ - /* spec does not indicate which rounding should be used */ - int mul = 100, ms = 0, c, p_start, p = *pp; - - c = sp[p]; - if (c == '.' || c == ',') { - p++; - p_start = p; - while ((c = sp[p]) >= '0' && c <= '9') { - ms += (c - '0') * mul; - mul /= 10; - p++; - if (p - p_start == 9) - break; - } - if (p > p_start) { - /* only consume the separator if digits are present */ - *pval = ms; - *pp = p; - } - } - return TRUE; -} - -static uint8_t upper_ascii(uint8_t c) { - return c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c; -} - -static BOOL string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, BOOL strict) { - int tz = 0, sgn, hh, mm, p = *pp; - - sgn = sp[p++]; - if (sgn == '+' || sgn == '-') { - int n = p; - if (!string_get_digits(sp, &p, &hh, 1, 0)) - return FALSE; - n = p - n; - if (strict && n != 2 && n != 4) - return FALSE; - while (n > 4) { - n -= 2; - hh /= 100; - } - if (n > 2) { - mm = hh % 100; - hh = hh / 100; - } else { - mm = 0; - if (string_skip_char(sp, &p, ':') /* optional separator */ - && !string_get_digits(sp, &p, &mm, 2, 2)) - return FALSE; - } - if (hh > 23 || mm > 59) - return FALSE; - tz = hh * 60 + mm; - if (sgn != '+') - tz = -tz; - } else - if (sgn != 'Z') { - return FALSE; - } - *pp = p; - *tzp = tz; - return TRUE; -} - -static BOOL string_match(const uint8_t *sp, int *pp, const char *s) { - int p = *pp; - while (*s != '\0') { - if (upper_ascii(sp[p]) != upper_ascii(*s++)) - return FALSE; - p++; - } - *pp = p; - return TRUE; -} - -static int find_abbrev(const uint8_t *sp, int p, const char *list, int count) { - int n, i; - - for (n = 0; n < count; n++) { - for (i = 0;; i++) { - if (upper_ascii(sp[p + i]) != upper_ascii(list[n * 3 + i])) - break; - if (i == 2) - return n; - } - } - return -1; -} - -static BOOL string_get_month(const uint8_t *sp, int *pp, int *pval) { - int n; - - n = find_abbrev(sp, *pp, month_names, 12); - if (n < 0) - return FALSE; - - *pval = n + 1; - *pp += 3; - return TRUE; -} - -/* parse toISOString format */ -static BOOL js_date_parse_isostring(const uint8_t *sp, int fields[9], BOOL *is_local) { - int sgn, i, p = 0; - - /* initialize fields to the beginning of the Epoch */ - for (i = 0; i < 9; i++) { - fields[i] = (i == 2); - } - *is_local = FALSE; - - /* year is either yyyy digits or [+-]yyyyyy */ - sgn = sp[p]; - if (sgn == '-' || sgn == '+') { - p++; - if (!string_get_digits(sp, &p, &fields[0], 6, 6)) - return FALSE; - if (sgn == '-') { - if (fields[0] == 0) - return FALSE; // reject -000000 - fields[0] = -fields[0]; - } - } else { - if (!string_get_digits(sp, &p, &fields[0], 4, 4)) - return FALSE; - } - if (string_skip_char(sp, &p, '-')) { - if (!string_get_digits(sp, &p, &fields[1], 2, 2)) /* month */ - return FALSE; - if (fields[1] < 1) - return FALSE; - fields[1] -= 1; - if (string_skip_char(sp, &p, '-')) { - if (!string_get_digits(sp, &p, &fields[2], 2, 2)) /* day */ - return FALSE; - if (fields[2] < 1) - return FALSE; - } - } - if (string_skip_char(sp, &p, 'T')) { - *is_local = TRUE; - if (!string_get_digits(sp, &p, &fields[3], 2, 2) /* hour */ - || !string_skip_char(sp, &p, ':') - || !string_get_digits(sp, &p, &fields[4], 2, 2)) { /* minute */ - fields[3] = 100; // reject unconditionally - return TRUE; - } - if (string_skip_char(sp, &p, ':')) { - if (!string_get_digits(sp, &p, &fields[5], 2, 2)) /* second */ - return FALSE; - string_get_milliseconds(sp, &p, &fields[6]); - } - } - /* parse the time zone offset if present: [+-]HH:mm or [+-]HHmm */ - if (sp[p]) { - *is_local = FALSE; - if (!string_get_tzoffset(sp, &p, &fields[8], TRUE)) - return FALSE; - } - /* error if extraneous characters */ - return sp[p] == '\0'; -} - -static struct { - char name[6]; - int16_t offset; -} const js_tzabbr[] = { - { "GMT", 0 }, // Greenwich Mean Time - { "UTC", 0 }, // Coordinated Universal Time - { "UT", 0 }, // Universal Time - { "Z", 0 }, // Zulu Time - { "EDT", -4 * 60 }, // Eastern Daylight Time - { "EST", -5 * 60 }, // Eastern Standard Time - { "CDT", -5 * 60 }, // Central Daylight Time - { "CST", -6 * 60 }, // Central Standard Time - { "MDT", -6 * 60 }, // Mountain Daylight Time - { "MST", -7 * 60 }, // Mountain Standard Time - { "PDT", -7 * 60 }, // Pacific Daylight Time - { "PST", -8 * 60 }, // Pacific Standard Time - { "WET", +0 * 60 }, // Western European Time - { "WEST", +1 * 60 }, // Western European Summer Time - { "CET", +1 * 60 }, // Central European Time - { "CEST", +2 * 60 }, // Central European Summer Time - { "EET", +2 * 60 }, // Eastern European Time - { "EEST", +3 * 60 }, // Eastern European Summer Time -}; - -static BOOL string_get_tzabbr(const uint8_t *sp, int *pp, int *offset) { - for (size_t i = 0; i < countof(js_tzabbr); i++) { - if (string_match(sp, pp, js_tzabbr[i].name)) { - *offset = js_tzabbr[i].offset; - return TRUE; - } - } - return FALSE; -} - -/* parse toString, toUTCString and other formats */ -static BOOL js_date_parse_otherstring(const uint8_t *sp, - int fields[minimum_length(9)], - BOOL *is_local) { - int c, i, val, p = 0, p_start; - int num[3]; - BOOL has_year = FALSE; - BOOL has_mon = FALSE; - BOOL has_time = FALSE; - int num_index = 0; - - /* initialize fields to the beginning of 2001-01-01 */ - fields[0] = 2001; - fields[1] = 1; - fields[2] = 1; - for (i = 3; i < 9; i++) { - fields[i] = 0; - } - *is_local = TRUE; - - while (string_skip_spaces(sp, &p)) { - p_start = p; - if ((c = sp[p]) == '+' || c == '-') { - if (has_time && string_get_tzoffset(sp, &p, &fields[8], FALSE)) { - *is_local = FALSE; - } else { - p++; - if (string_get_digits(sp, &p, &val, 1, 0)) { - if (c == '-') { - if (val == 0) - return FALSE; - val = -val; - } - fields[0] = val; - has_year = TRUE; - } - } - } else - if (string_get_digits(sp, &p, &val, 1, 0)) { - if (string_skip_char(sp, &p, ':')) { - /* time part */ - fields[3] = val; - if (!string_get_digits(sp, &p, &fields[4], 1, 2)) - return FALSE; - if (string_skip_char(sp, &p, ':')) { - if (!string_get_digits(sp, &p, &fields[5], 1, 2)) - return FALSE; - string_get_milliseconds(sp, &p, &fields[6]); - } - has_time = TRUE; - } else { - if (p - p_start > 2) { - fields[0] = val; - has_year = TRUE; - } else - if (val < 1 || val > 31) { - fields[0] = val + (val < 100) * 1900 + (val < 50) * 100; - has_year = TRUE; - } else { - if (num_index == 3) - return FALSE; - num[num_index++] = val; - } - } - } else - if (string_get_month(sp, &p, &fields[1])) { - has_mon = TRUE; - string_skip_until(sp, &p, "0123456789 -/("); - } else - if (has_time && string_match(sp, &p, "PM")) { - if (fields[3] < 12) - fields[3] += 12; - continue; - } else - if (has_time && string_match(sp, &p, "AM")) { - if (fields[3] == 12) - fields[3] -= 12; - continue; - } else - if (string_get_tzabbr(sp, &p, &fields[8])) { - *is_local = FALSE; - continue; - } else - if (c == '(') { /* skip parenthesized phrase */ - int level = 0; - while ((c = sp[p]) != '\0') { - p++; - level += (c == '('); - level -= (c == ')'); - if (!level) - break; - } - if (level > 0) - return FALSE; - } else - if (c == ')') { - return FALSE; - } else { - if (has_year + has_mon + has_time + num_index) - return FALSE; - /* skip a word */ - string_skip_until(sp, &p, " -/("); - } - string_skip_separators(sp, &p); - } - if (num_index + has_year + has_mon > 3) - return FALSE; - - switch (num_index) { - case 0: - if (!has_year) - return FALSE; - break; - case 1: - if (has_mon) - fields[2] = num[0]; - else - fields[1] = num[0]; - break; - case 2: - if (has_year) { - fields[1] = num[0]; - fields[2] = num[1]; - } else - if (has_mon) { - fields[0] = num[1] + (num[1] < 100) * 1900 + (num[1] < 50) * 100; - fields[2] = num[0]; - } else { - fields[1] = num[0]; - fields[2] = num[1]; - } - break; - case 3: - fields[0] = num[2] + (num[2] < 100) * 1900 + (num[2] < 50) * 100; - fields[1] = num[0]; - fields[2] = num[1]; - break; - default: - return FALSE; - } - if (fields[1] < 1 || fields[2] < 1) - return FALSE; - fields[1] -= 1; - return TRUE; -} - -static JSValue js_Date_parse(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - JSValue s, rv; - int fields[9]; - double fields1[9]; - double d; - int i, c; - JSString *sp; - uint8_t buf[128]; - BOOL is_local; - - rv = JS_NAN; - - s = JS_ToString(ctx, argv[0]); - if (JS_IsException(s)) - return JS_EXCEPTION; - - sp = JS_VALUE_GET_STRING(s); - /* convert the string as a byte array */ - for (i = 0; i < sp->len && i < (int)countof(buf) - 1; i++) { - c = string_get(sp, i); - if (c > 255) - c = (c == 0x2212) ? '-' : 'x'; - buf[i] = c; - } - buf[i] = '\0'; - if (js_date_parse_isostring(buf, fields, &is_local) - || js_date_parse_otherstring(buf, fields, &is_local)) { - static int const field_max[6] = { 0, 11, 31, 24, 59, 59 }; - BOOL valid = TRUE; - /* check field maximum values */ - for (i = 1; i < 6; i++) { - if (fields[i] > field_max[i]) - valid = FALSE; - } - /* special case 24:00:00.000 */ - if (fields[3] == 24 && (fields[4] | fields[5] | fields[6])) - valid = FALSE; - if (valid) { - for(i = 0; i < 7; i++) - fields1[i] = fields[i]; - d = set_date_fields(fields1, is_local) - fields[8] * 60000; - rv = JS_NewFloat64(ctx, d); - } - } - JS_FreeValue(ctx, s); - return rv; -} - -static JSValue js_Date_now(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // now() - return JS_NewInt64(ctx, date_now()); -} - -static JSValue js_date_Symbol_toPrimitive(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // Symbol_toPrimitive(hint) - JSValueConst obj = this_val; - JSAtom hint = JS_ATOM_NULL; - int hint_num; - - if (!JS_IsObject(obj)) - return JS_ThrowTypeErrorNotAnObject(ctx); - - if (JS_IsString(argv[0])) { - hint = JS_ValueToAtom(ctx, argv[0]); - if (hint == JS_ATOM_NULL) - return JS_EXCEPTION; - JS_FreeAtom(ctx, hint); - } - switch (hint) { - case JS_ATOM_number: - case JS_ATOM_integer: - hint_num = HINT_NUMBER; - break; - case JS_ATOM_string: - case JS_ATOM_default: - hint_num = HINT_STRING; - break; - default: - return JS_ThrowTypeError(ctx, "invalid hint"); - } - return JS_ToPrimitive(ctx, obj, hint_num | HINT_FORCE_ORDINARY); -} - -static JSValue js_date_getTimezoneOffset(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // getTimezoneOffset() - double v; - - if (JS_ThisTimeValue(ctx, &v, this_val)) - return JS_EXCEPTION; - if (isnan(v)) - return JS_NAN; - else - /* assuming -8.64e15 <= v <= -8.64e15 */ - return JS_NewInt64(ctx, getTimezoneOffset((int64_t)trunc(v))); -} - -static JSValue js_date_getTime(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // getTime() - double v; - - if (JS_ThisTimeValue(ctx, &v, this_val)) - return JS_EXCEPTION; - return JS_NewFloat64(ctx, v); -} - -static JSValue js_date_setTime(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // setTime(v) - double v; - - if (JS_ThisTimeValue(ctx, &v, this_val) || JS_ToFloat64(ctx, &v, argv[0])) - return JS_EXCEPTION; - return JS_SetThisTimeValue(ctx, this_val, time_clip(v)); -} - -static JSValue js_date_setYear(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // setYear(y) - double y; - JSValueConst args[1]; - - if (JS_ThisTimeValue(ctx, &y, this_val) || JS_ToFloat64(ctx, &y, argv[0])) - return JS_EXCEPTION; - y = +y; - if (isfinite(y)) { - y = trunc(y); - if (y >= 0 && y < 100) - y += 1900; - } - args[0] = JS_NewFloat64(ctx, y); - return set_date_field(ctx, this_val, 1, args, 0x011); -} - -static JSValue js_date_toJSON(JSContext *ctx, JSValueConst this_val, - int argc, JSValueConst *argv) -{ - // toJSON(key) - JSValue obj, tv, method, rv; - double d; - - rv = JS_EXCEPTION; - tv = JS_UNDEFINED; - - obj = JS_ToObject(ctx, this_val); - tv = JS_ToPrimitive(ctx, obj, HINT_NUMBER); - if (JS_IsException(tv)) - goto exception; - if (JS_IsNumber(tv)) { - if (JS_ToFloat64(ctx, &d, tv) < 0) - goto exception; - if (!isfinite(d)) { - rv = JS_NULL; - goto done; - } - } - method = JS_GetPropertyStr(ctx, obj, "toISOString"); - if (JS_IsException(method)) - goto exception; - if (!JS_IsFunction(ctx, method)) { - JS_ThrowTypeError(ctx, "object needs toISOString method"); - JS_FreeValue(ctx, method); - goto exception; - } - rv = JS_CallFree(ctx, method, obj, 0, NULL); -exception: -done: - JS_FreeValue(ctx, obj); - JS_FreeValue(ctx, tv); - return rv; -} - -static const JSCFunctionListEntry js_date_funcs[] = { - JS_CFUNC_DEF("now", 0, js_Date_now ), - JS_CFUNC_DEF("parse", 1, js_Date_parse ), - JS_CFUNC_DEF("UTC", 7, js_Date_UTC ), -}; - -static const JSCFunctionListEntry js_date_proto_funcs[] = { - JS_CFUNC_DEF("valueOf", 0, js_date_getTime ), - JS_CFUNC_MAGIC_DEF("toString", 0, get_date_string, 0x13 ), - JS_CFUNC_DEF("[Symbol.toPrimitive]", 1, js_date_Symbol_toPrimitive ), - JS_CFUNC_MAGIC_DEF("toUTCString", 0, get_date_string, 0x03 ), - JS_ALIAS_DEF("toGMTString", "toUTCString" ), - JS_CFUNC_MAGIC_DEF("toISOString", 0, get_date_string, 0x23 ), - JS_CFUNC_MAGIC_DEF("toDateString", 0, get_date_string, 0x11 ), - JS_CFUNC_MAGIC_DEF("toTimeString", 0, get_date_string, 0x12 ), - JS_CFUNC_MAGIC_DEF("toLocaleString", 0, get_date_string, 0x33 ), - JS_CFUNC_MAGIC_DEF("toLocaleDateString", 0, get_date_string, 0x31 ), - JS_CFUNC_MAGIC_DEF("toLocaleTimeString", 0, get_date_string, 0x32 ), - JS_CFUNC_DEF("getTimezoneOffset", 0, js_date_getTimezoneOffset ), - JS_CFUNC_DEF("getTime", 0, js_date_getTime ), - JS_CFUNC_MAGIC_DEF("getYear", 0, get_date_field, 0x101 ), - JS_CFUNC_MAGIC_DEF("getFullYear", 0, get_date_field, 0x01 ), - JS_CFUNC_MAGIC_DEF("getUTCFullYear", 0, get_date_field, 0x00 ), - JS_CFUNC_MAGIC_DEF("getMonth", 0, get_date_field, 0x11 ), - JS_CFUNC_MAGIC_DEF("getUTCMonth", 0, get_date_field, 0x10 ), - JS_CFUNC_MAGIC_DEF("getDate", 0, get_date_field, 0x21 ), - JS_CFUNC_MAGIC_DEF("getUTCDate", 0, get_date_field, 0x20 ), - JS_CFUNC_MAGIC_DEF("getHours", 0, get_date_field, 0x31 ), - JS_CFUNC_MAGIC_DEF("getUTCHours", 0, get_date_field, 0x30 ), - JS_CFUNC_MAGIC_DEF("getMinutes", 0, get_date_field, 0x41 ), - JS_CFUNC_MAGIC_DEF("getUTCMinutes", 0, get_date_field, 0x40 ), - JS_CFUNC_MAGIC_DEF("getSeconds", 0, get_date_field, 0x51 ), - JS_CFUNC_MAGIC_DEF("getUTCSeconds", 0, get_date_field, 0x50 ), - JS_CFUNC_MAGIC_DEF("getMilliseconds", 0, get_date_field, 0x61 ), - JS_CFUNC_MAGIC_DEF("getUTCMilliseconds", 0, get_date_field, 0x60 ), - JS_CFUNC_MAGIC_DEF("getDay", 0, get_date_field, 0x71 ), - JS_CFUNC_MAGIC_DEF("getUTCDay", 0, get_date_field, 0x70 ), - JS_CFUNC_DEF("setTime", 1, js_date_setTime ), - JS_CFUNC_MAGIC_DEF("setMilliseconds", 1, set_date_field, 0x671 ), - JS_CFUNC_MAGIC_DEF("setUTCMilliseconds", 1, set_date_field, 0x670 ), - JS_CFUNC_MAGIC_DEF("setSeconds", 2, set_date_field, 0x571 ), - JS_CFUNC_MAGIC_DEF("setUTCSeconds", 2, set_date_field, 0x570 ), - JS_CFUNC_MAGIC_DEF("setMinutes", 3, set_date_field, 0x471 ), - JS_CFUNC_MAGIC_DEF("setUTCMinutes", 3, set_date_field, 0x470 ), - JS_CFUNC_MAGIC_DEF("setHours", 4, set_date_field, 0x371 ), - JS_CFUNC_MAGIC_DEF("setUTCHours", 4, set_date_field, 0x370 ), - JS_CFUNC_MAGIC_DEF("setDate", 1, set_date_field, 0x231 ), - JS_CFUNC_MAGIC_DEF("setUTCDate", 1, set_date_field, 0x230 ), - JS_CFUNC_MAGIC_DEF("setMonth", 2, set_date_field, 0x131 ), - JS_CFUNC_MAGIC_DEF("setUTCMonth", 2, set_date_field, 0x130 ), - JS_CFUNC_DEF("setYear", 1, js_date_setYear ), - JS_CFUNC_MAGIC_DEF("setFullYear", 3, set_date_field, 0x031 ), - JS_CFUNC_MAGIC_DEF("setUTCFullYear", 3, set_date_field, 0x030 ), - JS_CFUNC_DEF("toJSON", 1, js_date_toJSON ), -}; - -JSValue JS_NewDate(JSContext *ctx, double epoch_ms) -{ - JSValue obj = js_create_from_ctor(ctx, JS_UNDEFINED, JS_CLASS_DATE); - if (JS_IsException(obj)) - return JS_EXCEPTION; - JS_SetObjectData(ctx, obj, __JS_NewFloat64(ctx, time_clip(epoch_ms))); - return obj; -} - -void JS_AddIntrinsicDate(JSContext *ctx) -{ - JSValueConst obj; - - /* Date */ - ctx->class_proto[JS_CLASS_DATE] = JS_NewObject(ctx); - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_DATE], js_date_proto_funcs, - countof(js_date_proto_funcs)); - obj = JS_NewGlobalCConstructor(ctx, "Date", js_date_constructor, 7, - ctx->class_proto[JS_CLASS_DATE]); - JS_SetPropertyFunctionList(ctx, obj, js_date_funcs, countof(js_date_funcs)); -} - /* eval */ void JS_AddIntrinsicEval(JSContext *ctx) diff --git a/source/quickjs.h b/source/quickjs.h index eb6d25e9..7340d7dc 100644 --- a/source/quickjs.h +++ b/source/quickjs.h @@ -396,7 +396,6 @@ JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id); save memory */ JSContext *JS_NewContextRaw(JSRuntime *rt); void JS_AddIntrinsicBaseObjects(JSContext *ctx); -void JS_AddIntrinsicDate(JSContext *ctx); void JS_AddIntrinsicEval(JSContext *ctx); void JS_AddIntrinsicStringNormalize(JSContext *ctx); void JS_AddIntrinsicRegExpCompiler(JSContext *ctx); @@ -766,8 +765,6 @@ int JS_IsArray(JSContext *ctx, JSValueConst val); int JS_GetLength(JSContext *ctx, JSValueConst obj, int64_t *pres); int JS_SetLength(JSContext *ctx, JSValueConst obj, int64_t len); -JSValue JS_NewDate(JSContext *ctx, double epoch_ms); - JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj, JSAtom prop, JSValueConst receiver, JS_BOOL throw_ref_error);