summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-06-28 13:41:22 -0400
committernodist <kevin.comas.git@gmail.com>2026-06-28 13:41:22 -0400
commitcf9285b1dbdf687630076149413f16e5d4af82e8 (patch)
tree7c10f7587cab9cd40c0d1b9e019cd4a2135e7193
parent254059e2ea2df0cd63cf75d836ac9ebe00a28302 (diff)
type body object definitions and garbage collection algoHEADmain
-rw-r--r--docs/application/identifier.md4
-rw-r--r--docs/application/index.md13
-rw-r--r--docs/application/interface.md2
-rw-r--r--docs/application/memory.md13
-rw-r--r--docs/application/namespace.md2
-rw-r--r--docs/application/queue.md2
-rw-r--r--docs/application/shared.md24
-rw-r--r--docs/application/thread.md4
-rw-r--r--docs/application/type.md6
-rw-r--r--docs/language/index.md10
-rw-r--r--docs/lifecycle/parse.md2
-rw-r--r--docs/type_system/bit.md8
-rw-r--r--docs/type_system/buffer.md8
-rw-r--r--docs/type_system/error.md8
-rw-r--r--docs/type_system/function.md10
-rw-r--r--docs/type_system/group.md8
-rw-r--r--docs/type_system/list.md10
-rw-r--r--docs/type_system/lock.md8
-rw-r--r--docs/type_system/map.md8
-rw-r--r--docs/type_system/name.md11
-rw-r--r--docs/type_system/namespace.md13
-rw-r--r--docs/type_system/native.md8
-rw-r--r--docs/type_system/op.md7
-rw-r--r--docs/type_system/overload.md10
-rw-r--r--docs/type_system/queue.md8
-rw-r--r--docs/type_system/select.md8
-rw-r--r--docs/type_system/symbol.md11
-rw-r--r--docs/type_system/task.md8
-rw-r--r--docs/type_system/union.md8
-rw-r--r--docs/type_system/value.md10
-rw-r--r--docs/type_system/var.md4
31 files changed, 229 insertions, 27 deletions
diff --git a/docs/application/identifier.md b/docs/application/identifier.md
index 8f85b15..47dcd79 100644
--- a/docs/application/identifier.md
+++ b/docs/application/identifier.md
@@ -7,9 +7,9 @@ Store vars, types and symbols as compressed strings
## Object Definitions
```c
-#define KPL_IDENTIFIER_PARTS 9
+#define KPL_IDENTIFIER_PARTS 6
-// TODO 90 charaters of [A-Za-z0-9_] in 72 bytes
+// TODO 60 charaters of [A-Za-z0-9_] in 48 bytes
typedef struct {
uint64_t parts[KPL_IDENTIFIER_PARTS];
diff --git a/docs/application/index.md b/docs/application/index.md
index 279ff6c..d99b941 100644
--- a/docs/application/index.md
+++ b/docs/application/index.md
@@ -32,6 +32,12 @@
## Startup
+1. Configuration
+2. Initialize tasks
+3. Initialize types
+4. Initialize allocators
+5. Initialize IO
+
## Main
### Module
@@ -42,7 +48,7 @@
1. ##### [Register](../lifecycle/register.md)
2. ##### [Parse](../lifecycle/parse.md)
-3. ##### Scan
+3. ##### Scope
4. ##### Import
5. ##### Check
6. ##### Eval
@@ -52,3 +58,8 @@
10. ##### Notify
## Shutdown
+
+1. Clean up IO
+2. Clean up allocators
+3. Clean up types
+4. Clean up tasks
diff --git a/docs/application/interface.md b/docs/application/interface.md
index 6f33f61..5acfba7 100644
--- a/docs/application/interface.md
+++ b/docs/application/interface.md
@@ -28,6 +28,8 @@ typedef ssize_t kpl_any_cmp_fn(const kpl_any a, const kpl_any b);
typedef int32_t kpl_write(const kpl_ant a, FILE *file, int32_t idnt, uint32_t opts);
+// TODO GC FUNCTION
+
typedef void kpl_any_free_fn(kpl_any a);
typedef struct {
diff --git a/docs/application/memory.md b/docs/application/memory.md
index f5f457c..a8e75b8 100644
--- a/docs/application/memory.md
+++ b/docs/application/memory.md
@@ -45,12 +45,17 @@ typdef strcut _kpl_slab_tree_obj {
KPL_SLAB_TREE_HEADER(struct _kpl_slab_tree_obj);
} kpl_slab_tree_obj;
+typdef struct _kpl_slab_bucket {
+ struct _kpl_slab_bucket *next;
+ uint8_t byte_obj_array[];
+} kpl_slab_bucket;
+
typedef struct _kpl_slab {
- KPL_ALLOC_HEADER(struct _kpl_slab);
- uint32_t obj_size, byte_index;
+ uint16_t obj_count, obj_index;
+ uint32_t obj_size;
kpl_slab_obj *pool;
+ kpl_slab_bucket *bucket;
kpl_mutex mutex;
- uint8_t byte_array[];
} kpl_slab;
```
@@ -64,8 +69,6 @@ Each bucket in the `kpl_alloc.pool` represents two to the power of the bucket in
# Slab
-Allocated by `kpl_alloc`
-
## Pooling
Objects for reuse are stored as a list by the `kpl_slab_obj.prev` on `kpl_slab.pool`
diff --git a/docs/application/namespace.md b/docs/application/namespace.md
index 3f34f61..38752ce 100644
--- a/docs/application/namespace.md
+++ b/docs/application/namespace.md
@@ -6,7 +6,7 @@
```c
typedef struct _kpl_export {
- KPL_ALLOC_TREE_HEADER(struct _kpl_export);
+ KPL_SLAB_TREE_HEADER(struct _kpl_export);
kpl_type_ptr type;
} kpl_export;
diff --git a/docs/application/queue.md b/docs/application/queue.md
index 2807ce9..cd9f363 100644
--- a/docs/application/queue.md
+++ b/docs/application/queue.md
@@ -11,7 +11,7 @@ typedef struct _kpl_queue_item {
} kpl_queue_item;
typedef struct _kpl_queue {
- KPL_ALLOC_HEADER(struct _kpl_queue);
+ KPL_SLAB_HEADER(struct _kpl_queue);
size_t item_length;
kpl_interface *interface;
kpl_pool_any *head, *tail;
diff --git a/docs/application/shared.md b/docs/application/shared.md
index 0990ae6..f597d8d 100644
--- a/docs/application/shared.md
+++ b/docs/application/shared.md
@@ -11,6 +11,28 @@ typedef struct _kpl_shared {
kpl_mutex mutex;
bool mark;
} kpl_shared;
+
+_Atomic uint32_t shared_threads_makred;
+
+static kpl_shared *shared_mark_head, *shared_head;
+
+static kpl_mutex shared_head_mutex;
```
-## Garbage Collection
+# Garbage Collection
+
+## Initiation Task
+
+1. Move `shared_head` to `shared_mark_head`
+2. Add a mark task to each of the threads
+
+## Mark Task(s)
+
+1. Run gc interface on each task in the queue
+2. Increase `shared_threads_makred`
+3. If `shared_threads_makred` is equal to `avaiable_threads` schedule sweep task
+
+## Sweep Task
+
+1. Go through `shared_mark_head` freeing anything that is not marked
+2. Add anything left on `shared_mark_head` to `shared_head`
diff --git a/docs/application/thread.md b/docs/application/thread.md
index ff03183..d564d20 100644
--- a/docs/application/thread.md
+++ b/docs/application/thread.md
@@ -14,7 +14,7 @@ typedef void kpl_task_fn(kpl_task *t);
typedef struct _task {
task *_Atomic next, *join;
kpl_class state[KPL_TASK_STATE_SIZE];
- kpl_result return_value;
+ kpl_result result;
task_fn *fn;
int32_t thread_id;
int16_t state_length;
@@ -24,7 +24,6 @@ typedef struct _task {
#define KPL_TASK_SLAB_SIZE 50
typedef struct _kpl_task_slab {
- size_t array_index;
struct _kpl_task_slab *next;
kpl_task array[KPL_TASK_SLAB_SIZE];
} kpl_task_slab;
@@ -43,6 +42,7 @@ typedef struct {
typedef struct {
kpl_task_queue queue;
_Atomic ssize_t priority;
+ size_t slab_array_index;
kpl_task_slab *slab;
kpl_task *pool;
sem_t counter;
diff --git a/docs/application/type.md b/docs/application/type.md
index 43a8f2c..40546c1 100644
--- a/docs/application/type.md
+++ b/docs/application/type.md
@@ -17,17 +17,17 @@ typedef enum {
} kpl_type_qualifiers;
typedef union {
- // 96 Bytes Max
+ // 64 Bytes Max
} kpl_type_body;
typedef struct {
kpl_type_template template;
uint8_t qualifiers;
uint16_t modifiers;
- kpl_ptr self, prev, next;
- uint32_t token_position,
uint16_t token_length, token_line;
+ uint32_t token_position;
_Atomic int32_t ref_count;
+ kpl_ptr self, prev, next;
kpl_namespace_module *module;
kpl_type_body body;
} kpl_type;
diff --git a/docs/language/index.md b/docs/language/index.md
index 2a8ff49..4fdccb6 100644
--- a/docs/language/index.md
+++ b/docs/language/index.md
@@ -58,6 +58,10 @@ Underscores `_` can separate digits in a number
'A'
```
+### String literals have a `2 ^ 16 - 2` token byte limit
+
+### Char literals have a `6` token byte limit
+
Any UTF-8 glyph is allowed between `""` or `''`
```text
@@ -72,13 +76,13 @@ Start with a lowercase letter
Variables starting with `_` are treated as unused
-### Variables names have a 90 character limit
+### Variables names have a 60 character limit
## Type Names
Start with an uppercase letter created with either \`alias or \`unique
-### Type names have a 90 character limit
+### Type names have a 60 character limit
## Type Qualifiers
@@ -113,7 +117,7 @@ Start with a `.`
.symbol
```
-### Symbols have a 90 character limit
+### Symbols have a 60 character limit
# Lists
diff --git a/docs/lifecycle/parse.md b/docs/lifecycle/parse.md
index 94fd76e..4c5851d 100644
--- a/docs/lifecycle/parse.md
+++ b/docs/lifecycle/parse.md
@@ -3,3 +3,5 @@
---
Build initial AST
+
+## Initialize
diff --git a/docs/type_system/bit.md b/docs/type_system/bit.md
index a5ba35f..ba11f30 100644
--- a/docs/type_system/bit.md
+++ b/docs/type_system/bit.md
@@ -14,6 +14,14 @@ REPRESENTATION_FLAGS : NUMERIC | INT | INT_UNSIGNED | INT_SIGNED | FLOAT |
Bit[[SIZE_FLAGS | REPRESENTATION_FLAGS]]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ // EMPTY
+} kpl_type_body_bit;
+```
+
# Casting
# Alias
diff --git a/docs/type_system/buffer.md b/docs/type_system/buffer.md
index 983fd4a..dca8ab9 100644
--- a/docs/type_system/buffer.md
+++ b/docs/type_system/buffer.md
@@ -8,6 +8,14 @@ An sequence of bytes with unknown size and a byte representation
Buffer[[TYPE | UTF8 | UTF16 | UTF32] TYPE]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type;
+} kpl_type_body_buffer;
+```
+
# Alias
```text
diff --git a/docs/type_system/error.md b/docs/type_system/error.md
index bbf58c7..fbd15eb 100644
--- a/docs/type_system/error.md
+++ b/docs/type_system/error.md
@@ -8,6 +8,14 @@ An error for reporting, the data used to create it cannot be accessed
Error[[]]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ // EMPTY
+} kpl_type_body_error;
+```
+
## Example
```text
diff --git a/docs/type_system/function.md b/docs/type_system/function.md
index e2e2c4c..af17b74 100644
--- a/docs/type_system/function.md
+++ b/docs/type_system/function.md
@@ -11,7 +11,15 @@ STATEFUL : TASK | ITERATOR | CLOSURE | BOUND | REGEX
FLAGS : INVOCATION | STATELESS | STATEFUL
-Function[[FLAGS]; STATE; List; RETURN_TYPE; Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
+Function[[FLAGS]; Body; RETURN_TYPE; Collection[VAR_LIST; TYPE.SYMBOL]]
+```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr body, return_type, var_list;
+} kpl_type_body_function;
```
# Alias
diff --git a/docs/type_system/group.md b/docs/type_system/group.md
index dcc3c0a..213e3e0 100644
--- a/docs/type_system/group.md
+++ b/docs/type_system/group.md
@@ -8,6 +8,14 @@ A sequence of different types accessed by index or a symbol mapped to an index
Group[[INDEX | SYMBOL] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr var_tree, var_list;
+} kpl_type_body_group;
+```
+
# Alias
```text
diff --git a/docs/type_system/list.md b/docs/type_system/list.md
index 0c90515..cbd7f84 100644
--- a/docs/type_system/list.md
+++ b/docs/type_system/list.md
@@ -3,5 +3,13 @@
---
```text
-List[[ROOT | STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] Parent; VAR_TREE_LIST; TARGET; STATEMENTS ...]
+List[[ROOT | STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] PARENT; TARGET; VAR_TREE; Collection[LIST; TYPE]]
+```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr parent, target, var_tree, statement_list;
+} kpl_type_body_list;
```
diff --git a/docs/type_system/lock.md b/docs/type_system/lock.md
index 3b7d90a..d03dbfa 100644
--- a/docs/type_system/lock.md
+++ b/docs/type_system/lock.md
@@ -6,4 +6,12 @@
Lock[[] TARGET]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr target;
+} kpl_type_body_lock;
+```
+
Prevent access to `TARGET` until a mutation occurs
diff --git a/docs/type_system/map.md b/docs/type_system/map.md
index 68b0464..44cd6cf 100644
--- a/docs/type_system/map.md
+++ b/docs/type_system/map.md
@@ -6,6 +6,14 @@
Map[[] KEY_TYPE; VALUE_TYPE]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr key, value;
+} kpl_type_body_map;
+```
+
# Alias
```text
diff --git a/docs/type_system/name.md b/docs/type_system/name.md
index 27bb784..1f0c332 100644
--- a/docs/type_system/name.md
+++ b/docs/type_system/name.md
@@ -3,5 +3,14 @@
---
```text
-Name[[UNKNOWN | IS_TYPE | ALIAS_TYPE | UNIQUE_TYPE] TYPE; IDENTIFIER]
+Name[[UNKNOWN | DATA_TYPE | ALIAS_TYPE | UNIQUE_TYPE] TYPE; IDENTIFIER]
+```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type;
+ kpl_interface identifier;
+} kpl_type_body_name;
```
diff --git a/docs/type_system/namespace.md b/docs/type_system/namespace.md
index 8e300b9..d3a43db 100644
--- a/docs/type_system/namespace.md
+++ b/docs/type_system/namespace.md
@@ -3,7 +3,18 @@
---
```text
-Namespace[[NATIVE | MODULE] NAMESPACE_IDENTIFIER]
+Namespace[[NATIVE | MODULE | MAIN] NAMESPACE_POINTER]
+```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ union {
+ kpl_namespace_native *native;
+ kpl_namespace_module *module;
+ } namespace;
+} kpl_type_body_namespace;
```
## Exports
diff --git a/docs/type_system/native.md b/docs/type_system/native.md
index 875314f..db34181 100644
--- a/docs/type_system/native.md
+++ b/docs/type_system/native.md
@@ -8,6 +8,14 @@ A representation of a native object
Native[[] INTERFACE_TABLE_POINTER]
```
+## Type Body Object Definitions
+
+```c
+typdef struct {
+ kpl_interface *interface;
+} kpl_type_body_native;
+```
+
## Alias
```text
diff --git a/docs/type_system/op.md b/docs/type_system/op.md
index 198d73f..79f0953 100644
--- a/docs/type_system/op.md
+++ b/docs/type_system/op.md
@@ -5,5 +5,12 @@
```text
Op[[OP_NAME] RETURN_TYPE; LEFT_TYPE; RIGHT_TYPE]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr return_type, statement_left, statement_right;
+} kpl_type_body_op;
+```
The `OP_NAME` a single value
diff --git a/docs/type_system/overload.md b/docs/type_system/overload.md
index fc60602..bc083e2 100644
--- a/docs/type_system/overload.md
+++ b/docs/type_system/overload.md
@@ -5,7 +5,15 @@
List of complete functions, selected by signature
```text
-Overload[[] Collection[VAR_TREE_LIST; Function[]]]
+Overload[[] Collection[VAR_LIST; Function[]]]
+```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr var_list;
+} kpl_type_body_overload;
```
## Example
diff --git a/docs/type_system/queue.md b/docs/type_system/queue.md
index 0a15d36..3b17512 100644
--- a/docs/type_system/queue.md
+++ b/docs/type_system/queue.md
@@ -6,6 +6,14 @@
Queue[[] TYPE]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type;
+} kpl_type_body_queue;
+```
+
# Operators
## ``length`
diff --git a/docs/type_system/select.md b/docs/type_system/select.md
index 5cee24a..4ef3bbb 100644
--- a/docs/type_system/select.md
+++ b/docs/type_system/select.md
@@ -8,6 +8,14 @@ A symbol associated with a type
Select[[SINGLE | MULTIPLE] Type; Collection[VAR_TREE_LIST; .symbol : %const Value]]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type, var_tree, var_list;
+} kpl_type_body_select;
+```
+
# Alias
```text
diff --git a/docs/type_system/symbol.md b/docs/type_system/symbol.md
index 3ce926e..ae5595f 100644
--- a/docs/type_system/symbol.md
+++ b/docs/type_system/symbol.md
@@ -3,5 +3,14 @@
---
```text
-Symbol[[] TARGET; TYPE; IDENTIFIER]
+Symbol[[] TYPE; TARGET; IDENTIFIER]
+```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type, target;
+ kpl_identifier identifier;
+} kpl_type_body_symbol;
```
diff --git a/docs/type_system/task.md b/docs/type_system/task.md
index 2cb0a4d..3561737 100644
--- a/docs/type_system/task.md
+++ b/docs/type_system/task.md
@@ -8,4 +8,12 @@ A segment of code assigned to a process, task code can be recursive
Task[[] TYPE]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type;
+} kpl_type_body_task;
+```
+
## \`await
diff --git a/docs/type_system/union.md b/docs/type_system/union.md
index 334c443..adaed4e 100644
--- a/docs/type_system/union.md
+++ b/docs/type_system/union.md
@@ -6,6 +6,14 @@
Union[CONTAINER | TRANSIENT] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
```
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr var_tree, var_list;
+} kpl_type_body_union;
+```
+
# Alias
```text
diff --git a/docs/type_system/value.md b/docs/type_system/value.md
index d2e23d1..19b150a 100644
--- a/docs/type_system/value.md
+++ b/docs/type_system/value.md
@@ -5,3 +5,13 @@
```text
Value[[] TYPE; ID; KPL_CLASS]
```
+
+## Type Body Object Definitions
+
+```c
+typedef struct {
+ kpl_ptr type;
+ int32_t id;
+ kpl_class *class;
+} kpl_type_body_value;
+```
diff --git a/docs/type_system/var.md b/docs/type_system/var.md
index 4e14e1f..1a5119f 100644
--- a/docs/type_system/var.md
+++ b/docs/type_system/var.md
@@ -10,8 +10,8 @@ Var[[SYMBOL | SCOPE | ARG | LOCAL | LOOP | IF | MATCH | MUTATE] TYPE; LEFT_VAR;
```c
typedef struct {
- kpl_ptr type, left, right;
+ kpl_ptr type, tree_left, tree_right;
uint32_t tree_weight;
kpl_identifier identifier;
-} type_var_body;
+} kpl_type_body_var;
```