diff --git a/Makefile b/Makefile index 82de870f0..b7e31d3a5 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ codegen: $(QJSC) $(QJSC) -e -o gen/hello.c examples/hello.js $(QJSC) -e -o gen/hello_module.c -m examples/hello_module.js $(QJSC) -e -o gen/test_fib.c -M examples/fib.so,fib -m examples/test_fib.js - $(QJSC) -m -ss -o gen/builtin-array-fromasync.h builtin-array-fromasync.js + $(QJSC) -C -ss -o gen/builtin-array-fromasync.h builtin-array-fromasync.js debug: BUILD_TYPE=Debug $(MAKE) diff --git a/builtin-array-fromasync.js b/builtin-array-fromasync.js index 4820e14a1..a07e40eff 100644 --- a/builtin-array-fromasync.js +++ b/builtin-array-fromasync.js @@ -1,4 +1,5 @@ -export function go(Array, TypeError, asyncIterator, defineProperty, iterator) { +;(function(Array, TypeError, asyncIterator, defineProperty, iterator) { + "use strict" // result.length=i should throw if .length is not writable return async function fromAsync(arrayLike, mapFn=undefined, thisArg=undefined) { if (mapFn !== undefined && typeof mapFn !== "function") throw new TypeError("not a function") let result, i = 0, isConstructor = typeof this === "function" @@ -32,4 +33,4 @@ export function go(Array, TypeError, asyncIterator, defineProperty, iterator) { result.length = i return result } -} +}) diff --git a/gen/builtin-array-fromasync.h b/gen/builtin-array-fromasync.h index 12a31ee8c..21c4c5fc9 100644 --- a/gen/builtin-array-fromasync.h +++ b/gen/builtin-array-fromasync.h @@ -2,14 +2,10 @@ #include -const uint32_t qjsc_builtin_array_fromasync_size = 875; +const uint32_t qjsc_builtin_array_fromasync_size = 826; -const uint8_t qjsc_builtin_array_fromasync[875] = { - 0x13, 0x0f, 0x01, 0x34, 0x62, 0x75, 0x69, 0x6c, - 0x74, 0x69, 0x6e, 0x2d, 0x61, 0x72, 0x72, 0x61, - 0x79, 0x2d, 0x66, 0x72, 0x6f, 0x6d, 0x61, 0x73, - 0x79, 0x6e, 0x63, 0x2e, 0x6a, 0x73, 0x01, 0x04, - 0x67, 0x6f, 0x01, 0x1a, 0x61, 0x73, 0x79, 0x6e, +const uint8_t qjsc_builtin_array_fromasync[826] = { + 0x13, 0x0d, 0x01, 0x1a, 0x61, 0x73, 0x79, 0x6e, 0x63, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x01, 0x10, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x01, 0x12, 0x61, 0x72, 0x72, @@ -24,96 +20,94 @@ const uint8_t qjsc_builtin_array_fromasync[875] = { 0x69, 0x74, 0x65, 0x72, 0x01, 0x1c, 0x6e, 0x6f, 0x74, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x01, 0x08, 0x63, 0x61, - 0x6c, 0x6c, 0x0d, 0xc2, 0x03, 0x00, 0x01, 0x00, - 0x00, 0xc4, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x20, - 0x02, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x01, 0x01, 0x09, 0x00, 0xc4, 0x03, 0x00, 0x01, - 0x0c, 0x43, 0x02, 0x01, 0xc4, 0x03, 0x05, 0x00, - 0x05, 0x01, 0x00, 0x01, 0x03, 0x05, 0xaa, 0x02, - 0x00, 0x01, 0x40, 0x9e, 0x03, 0x00, 0x01, 0x40, - 0xc6, 0x03, 0x00, 0x01, 0x40, 0xcc, 0x01, 0x00, - 0x01, 0x40, 0xc8, 0x03, 0x00, 0x01, 0x40, 0x0c, - 0x60, 0x02, 0x01, 0xf8, 0x01, 0x03, 0x0e, 0x01, - 0x06, 0x05, 0x00, 0x86, 0x04, 0x11, 0xca, 0x03, - 0x00, 0x01, 0x00, 0xcc, 0x03, 0x00, 0x01, 0x00, - 0xce, 0x03, 0x00, 0x01, 0x00, 0xca, 0x03, 0x01, - 0xff, 0xff, 0xff, 0xff, 0x0f, 0x20, 0xcc, 0x03, - 0x01, 0x01, 0x20, 0xce, 0x03, 0x01, 0x02, 0x20, - 0xd0, 0x03, 0x02, 0x00, 0x20, 0xd2, 0x03, 0x02, - 0x04, 0x20, 0xd4, 0x03, 0x02, 0x05, 0x20, 0xd6, - 0x03, 0x02, 0x06, 0x20, 0xd8, 0x03, 0x02, 0x07, - 0x20, 0x64, 0x06, 0x08, 0x20, 0x82, 0x01, 0x07, - 0x09, 0x20, 0xda, 0x03, 0x0a, 0x08, 0x30, 0x82, - 0x01, 0x0d, 0x0b, 0x20, 0xd4, 0x01, 0x0d, 0x0c, - 0x20, 0x10, 0x00, 0x01, 0x00, 0x9e, 0x03, 0x01, - 0x03, 0xc6, 0x03, 0x02, 0x03, 0xc8, 0x03, 0x04, - 0x03, 0xaa, 0x02, 0x00, 0x03, 0xcc, 0x01, 0x03, - 0x03, 0x08, 0xc3, 0x0d, 0x62, 0x02, 0x00, 0x62, - 0x01, 0x00, 0x62, 0x00, 0x00, 0xd2, 0xca, 0xd3, - 0x11, 0xf3, 0xeb, 0x08, 0x0e, 0x39, 0x46, 0x00, - 0x00, 0x00, 0xdb, 0xcb, 0xd4, 0x11, 0xf3, 0xeb, - 0x08, 0x0e, 0x39, 0x46, 0x00, 0x00, 0x00, 0xdc, - 0xcc, 0x62, 0x07, 0x00, 0x62, 0x06, 0x00, 0x62, - 0x05, 0x00, 0x62, 0x04, 0x00, 0x62, 0x03, 0x00, - 0xd3, 0x39, 0x46, 0x00, 0x00, 0x00, 0xb0, 0xeb, - 0x16, 0xd3, 0x98, 0x04, 0x1b, 0x00, 0x00, 0x00, - 0xb0, 0xeb, 0x0c, 0xde, 0x11, 0x04, 0xee, 0x00, - 0x00, 0x00, 0x21, 0x01, 0x00, 0x30, 0x06, 0xcd, - 0xb5, 0xc3, 0x04, 0xc2, 0x0d, 0xf6, 0xc3, 0x05, - 0x09, 0xc3, 0x06, 0xd2, 0xdf, 0x48, 0xc3, 0x07, - 0x63, 0x07, 0x00, 0x07, 0xad, 0xeb, 0x0f, 0x0a, - 0x11, 0x64, 0x06, 0x00, 0x0e, 0xd2, 0xe0, 0x48, - 0x11, 0x64, 0x07, 0x00, 0x0e, 0x63, 0x07, 0x00, - 0x07, 0xad, 0x6a, 0xa6, 0x00, 0x00, 0x00, 0x62, - 0x08, 0x00, 0x06, 0x11, 0xf3, 0xec, 0x0c, 0x71, - 0x43, 0x32, 0x00, 0x00, 0x00, 0xc3, 0x08, 0x0e, - 0xed, 0x05, 0x0e, 0xd2, 0xed, 0xf2, 0x63, 0x08, - 0x00, 0x8e, 0x11, 0xec, 0x03, 0x0e, 0xb5, 0x11, - 0x64, 0x08, 0x00, 0x0e, 0x63, 0x05, 0x00, 0xeb, - 0x0c, 0xc2, 0x0d, 0x11, 0x63, 0x08, 0x00, 0x21, - 0x01, 0x00, 0xed, 0x06, 0xe1, 0x63, 0x08, 0x00, - 0xf0, 0x11, 0x64, 0x03, 0x00, 0x0e, 0x63, 0x04, - 0x00, 0x63, 0x08, 0x00, 0xa7, 0x6a, 0x2a, 0x01, - 0x00, 0x00, 0x62, 0x09, 0x00, 0xd2, 0x63, 0x04, - 0x00, 0x48, 0xc3, 0x09, 0x63, 0x06, 0x00, 0xeb, - 0x0a, 0x63, 0x09, 0x00, 0x8c, 0x11, 0x64, 0x09, - 0x00, 0x0e, 0xd3, 0xeb, 0x17, 0xd3, 0x43, 0xef, - 0x00, 0x00, 0x00, 0xd4, 0x63, 0x09, 0x00, 0x63, - 0x04, 0x00, 0x24, 0x03, 0x00, 0x8c, 0x11, 0x64, - 0x09, 0x00, 0x0e, 0x5f, 0x04, 0x00, 0x63, 0x03, - 0x00, 0x63, 0x04, 0x00, 0x92, 0x64, 0x04, 0x00, - 0x0b, 0x63, 0x09, 0x00, 0x4d, 0x41, 0x00, 0x00, - 0x00, 0x0a, 0x4d, 0x3e, 0x00, 0x00, 0x00, 0x0a, - 0x4d, 0x3f, 0x00, 0x00, 0x00, 0xf2, 0x0e, 0xed, - 0x9e, 0x62, 0x0a, 0x00, 0x63, 0x07, 0x00, 0x43, - 0xef, 0x00, 0x00, 0x00, 0xd2, 0x24, 0x01, 0x00, - 0xc3, 0x0a, 0x63, 0x05, 0x00, 0xeb, 0x09, 0xc2, - 0x0d, 0x11, 0x21, 0x00, 0x00, 0xed, 0x03, 0xe1, - 0xef, 0x11, 0x64, 0x03, 0x00, 0x0e, 0x6d, 0x8c, - 0x00, 0x00, 0x00, 0x62, 0x0c, 0x00, 0x62, 0x0b, - 0x00, 0x06, 0x11, 0xf3, 0xec, 0x13, 0x71, 0x43, - 0x41, 0x00, 0x00, 0x00, 0xc3, 0x0b, 0x43, 0x6a, - 0x00, 0x00, 0x00, 0xc3, 0x0c, 0x0e, 0xed, 0x10, - 0x0e, 0x63, 0x0a, 0x00, 0x43, 0x6b, 0x00, 0x00, - 0x00, 0x24, 0x00, 0x00, 0x8c, 0xed, 0xe0, 0x63, - 0x0c, 0x00, 0xec, 0x4e, 0x63, 0x06, 0x00, 0xeb, - 0x0a, 0x63, 0x0b, 0x00, 0x8c, 0x11, 0x64, 0x0b, - 0x00, 0x0e, 0xd3, 0xeb, 0x17, 0xd3, 0x43, 0xef, - 0x00, 0x00, 0x00, 0xd4, 0x63, 0x0b, 0x00, 0x63, - 0x04, 0x00, 0x24, 0x03, 0x00, 0x8c, 0x11, 0x64, - 0x0b, 0x00, 0x0e, 0x5f, 0x04, 0x00, 0x63, 0x03, - 0x00, 0x63, 0x04, 0x00, 0x92, 0x64, 0x04, 0x00, - 0x0b, 0x63, 0x0b, 0x00, 0x4d, 0x41, 0x00, 0x00, - 0x00, 0x0a, 0x4d, 0x3e, 0x00, 0x00, 0x00, 0x0a, - 0x4d, 0x3f, 0x00, 0x00, 0x00, 0xf2, 0x0e, 0xed, - 0x83, 0x0e, 0x06, 0x6e, 0x0d, 0x00, 0x00, 0x00, - 0x0e, 0xed, 0x1e, 0x6e, 0x05, 0x00, 0x00, 0x00, - 0x30, 0x63, 0x0a, 0x00, 0x42, 0x06, 0x00, 0x00, - 0x00, 0xeb, 0x0d, 0x63, 0x0a, 0x00, 0x43, 0x06, - 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x0e, 0x6f, - 0x63, 0x03, 0x00, 0x63, 0x04, 0x00, 0x44, 0x32, - 0x00, 0x00, 0x00, 0x63, 0x03, 0x00, 0x2f, 0xc0, - 0x00, 0x28, 0x08, 0xeb, 0x05, 0xc0, 0x00, 0xe2, - 0x29, 0x06, 0x2f, + 0x6c, 0x6c, 0x0c, 0x00, 0x02, 0x00, 0xa2, 0x01, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, + 0xa4, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x43, 0x02, + 0x01, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x01, + 0x03, 0x05, 0xaa, 0x02, 0x00, 0x01, 0x40, 0x9e, + 0x03, 0x00, 0x01, 0x40, 0xc2, 0x03, 0x00, 0x01, + 0x40, 0xcc, 0x01, 0x00, 0x01, 0x40, 0xc4, 0x03, + 0x00, 0x01, 0x40, 0x0c, 0x60, 0x02, 0x01, 0xf8, + 0x01, 0x03, 0x0e, 0x01, 0x06, 0x05, 0x00, 0x86, + 0x04, 0x11, 0xc6, 0x03, 0x00, 0x01, 0x00, 0xc8, + 0x03, 0x00, 0x01, 0x00, 0xca, 0x03, 0x00, 0x01, + 0x00, 0xc6, 0x03, 0x01, 0xff, 0xff, 0xff, 0xff, + 0x0f, 0x20, 0xc8, 0x03, 0x01, 0x01, 0x20, 0xca, + 0x03, 0x01, 0x02, 0x20, 0xcc, 0x03, 0x02, 0x00, + 0x20, 0xce, 0x03, 0x02, 0x04, 0x20, 0xd0, 0x03, + 0x02, 0x05, 0x20, 0xd2, 0x03, 0x02, 0x06, 0x20, + 0xd4, 0x03, 0x02, 0x07, 0x20, 0x64, 0x06, 0x08, + 0x20, 0x82, 0x01, 0x07, 0x09, 0x20, 0xd6, 0x03, + 0x0a, 0x08, 0x30, 0x82, 0x01, 0x0d, 0x0b, 0x20, + 0xd4, 0x01, 0x0d, 0x0c, 0x20, 0x10, 0x00, 0x01, + 0x00, 0x9e, 0x03, 0x01, 0x03, 0xc2, 0x03, 0x02, + 0x03, 0xc4, 0x03, 0x04, 0x03, 0xaa, 0x02, 0x00, + 0x03, 0xcc, 0x01, 0x03, 0x03, 0x08, 0xc3, 0x0d, + 0x62, 0x02, 0x00, 0x62, 0x01, 0x00, 0x62, 0x00, + 0x00, 0xd2, 0xca, 0xd3, 0x11, 0xf3, 0xeb, 0x08, + 0x0e, 0x39, 0x46, 0x00, 0x00, 0x00, 0xdb, 0xcb, + 0xd4, 0x11, 0xf3, 0xeb, 0x08, 0x0e, 0x39, 0x46, + 0x00, 0x00, 0x00, 0xdc, 0xcc, 0x62, 0x07, 0x00, + 0x62, 0x06, 0x00, 0x62, 0x05, 0x00, 0x62, 0x04, + 0x00, 0x62, 0x03, 0x00, 0xd3, 0x39, 0x46, 0x00, + 0x00, 0x00, 0xb0, 0xeb, 0x16, 0xd3, 0x98, 0x04, + 0x1b, 0x00, 0x00, 0x00, 0xb0, 0xeb, 0x0c, 0xde, + 0x11, 0x04, 0xec, 0x00, 0x00, 0x00, 0x21, 0x01, + 0x00, 0x30, 0x06, 0xcd, 0xb5, 0xc3, 0x04, 0xc2, + 0x0d, 0xf6, 0xc3, 0x05, 0x09, 0xc3, 0x06, 0xd2, + 0xdf, 0x48, 0xc3, 0x07, 0x63, 0x07, 0x00, 0x07, + 0xad, 0xeb, 0x0f, 0x0a, 0x11, 0x64, 0x06, 0x00, + 0x0e, 0xd2, 0xe0, 0x48, 0x11, 0x64, 0x07, 0x00, + 0x0e, 0x63, 0x07, 0x00, 0x07, 0xad, 0x6a, 0xa6, + 0x00, 0x00, 0x00, 0x62, 0x08, 0x00, 0x06, 0x11, + 0xf3, 0xec, 0x0c, 0x71, 0x43, 0x32, 0x00, 0x00, + 0x00, 0xc3, 0x08, 0x0e, 0xed, 0x05, 0x0e, 0xd2, + 0xed, 0xf2, 0x63, 0x08, 0x00, 0x8e, 0x11, 0xec, + 0x03, 0x0e, 0xb5, 0x11, 0x64, 0x08, 0x00, 0x0e, + 0x63, 0x05, 0x00, 0xeb, 0x0c, 0xc2, 0x0d, 0x11, + 0x63, 0x08, 0x00, 0x21, 0x01, 0x00, 0xed, 0x06, + 0xe1, 0x63, 0x08, 0x00, 0xf0, 0x11, 0x64, 0x03, + 0x00, 0x0e, 0x63, 0x04, 0x00, 0x63, 0x08, 0x00, + 0xa7, 0x6a, 0x2a, 0x01, 0x00, 0x00, 0x62, 0x09, + 0x00, 0xd2, 0x63, 0x04, 0x00, 0x48, 0xc3, 0x09, + 0x63, 0x06, 0x00, 0xeb, 0x0a, 0x63, 0x09, 0x00, + 0x8c, 0x11, 0x64, 0x09, 0x00, 0x0e, 0xd3, 0xeb, + 0x17, 0xd3, 0x43, 0xed, 0x00, 0x00, 0x00, 0xd4, + 0x63, 0x09, 0x00, 0x63, 0x04, 0x00, 0x24, 0x03, + 0x00, 0x8c, 0x11, 0x64, 0x09, 0x00, 0x0e, 0x5f, + 0x04, 0x00, 0x63, 0x03, 0x00, 0x63, 0x04, 0x00, + 0x92, 0x64, 0x04, 0x00, 0x0b, 0x63, 0x09, 0x00, + 0x4d, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3e, + 0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3f, 0x00, 0x00, + 0x00, 0xf2, 0x0e, 0xed, 0x9e, 0x62, 0x0a, 0x00, + 0x63, 0x07, 0x00, 0x43, 0xed, 0x00, 0x00, 0x00, + 0xd2, 0x24, 0x01, 0x00, 0xc3, 0x0a, 0x63, 0x05, + 0x00, 0xeb, 0x09, 0xc2, 0x0d, 0x11, 0x21, 0x00, + 0x00, 0xed, 0x03, 0xe1, 0xef, 0x11, 0x64, 0x03, + 0x00, 0x0e, 0x6d, 0x8c, 0x00, 0x00, 0x00, 0x62, + 0x0c, 0x00, 0x62, 0x0b, 0x00, 0x06, 0x11, 0xf3, + 0xec, 0x13, 0x71, 0x43, 0x41, 0x00, 0x00, 0x00, + 0xc3, 0x0b, 0x43, 0x6a, 0x00, 0x00, 0x00, 0xc3, + 0x0c, 0x0e, 0xed, 0x10, 0x0e, 0x63, 0x0a, 0x00, + 0x43, 0x6b, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, + 0x8c, 0xed, 0xe0, 0x63, 0x0c, 0x00, 0xec, 0x4e, + 0x63, 0x06, 0x00, 0xeb, 0x0a, 0x63, 0x0b, 0x00, + 0x8c, 0x11, 0x64, 0x0b, 0x00, 0x0e, 0xd3, 0xeb, + 0x17, 0xd3, 0x43, 0xed, 0x00, 0x00, 0x00, 0xd4, + 0x63, 0x0b, 0x00, 0x63, 0x04, 0x00, 0x24, 0x03, + 0x00, 0x8c, 0x11, 0x64, 0x0b, 0x00, 0x0e, 0x5f, + 0x04, 0x00, 0x63, 0x03, 0x00, 0x63, 0x04, 0x00, + 0x92, 0x64, 0x04, 0x00, 0x0b, 0x63, 0x0b, 0x00, + 0x4d, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3e, + 0x00, 0x00, 0x00, 0x0a, 0x4d, 0x3f, 0x00, 0x00, + 0x00, 0xf2, 0x0e, 0xed, 0x83, 0x0e, 0x06, 0x6e, + 0x0d, 0x00, 0x00, 0x00, 0x0e, 0xed, 0x1e, 0x6e, + 0x05, 0x00, 0x00, 0x00, 0x30, 0x63, 0x0a, 0x00, + 0x42, 0x06, 0x00, 0x00, 0x00, 0xeb, 0x0d, 0x63, + 0x0a, 0x00, 0x43, 0x06, 0x00, 0x00, 0x00, 0x24, + 0x00, 0x00, 0x0e, 0x6f, 0x63, 0x03, 0x00, 0x63, + 0x04, 0x00, 0x44, 0x32, 0x00, 0x00, 0x00, 0x63, + 0x03, 0x00, 0x2f, 0xc0, 0x00, 0x28, 0xc0, 0x00, + 0xce, 0x28, }; diff --git a/qjs.c b/qjs.c index d2a68dfc1..4eed52efa 100644 --- a/qjs.c +++ b/qjs.c @@ -382,8 +382,8 @@ void help(void) "-h --help list options\n" "-e --eval EXPR evaluate EXPR\n" "-i --interactive go to interactive mode\n" - "-m --module load as ES6 module (default=autodetect)\n" - " --script load as ES6 script (default=autodetect)\n" + "-C --script load as JS classic script (default=autodetect)\n" + "-m --module load as ES module (default=autodetect)\n" "-I --include file include an additional file\n" " --std make 'std', 'os' and 'bjson' available to script\n" "-T --trace trace memory allocation\n" @@ -498,7 +498,7 @@ int main(int argc, char **argv) module = 1; continue; } - if (!strcmp(longopt, "script")) { + if (opt == 'C' || !strcmp(longopt, "script")) { module = 0; continue; } diff --git a/qjsc.c b/qjsc.c index 6e12b341d..8fb143545 100644 --- a/qjsc.c +++ b/qjsc.c @@ -347,7 +347,8 @@ void help(void) "-o output set the output filename\n" "-n script_name set the script name (as used in stack traces)\n" "-N cname set the C name of the generated data\n" - "-m compile as Javascript module (default=autodetect)\n" + "-C compile as JS classic script (default=autodetect)\n" + "-m compile as ES module (default=autodetect)\n" "-D module_name compile a dynamically loaded module or worker\n" "-M module_name[,cname] add initialization code for an external C module\n" "-p prefix set the prefix of the generated C names\n" @@ -390,7 +391,7 @@ int main(int argc, char **argv) namelist_add(&cmodule_list, "bjson", "bjson", 0); for(;;) { - c = getopt(argc, argv, "ho:N:mn:bxesvM:p:S:D:"); + c = getopt(argc, argv, "ho:N:Cmn:bxesvM:p:S:D:"); if (c == -1) break; switch(c) { @@ -411,6 +412,9 @@ int main(int argc, char **argv) case 'N': cname = optarg; break; + case 'C': + module = 0; + break; case 'm': module = 1; break; diff --git a/quickjs.c b/quickjs.c index af1c71460..ba4cf1ad0 100644 --- a/quickjs.c +++ b/quickjs.c @@ -7409,16 +7409,10 @@ static JSValue js_bytecode_autoinit(JSContext *ctx, JSObject *p, JSAtom atom, JS_READ_OBJ_BYTECODE); if (JS_IsException(obj)) return JS_EXCEPTION; - JSValue mod = JS_EvalFunction(ctx, obj); - JS_FreeValue(ctx, obj); - if (JS_IsException(mod)) + JSValue fun = JS_EvalFunction(ctx, obj); + if (JS_IsException(fun)) return JS_EXCEPTION; - assert(JS_IsModule(obj)); - JSModuleDef *m = JS_VALUE_GET_PTR(obj); - assert(m->export_entries_count == 1); - JSExportEntry *e = &m->export_entries[0]; - assert(e->export_type == JS_EXPORT_TYPE_LOCAL); - JSVarRef *v = e->u.local.var_ref; + assert(JS_IsFunction(ctx, fun)); JSValue args[] = { JS_NewCFunction(ctx, js_array_constructor, "Array", 0), JS_NewCFunctionMagic(ctx, js_error_constructor, "TypeError", 1, @@ -7430,11 +7424,11 @@ static JSValue js_bytecode_autoinit(JSContext *ctx, JSObject *p, JSAtom atom, JS_CFUNC_generic_magic, 0), JS_AtomToValue(ctx, JS_ATOM_Symbol_iterator), }; - JSValue result = JS_Call(ctx, v->value, JS_UNDEFINED, + JSValue result = JS_Call(ctx, fun, JS_UNDEFINED, countof(args), vc(args)); for (size_t i = 0; i < countof(args); i++) JS_FreeValue(ctx, args[i]); - JS_FreeValue(ctx, mod); + JS_FreeValue(ctx, fun); return result; } }