Check-in all generated C files

Closes: https://github.com/quickjs-ng/quickjs/issues/262
This commit is contained in:
Saúl Ibarra Corretgé 2024-02-12 15:45:42 +01:00
parent 7ded62c536
commit 7f928d289f
8 changed files with 13181 additions and 51 deletions

View file

@ -15,6 +15,15 @@ on:
- master
jobs:
codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: build
run: |
make codegen
- name: Check if the git repository is clean
run: $(exit $(git status --porcelain --untracked-files=no | head -255 | wc -l)) || (echo "Dirty git tree"; git diff; exit 1)
linux:
runs-on: ubuntu-latest
strategy:

View file

@ -5,9 +5,6 @@ project(quickjs LANGUAGES C)
include(CheckCCompilerFlag)
include(GNUInstallDirs)
# TODO:
# - Support cross-compilation
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
@ -183,19 +180,10 @@ target_link_libraries(qjsc ${qjs_libs})
# QuickJS CLI
#
add_custom_command(
OUTPUT repl.c
COMMAND qjsc -o ./repl.c -m ${CMAKE_CURRENT_SOURCE_DIR}/repl.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile repl.js to bytecode"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/repl.js
)
add_executable(qjs_exe
gen/repl.c
qjs.c
quickjs-libc.c
${CMAKE_CURRENT_BINARY_DIR}/repl.c
)
set_target_properties(qjs_exe PROPERTIES
OUTPUT_NAME "qjs"
@ -236,16 +224,8 @@ add_executable(unicode_gen EXCLUDE_FROM_ALL
)
target_compile_definitions(unicode_gen PRIVATE ${qjs_defines})
add_custom_command(
OUTPUT function_source.c
COMMAND qjsc -e -o function_source.c ${CMAKE_CURRENT_SOURCE_DIR}/tests/function_source.js
DEPENDS qjsc ${CMAKE_CURRENT_SOURCE_DIR}/tests/function_source.js
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile function_source.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/function_source.js
)
add_executable(function_source
${CMAKE_CURRENT_BINARY_DIR}/function_source.c
gen/function_source.c
quickjs-libc.c
)
target_include_directories(function_source PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
@ -256,32 +236,16 @@ target_link_libraries(function_source ${qjs_libs})
#
if(BUILD_EXAMPLES AND NOT WIN32)
add_custom_command(
OUTPUT hello.c
COMMAND qjsc -e -o hello.c ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile hello.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
)
add_executable(hello
${CMAKE_CURRENT_BINARY_DIR}/hello.c
gen/hello.c
quickjs-libc.c
)
target_include_directories(hello PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(hello PRIVATE ${qjs_defines})
target_link_libraries(hello ${qjs_libs})
add_custom_command(
OUTPUT hello_module.c
COMMAND qjsc -e -o hello_module.c -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile hello_module.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
)
add_executable(hello_module
${CMAKE_CURRENT_BINARY_DIR}/hello_module.c
gen/hello_module.c
quickjs-libc.c
)
target_include_directories(hello_module PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
@ -320,17 +284,9 @@ if(BUILD_EXAMPLES AND NOT WIN32)
endif()
endif()
add_custom_command(
OUTPUT test_fib.c
COMMAND qjsc -e -o test_fib.c -M ${CMAKE_CURRENT_SOURCE_DIR}/examples/fib.so,fib -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/test_fib.js
DEPENDS qjsc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compile test_fib.js to a C file with bytecode embedded"
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/examples/test_fib.js
)
add_executable(test_fib
${CMAKE_CURRENT_BINARY_DIR}/test_fib.c
examples/fib.c
gen/test_fib.c
quickjs-libc.c
)
target_include_directories(test_fib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

View file

@ -28,6 +28,7 @@ BUILD_DIR=build
BUILD_TYPE?=Release
QJS=$(BUILD_DIR)/qjs
QJSC=$(BUILD_DIR)/qjsc
RUN262=$(BUILD_DIR)/run-test262
JOBS?=$(shell getconf _NPROCESSORS_ONLN)
@ -49,12 +50,22 @@ $(BUILD_DIR):
$(QJS): $(BUILD_DIR)
cmake --build $(BUILD_DIR) -j $(JOBS)
install: $(QJS)
$(QJSC): $(BUILD_DIR)
cmake --build $(BUILD_DIR) --target qjsc -j $(JOBS)
install: $(QJS) $(QJSC)
cmake --build $(BUILD_DIR) --target install
clean:
cmake --build $(BUILD_DIR) --target clean
codegen: $(QJSC)
$(QJSC) -o gen/repl.c -m repl.js
$(QJSC) -e -o gen/function_source.c tests/function_source.js
$(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
debug:
BUILD_TYPE=Debug $(MAKE)
@ -92,4 +103,4 @@ unicode_gen: $(BUILD_DIR)
libunicode-table.h: unicode_gen
$(BUILD_DIR)/unicode_gen unicode $@
.PHONY: all debug install clean distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS)
.PHONY: all debug install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC)

84
gen/function_source.c Normal file
View file

@ -0,0 +1,84 @@
/* File generated automatically by the QuickJS-ng compiler. */
#include "quickjs-libc.h"
const uint32_t qjsc_function_source_size = 393;
const uint8_t qjsc_function_source[393] = {
0x08, 0x06, 0x0c, 0x61, 0x63, 0x74, 0x75, 0x61,
0x6c, 0x02, 0x66, 0x0c, 0x65, 0x78, 0x70, 0x65,
0x63, 0x74, 0x14, 0x75, 0x73, 0x65, 0x20, 0x73,
0x74, 0x72, 0x69, 0x63, 0x74, 0x34, 0x66, 0x75,
0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66,
0x28, 0x29, 0x20, 0x7b, 0x20, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6e, 0x20, 0x34, 0x32, 0x20, 0x7d,
0x30, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x66,
0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f,
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x6a,
0x73, 0x0c, 0x00, 0x02, 0x01, 0x9e, 0x01, 0x00,
0x06, 0x00, 0x03, 0x00, 0x01, 0xa0, 0x01, 0x06,
0xa0, 0x01, 0x00, 0x00, 0x00, 0xac, 0x03, 0x02,
0x00, 0x30, 0xae, 0x03, 0x04, 0x00, 0x70, 0xac,
0x03, 0x04, 0x03, 0x70, 0x10, 0x00, 0x01, 0x00,
0xe0, 0x01, 0x00, 0x01, 0x00, 0x0c, 0x03, 0xc1,
0x05, 0x08, 0xc1, 0x04, 0x3f, 0xd8, 0x00, 0x00,
0x00, 0x80, 0x3f, 0xd7, 0x00, 0x00, 0x00, 0x40,
0x3e, 0xd8, 0x00, 0x00, 0x00, 0x80, 0xbe, 0x00,
0x40, 0xd7, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd9,
0x00, 0x00, 0x00, 0xc8, 0x04, 0xda, 0x00, 0x00,
0x00, 0x3a, 0xd8, 0x00, 0x00, 0x00, 0x61, 0x01,
0x00, 0x38, 0xd7, 0x00, 0x00, 0x00, 0x42, 0x36,
0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0xc9, 0x06,
0xc8, 0x62, 0x01, 0x00, 0x38, 0xd8, 0x00, 0x00,
0x00, 0xaf, 0xe9, 0x0b, 0x38, 0x8f, 0x00, 0x00,
0x00, 0x62, 0x01, 0x00, 0xee, 0x2f, 0x61, 0x03,
0x00, 0x61, 0x02, 0x00, 0x38, 0x39, 0x00, 0x00,
0x00, 0x38, 0xd8, 0x00, 0x00, 0x00, 0x04, 0xd7,
0x00, 0x00, 0x00, 0x9d, 0x31, 0x01, 0x00, 0x04,
0x00, 0xca, 0x62, 0x02, 0x00, 0x42, 0x36, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0xcb, 0x06, 0xc8,
0x62, 0x03, 0x00, 0x38, 0xd8, 0x00, 0x00, 0x00,
0xaf, 0xe9, 0x0b, 0x38, 0x8f, 0x00, 0x00, 0x00,
0x62, 0x03, 0x00, 0xee, 0x2f, 0x68, 0x03, 0x00,
0x68, 0x02, 0x00, 0xc4, 0x28, 0xb6, 0x03, 0x01,
0x01, 0x28, 0x60, 0x01, 0x49, 0x02, 0x21, 0x1a,
0x1b, 0x04, 0x1e, 0x1d, 0x12, 0x26, 0x49, 0x1d,
0x0c, 0x06, 0x11, 0x18, 0x2a, 0x1c, 0x37, 0x41,
0x21, 0x1c, 0x34, 0x18, 0x1b, 0x04, 0x26, 0x11,
0x3f, 0x1d, 0x0c, 0x06, 0x11, 0x18, 0x2a, 0x1c,
0x53, 0x41, 0x00, 0xff, 0x49, 0x43, 0x01, 0x6c,
0x0c, 0x43, 0x02, 0x01, 0xae, 0x03, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0xbb, 0x2a,
0x28, 0xb6, 0x03, 0x03, 0x01, 0x04, 0x02, 0x1e,
0x0c, 0x0e, 0x1a, 0x66, 0x75, 0x6e, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x20, 0x66, 0x28, 0x29, 0x20,
0x7b, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x34, 0x32, 0x20, 0x7d, 0xff, 0x49, 0x43,
0x00,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
{
JSContext *ctx = JS_NewContext(rt);
if (!ctx)
return NULL;
return ctx;
}
int main(int argc, char **argv)
{
JSRuntime *rt;
JSContext *ctx;
rt = JS_NewRuntime();
js_std_set_worker_new_context_func(JS_NewCustomContext);
js_std_init_handlers(rt);
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
ctx = JS_NewCustomContext(rt);
js_std_add_helpers(ctx, argc, argv);
js_std_eval_binary(ctx, qjsc_function_source, qjsc_function_source_size, 0);
js_std_loop(ctx);
JS_FreeContext(ctx);
js_std_free_handlers(rt);
JS_FreeRuntime(rt);
return 0;
}

46
gen/hello.c Normal file
View file

@ -0,0 +1,46 @@
/* File generated automatically by the QuickJS-ng compiler. */
#include "quickjs-libc.h"
const uint32_t qjsc_hello_size = 95;
const uint8_t qjsc_hello[95] = {
0x08, 0x04, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
0x6c, 0x65, 0x06, 0x6c, 0x6f, 0x67, 0x16, 0x48,
0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72,
0x6c, 0x64, 0x22, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x2e, 0x6a, 0x73, 0x0c, 0x00, 0x02, 0x00,
0x9e, 0x01, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00,
0x14, 0x01, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x38,
0xd6, 0x00, 0x00, 0x00, 0x42, 0xd7, 0x00, 0x00,
0x00, 0x04, 0xd8, 0x00, 0x00, 0x00, 0x24, 0x01,
0x00, 0xcc, 0x28, 0xb2, 0x03, 0x01, 0x01, 0x00,
0x00, 0xff, 0x49, 0x43, 0x01, 0xae, 0x03,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
{
JSContext *ctx = JS_NewContext(rt);
if (!ctx)
return NULL;
return ctx;
}
int main(int argc, char **argv)
{
JSRuntime *rt;
JSContext *ctx;
rt = JS_NewRuntime();
js_std_set_worker_new_context_func(JS_NewCustomContext);
js_std_init_handlers(rt);
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
ctx = JS_NewCustomContext(rt);
js_std_add_helpers(ctx, argc, argv);
js_std_eval_binary(ctx, qjsc_hello, qjsc_hello_size, 0);
js_std_loop(ctx);
JS_FreeContext(ctx);
js_std_free_handlers(rt);
JS_FreeRuntime(rt);
return 0;
}

103
gen/hello_module.c Normal file
View file

@ -0,0 +1,103 @@
/* File generated automatically by the QuickJS-ng compiler. */
#include "quickjs-libc.h"
const uint32_t qjsc_fib_module_size = 318;
const uint8_t qjsc_fib_module[318] = {
0x08, 0x03, 0x2c, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x62, 0x5f,
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x6a,
0x73, 0x06, 0x66, 0x69, 0x62, 0x02, 0x6e, 0x0d,
0xac, 0x03, 0x00, 0x01, 0x00, 0x00, 0xae, 0x03,
0x00, 0x00, 0x0c, 0x20, 0x02, 0x01, 0x9e, 0x01,
0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09, 0x00,
0xae, 0x03, 0x00, 0x01, 0x08, 0xe9, 0x05, 0xbe,
0x00, 0xe0, 0x29, 0x06, 0x2e, 0xac, 0x03, 0x01,
0x01, 0x06, 0x01, 0x01, 0x00, 0x07, 0x14, 0x02,
0x00, 0xff, 0x49, 0x43, 0x00, 0x0c, 0x43, 0x02,
0x01, 0xae, 0x03, 0x01, 0x00, 0x01, 0x04, 0x01,
0x00, 0x1a, 0x01, 0xb0, 0x03, 0x00, 0x01, 0x00,
0xae, 0x03, 0x00, 0x00, 0xd0, 0xb3, 0xa7, 0xe9,
0x03, 0xb3, 0x28, 0xd0, 0xb4, 0xac, 0xe9, 0x03,
0xb4, 0x28, 0xdc, 0xd0, 0xb4, 0x9e, 0xee, 0xdc,
0xd0, 0xb5, 0x9e, 0xee, 0x9d, 0x28, 0xac, 0x03,
0x02, 0x08, 0x20, 0x04, 0x00, 0x07, 0x06, 0x07,
0x06, 0x12, 0x09, 0x08, 0x07, 0x07, 0x10, 0x07,
0x06, 0x07, 0x06, 0x12, 0x13, 0x08, 0x07, 0x08,
0x16, 0x0c, 0x0c, 0x07, 0x04, 0x0c, 0x0a, 0x0c,
0x0c, 0x07, 0x04, 0x8d, 0x01, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x69,
0x62, 0x28, 0x6e, 0x29, 0x0a, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e,
0x20, 0x3c, 0x3d, 0x20, 0x30, 0x29, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x30, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73,
0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x20,
0x3d, 0x3d, 0x20, 0x31, 0x29, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
0x74, 0x75, 0x72, 0x6e, 0x20, 0x31, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x66, 0x69, 0x62, 0x28, 0x6e, 0x20, 0x2d, 0x20,
0x31, 0x29, 0x20, 0x2b, 0x20, 0x66, 0x69, 0x62,
0x28, 0x6e, 0x20, 0x2d, 0x20, 0x32, 0x29, 0x3b,
0x0a, 0x7d, 0xff, 0x49, 0x43, 0x00,
};
const uint32_t qjsc_hello_module_size = 183;
const uint8_t qjsc_hello_module[183] = {
0x08, 0x07, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
0x2e, 0x6a, 0x73, 0x1e, 0x2e, 0x2f, 0x66, 0x69,
0x62, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
0x2e, 0x6a, 0x73, 0x06, 0x66, 0x69, 0x62, 0x0e,
0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x06,
0x6c, 0x6f, 0x67, 0x16, 0x48, 0x65, 0x6c, 0x6c,
0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x10,
0x66, 0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d,
0x0d, 0xac, 0x03, 0x01, 0xae, 0x03, 0x00, 0x00,
0x01, 0x00, 0xb0, 0x03, 0x00, 0x0c, 0x20, 0x02,
0x01, 0x9e, 0x01, 0x00, 0x00, 0x00, 0x05, 0x01,
0x00, 0x32, 0x00, 0xb0, 0x03, 0x00, 0x0c, 0x08,
0xe9, 0x02, 0x29, 0x38, 0xd9, 0x00, 0x00, 0x00,
0x42, 0xda, 0x00, 0x00, 0x00, 0x04, 0xdb, 0x00,
0x00, 0x00, 0x24, 0x01, 0x00, 0x0e, 0x38, 0xd9,
0x00, 0x00, 0x00, 0x42, 0xda, 0x00, 0x00, 0x00,
0x04, 0xdc, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00,
0xbb, 0x0a, 0xee, 0x24, 0x02, 0x00, 0x0e, 0x06,
0x2e, 0xac, 0x03, 0x01, 0x01, 0x0a, 0x01, 0x01,
0x00, 0x04, 0x0a, 0x02, 0x62, 0x00, 0x4d, 0x30,
0x00, 0xff, 0x49, 0x43, 0x01, 0xb4, 0x03,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
{
JSContext *ctx = JS_NewContext(rt);
if (!ctx)
return NULL;
js_std_eval_binary(ctx, qjsc_fib_module, qjsc_fib_module_size, 1);
return ctx;
}
int main(int argc, char **argv)
{
JSRuntime *rt;
JSContext *ctx;
rt = JS_NewRuntime();
js_std_set_worker_new_context_func(JS_NewCustomContext);
js_std_init_handlers(rt);
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
ctx = JS_NewCustomContext(rt);
js_std_add_helpers(ctx, argc, argv);
js_std_eval_binary(ctx, qjsc_hello_module, qjsc_hello_module_size, 0);
js_std_loop(ctx);
JS_FreeContext(ctx);
js_std_free_handlers(rt);
JS_FreeRuntime(rt);
return 0;
}

12861
gen/repl.c Normal file

File diff suppressed because it is too large Load diff

60
gen/test_fib.c Normal file
View file

@ -0,0 +1,60 @@
/* File generated automatically by the QuickJS-ng compiler. */
#include "quickjs-libc.h"
const uint32_t qjsc_test_fib_size = 172;
const uint8_t qjsc_test_fib[172] = {
0x08, 0x07, 0x28, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74,
0x5f, 0x66, 0x69, 0x62, 0x2e, 0x6a, 0x73, 0x10,
0x2e, 0x2f, 0x66, 0x69, 0x62, 0x2e, 0x73, 0x6f,
0x06, 0x66, 0x69, 0x62, 0x0e, 0x63, 0x6f, 0x6e,
0x73, 0x6f, 0x6c, 0x65, 0x06, 0x6c, 0x6f, 0x67,
0x16, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57,
0x6f, 0x72, 0x6c, 0x64, 0x10, 0x66, 0x69, 0x62,
0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d, 0xac, 0x03,
0x01, 0xae, 0x03, 0x00, 0x00, 0x01, 0x00, 0xb0,
0x03, 0x00, 0x0c, 0x20, 0x02, 0x01, 0x9e, 0x01,
0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x32, 0x00,
0xb0, 0x03, 0x00, 0x0c, 0x08, 0xe9, 0x02, 0x29,
0x38, 0xd9, 0x00, 0x00, 0x00, 0x42, 0xda, 0x00,
0x00, 0x00, 0x04, 0xdb, 0x00, 0x00, 0x00, 0x24,
0x01, 0x00, 0x0e, 0x38, 0xd9, 0x00, 0x00, 0x00,
0x42, 0xda, 0x00, 0x00, 0x00, 0x04, 0xdc, 0x00,
0x00, 0x00, 0x65, 0x00, 0x00, 0xbb, 0x0a, 0xee,
0x24, 0x02, 0x00, 0x0e, 0x06, 0x2e, 0xac, 0x03,
0x01, 0x01, 0x0a, 0x01, 0x01, 0x00, 0x04, 0x0a,
0x02, 0x62, 0x00, 0x4d, 0x30, 0x00, 0xff, 0x49,
0x43, 0x01, 0xb4, 0x03,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
{
JSContext *ctx = JS_NewContext(rt);
if (!ctx)
return NULL;
{
extern JSModuleDef *js_init_module_fib(JSContext *ctx, const char *name);
js_init_module_fib(ctx, "examples/fib.so");
}
return ctx;
}
int main(int argc, char **argv)
{
JSRuntime *rt;
JSContext *ctx;
rt = JS_NewRuntime();
js_std_set_worker_new_context_func(JS_NewCustomContext);
js_std_init_handlers(rt);
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
ctx = JS_NewCustomContext(rt);
js_std_add_helpers(ctx, argc, argv);
js_std_eval_binary(ctx, qjsc_test_fib, qjsc_test_fib_size, 0);
js_std_loop(ctx);
JS_FreeContext(ctx);
js_std_free_handlers(rt);
JS_FreeRuntime(rt);
return 0;
}