@mikrojs/quickjs 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  #undef NDEBUG
3
3
  #endif
4
4
  #include <assert.h>
5
+ #include <stdio.h>
5
6
  #include <stdlib.h>
6
7
  #include <string.h>
7
8
  #include "quickjs.h"
@@ -928,6 +929,59 @@ static void new_errors(void)
928
929
  JS_FreeRuntime(rt);
929
930
  }
930
931
 
932
+ // JS_NewContext() already installs DOMException by way of
933
+ // JS_AddIntrinsicAToB(), so a host that also calls JS_AddIntrinsicDOMException()
934
+ // explicitly installs it twice. The second install must release the prototype
935
+ // the first one left in ctx->class_proto[] instead of overwriting the slot;
936
+ // new_runtime() aborts at JS_FreeRuntime() if it does not.
937
+ static void dom_exception_added_twice(void)
938
+ {
939
+ JSValue ret;
940
+ const char *s;
941
+ int i;
942
+
943
+ JSRuntime *rt = new_runtime();
944
+ JSContext *ctx = JS_NewContext(rt);
945
+
946
+ // the implicit install left a working DOMException behind
947
+ ret = eval(ctx, "DOMException.prototype === "
948
+ "Object.getPrototypeOf(new DOMException)");
949
+ assert(JS_ToBool(ctx, ret) == true);
950
+ JS_FreeValue(ctx, ret);
951
+
952
+ // installing it again, repeatedly, must not leak the previous prototype
953
+ for (i = 0; i < 3; i++)
954
+ assert(JS_AddIntrinsicDOMException(ctx) == 0);
955
+
956
+ // and the class prototype still matches the global constructor, i.e. the
957
+ // slot tracks the newest install rather than a freed or stale object
958
+ ret = eval(ctx, "DOMException.prototype === "
959
+ "Object.getPrototypeOf(new DOMException)");
960
+ assert(JS_ToBool(ctx, ret) == true);
961
+ JS_FreeValue(ctx, ret);
962
+
963
+ ret = eval(ctx, "new DOMException('m', 'InvalidCharacterError').name");
964
+ assert(!JS_IsException(ret));
965
+ s = JS_ToCString(ctx, ret);
966
+ assert(s);
967
+ assert(!strcmp(s, "InvalidCharacterError"));
968
+ JS_FreeCString(ctx, s);
969
+ JS_FreeValue(ctx, ret);
970
+
971
+ // the internally thrown DOMExceptions pick up the current prototype too
972
+ ret = eval(ctx, "try { atob('a') } catch (e) { "
973
+ " e instanceof DOMException && e.name } ");
974
+ assert(!JS_IsException(ret));
975
+ s = JS_ToCString(ctx, ret);
976
+ assert(s);
977
+ assert(!strcmp(s, "InvalidCharacterError"));
978
+ JS_FreeCString(ctx, s);
979
+ JS_FreeValue(ctx, ret);
980
+
981
+ JS_FreeContext(ctx);
982
+ JS_FreeRuntime(rt);
983
+ }
984
+
931
985
  static void backtrace_oom_callsite_array(void)
932
986
  {
933
987
  static const char setup_code[] =
@@ -1822,6 +1876,182 @@ static void transfer_default_managed_array_buffer(void)
1822
1876
  JS_FreeRuntime(rt);
1823
1877
  }
1824
1878
 
