commit 045e096e6cad8dcb06f6f4f42bfdb34335d325cc
parent 6b0bad1730fcbd3f43d57c2424946993222ae5fb
Author: Drew DeVault <sir@cmpwn.com>
Date: Sat, 30 Jan 2021 15:15:57 -0500
stdlib: rig up os, strings
Diffstat:
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -24,9 +24,11 @@ $(HARECACHE)/hare.ssa: $(hare_srcs)
@$(HAREC) -o $@ $(hare_srcs)
hare_deps=\
+ $(stdlib_bytes) \
$(stdlib_io) \
+ $(stdlib_os) \
$(stdlib_strconv) \
- $(stdlib_bytes)
+ $(stdlib_strings)
hare: $(hare_deps) $(stdlib_rt) $(stdlib_start) $(HARECACHE)/hare.o
@printf 'LD\t$@\n'
diff --git a/main.ha b/main.ha
@@ -1,7 +1,9 @@
use io;
-use strconv;
+use os;
export fn main() void = {
io::println("Hello, world!");
- io::println(strconv::unsignedtos(1337u));
+ for (let i = 0z; i < len(os::args); i += 1z) {
+ io::println(os::args[i]);
+ };
};
diff --git a/stdlib.mk b/stdlib.mk
@@ -75,6 +75,9 @@ stdlib_strconv=$(HARECACHE)/strconv/strconv.o
# io
libio_srcs=\
$(STDLIB)/io/println.ha
+ # TODO:
+ #$(STDLIB)/io/types.ha \
+ #$(STDLIB)/io/stream.ha
$(HARECACHE)/io/io.ssa: $(libio_srcs) $(stdlib_rt)
@printf 'HAREC \t$@\n'
@@ -82,3 +85,28 @@ $(HARECACHE)/io/io.ssa: $(libio_srcs) $(stdlib_rt)
@$(HAREC) -o $@ -Nio -t$(HARECACHE)/io/io.td $(libio_srcs)
stdlib_io=$(HARECACHE)/io/io.o
+
+# strings
+libstrings_srcs=\
+ $(STDLIB)/strings/cstrings.ha
+
+$(HARECACHE)/strings/strings.ssa: $(libstrings_srcs) $(stdlib_rt)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/strings
+ @$(HAREC) -o $@ -Nstrings -t$(HARECACHE)/strings/strings.td $(libstrings_srcs)
+
+stdlib_strings=$(HARECACHE)/strings/strings.o
+
+# os
+libos_srcs=\
+ $(STDLIB)/os/$(PLATFORM)/environ.ha \
+ $(STDLIB)/os/$(PLATFORM)/exit.ha
+
+libos_deps=$(stdlib_rt) $(stdlib_strings) $(stdlib_types)
+
+$(HARECACHE)/os/os.ssa: $(libos_srcs) $(libos_deps)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/os
+ @$(HAREC) -o $@ -Nos -t$(HARECACHE)/os/os.td $(libos_srcs)
+
+stdlib_os=$(HARECACHE)/os/os.o