Browse Source

2019-10-27

- added example of C class in a module (examples/test_point.js)
- added JS_GetTypedArrayBuffer()
- misc bug fixes
pull/12/head 20191027
Horunabu Hofutenho 2 years ago
parent
commit
a0e06511d3
No known key found for this signature in database GPG Key ID: 7EB80FA93BC3054C
20 changed files with 365 additions and 107 deletions
  1. +6
    -0
      Changelog
  2. +19
    -11
      Makefile
  3. +4
    -4
      TODO
  4. +1
    -1
      VERSION
  5. +12
    -9
      doc/quickjs.html
  6. BIN
      doc/quickjs.pdf
  7. +11
    -9
      doc/quickjs.texi
  8. +151
    -0
      examples/point.c
  9. +0
    -0
      examples/test_fib.js
  10. +40
    -0
      examples/test_point.js
  11. +81
    -33
      quickjs.c
  12. +8
    -0
      quickjs.h
  13. +7
    -31
      release.sh
  14. +2
    -0
      test262.conf
  15. +2
    -0
      test262bn.conf
  16. +2
    -2
      tests/bjson.c
  17. +5
    -5
      tests/test262.patch
  18. +1
    -1
      tests/test_bjson.js
  19. +12
    -1
      tests/test_op.js
  20. +1
    -0
      unicode_gen.c

+ 6
- 0
Changelog View File

@ -1,3 +1,9 @@
2019-10-27:
- added example of C class in a module (examples/test_point.js)
- added JS_GetTypedArrayBuffer()
- misc bug fixes
2019-09-18:
- added os.exec and other system calls


+ 19
- 11
Makefile View File