1879
+ static void get_class_name(void)
1880
+ {
1881
+ static const struct {
1882
+ const char *code;
1883
+ const char *name;
1884
+ } builtins[] = {
1885
+ { "({})", "Object" },
1886
+ { "[]", "Array" },
1887
+ { "new Error()", "Error" },
1888
+ { "new Date()", "Date" },
1889
+ { "/re/", "RegExp" },
1890
+ { "new Map()", "Map" },
1891
+ { "new ArrayBuffer(0)", "ArrayBuffer" },
1892
+ { "new Uint8Array(0)", "Uint8Array" },
1893
+ { "(function(){})", "Function" },
1894
+ };
1895
+ JSClassDef def = (JSClassDef){ .class_name = "MyClass" };
1896
+ JSClassID class_id, unregistered_class_id;
1897
+ JSAtom atom, expected;
1898
+ JSRuntime *rt;
1899
+ JSContext *ctx;
1900
+ const char *s;
1901
+ JSValue obj;
1902
+ size_t i;
1903
+
1904
+ rt = new_runtime();
1905
+ class_id = 0;
1906
+ JS_NewClassID(rt, &class_id);
1907
+ assert(0 == JS_NewClass(rt, class_id, &def));
1908
+
1909
+ /* handed out by JS_NewClassID() but never passed to JS_NewClass() */
1910
+ unregistered_class_id = 0;
1911
+ JS_NewClassID(rt, &unregistered_class_id);
1912
+
1913
+ ctx = JS_NewContext(rt);
1914
+
1915
+ /* the name of a class registered from C, not its class id */
1916
+ expected = JS_NewAtom(ctx, "MyClass");
1917
+ atom = JS_GetClassName(rt, class_id);
1918
+ assert(atom == expected);
1919
+ s = JS_AtomToCString(ctx, atom);
1920
+ assert(s);
1921
+ assert(!strcmp(s, "MyClass"));
1922
+ JS_FreeCString(ctx, s);
1923
+ JS_FreeAtom(ctx, atom);
1924
+ JS_FreeAtom(ctx, expected);
1925
+
1926
+ /* the names of the built-in classes */
1927
+ for (i = 0; i < countof(builtins); i++) {
1928
+ obj = eval(ctx, builtins[i].code);
1929
+ assert(!JS_IsException(obj));
1930
+ atom = JS_GetClassName(rt, JS_GetClassID(obj));
1931
+ assert(atom != JS_ATOM_NULL);
1932
+ s = JS_AtomToCString(ctx, atom);
1933
+ assert(s);
1934
+ assert(!strcmp(s, builtins[i].name));
1935
+ JS_FreeCString(ctx, s);
1936
+ JS_FreeAtom(ctx, atom);
1937
+ JS_FreeValue(ctx, obj);
1938
+ }
1939
+
1940
+ /* class ids without a registered class have no name */
1941
+ assert(JS_ATOM_NULL == JS_GetClassName(rt, JS_INVALID_CLASS_ID));
1942
+ assert(JS_ATOM_NULL == JS_GetClassName(rt, unregistered_class_id));
1943
+ assert(JS_ATOM_NULL == JS_GetClassName(rt, class_id + 4096));
1944
+
1945
+ /* the caller owns the returned atom; the class keeps its own reference,
1946
+ so releasing it repeatedly doesn't free the name out from under it */
1947
+ for (i = 0; i < 64; i++)
1948
+ JS_FreeAtom(ctx, JS_GetClassName(rt, class_id));
1949
+ atom = JS_GetClassName(rt, class_id);
1950
+ s = JS_AtomToCString(ctx, atom);
1951
+ assert(s);
1952
+ assert(!strcmp(s, "MyClass"));
1953
+ JS_FreeCString(ctx, s);
1954
+ JS_FreeAtom(ctx, atom);
1955
+
1956
+ /* every registered class has a name, and it is a name rather than a
1957
+ number: returning the class id instead produced a valid-looking atom,
1958
+ either an unrelated predefined one for a small id or the id spelled out
1959
+ in decimal for a large one, so check the whole table rather than the
1960
+ handful of classes spelled out above */
1961
+ {
1962
+ JSClassID id;
1963
+ int registered = 0;
1964
+
1965
+ for (id = 1; id < class_id + 16; id++) {
1966
+ char decimal[32];
1967
+ if (!JS_IsRegisteredClass(rt, id))
1968
+ continue;
1969
+ registered++;
1970
+ atom = JS_GetClassName(rt, id);
1971
+ assert(atom != JS_ATOM_NULL);
1972
+ s = JS_AtomToCString(ctx, atom);
1973
+ assert(s);
1974
+ // a few internal classes are deliberately unnamed, but none is
1975
+ // named after a number
1976
+ snprintf(decimal, sizeof(decimal), "%u", (unsigned)id);
1977
+ assert(strcmp(s, decimal));
1978
+ assert(s[0] < '0' || s[0] > '9');
1979
+ JS_FreeCString(ctx, s);
1980
+ JS_FreeAtom(ctx, atom);
1981
+ }
1982
+ /* the built-ins alone are far more than this */
1983
+ assert(registered > 20);
1984
+ }
1985
+
1986
+ /* two classes sharing a name share the interned atom, and the name does
1987
+ not depend on which context asks */
1988
+ {
1989
+ JSClassDef def2 = (JSClassDef){ .class_name = "MyClass" };
1990
+ JSClassID class_id2 = 0;
1991
+ JSContext *ctx2;
1992
+ JSAtom a1, a2;
1993
+
1994
+ JS_NewClassID(rt, &class_id2);
1995
+ assert(0 == JS_NewClass(rt, class_id2, &def2));
1996
+ assert(class_id2 != class_id);
1997
+
1998
+ a1 = JS_GetClassName(rt, class_id);
1999
+ a2 = JS_GetClassName(rt, class_id2);
2000
+ assert(a1 == a2);
2001
+ JS_FreeAtom(ctx, a1);
2002
+ JS_FreeAtom(ctx, a2);
2003
+
2004
+ ctx2 = JS_NewContext(rt);
2005
+ a1 = JS_GetClassName(rt, class_id);
2006
+ a2 = JS_GetClassName(rt, class_id);
2007
+ assert(a1 == a2);
2008
+ JS_FreeAtom(ctx2, a1);
2009
+ JS_FreeAtom(ctx2, a2);
2010
+ JS_FreeContext(ctx2);
2011
+ }
2012
+
2013
+ JS_FreeContext(ctx);
2014
+ JS_FreeRuntime(rt);
2015
+ }
2016
+
2017
+ void object_from(void)
2018
+ {
2019
+ JSRuntime *rt = new_runtime();
2020
+ JSContext *ctx = JS_NewContext(rt);
2021
+ JSValue t0 = JS_NewObject(ctx);
2022
+ assert(!JS_IsException(t0));
2023
+ assert(JS_IsObject(t0));
2024
+ JSAtom prop = JS_NewAtomLen(ctx, "prop", 4);
2025
+ assert(prop != JS_ATOM_NULL);
2026
+ JSValue val = JS_NULL;
2027
+ JSValue t1 = JS_NewObjectFrom(ctx, 1, &prop, &val);
2028
+ assert(!JS_IsException(t1));
2029
+ assert(JS_IsObject(t1));
2030
+ uint32_t old_shape_hash_count = js_std_cmd(/*GetShapeHashCount*/4, rt);
2031
+ JSValue t2 = JS_NewObjectFrom(ctx, 1, &prop, &val);
2032
+ assert(!JS_IsException(t2));
2033
+ assert(JS_IsObject(t2));
2034
+ uint32_t new_shape_hash_count = js_std_cmd(/*GetShapeHashCount*/4, rt);
2035
+ assert(old_shape_hash_count == new_shape_hash_count);
2036
+ JS_FreeAtom(ctx, prop);
2037
+ JS_FreeValue(ctx, t2);
2038
+ JS_FreeValue(ctx, t1);
2039
+ JS_FreeValue(ctx, t0);
2040
+ JS_FreeContext(ctx);
2041
+ JS_FreeRuntime(rt);
2042
+ }
2043
+
2044
+ void add_intrinsic_bigint(void)
2045
+ {
2046
+ JSRuntime *rt = new_runtime();
2047
+ JSContext *ctx = JS_NewContextRaw(rt);
2048
+ JS_AddIntrinsicBaseObjects(ctx);
2049
+ JS_AddIntrinsicBigInt(ctx);
2050
+ assert(!JS_HasException(ctx));
2051
+ JS_FreeContext(ctx);
2052
+ JS_FreeRuntime(rt);
2053
+ }
2054
+
1825
2055
  int main(void)
