Skip to content

Commit

Permalink
Prepare new version 2020-09-06.
Browse files Browse the repository at this point in the history
  • Loading branch information
NickNaso committed Sep 10, 2020
1 parent 46a395c commit 305934f
Show file tree
Hide file tree
Showing 10 changed files with 652 additions and 326 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# quickjs-build changelog

## 2020-09-10 Version 3.0.0, @NickNaso

- added logical assignment operators
- added IsHTMLDDA support
- faster for-of loops
- os.Worker now takes a module filename as parameter
- qjsc: added -D option to compile dynamically loaded modules or workers
- misc bug fixes

## 2020-09-04 Version 2.0.0, @NickNaso

- modified JS_GetPrototype() to return a live value
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

## Version 2020-07-05
## Version 2020-09-06

- [Introduction](#introduction)
- [Building](#building)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2020-07-05
2020-09-06
10 changes: 10 additions & 0 deletions include/quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s);
void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt);

/* atom support */
#define JS_ATOM_NULL 0

JSAtom JS_NewAtomLen(JSContext *ctx, const char *str, size_t len);
JSAtom JS_NewAtom(JSContext *ctx, const char *str);
JSAtom JS_NewAtomUInt32(JSContext *ctx, uint32_t n);
Expand Down Expand Up @@ -835,6 +837,8 @@ typedef int JSInterruptHandler(JSRuntime *rt, void *opaque);
void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, void *opaque);
/* if can_block is TRUE, Atomics.wait() can be used */
void JS_SetCanBlock(JSRuntime *rt, JS_BOOL can_block);
/* set the [IsHTMLDDA] internal slot */
void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj);

typedef struct JSModuleDef JSModuleDef;

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

/* only exported for os.Worker() */
JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels);
/* only exported for os.Worker() */
JSModuleDef *JS_RunModule(JSContext *ctx, const char *basename,
const char *filename);

/* C function definition */
typedef enum JSCFunctionEnum { /* XXX: should rename for namespace isolation */
JS_CFUNC_generic,
Expand Down
21 changes: 16 additions & 5 deletions src/cutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,30 @@ int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
return c;
}
switch(c) {
case 0xc0 ... 0xdf:
case 0xc0: case 0xc1: case 0xc2: case 0xc3:
case 0xc4: case 0xc5: case 0xc6: case 0xc7:
case 0xc8: case 0xc9: case 0xca: case 0xcb:
case 0xcc: case 0xcd: case 0xce: case 0xcf:
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
case 0xd8: case 0xd9: case 0xda: case 0xdb:
case 0xdc: case 0xdd: case 0xde: case 0xdf:
l = 1;
break;
case 0xe0 ... 0xef:
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
case 0xe8: case 0xe9: case 0xea: case 0xeb:
case 0xec: case 0xed: case 0xee: case 0xef:
l = 2;
break;
case 0xf0 ... 0xf7:
case 0xf0: case 0xf1: case 0xf2: case 0xf3:
case 0xf4: case 0xf5: case 0xf6: case 0xf7:
l = 3;
break;
case 0xf8 ... 0xfb:
case 0xf8: case 0xf9: case 0xfa: case 0xfb:
l = 4;
break;
case 0xfc ... 0xfd:
case 0xfc: case 0xfd:
l = 5;
break;
default:
Expand Down
20 changes: 17 additions & 3 deletions src/libregexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
}
}
break;
case '0' ... '7':
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 */
Expand Down Expand Up @@ -1410,7 +1411,9 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
}
}
goto normal_char;
case '1' ... '9':
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8':
case '9':
{
const uint8_t *q = ++p;

Expand All @@ -1434,7 +1437,7 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
}
goto normal_char;
}
return re_parse_error(s, "back reference out of range in reguar expression");
return re_parse_error(s, "back reference out of range in regular expression");
}
emit_back_reference:
last_atom_start = s->byte_code.size;
Expand Down Expand Up @@ -2533,6 +2536,17 @@ 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)
Expand Down
1 change: 1 addition & 0 deletions src/libregexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
void *opaque);
int lre_get_capture_count(const uint8_t *bc_buf);
int lre_get_flags(const uint8_t *bc_buf);
const char *lre_get_groupnames(const uint8_t *bc_buf);
int lre_exec(uint8_t **capture,
const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen,
int cbuf_type, void *opaque);
Expand Down
26 changes: 22 additions & 4 deletions src/libunicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,22 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c,
} else {
d = unicode_decomp_data + unicode_decomp_table2[idx];
switch(type) {
case DECOMP_TYPE_L1 ... DECOMP_TYPE_L7:
case DECOMP_TYPE_L1:
case DECOMP_TYPE_L2:
case DECOMP_TYPE_L3:
case DECOMP_TYPE_L4:
case DECOMP_TYPE_L5:
case DECOMP_TYPE_L6:
case DECOMP_TYPE_L7:
l = type - DECOMP_TYPE_L1 + 1;
d += (c - code) * l * 2;
for(i = 0; i < l; i++) {
if ((res[i] = unicode_get16(d + 2 * i)) == 0)
return 0;
}
return l;
case DECOMP_TYPE_LL1 ... DECOMP_TYPE_LL2:
case DECOMP_TYPE_LL1:
case DECOMP_TYPE_LL2:
{
uint32_t k, p;
l = type - DECOMP_TYPE_LL1 + 1;
Expand All @@ -551,7 +558,11 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c,
}
}
return l;
case DECOMP_TYPE_S1 ... DECOMP_TYPE_S5:
case DECOMP_TYPE_S1:
case DECOMP_TYPE_S2:
case DECOMP_TYPE_S3:
case DECOMP_TYPE_S4:
case DECOMP_TYPE_S5:
l = type - DECOMP_TYPE_S1 + 1;
d += (c - code) * l;
for(i = 0; i < l; i++) {
Expand Down Expand Up @@ -582,7 +593,14 @@ static int unicode_decomp_entry(uint32_t *res, uint32_t c,
case DECOMP_TYPE_B18:
l = 18;
goto decomp_type_b;
case DECOMP_TYPE_B1 ... DECOMP_TYPE_B8:
case DECOMP_TYPE_B1:
case DECOMP_TYPE_B2:
case DECOMP_TYPE_B3:
case DECOMP_TYPE_B4:
case DECOMP_TYPE_B5:
case DECOMP_TYPE_B6:
case DECOMP_TYPE_B7:
case DECOMP_TYPE_B8:
l = type - DECOMP_TYPE_B1 + 1;
decomp_type_b:
{
Expand Down
3 changes: 2 additions & 1 deletion src/quickjs-opcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ DEF( call3, 1, 1, 1, npopx)

DEF( is_undefined, 1, 1, 1, none)
DEF( is_null, 1, 1, 1, none)
DEF( is_function, 1, 1, 1, none)
DEF(typeof_is_undefined, 1, 1, 1, none)
DEF( typeof_is_function, 1, 1, 1, none)
#endif

#undef DEF
Expand Down
Loading

0 comments on commit 305934f

Please sign in to comment.