hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 5d37b4c18d29dea24d22ac016bfe5196020c46f6
parent 4a2bea93ccb1002013ab8cbe0e041c4230ea0231
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 26 Feb 2021 12:32:18 -0500

stdlib: new modules

Diffstat:
Mgen-stdlib | 48++++++++++++++++++++++++++++++++++++++++++++++++
Mmk/stdlib.mk | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 153 insertions(+), 0 deletions(-)

diff --git a/gen-stdlib b/gen-stdlib @@ -117,6 +117,13 @@ bytes() { gen_ssa bytes types } +crypto_math() { + printf '# crypto::math\n' + gen_srcs crypto::math \ + bits.ha + gen_ssa crypto::math +} + crypto_random() { printf '# crypto::random\n' gen_srcs crypto::random \ @@ -125,6 +132,29 @@ crypto_random() { gen_ssa crypto::random rt io } +gensrcs_crypto_sha256() { + gen_srcs crypto::sha256 \ + sha256.ha \ + $* +} + +genssa_crypto_sha256() { + gen_ssa crypto::sha256 hash io endian $* +} + +crypto_sha256() { + printf '# crypto::sha256\n' + if [ $testing -eq 0 ] + then + gensrcs_crypto_sha256 + genssa_crypto_sha256 + else + gensrcs_crypto_sha256 \ + +test.ha + genssa_crypto_sha256 fmt strio strings + fi +} + encoding_utf8() { # XXX: Also has ordering issues printf '# encoding::utf8\n' @@ -135,6 +165,13 @@ encoding_utf8() { gen_ssa encoding::utf8 types } +endian() { + printf '# endian\n' + gen_srcs endian\ + big.ha + gen_ssa endian +} + fmt() { printf '# fmt\n' gen_srcs fmt \ @@ -213,6 +250,13 @@ hare_parse() { gen_ssa hare::parse hare::ast hare::lex slice } +hash() { + printf '# hash\n' + gen_srcs hash \ + hash.ha + gen_ssa hash io +} + gensrcs_io() { gen_srcs io \ 'arch$(ARCH).ha' \ @@ -369,8 +413,11 @@ printf '# This file is generated by the gen-stdlib script, do not edit it by han modules="ascii bufio bytes +crypto_math crypto_random +crypto_sha256 encoding_utf8 +endian fmt format_elf fs @@ -378,6 +425,7 @@ hare_ast hare_lex hare_module hare_parse +hash io os os_exec diff --git a/mk/stdlib.mk b/mk/stdlib.mk @@ -69,12 +69,21 @@ hare_stdlib_deps+=$(stdlib_bufio) stdlib_bytes=$(HARECACHE)/bytes/bytes.o hare_stdlib_deps+=$(stdlib_bytes) +stdlib_crypto_math=$(HARECACHE)/crypto/math/crypto.math.o +hare_stdlib_deps+=$(stdlib_crypto_math) + stdlib_crypto_random=$(HARECACHE)/crypto/random/crypto.random.o hare_stdlib_deps+=$(stdlib_crypto_random) +stdlib_crypto_sha256=$(HARECACHE)/crypto/sha256/crypto.sha256.o +hare_stdlib_deps+=$(stdlib_crypto_sha256) + stdlib_encoding_utf8=$(HARECACHE)/encoding/utf8/encoding.utf8.o hare_stdlib_deps+=$(stdlib_encoding_utf8) +stdlib_endian=$(HARECACHE)/endian/endian.o +hare_stdlib_deps+=$(stdlib_endian) + stdlib_fmt=$(HARECACHE)/fmt/fmt.o hare_stdlib_deps+=$(stdlib_fmt) @@ -96,6 +105,9 @@ hare_stdlib_deps+=$(stdlib_hare_module) stdlib_hare_parse=$(HARECACHE)/hare/parse/hare.parse.o hare_stdlib_deps+=$(stdlib_hare_parse) +stdlib_hash=$(HARECACHE)/hash/hash.o +hare_stdlib_deps+=$(stdlib_hash) + stdlib_io=$(HARECACHE)/io/io.o hare_stdlib_deps+=$(stdlib_io) @@ -163,6 +175,16 @@ $(HARECACHE)/bytes/bytes.ssa: $(stdlib_bytes_srcs) $(stdlib_rt) $(stdlib_types) @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nbytes \ -t$(HARECACHE)/bytes/bytes.td $(stdlib_bytes_srcs) +# crypto::math +stdlib_crypto_math_srcs= \ + $(STDLIB)/crypto/math/bits.ha + +$(HARECACHE)/crypto/math/crypto.math.ssa: $(stdlib_crypto_math_srcs) $(stdlib_rt) + @printf 'HAREC \t$@\n' + @mkdir -p $(HARECACHE)/crypto/math + @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Ncrypto::math \ + -t$(HARECACHE)/crypto/math/crypto.math.td $(stdlib_crypto_math_srcs) + # crypto::random stdlib_crypto_random_srcs= \ $(STDLIB)/crypto/random/$(PLATFORM).ha \ @@ -174,6 +196,16 @@ $(HARECACHE)/crypto/random/crypto.random.ssa: $(stdlib_crypto_random_srcs) $(std @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Ncrypto::random \ -t$(HARECACHE)/crypto/random/crypto.random.td $(stdlib_crypto_random_srcs) +# crypto::sha256 +stdlib_crypto_sha256_srcs= \ + $(STDLIB)/crypto/sha256/sha256.ha + +$(HARECACHE)/crypto/sha256/crypto.sha256.ssa: $(stdlib_crypto_sha256_srcs) $(stdlib_rt) $(stdlib_hash) $(stdlib_io) $(stdlib_endian) + @printf 'HAREC \t$@\n' + @mkdir -p $(HARECACHE)/crypto/sha256 + @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Ncrypto::sha256 \ + -t$(HARECACHE)/crypto/sha256/crypto.sha256.td $(stdlib_crypto_sha256_srcs) + # encoding::utf8 stdlib_encoding_utf8_srcs= \ $(STDLIB)/encoding/utf8/rune.ha \ @@ -186,6 +218,16 @@ $(HARECACHE)/encoding/utf8/encoding.utf8.ssa: $(stdlib_encoding_utf8_srcs) $(std @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nencoding::utf8 \ -t$(HARECACHE)/encoding/utf8/encoding.utf8.td $(stdlib_encoding_utf8_srcs) +# endian +stdlib_endian_srcs= \ + $(STDLIB)/endian/big.ha + +$(HARECACHE)/endian/endian.ssa: $(stdlib_endian_srcs) $(stdlib_rt) + @printf 'HAREC \t$@\n' + @mkdir -p $(HARECACHE)/endian + @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nendian \ + -t$(HARECACHE)/endian/endian.td $(stdlib_endian_srcs) + # fmt stdlib_fmt_srcs= \ $(STDLIB)/fmt/fmt.ha @@ -263,6 +305,16 @@ $(HARECACHE)/hare/parse/hare.parse.ssa: $(stdlib_hare_parse_srcs) $(stdlib_rt) $ @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nhare::parse \ -t$(HARECACHE)/hare/parse/hare.parse.td $(stdlib_hare_parse_srcs) +# hash +stdlib_hash_srcs= \ + $(STDLIB)/hash/hash.ha + +$(HARECACHE)/hash/hash.ssa: $(stdlib_hash_srcs) $(stdlib_rt) $(stdlib_io) + @printf 'HAREC \t$@\n' + @mkdir -p $(HARECACHE)/hash + @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nhash \ + -t$(HARECACHE)/hash/hash.td $(stdlib_hash_srcs) + # io stdlib_io_srcs= \ $(STDLIB)/io/arch$(ARCH).ha \ @@ -469,12 +521,21 @@ hare_testlib_deps+=$(testlib_bufio) testlib_bytes=$(TESTCACHE)/bytes/bytes.o hare_testlib_deps+=$(testlib_bytes) +testlib_crypto_math=$(TESTCACHE)/crypto/math/crypto.math.o +hare_testlib_deps+=$(testlib_crypto_math) + testlib_crypto_random=$(TESTCACHE)/crypto/random/crypto.random.o hare_testlib_deps+=$(testlib_crypto_random) +testlib_crypto_sha256=$(TESTCACHE)/crypto/sha256/crypto.sha256.o +hare_testlib_deps+=$(testlib_crypto_sha256) + testlib_encoding_utf8=$(TESTCACHE)/encoding/utf8/encoding.utf8.o hare_testlib_deps+=$(testlib_encoding_utf8) +testlib_endian=$(TESTCACHE)/endian/endian.o +hare_testlib_deps+=$(testlib_endian) + testlib_fmt=$(TESTCACHE)/fmt/fmt.o hare_testlib_deps+=$(testlib_fmt) @@ -496,6 +557,9 @@ hare_testlib_deps+=$(testlib_hare_module) testlib_hare_parse=$(TESTCACHE)/hare/parse/hare.parse.o hare_testlib_deps+=$(testlib_hare_parse) +testlib_hash=$(TESTCACHE)/hash/hash.o +hare_testlib_deps+=$(testlib_hash) + testlib_io=$(TESTCACHE)/io/io.o hare_testlib_deps+=$(testlib_io) @@ -563,6 +627,16 @@ $(TESTCACHE)/bytes/bytes.ssa: $(testlib_bytes_srcs) $(testlib_rt) $(testlib_type @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nbytes \ -t$(TESTCACHE)/bytes/bytes.td $(testlib_bytes_srcs) +# crypto::math +testlib_crypto_math_srcs= \ + $(STDLIB)/crypto/math/bits.ha + +$(TESTCACHE)/crypto/math/crypto.math.ssa: $(testlib_crypto_math_srcs) $(testlib_rt) + @printf 'HAREC \t$@\n' + @mkdir -p $(TESTCACHE)/crypto/math + @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Ncrypto::math \ + -t$(TESTCACHE)/crypto/math/crypto.math.td $(testlib_crypto_math_srcs) + # crypto::random testlib_crypto_random_srcs= \ $(STDLIB)/crypto/random/$(PLATFORM).ha \ @@ -574,6 +648,17 @@ $(TESTCACHE)/crypto/random/crypto.random.ssa: $(testlib_crypto_random_srcs) $(te @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Ncrypto::random \ -t$(TESTCACHE)/crypto/random/crypto.random.td $(testlib_crypto_random_srcs) +# crypto::sha256 +testlib_crypto_sha256_srcs= \ + $(STDLIB)/crypto/sha256/sha256.ha \ + $(STDLIB)/crypto/sha256/+test.ha + +$(TESTCACHE)/crypto/sha256/crypto.sha256.ssa: $(testlib_crypto_sha256_srcs) $(testlib_rt) $(testlib_hash) $(testlib_io) $(testlib_endian) $(testlib_fmt) $(testlib_strio) $(testlib_strings) + @printf 'HAREC \t$@\n' + @mkdir -p $(TESTCACHE)/crypto/sha256 + @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Ncrypto::sha256 \ + -t$(TESTCACHE)/crypto/sha256/crypto.sha256.td $(testlib_crypto_sha256_srcs) + # encoding::utf8 testlib_encoding_utf8_srcs= \ $(STDLIB)/encoding/utf8/rune.ha \ @@ -586,6 +671,16 @@ $(TESTCACHE)/encoding/utf8/encoding.utf8.ssa: $(testlib_encoding_utf8_srcs) $(te @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nencoding::utf8 \ -t$(TESTCACHE)/encoding/utf8/encoding.utf8.td $(testlib_encoding_utf8_srcs) +# endian +testlib_endian_srcs= \ + $(STDLIB)/endian/big.ha + +$(TESTCACHE)/endian/endian.ssa: $(testlib_endian_srcs) $(testlib_rt) + @printf 'HAREC \t$@\n' + @mkdir -p $(TESTCACHE)/endian + @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nendian \ + -t$(TESTCACHE)/endian/endian.td $(testlib_endian_srcs) + # fmt testlib_fmt_srcs= \ $(STDLIB)/fmt/fmt.ha @@ -665,6 +760,16 @@ $(TESTCACHE)/hare/parse/hare.parse.ssa: $(testlib_hare_parse_srcs) $(testlib_rt) @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nhare::parse \ -t$(TESTCACHE)/hare/parse/hare.parse.td $(testlib_hare_parse_srcs) +# hash +testlib_hash_srcs= \ + $(STDLIB)/hash/hash.ha + +$(TESTCACHE)/hash/hash.ssa: $(testlib_hash_srcs) $(testlib_rt) $(testlib_io) + @printf 'HAREC \t$@\n' + @mkdir -p $(TESTCACHE)/hash + @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nhash \ + -t$(TESTCACHE)/hash/hash.td $(testlib_hash_srcs) + # io testlib_io_srcs= \ $(STDLIB)/io/arch$(ARCH).ha \