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
This commit is contained in:
Cory McWilliams 2024-02-14 17:39:27 +00:00
parent 685754895b
commit ed741d53d7

View File

@ -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;