summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--allocator.c2
-rw-r--r--main.c4
-rwxr-xr-xrunv7
-rw-r--r--test.toc13
-rw-r--r--types.c2
5 files changed, 17 insertions, 11 deletions
diff --git a/allocator.c b/allocator.c
index 202b238..aeae87f 100644
--- a/allocator.c
+++ b/allocator.c
@@ -1,7 +1,7 @@
static void *err_malloc(size_t bytes);
static void *err_calloc(size_t n, size_t sz);
static void *err_realloc(void *prev, size_t new_size);
-#define NO_ALLOCATOR 1 /* useful for debugging; valgrind (maybe) checks writing past the end of a malloc, but that won't work with an allocator */
+/* #define NO_ALLOCATOR 1 /\* useful for debugging; valgrind (maybe) checks writing past the end of a malloc, but that won't work with an allocator *\/ */
/* number of bytes a page hold, not including the header */
#define PAGE_BYTES (16384 - sizeof(Page))
#define PAGE_MAX_ALIGNS (PAGE_BYTES / sizeof(MaxAlign))
diff --git a/main.c b/main.c
index 1f4655d..39d2c0e 100644
--- a/main.c
+++ b/main.c
@@ -1,9 +1,5 @@
/*
TODO:
-check for leaks
-clean up
-
-
switch to enums for flags
struct parameters
diff --git a/runv b/runv
index ccd621f..614eda3 100755
--- a/runv
+++ b/runv
@@ -1,5 +1,10 @@
#!/bin/sh
-valgrind -q --track-origins=yes --error-exitcode=1 --malloc-fill=0xcd --free-fill=0xef --num-callers=100 ./toc test.toc || exit 1
+if [ "$2" = "" ]; then
+ tocf=test.toc
+else
+ tocf="$2"
+fi
+valgrind -q --track-origins=yes --error-exitcode=1 --malloc-fill=0xcd --free-fill=0xef --num-callers=100 ./toc $tocf || exit 1
if [ "$1" = "c" ]; then
gcc out.c && ./a.out
elif [ "$1" = "pc" ]; then
diff --git a/test.toc b/test.toc
index 12fef3a..6272493 100644
--- a/test.toc
+++ b/test.toc
@@ -8,11 +8,16 @@ puti @= fn(x: int) {
// };
-f @= fn(x: int, r := x) y := x {
+f @= fn(t @ Type, x: t) t {
+ x + 1
+};
+
+g @= fn(x, y @ Type) int {
+(3 as x) + (5 as y)
};
main @= fn() {
-R @= f(2837);
-puti(R);
- puti(f(3218));
+ puti(f(int, 3));
+ puti(f(u8, 255) as int);
+ puti(g(int, int));
}; \ No newline at end of file
diff --git a/types.c b/types.c
index d5d1eba..911c0d2 100644
--- a/types.c
+++ b/types.c
@@ -666,7 +666,7 @@ static bool types_fn(Typer *tr, FnExpr *f, Type *t, Location where,
bool entered_fn = false;
assert(t->kind == TYPE_FN);
if (instance) {
- *(Location *)arr_add(&err_ctx->instance_stack) = where;
+ *(Location *)typer_arr_add(tr, &err_ctx->instance_stack) = where;
f = &instance->fn;
} else {
if (t->fn.constness)