aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-11-21 18:27:38 -0500
committerFranklin Wei <git@fwei.tk>2015-11-21 18:27:38 -0500
commitafc3e4b88e193025e49736e545ccb7765b19d1b5 (patch)
treeefb32f2b86739e38c466ee514f2cb6338fa99fe7 /target
parent03a7066353fad59b7c29b57baa94f84bcc5cfcda (diff)
downloadducky-afc3e4b88e193025e49736e545ccb7765b19d1b5.zip
ducky-afc3e4b88e193025e49736e545ccb7765b19d1b5.tar.gz
ducky-afc3e4b88e193025e49736e545ccb7765b19d1b5.tar.bz2
ducky-afc3e4b88e193025e49736e545ccb7765b19d1b5.tar.xz
better error handling
Diffstat (limited to 'target')
-rw-r--r--target/unix/main.c24
-rw-r--r--target/unix/platform.h1
2 files changed, 21 insertions, 4 deletions
diff --git a/target/unix/main.c b/target/unix/main.c
index b05bcb5..d7f49bf 100644
--- a/target/unix/main.c
+++ b/target/unix/main.c
@@ -50,18 +50,34 @@ int main(int argc, char *argv[])
switch(action)
{
case INTERP:
- ducky_main(fd, false);
+ if(ducky_interp(fd, false))
+ {
+ printf("Interpreter error.\n");
+ return 1;
+ }
break;
case COMPILE:
out_fd = open("a.out", O_WRONLY | O_CREAT | O_TRUNC, 0644);
- ducky_compile(fd, false, out_fd);
+ if(ducky_compile(fd, false, out_fd))
+ {
+ printf("Compiler error.\n");
+ return 1;
+ }
break;
case EXECUTE:
- ducky_vm(fd);
+ if(ducky_vm(fd))
+ {
+ printf("Bytecode interpreter error.\n");
+ return 1;
+ }
break;
case TRANSCOMPILE:
out_fd = open("a.c", O_WRONLY | O_CREAT | O_TRUNC, 0644);
- ducky_to_c(fd, out_fd);
+ if(ducky_to_c(fd, out_fd))
+ {
+ printf("Transcompiler error.\n");
+ return 1;
+ }
break;
default:
break;
diff --git a/target/unix/platform.h b/target/unix/platform.h
index ca331e2..328d35b 100644
--- a/target/unix/platform.h
+++ b/target/unix/platform.h
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <math.h>
+#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>