commit e88e679b97ee081718db34c4957e1411d564ebb4
parent 3f005099f4227c96c4548a5a9fd30a1dae689bbb
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 24 Jan 2021 13:17:17 -0500
stdlib.mk: add new modules
Diffstat:
3 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -24,14 +24,17 @@ $(HARECACHE)/hare.ssa: $(hare_srcs)
@$(HAREC) -o $@ $(hare_srcs)
hare_deps=\
- $(stdlib_io)
+ $(stdlib_io) \
+ $(stdlib_strconv) \
+ $(stdlib_bytes)
hare: $(hare_deps) $(stdlib_rt) $(stdlib_start) $(HARECACHE)/hare.o
@printf 'LD\t$@\n'
@$(LD) -o $@ $(stdlib_start) $(HARECACHE)/hare.o $(stdlib_rt) $(hare_deps)
clean:
- false # TODO
+ @rm -rf cache
+ @rm hare
all: hare
diff --git a/main.ha b/main.ha
@@ -1,5 +1,7 @@
use io;
+use strconv;
export fn main() void = {
io::println("Hello, world!");
+ io::println(strconv::unsignedtos(1337u));
};
diff --git a/stdlib.mk b/stdlib.mk
@@ -1,3 +1,5 @@
+# TODO: Write a script to generate this file
+
# rt
librt_srcs=$(STDLIB)/rt/$(PLATFORM)/abort.ha \
$(STDLIB)/rt/$(PLATFORM)/env.ha \
@@ -31,6 +33,45 @@ $(HARECACHE)/rt/rt.a: $(HARECACHE)/rt/rt.o $(HARECACHE)/rt/syscall.o
stdlib_rt=$(HARECACHE)/rt/rt.a
stdlib_start=$(HARECACHE)/rt/start.o
+# bytes
+libbytes_srcs=\
+ $(STDLIB)/bytes/reverse.ha
+
+$(HARECACHE)/bytes/bytes.ssa: $(libbytes_srcs) $(stdlib_rt)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/bytes
+ @$(HAREC) -o $@ -Nbytes -t$(HARECACHE)/bytes/bytes.td $(libbytes_srcs)
+
+stdlib_bytes=$(HARECACHE)/bytes/bytes.o
+
+# types
+libtypes_srcs=\
+ $(STDLIB)/types/limits.ha \
+ $(STDLIB)/types/classes.ha
+ # $(STDLIB)/types/arch$(ARCH).ha
+
+$(HARECACHE)/types/types.ssa: $(libtypes_srcs) $(stdlib_rt)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/types
+ @$(HAREC) -o $@ -Ntypes -t$(HARECACHE)/types/types.td $(libtypes_srcs)
+
+stdlib_types=$(HARECACHE)/types/types.o
+
+# strconv
+libstrconv_srcs=\
+ $(STDLIB)/strconv/itos.ha \
+ $(STDLIB)/strconv/utos.ha \
+ $(STDLIB)/strconv/numeric.ha
+
+$(HARECACHE)/strconv/strconv.ssa: $(libstrconv_srcs)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/strconv
+ @$(HAREC) -o $@ -Nstrconv -t$(HARECACHE)/strconv/strconv.td $(libstrconv_srcs)
+
+$(HARECACHE)/strconv/strconv.ssa: $(stdlib_rt) $(stdlib_bytes) $(stdlib_types)
+
+stdlib_strconv=$(HARECACHE)/strconv/strconv.o
+
# io
libio_srcs=\
$(STDLIB)/io/println.ha