This commit is contained in:
luboslenco
2025-08-03 20:46:22 +02:00
parent 5b1560cb60
commit 93a56e1685
+16 -18
View File
@@ -74,24 +74,22 @@ void js_init() {
float alang_eval(char *data);
float js_eval(const char *js) {
return alang_eval(js);
// if (js_runtime == NULL) {
// js_init();
// }
// JSValue ret = JS_Eval(js_ctx, js, strlen(js), "iron", JS_EVAL_TYPE_GLOBAL);
// if (JS_IsException(ret)) {
// js_std_dump_error(js_ctx);
// JS_ResetUncatchableError(js_ctx);
// }
// double d;
// JS_ToFloat64(js_ctx, &d, ret);
// JS_RunGC(js_runtime);
// if (d != d) { // nan
// d = 0.0;
// }
// return d;
// return alang_eval(js);
if (js_runtime == NULL) {
js_init();
}
JSValue ret = JS_Eval(js_ctx, js, strlen(js), "iron", JS_EVAL_TYPE_GLOBAL);
if (JS_IsException(ret)) {
js_std_dump_error(js_ctx);
JS_ResetUncatchableError(js_ctx);
}
double d;
JS_ToFloat64(js_ctx, &d, ret);
JS_RunGC(js_runtime);
if (d != d) { // nan
d = 0.0;
}
return d;
}
JSValue js_call_result;