aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ast.h4
-rw-r--r--stdlib/util.h1
2 files changed, 3 insertions, 2 deletions
diff --git a/ast.h b/ast.h
index 56633b47..69bdc994 100644
--- a/ast.h
+++ b/ast.h
@@ -2,11 +2,12 @@
// Logic defining ASTs (abstract syntax trees) to represent code
+#include <err.h>
#include <gc/cord.h>
+#include <printf.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
-#include <printf.h>
#include "stdlib/datatypes.h"
#include "stdlib/files.h"
@@ -19,6 +20,7 @@
#define FakeAST(ast_tag, ...) (new(ast_t, .tag=ast_tag, .__data.ast_tag={__VA_ARGS__}))
#define WrapAST(ast, ast_tag, ...) (new(ast_t, .file=(ast)->file, .start=(ast)->start, .end=(ast)->end, .tag=ast_tag, .__data.ast_tag={__VA_ARGS__}))
#define TextAST(ast, _str) WrapAST(ast, TextLiteral, .str=GC_strdup(_str))
+#define Match(x, _tag) ((x)->tag == _tag ? &(x)->__data._tag : (errx(1, __FILE__ ":%d This was supposed to be a " # _tag "\n", __LINE__), &(x)->__data._tag))
#define REVERSE_LIST(list) do { \
__typeof(list) _prev = NULL; \
diff --git a/stdlib/util.h b/stdlib/util.h
index 95a40018..b68e59bc 100644
--- a/stdlib/util.h
+++ b/stdlib/util.h
@@ -14,7 +14,6 @@
#define new(t, ...) ((t*)memcpy(GC_MALLOC(sizeof(t)), &(t){__VA_ARGS__}, sizeof(t)))
#define heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x))
#define stack(x) (__typeof(x)*)((__typeof(x)[1]){x})
-#define Match(x, _tag) ((x)->tag == _tag ? &(x)->__data._tag : (errx(1, __FILE__ ":%d This was supposed to be a " # _tag "\n", __LINE__), &(x)->__data._tag))
#define check_initialized(var, name) *({ if (!var ## $initialized) fail("The variable " name " is being accessed before it has been initialized!"); \
&var; })