summaryrefslogtreecommitdiff
path: root/src/js.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/js.c')
-rw-r--r--src/js.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/js.c b/src/js.c
index 96557604..08fbdcb9 100644
--- a/src/js.c
+++ b/src/js.c
@@ -341,3 +341,18 @@ js_value_to_function(JSContextRef ctx, JSValueRef val, JSValueRef *exc)
return NULL;
}
+gboolean
+js_check_syntax(JSContextRef ctx, const char *script, const char *filename, int lineOffset)
+{
+ JSValueRef exc = NULL;
+ JSStringRef jsscript = JSStringCreateWithUTF8CString(script);
+ gboolean correct = JSCheckScriptSyntax(ctx, jsscript, NULL, lineOffset, &exc);
+ if (!correct)
+ {
+ fprintf(stderr, "DWB SCRIPT EXCEPTION: in file %s\n", filename);
+ js_print_exception(ctx, exc);
+ }
+ JSStringRelease(jsscript);
+ return correct;
+}
+