aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-13 20:12:44 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-13 20:12:44 -0400
commitaa0c16f91913c32cab0cb09dd0863b2e077a786a (patch)
treecbaad686571d41082aad29d74fddf99733aa4a6c
parent0c8b2f8e99fdb60ed6ac2648ee49d97b1d675557 (diff)
Clean up macro code
-rw-r--r--builtins/macros.h9
-rw-r--r--builtins/tomo.h1
-rw-r--r--builtins/util.h4
3 files changed, 2 insertions, 12 deletions
diff --git a/builtins/macros.h b/builtins/macros.h
deleted file mode 100644
index 9e51eba3..00000000
--- a/builtins/macros.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-
-// A few helper macros
-
-#include <gc.h>
-#include <string.h>
-
-#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})
diff --git a/builtins/tomo.h b/builtins/tomo.h
index af644cac..7db0f490 100644
--- a/builtins/tomo.h
+++ b/builtins/tomo.h
@@ -16,7 +16,6 @@
#include "datatypes.h"
#include "functiontype.h"
#include "integers.h"
-#include "macros.h"
#include "memory.h"
#include "metamethods.h"
#include "nums.h"
diff --git a/builtins/util.h b/builtins/util.h
index a497fcf5..a24264cd 100644
--- a/builtins/util.h
+++ b/builtins/util.h
@@ -12,9 +12,9 @@
#define starts_with(line, prefix) (strncmp(line, prefix, strlen(prefix)) == 0)
#define ends_with(line, suffix) (strlen(line) >= strlen(suffix) && strcmp(line + strlen(line) - strlen(suffix), suffix) == 0)
#define new(t, ...) ((t*)memcpy(GC_MALLOC(sizeof(t)), &(t){__VA_ARGS__}, sizeof(t)))
-#define copy(obj_ptr) ((__typeof(obj_ptr))memcpy(GC_MALLOC(sizeof(*(obj_ptr))), obj_ptr, sizeof(*(obj_ptr))))
+#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 Tagged(t, _tag, ...) new(t, .tag=_tag, .__data._tag={__VA_ARGS__})
#define check_initialized(var, name) *({ if (!var ## $initialized) fail("The variable " name " is being accessed before it has been initialized!"); \
&var; })