1826
2056
  {
1827
2057
  cfunctions();
@@ -1840,6 +2070,7 @@ int main(void)
1840
2070
  promise_hook();
1841
2071
  dump_memory_usage();
1842
2072
  new_errors();
2073
+ dom_exception_added_twice();
1843
2074
  backtrace_oom_current_exception();
1844
2075
  backtrace_oom_callsite_array();
1845
2076
  proxy_own_keys_huge_length();
@@ -1855,5 +2086,8 @@ int main(void)
1855
2086
  transfer_external_array_buffer();
1856
2087
  resize_external_array_buffer();
1857
2088
  transfer_default_managed_array_buffer();
2089
+ get_class_name();
2090
+ object_from();
2091
+ add_intrinsic_bigint();
1858
2092
  return 0;
1859
2093
  }
@@ -1025,7 +1025,7 @@ static int parse_class_string_disjunction(REParseState *s, REStringList *cr,
1025
1025
  for(;;) {
1026
1026
  str.size = 0;
1027
1027
  while (*p != '}' && *p != '|') {
1028
- c = get_class_atom(s, NULL, &p, false);
1028
+ c = get_class_atom(s, NULL, &p, true);
1029
1029
  if (c < 0)
1030
1030
  goto fail;
1031
1031
  if (dbuf_put_u32(&str, c)) {
@@ -1119,6 +1119,23 @@ static int get_class_atom(REParseState *s, REStringList *cr,
1119
1119
  if (!inclass && s->is_unicode)
1120
1120
  goto invalid_escape;
1121
1121
  break;
1122
+ case '&':
1123
+ case '!':
1124
+ case '#':
1125
+ case '%':
1126
+ case ',':
1127
+ case ':':
1128
+ case ';':
1129
+ case '<':
1130
+ case '=':
1131
+ case '>':
1132
+ case '@':
1133
+ case '`':
1134
+ case '~':
1135
+ if (s->is_unicode && (!inclass || !s->unicode_sets))
1136
+ /* Only illegal if in unicode mode and not in a class */
1137
+ goto invalid_escape;
1138
+ break;
1122
1139
  case '^':
1123
1140
  case '$':
1124
1141
  case '\\':
@@ -4067,6 +4067,76 @@ static const uint8_t unicode_prop_Changes_When_NFKC_Casefolded1_table[449] = {
4067
4067
  0xff,
4068
4068
  };
4069
4069
 
4070
+ static const uint8_t unicode_prop_Basic_Emoji1_table[144] = {
4071
+ 0x60, 0x23, 0x19, 0x81, 0x40, 0xcc, 0x1a, 0x01,
4072
+ 0x80, 0x42, 0x08, 0x81, 0x94, 0x81, 0xb1, 0x8b,
4073
+ 0xaa, 0x80, 0x92, 0x80, 0x8c, 0x07, 0x81, 0x90,
4074
+ 0x0c, 0x0f, 0x04, 0x80, 0x94, 0x06, 0x08, 0x03,
4075
+ 0x01, 0x06, 0x03, 0x81, 0x9b, 0x80, 0xa2, 0x00,
4076
+ 0x03, 0x10, 0x80, 0xbc, 0x82, 0x97, 0x80, 0x8d,
4077
+ 0x80, 0x43, 0x5a, 0x81, 0xb2, 0x03, 0x80, 0x61,
4078
+ 0xc4, 0xad, 0x80, 0x40, 0xc9, 0x80, 0x40, 0xbd,
4079
+ 0x01, 0x89, 0xe5, 0x80, 0x97, 0x80, 0x93, 0x01,
4080
+ 0x20, 0x82, 0x94, 0x81, 0x40, 0xad, 0xa0, 0x8b,
4081
+ 0x88, 0x80, 0xc5, 0x80, 0x95, 0x8b, 0xaa, 0x1c,
4082
+ 0x8b, 0x90, 0x10, 0x82, 0xc6, 0x00, 0x80, 0x40,
4083
+ 0xba, 0x81, 0xbe, 0x8c, 0x18, 0x97, 0x91, 0x80,
4084
+ 0x99, 0x81, 0x8c, 0x80, 0xd5, 0xd4, 0xaf, 0xc5,
4085
+ 0x28, 0x12, 0x0b, 0x13, 0x8a, 0x0e, 0x88, 0x40,
4086
+ 0xe2, 0x8b, 0x18, 0x41, 0x1a, 0xae, 0x80, 0x89,
4087
+ 0x80, 0x40, 0xb8, 0xef, 0x8c, 0x82, 0x8a, 0x82,
4088
+ 0xb8, 0x00, 0x83, 0x8f, 0x81, 0x8b, 0x83, 0x89,
4089
+ };
4090
+
4091
+ static const uint8_t unicode_prop_Basic_Emoji2_table[183] = {
4092
+ 0x40, 0xa8, 0x03, 0x80, 0x5f, 0x8c, 0x80, 0x8b,
4093
+ 0x80, 0x40, 0xd7, 0x80, 0x95, 0x80, 0xd9, 0x85,
4094
+ 0x8e, 0x81, 0x41, 0x7c, 0x80, 0x40, 0xa5, 0x80,
4095
+ 0x9c, 0x10, 0x0c, 0x82, 0x40, 0xc6, 0x80, 0x40,
4096
+ 0xe6, 0x81, 0x89, 0x80, 0x88, 0x80, 0xb9, 0x0a,
4097
+ 0x84, 0x88, 0x01, 0x05, 0x03, 0x01, 0x00, 0x09,
4098
+ 0x02, 0x02, 0x0f, 0x14, 0x00, 0x80, 0x9b, 0x09,
4099
+ 0x00, 0x08, 0x80, 0x91, 0x01, 0x80, 0x92, 0x00,
4100
+ 0x18, 0x00, 0x0a, 0x05, 0x07, 0x81, 0x95, 0x05,
4101
+ 0x00, 0x00, 0x80, 0x94, 0x05, 0x09, 0x01, 0x17,
4102
+ 0x04, 0x09, 0x08, 0x01, 0x00, 0x00, 0x05, 0x02,
4103
+ 0x80, 0x90, 0x81, 0x8e, 0x01, 0x80, 0x9a, 0x81,
4104
+ 0xbb, 0x80, 0x41, 0x91, 0x81, 0x41, 0xce, 0x82,
4105
+ 0x45, 0x27, 0x80, 0x8b, 0x80, 0x42, 0x58, 0x00,
4106
+ 0x80, 0x61, 0xbe, 0xd5, 0x81, 0x8b, 0x81, 0x40,
4107
+ 0x81, 0x80, 0xb3, 0x80, 0x40, 0xe8, 0x01, 0x88,
4108
+ 0x88, 0x80, 0xc5, 0x80, 0x97, 0x08, 0x11, 0x81,
4109
+ 0xaa, 0x1c, 0x8b, 0x92, 0x00, 0x00, 0x80, 0xc6,
4110
+ 0x00, 0x80, 0x40, 0xba, 0x80, 0xca, 0x81, 0xa3,
4111
+ 0x09, 0x86, 0x8c, 0x01, 0x19, 0x80, 0x93, 0x01,
4112
+ 0x07, 0x81, 0x88, 0x04, 0x82, 0x8b, 0x17, 0x11,
4113
+ 0x00, 0x03, 0x05, 0x02, 0x05, 0x80, 0x40, 0xcf,
4114
+ 0x00, 0x82, 0x8f, 0x2a, 0x05, 0x01, 0x80,
4115
+ };
4116
+
4117
+ static const uint8_t unicode_prop_RGI_Emoji_Flag_Sequence_table[128] = {
4118
+ 0x0c, 0x00, 0x09, 0x00, 0x04, 0x01, 0x02, 0x06,
4119
+ 0x03, 0x03, 0x01, 0x02, 0x01, 0x03, 0x07, 0x0d,
4120
+ 0x18, 0x00, 0x09, 0x00, 0x00, 0x89, 0x08, 0x00,
4121
+ 0x00, 0x81, 0x88, 0x83, 0x8c, 0x10, 0x00, 0x01,
4122
+ 0x07, 0x08, 0x29, 0x10, 0x28, 0x00, 0x80, 0x8a,
4123
+ 0x00, 0x0a, 0x00, 0x0e, 0x15, 0x18, 0x83, 0x89,
4124
+ 0x06, 0x00, 0x81, 0x8d, 0x00, 0x12, 0x08, 0x00,
4125
+ 0x03, 0x00, 0x24, 0x00, 0x05, 0x21, 0x00, 0x00,
4126
+ 0x29, 0x90, 0x00, 0x02, 0x00, 0x08, 0x09, 0x00,
4127
+ 0x08, 0x18, 0x8b, 0x80, 0x8c, 0x02, 0x19, 0x1a,
4128
+ 0x11, 0x00, 0x00, 0x80, 0x9c, 0x80, 0x88, 0x02,
4129
+ 0x00, 0x00, 0x02, 0x20, 0x88, 0x0a, 0x00, 0x03,
4130
+ 0x01, 0x02, 0x05, 0x08, 0x00, 0x01, 0x09, 0x20,
4131
+ 0x21, 0x18, 0x22, 0x00, 0x00, 0x00, 0x00, 0x18,
4132
+ 0x28, 0x89, 0x80, 0x8b, 0x80, 0x90, 0x80, 0x92,
4133
+ 0x80, 0x8d, 0x05, 0x80, 0x8a, 0x80, 0x88, 0x80,
4134
+ };
4135
+
4136
+ static const uint8_t unicode_prop_Emoji_Keycap_Sequence_table[4] = {
4137
+ 0xa2, 0x05, 0x04, 0x89,
4138
+ };
4139
+
4070
4140
  static const uint8_t unicode_prop_ASCII_Hex_Digit_table[5] = {
4071
4141
  0xaf, 0x89, 0x35, 0x99, 0x85,
4072
4142
  };
@@ -4641,89 +4711,6 @@ static const char unicode_prop_name_table[] =
4641
4711
  "XID_Start,XIDS" "\0"
4642
4712
  ;
4643
4713
 
4644
- /* RGI emoji sequence support */
4645
- static const uint8_t unicode_prop_Basic_Emoji1_table[144] = {
4646
- 0x60, 0x23, 0x19, 0x81, 0x40, 0xcc, 0x1a, 0x01,
4647
- 0x80, 0x42, 0x08, 0x81, 0x94, 0x81, 0xb1, 0x8b,
4648
- 0xaa, 0x80, 0x92, 0x80, 0x8c, 0x07, 0x81, 0x90,
4649
- 0x0c, 0x0f, 0x04, 0x80, 0x94, 0x06, 0x08, 0x03,
4650
- 0x01, 0x06, 0x03, 0x81, 0x9b, 0x80, 0xa2, 0x00,
4651
- 0x03, 0x10, 0x80, 0xbc, 0x82, 0x97, 0x80, 0x8d,
4652
- 0x80, 0x43, 0x5a, 0x81, 0xb2, 0x03, 0x80, 0x61,
4653
- 0xc4, 0xad, 0x80, 0x40, 0xc9, 0x80, 0x40, 0xbd,
4654
- 0x01, 0x89, 0xe5, 0x80, 0x97, 0x80, 0x93, 0x01,
4655
- 0x20, 0x82, 0x94, 0x81, 0x40, 0xad, 0xa0, 0x8b,
4656
- 0x88, 0x80, 0xc5, 0x80, 0x95, 0x8b, 0xaa, 0x1c,
4657
- 0x8b, 0x90, 0x10, 0x82, 0xc6, 0x00, 0x80, 0x40,
4658
- 0xba, 0x81, 0xbe, 0x8c, 0x18, 0x97, 0x91, 0x80,
4659
- 0x99, 0x81, 0x8c, 0x80, 0xd5, 0xd4, 0xaf, 0xc5,
4660
- 0x28, 0x12, 0x0b, 0x13, 0x8a, 0x0e, 0x88, 0x40,
4661
- 0xe2, 0x8b, 0x18, 0x41, 0x1a, 0xae, 0x80, 0x89,
4662
- 0x80, 0x40, 0xb8, 0xef, 0x8c, 0x82, 0x8a, 0x82,
4663
- 0xb8, 0x00, 0x83, 0x8f, 0x81, 0x8b, 0x83, 0x89,
4664
- };
4665
-
4666
- static const uint8_t unicode_prop_Basic_Emoji2_table[183] = {
4667
- 0x40, 0xa8, 0x03, 0x80, 0x5f, 0x8c, 0x80, 0x8b,
4668
- 0x80, 0x40, 0xd7, 0x80, 0x95, 0x80, 0xd9, 0x85,
4669
- 0x8e, 0x81, 0x41, 0x7c, 0x80, 0x40, 0xa5, 0x80,
4670
- 0x9c, 0x10, 0x0c, 0x82, 0x40, 0xc6, 0x80, 0x40,
4671
- 0xe6, 0x81, 0x89, 0x80, 0x88, 0x80, 0xb9, 0x0a,
4672
- 0x84, 0x88, 0x01, 0x05, 0x03, 0x01, 0x00, 0x09,
4673
- 0x02, 0x02, 0x0f, 0x14, 0x00, 0x80, 0x9b, 0x09,
4674
- 0x00, 0x08, 0x80, 0x91, 0x01, 0x80, 0x92, 0x00,
4675
- 0x18, 0x00, 0x0a, 0x05, 0x07, 0x81, 0x95, 0x05,
4676
- 0x00, 0x00, 0x80, 0x94, 0x05, 0x09, 0x01, 0x17,
4677
- 0x04, 0x09, 0x08, 0x01, 0x00, 0x00, 0x05, 0x02,
4678
- 0x80, 0x90, 0x81, 0x8e, 0x01, 0x80, 0x9a, 0x81,
4679
- 0xbb, 0x80, 0x41, 0x91, 0x81, 0x41, 0xce, 0x82,
4680
- 0x45, 0x27, 0x80, 0x8b, 0x80, 0x42, 0x58, 0x00,
4681
- 0x80, 0x61, 0xbe, 0xd5, 0x81, 0x8b, 0x81, 0x40,
4682
- 0x81, 0x80, 0xb3, 0x80, 0x40, 0xe8, 0x01, 0x88,
4683
- 0x88, 0x80, 0xc5, 0x80, 0x97, 0x08, 0x11, 0x81,
4684
- 0xaa, 0x1c, 0x8b, 0x92, 0x00, 0x00, 0x80, 0xc6,
4685
- 0x00, 0x80, 0x40, 0xba, 0x80, 0xca, 0x81, 0xa3,
4686
- 0x09, 0x86, 0x8c, 0x01, 0x19, 0x80, 0x93, 0x01,
4687
- 0x07, 0x81, 0x88, 0x04, 0x82, 0x8b, 0x17, 0x11,
4688
- 0x00, 0x03, 0x05, 0x02, 0x05, 0x80, 0x40, 0xcf,
4689
- 0x00, 0x82, 0x8f, 0x2a, 0x05, 0x01, 0x80,
4690
- };
4691
-
4692
- static const uint8_t unicode_prop_RGI_Emoji_Modifier_Sequence_table[72] = {
4693
- 0x60, 0x26, 0x1c, 0x80, 0x40, 0xda, 0x80, 0x8f,
4694
- 0x83, 0x61, 0xcc, 0x76, 0x80, 0xbb, 0x11, 0x01,
4695
- 0x82, 0xf4, 0x09, 0x8a, 0x94, 0x18, 0x8d, 0x10,
4696
- 0x1a, 0x02, 0x30, 0x00, 0x97, 0x80, 0x40, 0xc8,
4697
- 0x0b, 0x80, 0x94, 0x03, 0x81, 0x40, 0xad, 0x12,
4698
- 0x84, 0xd2, 0x80, 0x8f, 0x82, 0x88, 0x80, 0x8a,
4699
- 0x80, 0x42, 0x3e, 0x01, 0x07, 0x3d, 0x80, 0x88,
4700
- 0x89, 0x0a, 0xb7, 0x80, 0xbc, 0x08, 0x08, 0x80,
4701
- 0x90, 0x10, 0x8c, 0x40, 0xe4, 0x82, 0xa9, 0x88,
4702
- };
4703
-
4704
- static const uint8_t unicode_prop_RGI_Emoji_Flag_Sequence_table[128] = {
4705
- 0x0c, 0x00, 0x09, 0x00, 0x04, 0x01, 0x02, 0x06,
4706
- 0x03, 0x03, 0x01, 0x02, 0x01, 0x03, 0x07, 0x0d,
4707
- 0x18, 0x00, 0x09, 0x00, 0x00, 0x89, 0x08, 0x00,
4708
- 0x00, 0x81, 0x88, 0x83, 0x8c, 0x10, 0x00, 0x01,
4709
- 0x07, 0x08, 0x29, 0x10, 0x28, 0x00, 0x80, 0x8a,
4710
- 0x00, 0x0a, 0x00, 0x0e, 0x15, 0x18, 0x83, 0x89,
4711
- 0x06, 0x00, 0x81, 0x8d, 0x00, 0x12, 0x08, 0x00,
4712
- 0x03, 0x00, 0x24, 0x00, 0x05, 0x21, 0x00, 0x00,
4713
- 0x29, 0x90, 0x00, 0x02, 0x00, 0x08, 0x09, 0x00,
4714
- 0x08, 0x18, 0x8b, 0x80, 0x8c, 0x02, 0x19, 0x1a,
4715
- 0x11, 0x00, 0x00, 0x80, 0x9c, 0x80, 0x88, 0x02,
4716
- 0x00, 0x00, 0x02, 0x20, 0x88, 0x0a, 0x00, 0x03,
4717
- 0x01, 0x02, 0x05, 0x08, 0x00, 0x01, 0x09, 0x20,
4718
- 0x21, 0x18, 0x22, 0x00, 0x00, 0x00, 0x00, 0x18,
4719
- 0x28, 0x89, 0x80, 0x8b, 0x80, 0x90, 0x80, 0x92,
4720
- 0x80, 0x8d, 0x05, 0x80, 0x8a, 0x80, 0x88, 0x80,
4721
- };
4722
-
4723
- static const uint8_t unicode_prop_Emoji_Keycap_Sequence_table[4] = {
4724
- 0xa2, 0x05, 0x04, 0x89,
4725
- };
4726
-
4727
4714
  static const uint8_t * const unicode_prop_table[] = {
4728
4715
  unicode_prop_Hyphen_table,
4729
4716
  unicode_prop_Other_Math_table,
@@ -4842,7 +4829,6 @@ static const uint16_t unicode_prop_len_table[] = {
4842
4829
  countof(unicode_prop_Case_Ignorable_table),
4843
4830
  };
4844
4831
 
4845
- /* RGI emoji sequence-property tables */
4846
4832
  typedef enum {
4847
4833
  UNICODE_SEQUENCE_PROP_Basic_Emoji,
4848
4834
  UNICODE_SEQUENCE_PROP_Emoji_Keycap_Sequence,
@@ -5171,3 +5157,4 @@ static const uint8_t unicode_rgi_emoji_zwj_sequence[2392] = {
5171
5157
  0x86, 0x02, 0x4b, 0x16, 0x40, 0x86, 0x02, 0x26,
5172
5158
  0x19, 0x42, 0x86, 0x02, 0xd7, 0x19, 0x40, 0x86,
5173
5159
  };
5160
+
@@ -1920,7 +1920,7 @@ static const JSCFunctionListEntry js_std_funcs[] = {
1920
1920
  JS_CFUNC_DEF("evalScript", 1, js_evalScript ),
1921
1921
  JS_CFUNC_DEF("loadScript", 1, js_loadScript ),
1922
1922
  JS_CFUNC_DEF("getenv", 1, js_std_getenv ),
1923
- JS_CFUNC_DEF("setenv", 1, js_std_setenv ),
1923
+ JS_CFUNC_DEF("setenv", 2, js_std_setenv ),
1924
1924
  JS_CFUNC_DEF("unsetenv", 1, js_std_unsetenv ),
1925
1925
  JS_CFUNC_DEF("getenviron", 1, js_std_getenviron ),
1926
1926
  #if !defined(__wasi__)
@@ -4449,7 +4449,7 @@ static const JSCFunctionListEntry js_os_funcs[] = {
4449
4449
  JS_CFUNC_DEF("sleepAsync", 1, js_os_sleepAsync ),
4450
4450
  JS_PROP_STRING_DEF("platform", OS_PLATFORM, 0 ),
4451
4451
  JS_CFUNC_DEF("getcwd", 0, js_os_getcwd ),
4452
- JS_CFUNC_DEF("chdir", 0, js_os_chdir ),
4452
+ JS_CFUNC_DEF("chdir", 1, js_os_chdir ),
4453
4453
  JS_CFUNC_DEF("mkdir", 1, js_os_mkdir ),
4454
4454
  JS_CFUNC_DEF("readdir", 1, js_os_readdir ),
4455
4455
  #if !defined(_WIN32) && !defined(__wasi__)