summaryrefslogtreecommitdiffstats
path: root/bytecode/slice.c
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2023-02-11 13:40:10 -0800
committerRose Hogenson <rhogenson@posteo.net>2023-02-11 13:40:10 -0800
commit60622614731bc42dd44704d3cff55b4e4c4f492c (patch)
treedcf3b31f46c1b46e23d5c379a9201195ccb4f1ce /bytecode/slice.c
parent5aec138c3832a65bad4b2bdaa7ca36cf5c279ac8 (diff)
downloadsml-60622614731bc42dd44704d3cff55b4e4c4f492c.tar.zst
Write a garbage collector.
Does it work? No, but it compiles.
Diffstat (limited to 'bytecode/slice.c')
-rw-r--r--bytecode/slice.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/bytecode/slice.c b/bytecode/slice.c
index c7b2820..0739a4a 100644
--- a/bytecode/slice.c
+++ b/bytecode/slice.c
@@ -10,6 +10,16 @@ struct slice slice(struct slice a, size_t i, size_t j)
struct slice slice1(struct slice a, size_t i)
{
- assert(i <= a.size);
- return (struct slice) { .size = a.size - i, .buf = a.buf + i };
+ return slice(a, i, a.size);
+}
+
+struct val_slice val_slice(struct val_slice a, size_t i, size_t j)
+{
+ assert(i <= a.size && j <= a.size && i <= j);
+ return (struct val_slice) { .size = j - i, .buf = a.buf + i };
+}
+
+struct val_slice val_slice1(struct val_slice a, size_t i)
+{
+ return val_slice(a, i, a.size);
}