diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-06-09 15:15:28 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-06-09 15:15:28 +0330 |
commit | 922b6c51fbcdabd3823e311c46fe55af193196e1 (patch) | |
tree | 976876bcbdc18308b8ca8672684e2c751a7e0350 /code | |
parent | e711e6e55e9c83563db9bb04af7516632f27b91d (diff) |
fixing bug in anytype
Diffstat (limited to 'code')
-rw-r--r-- | code/basic.felan | 1 | ||||
-rw-r--r-- | code/lib/memory.felan | 2 | ||||
-rw-r--r-- | code/lib/vector.felan | 22 | ||||
-rw-r--r-- | code/main.felan | 18 |
4 files changed, 32 insertions, 11 deletions
diff --git a/code/basic.felan b/code/basic.felan index 1e4ce2f..8f9adb0 100644 --- a/code/basic.felan +++ b/code/basic.felan @@ -3,3 +3,4 @@ @import("lib/io.felan"); @import("lib/memory.felan"); @import("lib/string.felan"); +@import("lib/vector.felan"); diff --git a/code/lib/memory.felan b/code/lib/memory.felan index f1f9898..7715d0e 100644 --- a/code/lib/memory.felan +++ b/code/lib/memory.felan @@ -1,3 +1,5 @@ +@import("operator.felan"); + libc :: @c_library("/usr/lib/libc.so.6"); malloc :: @c_function(libc,"malloc",(i64)->(*void)); free :: @c_function(libc,"free",(*void)->void); diff --git a/code/lib/vector.felan b/code/lib/vector.felan new file mode 100644 index 0000000..6ad1991 --- /dev/null +++ b/code/lib/vector.felan @@ -0,0 +1,22 @@ +@import("operator.felan"); +@import("memory.felan"); + +vector :: (comptime t:type)->type{ + return struct { + ptr : *t; + size : u64; + capacity : u64; + }; +}; + +vector_new :: (comptime t:type) -> (vector(t)) { + v : vector(t) = undefined; + v.ptr = malloc(0,@type_of(v.ptr.*)); + v.size = 0u64; + v.capacity = 0u64; + return v; +}; + +delete :: (vec:vector(anytype)) -> void { + free(vec.ptr); +}; diff --git a/code/main.felan b/code/main.felan index be0bc72..b297e3f 100644 --- a/code/main.felan +++ b/code/main.felan @@ -1,8 +1,9 @@ -/* -@import("basic.felan"); -file :: @import("file.felan"); +// @import("basic.felan"); +@import("lib/vector.felan"); +// @import("lib/memory.felan"); -t :: (comptime formatter : string) macro -> string { +/* +t :: (comptime formatter : string) macro -> void { i := 0; in := 0; opening := 0; @@ -27,13 +28,8 @@ t :: (comptime formatter : string) macro -> string { }; */ -p :: () macro -> void { - @putc(a); - // print("Hello world"); -}; - main :: () -> void { - a := 'a'; - p(); + v := vector_new(u8); + delete(v); }; |