summaryrefslogtreecommitdiff
path: root/tnslc/vector.tnsl
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc/vector.tnsl')
-rw-r--r--tnslc/vector.tnsl31
1 files changed, 28 insertions, 3 deletions
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)
+ ;/
+;/
+