summaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile14
-rw-r--r--unix/main.c18
2 files changed, 23 insertions, 9 deletions
diff --git a/unix/Makefile b/unix/Makefile
index 6a48cee22..0c8c449e7 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -3,13 +3,13 @@ BUILD=build
CC = gcc
CFLAGS = -I. -I$(PYSRC) -Wall -ansi -std=gnu99 -Os #-DNDEBUG
-CFLAGS_PY = -DEMIT_ENABLE_CPY -DEMIT_ENABLE_THUMB
LDFLAGS =
SRC_C = \
main.c \
PY_O = \
+ nlrx64.o \
malloc.o \
qstr.o \
misc.o \
@@ -43,19 +43,23 @@ $(BUILD):
$(BUILD)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
+$(BUILD)/%.o: $(PYSRC)/%.s
+ $(AS) -c -o $@ $<
+
$(BUILD)/%.o: $(PYSRC)/%.c mpyconfig.h
- $(CC) $(CFLAGS) $(CFLAGS_PY) -c -o $@ $<
+ $(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/emitnx64.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
- $(CC) $(CFLAGS) $(CFLAGS_PY) -DN_X64 -c -o $@ $<
+ $(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
- $(CC) $(CFLAGS) $(CFLAGS_PY) -DN_THUMB -c -o $@ $<
+ $(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(BUILD)/vm.o: $(PYSRC)/vm.c
- $(CC) $(CFLAGS) $(CFLAGS_PY) -O3 -c -o $@ $<
+ $(CC) $(CFLAGS) -O3 -c -o $@ $<
+$(BUILD)/main.o: mpyconfig.h
$(BUILD)/parse.o: $(PYSRC)/grammar.h
$(BUILD)/compile.o: $(PYSRC)/grammar.h
$(BUILD)/emitcpy.o: $(PYSRC)/emit.h
diff --git a/unix/main.c b/unix/main.c
index eb120da01..8ceaf4264 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
+#include "nlr.h"
#include "misc.h"
#include "mpyconfig.h"
#include "lexer.h"
@@ -47,10 +48,19 @@ int main(int argc, char **argv) {
// execute it
py_obj_t module_fun = rt_make_function_from_id(1);
if (module_fun != py_const_none) {
- py_obj_t ret = rt_call_function_0(module_fun);
- printf("done! got: ");
- py_obj_print(ret);
- printf("\n");
+ nlr_buf_t nlr;
+ if (nlr_push(&nlr) == 0) {
+ py_obj_t ret = rt_call_function_0(module_fun);
+ printf("done! got: ");
+ py_obj_print(ret);
+ printf("\n");
+ nlr_pop();
+ } else {
+ // uncaught exception
+ printf("exception: ");
+ py_obj_print((py_obj_t)nlr.ret_val);
+ printf("\n");
+ }
}
}
#endif