aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-24 12:36:42 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-24 12:36:42 -0500
commit88ccdab43c0a3ee53177e21a28724e496406a376 (patch)
treeccc6f369d73276b5f7ae5aa841b725fb81bffa9c
parenta39fd17e8c3af7a958f25da9dfffe0e3d33b35b6 (diff)
Split utils into stdlib/utils and utils
-rw-r--r--Makefile4
-rw-r--r--src/ast.h2
-rw-r--r--src/compile/assertions.c2
-rw-r--r--src/compile/assignments.c2
-rw-r--r--src/compile/binops.c2
-rw-r--r--src/compile/blocks.c2
-rw-r--r--src/compile/cli.c2
-rw-r--r--src/compile/conditionals.c2
-rw-r--r--src/compile/debuglog.c2
-rw-r--r--src/compile/declarations.c2
-rw-r--r--src/compile/expressions.c2
-rw-r--r--src/compile/fieldaccess.c2
-rw-r--r--src/compile/functions.c2
-rw-r--r--src/compile/indexing.c2
-rw-r--r--src/compile/integers.c2
-rw-r--r--src/compile/lists.c2
-rw-r--r--src/compile/loops.c2
-rw-r--r--src/compile/optionals.c2
-rw-r--r--src/compile/reductions.c2
-rw-r--r--src/compile/statements.c2
-rw-r--r--src/compile/text.h2
-rw-r--r--src/compile/types.c2
-rw-r--r--src/compile/whens.c2
-rw-r--r--src/environment.c2
-rw-r--r--src/modules.c2
-rw-r--r--src/parse/binops.c2
-rw-r--r--src/parse/containers.c2
-rw-r--r--src/parse/controlflow.c2
-rw-r--r--src/parse/expressions.c2
-rw-r--r--src/parse/files.c2
-rw-r--r--src/parse/functions.c2
-rw-r--r--src/parse/statements.c2
-rw-r--r--src/parse/suffixes.c2
-rw-r--r--src/parse/text.c2
-rw-r--r--src/parse/typedefs.c2
-rw-r--r--src/parse/utils.c2
-rw-r--r--src/parse/utils.h2
-rw-r--r--src/tomo.c2
-rw-r--r--src/typecheck.c2
-rw-r--r--src/types.c2
-rw-r--r--src/util.h3
-rw-r--r--vendor/Makefile16
42 files changed, 52 insertions, 49 deletions
diff --git a/Makefile b/Makefile
index be131bfb..1bac7823 100644
--- a/Makefile
+++ b/Makefile
@@ -87,7 +87,7 @@ CFLAGS+=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO)
-DSUDO='"$(SUDO)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' \
-DGIT_VERSION='"$(GIT_VERSION)"' -ffunction-sections -fdata-sections
CFLAGS_PLACEHOLDER="$$(printf '\033[2m<flags...>\033[m\n')"
-LDLIBS=-lm ./vendor/build/lib/libgc.a ./vendor/build/lib/libgmp.a ./vendor/build/lib/libunistring.a
+LDLIBS=-lm ./build/gc/lib/libgc.a ./build/gmp/lib/libgmp.a ./build/unistring/lib/libunistring.a
AR_FILE=libtomo@$(TOMO_VERSION).a
ifeq ($(OS),Darwin)
@@ -194,7 +194,7 @@ test: $(TESTS)
@printf '\033[32;7m ALL TESTS PASSED! \033[m\n'
clean:
- rm -rf build/* $(COMPILER_OBJS) $(STDLIB_OBJS) test/*.tm.testresult test/.build lib/*/.build examples/.build examples/*/.build
+ rm -rf build/tomo* $(COMPILER_OBJS) $(STDLIB_OBJS) test/*.tm.testresult test/.build lib/*/.build examples/.build examples/*/.build
%: %.md
pandoc --lua-filter=docs/.pandoc/bold-code.lua -s $< -t man -o $@
diff --git a/src/ast.h b/src/ast.h
index b6930ab7..65ab0c63 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -9,7 +9,7 @@
#include "stdlib/datatypes.h"
#include "stdlib/files.h"
-#include "stdlib/util.h"
+#include "util.h"
#define NewAST(_file, _start, _end, ast_tag, ...) \
(new (ast_t, .file = _file, .start = _start, .end = _end, .tag = ast_tag, .__data.ast_tag = {__VA_ARGS__}))
diff --git a/src/compile/assertions.c b/src/compile/assertions.c
index 18531fd9..5cbb4359 100644
--- a/src/compile/assertions.c
+++ b/src/compile/assertions.c
@@ -5,7 +5,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/assignments.c b/src/compile/assignments.c
index 74a00e0b..7d989b06 100644
--- a/src/compile/assignments.c
+++ b/src/compile/assignments.c
@@ -4,7 +4,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/binops.c b/src/compile/binops.c
index acf1e031..a06cba22 100644
--- a/src/compile/binops.c
+++ b/src/compile/binops.c
@@ -4,7 +4,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "../types.h"
#include "compilation.h"
diff --git a/src/compile/blocks.c b/src/compile/blocks.c
index 1059fd34..470597a8 100644
--- a/src/compile/blocks.c
+++ b/src/compile/blocks.c
@@ -4,7 +4,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/cli.c b/src/compile/cli.c
index ade6caa7..447e437a 100644
--- a/src/compile/cli.c
+++ b/src/compile/cli.c
@@ -5,7 +5,7 @@
#include "../stdlib/datatypes.h"
#include "../stdlib/optionals.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "../types.h"
#include "compilation.h"
diff --git a/src/compile/conditionals.c b/src/compile/conditionals.c
index 64be29fa..c1b1e60e 100644
--- a/src/compile/conditionals.c
+++ b/src/compile/conditionals.c
@@ -5,7 +5,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/debuglog.c b/src/compile/debuglog.c
index 4128bfa7..9da1bf57 100644
--- a/src/compile/debuglog.c
+++ b/src/compile/debuglog.c
@@ -5,7 +5,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/declarations.c b/src/compile/declarations.c
index 3b80bade..ae5da0f7 100644
--- a/src/compile/declarations.c
+++ b/src/compile/declarations.c
@@ -4,7 +4,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/expressions.c b/src/compile/expressions.c
index c3918de3..3a6683c4 100644
--- a/src/compile/expressions.c
+++ b/src/compile/expressions.c
@@ -5,7 +5,7 @@
#include "../config.h"
#include "../environment.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/fieldaccess.c b/src/compile/fieldaccess.c
index 033851a7..cca9d9e6 100644
--- a/src/compile/fieldaccess.c
+++ b/src/compile/fieldaccess.c
@@ -5,7 +5,7 @@
#include "../environment.h"
#include "../stdlib/tables.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/functions.c b/src/compile/functions.c
index 01377a89..a1b0a28c 100644
--- a/src/compile/functions.c
+++ b/src/compile/functions.c
@@ -10,7 +10,7 @@
#include "../stdlib/optionals.h"
#include "../stdlib/tables.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "../types.h"
#include "compilation.h"
diff --git a/src/compile/indexing.c b/src/compile/indexing.c
index 031ef9a0..447b1a4e 100644
--- a/src/compile/indexing.c
+++ b/src/compile/indexing.c
@@ -6,7 +6,7 @@
#include "../config.h"
#include "../environment.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/integers.c b/src/compile/integers.c
index 78d48b70..5f99afbd 100644
--- a/src/compile/integers.c
+++ b/src/compile/integers.c
@@ -7,7 +7,7 @@
#include "../stdlib/datatypes.h"
#include "../stdlib/integers.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "../types.h"
#include "compilation.h"
diff --git a/src/compile/lists.c b/src/compile/lists.c
index 31255c1e..d0d00473 100644
--- a/src/compile/lists.c
+++ b/src/compile/lists.c
@@ -9,7 +9,7 @@
#include "../config.h"
#include "../environment.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/loops.c b/src/compile/loops.c
index 96299c5e..3ccf0416 100644
--- a/src/compile/loops.c
+++ b/src/compile/loops.c
@@ -8,7 +8,7 @@
#include "../stdlib/datatypes.h"
#include "../stdlib/integers.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/optionals.c b/src/compile/optionals.c
index 75dff935..e0013375 100644
--- a/src/compile/optionals.c
+++ b/src/compile/optionals.c
@@ -4,7 +4,7 @@
#include "../naming.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "../types.h"
#include "compilation.h"
diff --git a/src/compile/reductions.c b/src/compile/reductions.c
index 159158e3..eddbddb7 100644
--- a/src/compile/reductions.c
+++ b/src/compile/reductions.c
@@ -4,7 +4,7 @@
#include "../config.h"
#include "../environment.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/statements.c b/src/compile/statements.c
index 13dcc064..7a2f1947 100644
--- a/src/compile/statements.c
+++ b/src/compile/statements.c
@@ -12,7 +12,7 @@
#include "../stdlib/print.h"
#include "../stdlib/tables.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/compile/text.h b/src/compile/text.h
index c160c7a9..510c3ed1 100644
--- a/src/compile/text.h
+++ b/src/compile/text.h
@@ -6,7 +6,7 @@
#include "../environment.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../types.h"
Text_t compile_text_ast(env_t *env, ast_t *ast);
diff --git a/src/compile/types.c b/src/compile/types.c
index aac27f4c..2f22e41c 100644
--- a/src/compile/types.c
+++ b/src/compile/types.c
@@ -6,7 +6,7 @@
#include "../naming.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "compilation.h"
public
diff --git a/src/compile/whens.c b/src/compile/whens.c
index 618a667c..8cc8ae4f 100644
--- a/src/compile/whens.c
+++ b/src/compile/whens.c
@@ -6,7 +6,7 @@
#include "../naming.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "../typecheck.h"
#include "compilation.h"
diff --git a/src/environment.c b/src/environment.c
index a82274e7..cdf02884 100644
--- a/src/environment.c
+++ b/src/environment.c
@@ -10,8 +10,8 @@
#include "stdlib/datatypes.h"
#include "stdlib/tables.h"
#include "stdlib/text.h"
-#include "stdlib/util.h"
#include "typecheck.h"
+#include "util.h"
type_t *TEXT_TYPE = NULL;
public
diff --git a/src/modules.c b/src/modules.c
index c7c29d24..54b461f9 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -15,7 +15,7 @@
#include "stdlib/tables.h"
#include "stdlib/text.h"
#include "stdlib/types.h"
-#include "stdlib/util.h"
+#include "util.h"
#define xsystem(...) \
({ \
diff --git a/src/parse/binops.c b/src/parse/binops.c
index ad3fff54..e095a1bc 100644
--- a/src/parse/binops.c
+++ b/src/parse/binops.c
@@ -2,7 +2,7 @@
#include <stdbool.h>
#include "../ast.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "expressions.h"
diff --git a/src/parse/containers.c b/src/parse/containers.c
index 8f9922f3..416f562c 100644
--- a/src/parse/containers.c
+++ b/src/parse/containers.c
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include "../ast.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "expressions.h"
diff --git a/src/parse/controlflow.c b/src/parse/controlflow.c
index 1087e20e..24de3cfe 100644
--- a/src/parse/controlflow.c
+++ b/src/parse/controlflow.c
@@ -4,7 +4,7 @@
#include <string.h>
#include "../ast.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "controlflow.h"
#include "errors.h"
diff --git a/src/parse/expressions.c b/src/parse/expressions.c
index d031c49f..9cc0aa07 100644
--- a/src/parse/expressions.c
+++ b/src/parse/expressions.c
@@ -4,7 +4,7 @@
#include <string.h>
#include "../ast.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "binops.h"
#include "containers.h"
#include "context.h"
diff --git a/src/parse/files.c b/src/parse/files.c
index f5d9554a..73f8fde5 100644
--- a/src/parse/files.c
+++ b/src/parse/files.c
@@ -12,7 +12,7 @@
#include "../stdlib/stdlib.h"
#include "../stdlib/tables.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "expressions.h"
diff --git a/src/parse/functions.c b/src/parse/functions.c
index 8fb9f78e..742f29a6 100644
--- a/src/parse/functions.c
+++ b/src/parse/functions.c
@@ -12,7 +12,7 @@
#include "../formatter/utils.h"
#include "../stdlib/datatypes.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "controlflow.h"
#include "errors.h"
diff --git a/src/parse/statements.c b/src/parse/statements.c
index 24917a76..9c6f9e31 100644
--- a/src/parse/statements.c
+++ b/src/parse/statements.c
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include "../ast.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "expressions.h"
diff --git a/src/parse/suffixes.c b/src/parse/suffixes.c
index 85e20721..71844642 100644
--- a/src/parse/suffixes.c
+++ b/src/parse/suffixes.c
@@ -4,7 +4,7 @@
#include "../ast.h"
#include "../stdlib/print.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "expressions.h"
diff --git a/src/parse/text.c b/src/parse/text.c
index e23b8417..d4c1f825 100644
--- a/src/parse/text.c
+++ b/src/parse/text.c
@@ -10,7 +10,7 @@
#include "../ast.h"
#include "../stdlib/text.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "expressions.h"
diff --git a/src/parse/typedefs.c b/src/parse/typedefs.c
index 56bb687f..b00ee50d 100644
--- a/src/parse/typedefs.c
+++ b/src/parse/typedefs.c
@@ -4,7 +4,7 @@
#include <string.h>
#include "../ast.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#include "errors.h"
#include "files.h"
diff --git a/src/parse/utils.c b/src/parse/utils.c
index f1b518ca..26a33e70 100644
--- a/src/parse/utils.c
+++ b/src/parse/utils.c
@@ -7,7 +7,7 @@
#include <uniname.h>
#include "../stdlib/tables.h"
-#include "../stdlib/util.h"
+#include "../util.h"
#include "errors.h"
#include "utils.h"
diff --git a/src/parse/utils.h b/src/parse/utils.h
index b8fb0756..9a6f0aac 100644
--- a/src/parse/utils.h
+++ b/src/parse/utils.h
@@ -3,7 +3,7 @@
#include <stdbool.h>
-#include "../stdlib/util.h"
+#include "../util.h"
#include "context.h"
#define SPACES_PER_INDENT 4
diff --git a/src/tomo.c b/src/tomo.c
index ceee2518..4a886bfc 100644
--- a/src/tomo.c
+++ b/src/tomo.c
@@ -36,8 +36,8 @@
#include "stdlib/siphash.h"
#include "stdlib/tables.h"
#include "stdlib/text.h"
-#include "stdlib/util.h"
#include "types.h"
+#include "util.h"
#define run_cmd(...) \
({ \
diff --git a/src/typecheck.c b/src/typecheck.c
index a073cb2e..1e3e1c7c 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -18,9 +18,9 @@
#include "stdlib/paths.h"
#include "stdlib/tables.h"
#include "stdlib/text.h"
-#include "stdlib/util.h"
#include "typecheck.h"
#include "types.h"
+#include "util.h"
type_t *parse_type_ast(env_t *env, type_ast_t *ast) {
#ifdef __GNUC__
diff --git a/src/types.c b/src/types.c
index 1ccb7952..ca44479e 100644
--- a/src/types.c
+++ b/src/types.c
@@ -10,8 +10,8 @@
#include "stdlib/integers.h"
#include "stdlib/tables.h"
#include "stdlib/text.h"
-#include "stdlib/util.h"
#include "types.h"
+#include "util.h"
Text_t arg_types_to_text(arg_t *args, const char *separator) {
Text_t text = EMPTY_TEXT;
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 00000000..79cb31d8
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#include "./stdlib/util.h" // IWYU pragma: export
diff --git a/vendor/Makefile b/vendor/Makefile
index 19f5d5ae..15446254 100644
--- a/vendor/Makefile
+++ b/vendor/Makefile
@@ -2,7 +2,7 @@ GMP_VERSION=6.3.0
UNISTRING_VERSION=1.4.1
GC_VERSION=8.2.8
-all: build-gc/include/gc.h build-gc/lib/libgc.a build-gmp/lib/libgmp.a build-unistring/lib/libunistring.a
+all: ../build/gc/include/gc.h ../build/gc/lib/libgc.a ../build/gmp/lib/libgmp.a ../build/unistring/lib/libunistring.a
# Boehm-Demers-Weiser Garbage collector
gc-$(GC_VERSION).tar.gz:
@@ -12,14 +12,14 @@ gc-$(GC_VERSION)/configure: gc-$(GC_VERSION).tar.gz
tar xzfm $<
gc-$(GC_VERSION)/Makefile: gc-$(GC_VERSION)/configure
- prefix=$$(realpath ./build-gc); \
+ prefix=$$(realpath ../build/gc); \
cd gc-$(GC_VERSION); \
./configure \
--enable-static \
--disable-shared \
--prefix="$$prefix"; \
-build-gc/include/gc.h build-gc/lib/libgc.a: gc-$(GC_VERSION)/Makefile
+../build/gc/include/gc.h ../build/gc/lib/libgc.a: gc-$(GC_VERSION)/Makefile
cd gc-$(GC_VERSION); \
$(MAKE) -j install
@@ -32,14 +32,14 @@ gmp-$(GMP_VERSION)/configure: gmp-$(GMP_VERSION).tar.xz
cd gmp-$(GMP_VERSION) && patch -p0 -N < ../gmp-configure-fix.patch
gmp-$(GMP_VERSION)/Makefile: gmp-$(GMP_VERSION)/configure
- prefix=$$(realpath ./build-gmp); \
+ prefix=$$(realpath ../build/gmp); \
cd gmp-$(GMP_VERSION); \
./configure \
--enable-static \
--disable-shared \
--prefix="$$prefix"
-build-gmp/lib/libgmp.a: gmp-$(GMP_VERSION)/Makefile
+../build/gmp/lib/libgmp.a: gmp-$(GMP_VERSION)/Makefile
$(MAKE) -C gmp-$(GMP_VERSION) -j
$(MAKE) -C gmp-$(GMP_VERSION) check
$(MAKE) -C gmp-$(GMP_VERSION) install
@@ -52,19 +52,19 @@ libunistring-$(UNISTRING_VERSION)/configure: libunistring-$(UNISTRING_VERSION).t
tar xzfm $<
libunistring-$(UNISTRING_VERSION)/Makefile: libunistring-$(UNISTRING_VERSION)/configure
- prefix=$$(realpath ./build-unistring); \
+ prefix=$$(realpath ../build/unistring); \
cd libunistring-$(UNISTRING_VERSION); \
./configure \
--enable-static \
--disable-shared \
--prefix="$$prefix"
-build-unistring/lib/libunistring.a: libunistring-$(UNISTRING_VERSION)/Makefile
+../build/unistring/lib/libunistring.a: libunistring-$(UNISTRING_VERSION)/Makefile
$(MAKE) -C libunistring-$(UNISTRING_VERSION) -j
$(MAKE) -C libunistring-$(UNISTRING_VERSION) check
$(MAKE) -C libunistring-$(UNISTRING_VERSION) install
clean:
- rm -rf build-gc build-gmp build-unistring
+ rm -rf ../build/gc ../build/gmp ../build/unistring
.PHONY: all clean