diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-03-26 14:39:54 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-03-26 14:39:54 -0400 |
commit | 948cfe891a1234f52057db56f7cb1ea088de5ade (patch) | |
tree | e83a406326b083b8215cddb84cbc667f6f4fc4e0 | |
parent | bb59c119af8ca19fa0eece110f6f7444e52dd558 (diff) |
vector bugfix
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | tnslc/build.sh (renamed from tnslc/run.sh) | 2 | ||||
-rw-r--r-- | tnslc/file.tnsl | 2 | ||||
-rw-r--r-- | tnslc/tnslc.tnsl | 3 | ||||
-rw-r--r-- | tnslc/vector.tnsl | 31 |
5 files changed, 32 insertions, 7 deletions
@@ -6,4 +6,5 @@ *.exe **/build/ +**/out/ ctc diff --git a/tnslc/run.sh b/tnslc/build.sh index 904e281..d86c9ae 100755 --- a/tnslc/run.sh +++ b/tnslc/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -BUILD_DIR=./build +BUILD_DIR=./out ARTIFACT_DIR=$BUILD_DIR/artifacts mkdir -p $BUILD_DIR diff --git a/tnslc/file.tnsl b/tnslc/file.tnsl index 0b24aea..e17ec70 100644 --- a/tnslc/file.tnsl +++ b/tnslc/file.tnsl @@ -1,5 +1,5 @@ struct File { - int i + } /; method File diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl index 6269ef2..8fb65c3 100644 --- a/tnslc/tnslc.tnsl +++ b/tnslc/tnslc.tnsl @@ -13,9 +13,8 @@ TNSLC v1.0.0 (C) 2024 CircleShift usage: - tnslc [options] (file in) [file out] + tnslc (file in) [file out] - -h print this help text \0" /; main (int argc, ~~uint8 argv) [int] diff --git a/tnslc/vector.tnsl b/tnslc/vector.tnsl index c8450ac..ea61d78 100644 --- a/tnslc/vector.tnsl +++ b/tnslc/vector.tnsl @@ -35,7 +35,7 @@ uint VECTOR_MAX_GROW = 256 ;/ /; push (~void el) - /; if (self.size == self.count) + /; if (self.size == self.count + 1) /; if (self.size < VECTOR_MAX_GROW) self._grow(self.size) ;; else @@ -45,8 +45,8 @@ uint VECTOR_MAX_GROW = 256 ~void start = self.data + self.count * self._elsz /; loop (int i = 0; i < self._elsz) [i++] - ~void to = start + i - ~void from = el + i + ~uint8 to = start + i + ~uint8 from = el + i to` = from` ;/ self.count++ @@ -63,6 +63,12 @@ uint VECTOR_MAX_GROW = 256 self.push(ch) ;/ + /; as_cstr [~uint8] + ~uint8 z = self.data + self.count + z` = 0 + return self.data + ;/ + /; end self.count = 0 self.size = 0 @@ -71,3 +77,22 @@ uint VECTOR_MAX_GROW = 256 ;/ ;/ + +# Artifacts + +struct Artifact { + ~~uint8 strings, + uint + size, + count +} + +/; method Artifact + + /; init + self.size = VECTOR_MIN_ELEMENTS + self.count = 0 + self.strings = _alloc(self.size * 8) + ;/ +;/ + |