Skip to content

Commit 305934f

Browse files
committed
Prepare new version 2020-09-06.
1 parent 46a395c commit 305934f

File tree

10 files changed

+652
-326
lines changed

10 files changed

+652
-326
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# quickjs-build changelog
22

3+
## 2020-09-10 Version 3.0.0, @NickNaso
4+
5+
- added logical assignment operators
6+
- added IsHTMLDDA support
7+
- faster for-of loops
8+
- os.Worker now takes a module filename as parameter
9+
- qjsc: added -D option to compile dynamically loaded modules or workers
10+
- misc bug fixes
11+
312
## 2020-09-04 Version 2.0.0, @NickNaso
413

514
- modified JS_GetPrototype() to return a live value

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![QuickJS Build Matrix](https://github.com/napi-bindings/quickjs-build/workflows/QuickJS%20Build%20Matrix/badge.svg?branch=master)
44

5-
## Version 2020-07-05
5+
## Version 2020-09-06
66

77
- [Introduction](#introduction)
88
- [Building](#building)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2020-07-05
1+
2020-09-06

include/quickjs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s);
412412
void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt);
413413

414414
/* atom support */
415+
#define JS_ATOM_NULL 0
416+
415417
JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len);
416418
JSAtom JS_NewAtom(JSContext *ctx, const char *str);
417419
JSAtom JS_NewAtomUInt32(JSContext *ctx, uint32_t n);
@@ -835,6 +837,8 @@ typedef int JSInterruptHandler(JSRuntime *rt, void *opaque);
835837
void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque);
836838
/* if can_block is TRUE, Atomics.wait() can be used */
837839
void JS_SetCanBlock(JSRuntime *rt, JS_BOOL can_block);
840+
/* set the [IsHTMLDDA] internal slot */
841+
void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj);
838842

839843
typedef struct JSModuleDef JSModuleDef;
840844

@@ -886,6 +890,12 @@ JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len,
886890
returns a module. */
887891
int JS_ResolveModule(JSContext *ctx, JSValueConst obj);
888892

893+
/* only exported for os.Worker() */
894+
JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels);
895+
/* only exported for os.Worker() */
896+
JSModuleDef *JS_RunModule(JSContext *ctx, const char *basename,
897+
const char *filename);
898+
889899
/* C function definition */
890900
typedef enum JSCFunctionEnum { /* XXX: should rename for namespace isolation */
891901
JS_CFUNC_generic,

src/cutils.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,30 @@ int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
258258
return c;
259259
}
260260
switch(c) {
261-
case 0xc0 ... 0xdf:
261+
case 0xc0: case 0xc1: case 0xc2: case 0xc3:
262+
case 0xc4: case 0xc5: case 0xc6: case 0xc7:
263+
case 0xc8: case 0xc9: case 0xca: case 0xcb:
264+
case 0xcc: case 0xcd: case 0xce: case 0xcf:
265+
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
266+
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
267+
case 0xd8: case 0xd9: case 0xda: case 0xdb:
268+
case 0xdc: case 0xdd: case 0xde: case 0xdf:
262269
l = 1;
263270
break;
264-
case 0xe0 ... 0xef:
271+
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
272+
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
273+
case 0xe8: case 0xe9: case 0xea: case 0xeb:
274+
case 0xec: case 0xed: case 0xee: case 0xef:
265275
l = 2;
266276
break;
267-
case 0xf0 ... 0xf7:
277+
case 0xf0: case 0xf1: case 0xf2: case 0xf3:
278+
case 0xf4: case 0xf5: case 0xf6: case 0xf7:
268279
l = 3;
269280
break;
270-
case 0xf8 ... 0xfb:
281+
case 0xf8: case 0xf9: case 0xfa: case 0xfb:
271282
l = 4;
272283
break;
273-
case 0xfc ... 0xfd:
284+
case 0xfc: case 0xfd:
274285
l = 5;
275286
break;
276287
default:

src/libregexp.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
569569
}
570570
}
571571
break;
572-
case '0' ... '7':
572+
case '0': case '1': case '2': case '3':
573+
case '4': case '5': case '6': case '7':
573574
c -= '0';
574575
if (allow_utf16 == 2) {
575576
/* only accept \0 not followed by digit */
@@ -1410,7 +1411,9 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
14101411
}
14111412
}
14121413
goto normal_char;
1413-
case '1' ... '9':
1414+
case '1': case '2': case '3': case '4':
1415+
case '5': case '6': case '7': case '8':
1416+
case '9':
14141417
{
14151418
const uint8_t *q = ++p;
14161419

@@ -1434,7 +1437,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
14341437
}
14351438
goto normal_char;
14361439
}
1437-
return re_parse_error(s, "back reference out of range in reguar expression");
1440+
return re_parse_error(s, "back reference out of range in regular expression");
14381441
}
14391442
emit_back_reference:
14401443
last_atom_start = s->byte_code.size;
@@ -2533,6 +2536,17 @@ int lre_get_flags(const uint8_t *bc_buf)
25332536
return bc_buf[RE_HEADER_FLAGS];
25342537
}
25352538

