From ed741d53d705b0b58fe5fc10f86f9d5eeaab12c8 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 14 Feb 2024 17:39:27 +0000 Subject: [PATCH] Enable top-level async and JS_EVAL_FLAG_STRIP. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4842 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/task.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/task.c b/src/task.c index d4f9857e..af9fb4a7 100644 --- a/src/task.c +++ b/src/task.c @@ -414,7 +414,7 @@ int tf_task_execute(tf_task_t* task, const char* fileName) } if (source) { - JSValue result = JS_Eval(task->_context, source, strlen(source), fileName, JS_EVAL_TYPE_MODULE); + JSValue result = JS_Eval(task->_context, source, strlen(source), fileName, JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_STRIP | JS_EVAL_FLAG_ASYNC); if (tf_util_report_error(task->_context, result)) { tf_printf("Reported an error.\n"); @@ -1183,7 +1183,7 @@ void tf_task_on_receive_packet(int packetType, const char* begin, size_t length, static JSValue _tf_task_executeSource(tf_task_t* task, const char* source, const char* name) { tf_trace_begin(task->_trace, "_tf_task_executeSource"); - JSValue result = JS_Eval(task->_context, source, strlen(source), name, JS_EVAL_TYPE_MODULE); + JSValue result = JS_Eval(task->_context, source, strlen(source), name, JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_STRIP | JS_EVAL_FLAG_ASYNC); if (!*task->_scriptName) { snprintf(task->_scriptName, sizeof(task->_scriptName), "%s", name); @@ -1565,13 +1565,12 @@ static JSModuleDef* _tf_task_module_loader(JSContext* context, const char* modul return NULL; } - JSValue result = JS_Eval(context, source, length, module_name, JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY); + JSValue result = JS_Eval(context, source, length, module_name, JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY | JS_EVAL_FLAG_STRIP | JS_EVAL_FLAG_ASYNC); tf_free(source); if (tf_util_report_error(task->_context, result)) { return NULL; } - JSModuleDef* module = JS_VALUE_GET_PTR(result); JS_FreeValue(context, result); return module;