@ -146,7 +146,10 @@ ifeq ($(CROSS_PREFIX),)
ifdef CONFIG_ASAN
PROGS+=
else
PROGS+=examples/hello examples/hello_module examples/c_module
PROGS+=examples/hello examples/hello_module examples/test_fib
ifndef CONFIG_DARWIN
PROGS+=examples/fib.so examples/point.so
endif
endif
endif
@ -166,7 +169,7 @@ LIBS+=-ldl
endif
$(OBJDIR):
mkdir -p $(OBJDIR)
mkdir -p $(OBJDIR) $(OBJDIR)/examples $(OBJDIR)/tests
qjs$(EXE): $(QJS_OBJS)
$(CC) $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS)
@ -324,8 +327,9 @@ unicode_gen: $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o libunicode.c u
clean:
rm -f repl.c repl-bn.c qjscalc.c out.c
rm -f *.a *.so *.o *.d *~ jscompress unicode_gen regexp_test $(PROGS)
rm -f hello.c hello_module.c c_module.c
rm -f *.a *.o *.d *~ jscompress unicode_gen regexp_test $(PROGS)
rm -f hello.c hello_module.c test_fib.c
rm -f examples/*.so tests/*.so
rm -rf $(OBJDIR)/ *.dSYM/ qjs-debug qjsbn-debug
rm -rf run-test262-debug run-test262-32 run-test262-bn32
@ -372,14 +376,17 @@ examples/hello_module: $(QJSC) libquickjs$(LTOEXT).a $(HELLO_MODULE_SRCS)
# use of an external C module (static compilation)
c_module.c: $(QJSC) examples/c_module.js
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/c_module.js
test_fib.c: $(QJSC) examples/test_fib.js
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/test_fib.js
examples/c_module: $(OBJDIR)/c_module.o $(OBJDIR)/fib.o libquickjs$(LTOEXT).a
examples/test_fib: $(OBJDIR)/test_fib.o $(OBJDIR)/examples/fib.o libquickjs$(LTOEXT).a
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJDIR)/fib.o: examples/fib.c
$(CC) $(CFLAGS_OPT) -c -o $@ $<
examples/fib.so: $(OBJDIR)/examples/fib.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^
examples/point.so: $(OBJDIR)/examples/point.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^
###############################################################################
# documentation
@ -404,7 +411,7 @@ doc/%.html: doc/%.html.pre
# tests
ifndef CONFIG_DARWIN
test: bjson.so
test: tests/bjson.so
endif
test: qjs qjsbn
@ -415,6 +422,7 @@ test: qjs qjsbn
./qjs tests/test_std.js
ifndef CONFIG_DARWIN
./qjs tests/test_bjson.js
./qjs examples/test_point.js
endif
./qjsbn tests/test_closure.js
./qjsbn tests/test_op.js
@ -492,7 +500,7 @@ bench-v8: qjs qjs32
make -C tests/bench-v8
./qjs -d tests/bench-v8/combined.js
bjson.so: $(OBJDIR)/bjson.pic.o
tests/bjson.so: $(OBJDIR)/tests/bjson.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
-include $(wildcard $(OBJDIR)/*.d)

+ 4
- 4
TODO View File

@ -55,7 +55,7 @@ Extensions:
- limited support for web assembly
- get rid of __loadScript, use more common name
- BSD sockets
- Process or thread control
- Workers
- use custom printf to avoid C library compatibility issues
- use custom timezone support to avoid C library compatibility issues
@ -75,6 +75,6 @@ REPL:
Test262o: 0/11262 errors, 463 excluded
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
Test262: 2/67351 errors, 839 excluded, 1370 skipped
Test262bn: 2/69452 errors, 772 excluded, 383 skipped
test262 commit: d65b9b35be091147edf31ec527a47cb95a327217
Test262: 2/67433 errors, 901 excluded, 1658 skipped
Test262bn: 2/69536 errors, 834 excluded, 670 skipped
test262 commit: 21195de94cfc36eadbde00a825ca7efb3d9c3dde

+ 1
- 1
VERSION View File

@ -1 +1 @@
2019-09-18
2019-10-27

+ 12
- 9
doc/quickjs.html View File

@ -243,7 +243,9 @@ compiler with the mathematical extensions:
</dd>
<dt><code>-m</code></dt>
<dt><code>--module</code></dt>
<dd><p>Load as ES6 module (default=autodetect).
<dd><p>Load as ES6 module (default=autodetect). A module is autodetected if
the filename extension is <code>.mjs</code> or if the first keyword of the
source is <code>import</code>.
</p>
</dd>
<dt><code>--script</code></dt>
@ -333,13 +335,8 @@ QuickJS archive.
<a name="Test262-_0028ECMAScript-Test-Suite_0029"></a>
<h3 class="section">2.6 Test262 (ECMAScript Test Suite)</h3>
<p>A test262 runner is included in the QuickJS archive.
</p>
<p>For reference, the full test262 tests are provided in the archive
<samp>qjs-tests-yyyy-mm-dd.tar.xz</samp>. You just need to untar it into the
QuickJS source code directory.
</p>
<p>Alternatively, the test262 tests can be installed with:
<p>A test262 runner is included in the QuickJS archive. The test262 tests
can be installed in the QuickJS source directory with:
</p>
<div class="example">
<pre class="example">git clone https://github.com/tc39/test262.git test262
@ -663,8 +660,14 @@ position <code>position</code> (wrapper to the libc <code>fread</code>).
the trailing line feed.
</p>
</dd>
<dt><code>readAsString(max_size = undefined)</code></dt>
<dd><p>Read <code>max_size</code> bytes from the file and return them as a string
assuming UTF-8 encoding. If <code>max_size</code> is not present, the file
is read up its end.
</p>
</dd>
<dt><code>getByte()</code></dt>
<dd><p>Return the next byte from the file.
<dd><p>Return the next byte from the file. Return -1 if the end of file is reached.
</p>
</dd>
<dt><code>putByte(c)</code></dt>


BIN
doc/quickjs.pdf View File


+ 11
- 9
doc/quickjs.texi View File

@ -127,7 +127,9 @@ Go to interactive mode (it is not the default when files are provided on the com
@item -m
@item --module
Load as ES6 module (default=autodetect).
Load as ES6 module (default=autodetect). A module is autodetected if
the filename extension is @code{.mjs} or if the first keyword of the
source is @code{import}.
@item --script
Load as ES6 script (default=autodetect).
@ -202,13 +204,8 @@ QuickJS archive.
@section Test262 (ECMAScript Test Suite)
A test262 runner is included in the QuickJS archive.
For reference, the full test262 tests are provided in the archive
@file{qjs-tests-yyyy-mm-dd.tar.xz}. You just need to untar it into the
QuickJS source code directory.
Alternatively, the test262 tests can be installed with:
A test262 runner is included in the QuickJS archive. The test262 tests
can be installed in the QuickJS source directory with:
@example
git clone https://github.com/tc39/test262.git test262
@ -494,8 +491,13 @@ position @code{position} (wrapper to the libc @code{fread}).
Return the next line from the file, assuming UTF-8 encoding, excluding
the trailing line feed.
@item readAsString(max_size = undefined)
Read @code{max_size} bytes from the file and return them as a string
assuming UTF-8 encoding. If @code{max_size} is not present, the file
is read up its end.
@item getByte()
Return the next byte from the file.
Return the next byte from the file. Return -1 if the end of file is reached.
@item putByte(c)
Write one byte to the file.


+ 151
- 0
examples/point.c View File

@ -0,0 +1,151 @@
/*
* QuickJS: Example of C module with a class
*
* Copyright (c) 2019 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "../quickjs.h"
#include <math.h>
#define countof(x) (sizeof(x) / sizeof((x)[0]))
/* Point Class */
typedef struct {
int x;
int y;
} JSPointData;
static JSClassID js_point_class_id;
static void js_point_finalizer(JSRuntime *rt, JSValue val)
{
JSPointData *s = JS_GetOpaque(val, js_point_class_id);
/* Note: 's' can be NULL in case JS_SetOpaque() was not called */
js_free_rt(rt, s);
}
static JSValue js_point_ctor(JSContext *ctx,
JSValueConst new_target,
int argc, JSValueConst *argv)
{
JSPointData *s;
JSValue obj = JS_UNDEFINED;
JSValue proto;
s = js_mallocz(ctx, sizeof(*s));
if (!s)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &s->x, argv[0]))
goto fail;
if (JS_ToInt32(ctx, &s->y, argv[1]))
goto fail;
/* using new_target to get the prototype is necessary when the
class is extended. */
proto = JS_GetPropertyStr(ctx, new_target, "prototype");
if (JS_IsException(proto))
goto fail;
obj = JS_NewObjectProtoClass(ctx, proto, js_point_class_id);
JS_FreeValue(ctx, proto);
if (JS_IsException(obj))
goto fail;
JS_SetOpaque(obj, s);
return obj;
fail:
js_free(ctx, s);
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, int magic)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
if (!s)
return JS_EXCEPTION;
if (magic == 0)
return JS_NewInt32(ctx, s->x);
else
return JS_NewInt32(ctx, s->y);
}
static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JSValue val, int magic)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
int v;
if (!s)
return JS_EXCEPTION;
if (JS_ToInt32(ctx, &v, val))
return JS_EXCEPTION;
if (magic == 0)
s->x = v;
else
s->y = v;
return JS_UNDEFINED;
}
static JSValue js_point_norm(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
if (!s)
return JS_EXCEPTION;
return JS_NewFloat64(ctx, sqrt((double)s->x * s->x + (double)s->y * s->y));
}
static JSClassDef js_point_class = {
"Point",
.finalizer = js_point_finalizer,
};
static const JSCFunctionListEntry js_point_proto_funcs[] = {
JS_CGETSET_MAGIC_DEF("x", js_point_get_xy, js_point_set_xy, 0),
JS_CGETSET_MAGIC_DEF("y", js_point_get_xy, js_point_set_xy, 1),
JS_CFUNC_DEF("norm", 0, js_point_norm),
};
static int js_point_init(JSContext *ctx, JSModuleDef *m)
{
JSValue point_proto, point_class;
/* create the Point class */
JS_NewClassID(&js_point_class_id);
JS_NewClass(JS_GetRuntime(ctx), js_point_class_id, &js_point_class);
point_proto = JS_NewObject(ctx);
JS_SetPropertyFunctionList(ctx, point_proto, js_point_proto_funcs, countof(js_point_proto_funcs));
JS_SetClassProto(ctx, js_point_class_id, point_proto);
point_class = JS_NewCFunction2(ctx, js_point_ctor, "Point", 2, JS_CFUNC_constructor, 0);
/* set proto.constructor and ctor.prototype */
JS_SetConstructor(ctx, point_class, point_proto);
JS_SetModuleExport(ctx, m, "Point", point_class);
return 0;
}
JSModuleDef *js_init_module(JSContext *ctx, const char *module_name)
{
JSModuleDef *m;
m = JS_NewCModule(ctx, module_name, js_point_init);
if (!m)
return NULL;
JS_AddModuleExport(ctx, m, "Point");
return m;
}