2539+
/* Return NULL if no group names. Otherwise, return a pointer to
2540+
'capture_count - 1' zero terminated UTF-8 strings. */
2541+
const char *lre_get_groupnames(const uint8_t *bc_buf)
2542+
{
2543+
uint32_t re_bytecode_len;
2544+
if ((lre_get_flags(bc_buf) & LRE_FLAG_NAMED_GROUPS) == 0)
2545+
return NULL;
2546+
re_bytecode_len = get_u32(bc_buf + 3);
2547+
return (const char *)(bc_buf + 7 + re_bytecode_len);
2548+
}
2549+
25362550
#ifdef TEST
25372551

25382552
BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size)

src/libregexp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
4444
void *opaque);
4545
int lre_get_capture_count(const uint8_t *bc_buf);
4646
int lre_get_flags(const uint8_t *bc_buf);
47+
const char *lre_get_groupnames(const uint8_t *bc_buf);
4748
int lre_exec(uint8_t **capture,
4849
const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen,
4950
int cbuf_type, void *opaque);

src/libunicode.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,22 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c,
527527
} else {
528528
d = unicode_decomp_data + unicode_decomp_table2[idx];
529529
switch(type) {
530-
case DECOMP_TYPE_L1 ... DECOMP_TYPE_L7:
530+
case DECOMP_TYPE_L1:
531+
case DECOMP_TYPE_L2:
532+
case DECOMP_TYPE_L3:
533+
case DECOMP_TYPE_L4:
534+
case DECOMP_TYPE_L5:
535+
case DECOMP_TYPE_L6:
536+
case DECOMP_TYPE_L7:
531537
l = type - DECOMP_TYPE_L1 + 1;
532538
d += (c - code) * l * 2;
533539
for(i = 0; i < l; i++) {
534540
if ((res[i] = unicode_get16(d + 2 * i)) == 0)
535541
return 0;
536542
}
537543
return l;
538-
case DECOMP_TYPE_LL1 ... DECOMP_TYPE_LL2:
544+
case DECOMP_TYPE_LL1:
545+
case DECOMP_TYPE_LL2:
539546
{
540547
uint32_t k, p;
541548
l = type - DECOMP_TYPE_LL1 + 1;
@@ -551,7 +558,11 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c,
551558
}
552559
}
553560
return l;
554-
case DECOMP_TYPE_S1 ... DECOMP_TYPE_S5:
561+
case DECOMP_TYPE_S1:
562+
case DECOMP_TYPE_S2:
563+
case DECOMP_TYPE_S3:
564+
case DECOMP_TYPE_S4:
565+
case DECOMP_TYPE_S5:
555566
l = type - DECOMP_TYPE_S1 + 1;
556567
d += (c - code) * l;
557568
for(i = 0; i < l; i++) {
@@ -582,7 +593,14 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c,
582593
case DECOMP_TYPE_B18:
583594
l = 18;
584595
goto decomp_type_b;
585-
case DECOMP_TYPE_B1 ... DECOMP_TYPE_B8:
596+
case DECOMP_TYPE_B1:
597+
case DECOMP_TYPE_B2:
598+
case DECOMP_TYPE_B3:
599+
case DECOMP_TYPE_B4:
600+
case DECOMP_TYPE_B5:
601+
case DECOMP_TYPE_B6:
602+
case DECOMP_TYPE_B7:
603+
case DECOMP_TYPE_B8:
586604
l = type - DECOMP_TYPE_B1 + 1;
587605
decomp_type_b:
588606
{

src/quickjs-opcode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ DEF( call3, 1, 1, 1, npopx)
359359

360360
DEF( is_undefined, 1, 1, 1, none)
361361
DEF( is_null, 1, 1, 1, none)
362-
DEF( is_function, 1, 1, 1, none)
362+
DEF(typeof_is_undefined, 1, 1, 1, none)
363+
DEF( typeof_is_function, 1, 1, 1, none)
363364
#endif
364365

365366
#undef DEF

0 commit comments

Comments
 (0)