diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-03-14 01:11:23 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-03-14 01:11:23 -0400 |
commit | e25b738656928b38781458ed85880e8ae7bdd5a6 (patch) | |
tree | 3c21849a0139d778a65923081cf37a2ead9f03fb /tnslc | |
parent | 392984c0cf53fff4a64bc74e3f32ccba4c93dba8 (diff) |
Test vector impl
Diffstat (limited to 'tnslc')
-rwxr-xr-x | tnslc/build.sh | 2 | ||||
-rw-r--r-- | tnslc/main.tnsl | 13 | ||||
-rw-r--r-- | tnslc/vector.tnsl | 32 |
3 files changed, 38 insertions, 9 deletions
diff --git a/tnslc/build.sh b/tnslc/build.sh index b492dcd..798e77d 100755 --- a/tnslc/build.sh +++ b/tnslc/build.sh @@ -3,5 +3,5 @@ ../ctc main.tnsl tnslc.asm nasm -f elf64 -o tnslc.o tnslc.asm gcc -o tnslc tnslc.o -rm tnslc.asm tnslc.o +# rm tnslc.asm tnslc.o diff --git a/tnslc/main.tnsl b/tnslc/main.tnsl index 1abedb3..ac56836 100644 --- a/tnslc/main.tnsl +++ b/tnslc/main.tnsl @@ -1,14 +1,11 @@ :import "c_wrap_linux.tnsl" +:import "vector.tnsl" -~uint8 str_a = "Hello World\n\0" -~uint8 str_b = "!\n\0" +/; main [int] -/; main (int argc, ~~uint8 argv) [int] - _printf(str_a) + Vector a + a.init(1) - /; if (argc > 2) - _printf(str_b) - ;/ - return 0 ;/ + diff --git a/tnslc/vector.tnsl b/tnslc/vector.tnsl new file mode 100644 index 0000000..1377938 --- /dev/null +++ b/tnslc/vector.tnsl @@ -0,0 +1,32 @@ +struct Vector { + ~void data, + int + size, + count, + _elsz +} + +int VECT_DEFAULT_SIZE = 4 + +/; method Vector + + /; init (int elsz) + self._elsz = elsz + self.size = VECT_DEFAULT_SIZE + self.data = _alloc(elsz * self.size) + self.count = 0 + ;/ + + /; get (int index) [~void] + return self.data + ;/ + + /; end + _delete(self.data) + self.size = 0 + self._elsz = 0 + self.count = 0 + ;/ + +;/ + |