examples/c_module.js → examples/test_fib.js View File


+ 40
- 0
examples/test_point.js View File

@ -0,0 +1,40 @@
/* example of JS module importing a C module */
import { Point } from "./point.so";
function assert(b, str)
{
if (b) {
return;
} else {
throw Error("assertion failed: " + str);
}
}
class ColorPoint extends Point {
constructor(x, y, color) {
super(x, y);
this.color = color;
}
get_color() {
return this.color;
}
};
function main()
{
var pt, pt2;
pt = new Point(2, 3);
assert(pt.x === 2);
assert(pt.y === 3);
pt.x = 4;
assert(pt.x === 4);
assert(pt.norm() == 5);
pt2 = new ColorPoint(2, 3, 0xffffff);
assert(pt2.x === 2);
assert(pt2.color === 0xffffff);
assert(pt2.get_color() === 0xffffff);
}
main();

+ 81
- 33
quickjs.c View File

@ -7970,7 +7970,8 @@ retry:
}
if (p->is_exotic) {
if (p->class_id == JS_CLASS_ARRAY && p->fast_array) {
if (p->class_id == JS_CLASS_ARRAY && p->fast_array &&
__JS_AtomIsTaggedInt(prop)) {
uint32_t idx = __JS_AtomToUInt32(prop);
if (idx == p->u.array.count) {
/* fast case */
@ -20437,11 +20438,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name,
}
if (var_def_type != JS_VAR_DEF_FUNCTION_DECL &&
var_def_type != JS_VAR_DEF_NEW_FUNCTION_DECL &&
(fd->func_kind == JS_FUNC_ASYNC ||
fd->func_kind == JS_FUNC_GENERATOR ||
fd->func_kind == JS_FUNC_ASYNC_GENERATOR ||
fd->func_type == JS_PARSE_FUNC_METHOD ||
fd->scope_level == 1) &&
fd->scope_level == 1 &&
find_arg(ctx, fd, name) >= 0) {
/* lexical variable redefines a parameter name */
return js_parse_error(s, "invalid redefinition of parameter name");
@ -24026,9 +24023,10 @@ static void emit_return(JSParseState *s, BOOL hasval)
}
#define DECL_MASK_FUNC (1 << 0) /* allow normal function declaration */
#define DECL_MASK_LABEL (1 << 1) /* allow labelled statement */
/* ored with DECL_MASK_FUNC if function declarations are allowed with a label */
#define DECL_MASK_FUNC_WITH_LABEL (1 << 1)
#define DECL_MASK_OTHER (1 << 2) /* all other declarations */
#define DECL_MASK_ALL (DECL_MASK_FUNC | DECL_MASK_LABEL | DECL_MASK_OTHER)
#define DECL_MASK_ALL (DECL_MASK_FUNC | DECL_MASK_FUNC_WITH_LABEL | DECL_MASK_OTHER)
static __exception int js_parse_statement_or_decl(JSParseState *s,
int decl_mask);
@ -24463,10 +24461,6 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
if (is_label(s)) {
BlockEnv *be;
if (!(decl_mask & DECL_MASK_LABEL)) {
js_parse_error(s, "functions can only be labelled inside blocks");
goto fail;
}
label_name = JS_DupAtom(ctx, s->token.u.ident.atom);
for (be = s->cur_func->top_break; be; be = be->prev) {
@ -24490,11 +24484,12 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
label_break = new_label(s);
push_break_entry(s->cur_func, &break_entry,
label_name, label_break, -1, 0);
if (s->cur_func->js_mode & JS_MODE_STRICT)
if (!(s->cur_func->js_mode & JS_MODE_STRICT) &&
(decl_mask & DECL_MASK_FUNC_WITH_LABEL)) {
mask = DECL_MASK_FUNC | DECL_MASK_FUNC_WITH_LABEL;
} else {
mask = 0;
else
mask = DECL_MASK_FUNC;
mask |= DECL_MASK_LABEL;
}
if (js_parse_statement_or_decl(s, mask))
goto fail;
emit_label(s, label_break);
@ -26578,8 +26573,8 @@ static __exception int js_parse_export(JSParseState *s)
emit_atom(s, local_name);
emit_u16(s, 0);
if (add_export_entry(s, m, local_name, JS_ATOM_default,
JS_EXPORT_TYPE_LOCAL) < 0)
if (!add_export_entry(s, m, local_name, JS_ATOM_default,
JS_EXPORT_TYPE_LOCAL))
return -1;
break;
case TOK_VAR:
@ -28089,12 +28084,12 @@ static int find_private_class_field_all(JSContext *ctx, JSFunctionDef *fd,
static void get_loc_or_ref(DynBuf *bc, BOOL is_ref, int idx)
{
/* Note: the private field can be uninitialized, so the _check is
necessary */
/* if the field is not initialized, the error is catched when
accessing it */
if (is_ref)
dbuf_putc(bc, OP_get_var_ref_check);
dbuf_putc(bc, OP_get_var_ref);
else
dbuf_putc(bc, OP_get_loc_check);
dbuf_putc(bc, OP_get_loc);
dbuf_put_u16(bc, idx);
}
@ -33455,9 +33450,8 @@ static void JS_SetConstructor2(JSContext *ctx,
set_cycle_flag(ctx, proto);
}
static void JS_SetConstructor(JSContext *ctx,
JSValueConst func_obj,
JSValueConst proto)
void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
JSValueConst proto)
{
JS_SetConstructor2(ctx, func_obj, proto,
0, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
@ -37984,6 +37978,34 @@ static JSValue js_string_match(JSContext *ctx, JSValueConst this_val,
matcher = JS_GetProperty(ctx, regexp, atom);
if (JS_IsException(matcher))
return JS_EXCEPTION;
if (atom == JS_ATOM_Symbol_matchAll) {
int ret;
JSValue flags;
ret = js_is_regexp(ctx, regexp);
if (ret < 0)
goto fail1;
if (ret) {
flags = JS_GetProperty(ctx, regexp, JS_ATOM_flags);
if (JS_IsException(flags))
goto fail1;
if (JS_IsUndefined(flags) || JS_IsNull(flags)) {
JS_ThrowTypeError(ctx, "cannot convert to object");
goto fail1;
}
flags = JS_ToStringFree(ctx, flags);
if (JS_IsException(flags))
goto fail1;
ret = string_indexof_char(JS_VALUE_GET_STRING(flags), 'g', 0);
JS_FreeValue(ctx, flags);
if (ret < 0) {
JS_ThrowTypeError(ctx, "regexp must have the 'g' flag");
fail1:
JS_FreeValue(ctx, matcher);
return JS_EXCEPTION;
}
}
}
if (!JS_IsUndefined(matcher) && !JS_IsNull(matcher)) {
return JS_CallFree(ctx, matcher, regexp, 1, &O);
}
@ -42707,11 +42729,11 @@ static int js_proxy_get_own_property_names(JSContext *ctx,
len2 = 0;
if (js_get_length32(ctx, &len, prop_array))
goto fail;
if (len == 0)
goto done;
tab = js_mallocz(ctx, sizeof(tab[0]) * len);
if (!tab)
goto fail;
if (len > 0) {
tab = js_mallocz(ctx, sizeof(tab[0]) * len);
if (!tab)
goto fail;
}
for(i = 0; i < len; i++) {
val = JS_GetPropertyUint32(ctx, prop_array, i);
if (JS_IsException(val))
@ -42783,7 +42805,6 @@ static int js_proxy_get_own_property_names(JSContext *ctx,
}
}
done:
js_free_prop_enum(ctx, tab2, len2);
JS_FreeValue(ctx, prop_array);
*ptab = tab;
@ -45265,7 +45286,8 @@ static JSValue js_global_decodeURI(JSContext *ctx, JSValueConst this_val,
}
c = (c << 6) | (c1 & 0x3f);
}
if (c < c_min || c > 0x10FFFF) {
if (c < c_min || c > 0x10FFFF ||
(c >= 0xd800 && c < 0xe000)) {
js_throw_URIError(ctx, "malformed UTF-8");
goto fail;
}
@ -47817,6 +47839,32 @@ static JSValue js_typed_array_get_byteOffset(JSContext *ctx,
return JS_NewInt32(ctx, ta->offset);
}
/* Return the buffer associated to the typed array or an exception if
it is not a typed array or if the buffer is detached. pbyte_offset,
pbyte_length or pbytes_per_element can be NULL. */
JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
size_t *pbyte_offset,
size_t *pbyte_length,
size_t *pbytes_per_element)
{
JSObject *p;
JSTypedArray *ta;
p = get_typed_array(ctx, obj, FALSE);
if (!p)
return JS_EXCEPTION;
if (typed_array_is_detached(ctx, p))
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
ta = p->u.typed_array;
if (pbyte_offset)
*pbyte_offset = ta->offset;
if (pbyte_length)
*pbyte_length = ta->length;
if (pbytes_per_element) {
*pbytes_per_element = 1 << typed_array_size_log2(p->class_id);
}
return JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, ta->buffer));
}
static JSValue js_typed_array_get_toStringTag(JSContext *ctx,
JSValueConst this_val)
{
@ -48877,7 +48925,7 @@ struct TA_sort_context {
JSValueConst arr;
JSValueConst cmp;
JSValue (*getfun)(JSContext *ctx, const void *a);
void *array_ptr; /* cannot change unless the array is detached */
uint8_t *array_ptr; /* cannot change unless the array is detached */
int elt_size;
};


+ 8
- 0
quickjs.h View File

@ -684,6 +684,7 @@ int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
JSValueConst obj, JSAtom prop);
/* 'buf' must be zero terminated i.e. buf[buf_len] = '\0'. */
JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
const char *filename);
JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj,
@ -696,6 +697,7 @@ JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
JSValueConst new_target,
int argc, JSValueConst *argv);
JS_BOOL JS_DetectModule(const char *input, size_t input_len);
/* 'input' must be zero terminated i.e. input[input_len] = '\0'. */
JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
const char *filename, int eval_flags);
JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj);
@ -724,6 +726,10 @@ JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len);
void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj);
uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj);
JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
size_t *pbyte_offset,
size_t *pbyte_length,
size_t *pbytes_per_element);
JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs);
@ -825,6 +831,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun
{
return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
}
void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
JSValueConst proto);
/* C property definition */


+ 7
- 31
release.sh View File

@ -12,14 +12,12 @@ if [ "$1" = "-h" ] ; then
exit 1
fi
unicode="no"
tests="no"
extras="no"
binary="no"
quickjs="no"
if [ "$1" = "all" ] ; then
unicode="yes"
tests="yes"
extras="yes"
binary="yes"
quickjs="yes"
elif [ "$1" = "binary" ] ; then
@ -29,39 +27,18 @@ else
fi
#################################################"
# unicode data
# extras
if [ "$unicode" = "yes" ] ; then
if [ "$extras" = "yes" ] ; then
d="quickjs-${version}"
name="quickjs-unicode-data-${version}"
name="quickjs-extras-${version}"
outdir="/tmp/${d}"
rm -rf $outdir
mkdir -p $outdir $outdir/unicode
mkdir -p $outdir $outdir/unicode $outdir/tests
cp unicode/* $outdir/unicode
( cd /tmp && tar Jcvf /tmp/${name}.tar.xz ${d} )
fi
#################################################"
# all tests
if [ "$tests" = "yes" ] ; then
d="quickjs-${version}"
name="quickjs-tests-${version}"
outdir="/tmp/${d}"
rm -rf $outdir
mkdir -p $outdir $outdir/test262o $outdir/test262 $outdir/tests
cp -a test262o/test $outdir/test262o
cp -a test262/test test262/harness $outdir/test262
cp -a tests/bench-v8 $outdir/tests
( cd /tmp && tar Jcvf /tmp/${name}.tar.xz ${d} )
@ -113,12 +90,11 @@ cp Makefile VERSION TODO Changelog readme.txt release.sh unicode_download.sh \
libunicode.c libunicode.h libunicode-table.h \
libbf.c libbf.h \
jscompress.c unicode_gen.c unicode_gen_def.h \
bjson.c \
run-test262.c test262o.conf test262.conf test262bn.conf \
test262o_errors.txt test262_errors.txt test262bn_errors.txt \
$outdir
cp tests/*.js tests/*.patch $outdir/tests
cp tests/*.js tests/*.patch tests/bjson.c $outdir/tests
cp examples/*.js examples/*.c $outdir/examples


+ 2
- 0
test262.conf View File

@ -66,6 +66,7 @@ class-methods-private
class-static-fields-public
class-static-fields-private
class-static-methods-private
coalesce-expression=skip
computed-property-names
const
cross-realm=skip
@ -117,6 +118,7 @@ Reflect.set
Reflect.setPrototypeOf
regexp-dotall
regexp-lookbehind
regexp-match-indices=skip
regexp-named-groups
regexp-unicode-property-escapes
rest-parameters


+ 2
- 0
test262bn.conf View File

@ -67,6 +67,7 @@ class-methods-private
class-static-fields-public
class-static-fields-private
class-static-methods-private
coalesce-expression=skip
computed-property-names
const
cross-realm=skip
@ -118,6 +119,7 @@ Reflect.set
Reflect.setPrototypeOf
regexp-dotall
regexp-lookbehind
regexp-match-indices=skip
regexp-named-groups
regexp-unicode-property-escapes
rest-parameters


bjson.c → tests/bjson.c View File


+ 5
- 5
tests/test262.patch View File

@ -1,8 +1,8 @@
diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js
index 135c16e..b19f2ef 100644
index 9c1217351e..3c24755558 100644
--- a/harness/atomicsHelper.js
+++ b/harness/atomicsHelper.js
@@ -222,10 +222,14 @@ $262.agent.waitUntil = function(typedArray, index, expected) {
@@ -227,10 +227,14 @@ $262.agent.waitUntil = function(typedArray, index, expected) {
* }
*/
$262.agent.timeouts = {
@ -22,11 +22,11 @@ index 135c16e..b19f2ef 100644
/**
diff --git a/harness/regExpUtils.js b/harness/regExpUtils.js
index 2abfee3..e7c07b1 100644
index be7039fda0..7b38abf8df 100644
--- a/harness/regExpUtils.js
+++ b/harness/regExpUtils.js
@@ -5,24 +5,27 @@ description: |
Collection of functions used to assert the correctness of RegExp objects.
@@ -6,24 +6,27 @@ description: |
defines: [buildString, testPropertyEscapes, matchValidator]
---*/
+if ($262 && typeof $262.codePointRange === "function") {


+ 1
- 1
tests/test_bjson.js View File

@ -1,4 +1,4 @@
import * as bjson from "../bjson.so";
import * as bjson from "./bjson.so";
function assert(b, str)
{


+ 12
- 1
tests/test_op.js View File

@ -337,6 +337,17 @@ function test_regexp_skip()
assert(a === 2);
}
function test_labels()
{
do x: { break x; } while(0);
if (1)
x: { break x; }
else
x: { break x; }
with ({}) x: { break x; };
while (0) x: { break x; };
}
test_op1();
test_cvt();
test_eq();
@ -349,4 +360,4 @@ test_class();
test_template();
test_object_literal();
test_regexp_skip();
test_labels();

+ 1
- 0
unicode_gen.c View File

@ -296,6 +296,7 @@ void parse_unicode_data(const char *filename)
exit(1);
}
last_code = 0;
for(;;) {
if (!get_line(line, sizeof(line), f))
break;


Loading…
Cancel
Save