diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-07-15 20:40:49 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-07-15 20:40:49 -0400 |
| commit | 224c245a875a6f28c01e93d037329c708ef81dd4 (patch) | |
| tree | 7a368ccb80743651d5eb2f4b30a788ef70dae0ee | |
| parent | 4c008d258f6fd23fd64e2a6b059448748d7f7d24 (diff) | |
type var definitions
| -rw-r--r-- | docs/application/group.md | 1 | ||||
| -rw-r--r-- | docs/application/index.md | 10 | ||||
| -rw-r--r-- | docs/application/namespace.md | 29 | ||||
| -rw-r--r-- | docs/application/type.md | 16 | ||||
| -rw-r--r-- | docs/lifecycle/eval.md | 2 | ||||
| -rw-r--r-- | docs/lifecycle/ir.md | 4 | ||||
| -rw-r--r-- | docs/lifecycle/scope.md | 8 | ||||
| -rw-r--r-- | docs/type_system/bit.md | 4 | ||||
| -rw-r--r-- | docs/type_system/function.md | 19 | ||||
| -rw-r--r-- | docs/type_system/list.md | 9 |
10 files changed, 71 insertions, 31 deletions
diff --git a/docs/application/group.md b/docs/application/group.md index 1294afe..7ed6382 100644 --- a/docs/application/group.md +++ b/docs/application/group.md @@ -7,6 +7,7 @@ ```c typedef struct _kpl_group { KPL_DYNAMIC_OBJ_HEADER(); + int32_t item_length; kpl_class items[]; } kpl_group; ``` diff --git a/docs/application/index.md b/docs/application/index.md index 6c84525..0dd4b7e 100644 --- a/docs/application/index.md +++ b/docs/application/index.md @@ -40,6 +40,7 @@ * Built In Alias 5. Initialize IO * Size of registered sparse buffers +6. Initialize Jit ## Main @@ -62,7 +63,8 @@ ## Shutdown -1. Clean up IO -2. Clean up types -3. Clean up tasks -4. Clean up allocators +1. Clean up Jit +2. Clean up IO +3. Clean up types +4. Clean up tasks +5. Clean up allocators diff --git a/docs/application/namespace.md b/docs/application/namespace.md index e9842cd..cd1f89e 100644 --- a/docs/application/namespace.md +++ b/docs/application/namespace.md @@ -5,29 +5,24 @@ ## Object Definitions ```c -typedef struct _kpl_export { - int32_t tree_weight; - struct _kpl_export *tree_left, *tree_right; - kpl_type *type; -} kpl_export; +#define KPL_TREE_HEADER() uint32_t tree_weight, module_id; struct _kpl_namespace_tree *tree_left, *tree_right; kpl_buffer *name + +typedef struct _kpl_namespace_tree { + KPL_TREE_HEADER(); +} kpl_namespace_tree_obj; typedef struct _kpl_namespace_native { - int32_t tree_weight; - struct _kpl_namespace_native *tree_left, *tree_right; - const char *name; - kpl_export *export_tree; + KPL_TREE_HEADER(); + kpl_type *export_var_tree; } kpl_namespace_native; static kpl_namespace_native *namespace_native_tree; typedef struct _kpl_namespace_module { - uint32_t module_id; - int32_t tree_weight; - struct _kpl_namespace_module *tree_left, *tree_right; - kpl_buffer *module_string, *module_name; - kpl_export *export_tree; + KPL_TREE_HEADER(); + kpl_buffer *body; + kpl_type *ast, *export_var_tree; kpl_mutex export_mutex; - kpl_type *ast; } kpl_namespace_module; static kpl_namespace_module *namespace_module_tree; @@ -73,7 +68,7 @@ Add a [Register](../lifecycle/register.md) task to `namespace_module_mutex` ### ``export` -Add exports directly to the namespaces `export_tree`, thread safe +Add exports directly to the namespaces `export_var_tree`, thread safe ## String/REPL @@ -94,7 +89,7 @@ Since the native modules are loaded statically the `native_module_tree` becomes 1. Add find namespace task to the `namespace_module_mutex`, the namespace not existing is an error 2. Add a get export task to the namespaces `export_mutex` 3. The `export_mutex` will not start processing it's queue until the namespace notifies that it's and unlocks its `export_mutex` -4. The importer will get a copy of the read only `export_tree` +4. The importer will get a copy of the read only `export_var_tree` # AVL Tree Storage and Lookup diff --git a/docs/application/type.md b/docs/application/type.md index f028fba..3a831b2 100644 --- a/docs/application/type.md +++ b/docs/application/type.md @@ -26,6 +26,17 @@ typedef struct { int32_t position, module_id; } kpl_token; +typedef enum { + NONE, + GENERAL_REGISTER, + XMM_REGISTER, + STACK +} kpl_native_storage; + +typedef struct { + uint8_t storage : 2, id : 6; +} kpl_native_id; + typedef struct _kpl_type { kpl_type_template template; uint8_t qualifiers; @@ -33,7 +44,10 @@ typedef struct _kpl_type { union { kpl_token token; struct { - int32_t id, tree_weight; + kpl_native_id native_id; + int8_t process_state_id; // -1 not used + uint16_t tree_weight; + struct _kpl_type *function; } var; } meta; _Atomic ssize_t ref_count; diff --git a/docs/lifecycle/eval.md b/docs/lifecycle/eval.md index 659fa1e..b96482d 100644 --- a/docs/lifecycle/eval.md +++ b/docs/lifecycle/eval.md @@ -6,4 +6,6 @@ Reduce AST size by evaluating expressions ## Constant Expressions +## Known Variables + ## Type Operations diff --git a/docs/lifecycle/ir.md b/docs/lifecycle/ir.md index 1d63ce0..08659f0 100644 --- a/docs/lifecycle/ir.md +++ b/docs/lifecycle/ir.md @@ -4,6 +4,10 @@ Convert an AST into a list of 6 address instructions +# Ops + +# Actions + # Process ## Tasks diff --git a/docs/lifecycle/scope.md b/docs/lifecycle/scope.md index 64cf55b..1f4508b 100644 --- a/docs/lifecycle/scope.md +++ b/docs/lifecycle/scope.md @@ -2,16 +2,16 @@ --- -## Link Parent Lists +## Initialize Functions ## Create Vars -## Initialize Functions - -## Initialize Actions +## Link Functions Parents ## Split Process Into Tasks by `await` +## Initialize Actions + ## Register Imports On finding an import node add a register task for the imported string diff --git a/docs/type_system/bit.md b/docs/type_system/bit.md index 26d5a98..b5ffed3 100644 --- a/docs/type_system/bit.md +++ b/docs/type_system/bit.md @@ -7,7 +7,7 @@ A sequence of bits that can fit into a general register ```text SIZE_FLAGS : BIT_ANY | BIT8 | BIT16 | BIT32 | BIT64 -REPRESENTATION_FLAGS : INT | INT_UNSIGNED | INT_SIGNED | FLOAT | +REPRESENTATION_FLAGS : NUMBER | INT | INT_UNSIGNED | INT_SIGNED | FLOAT | UTF8 | UTF16 | UTF32 | BOOL | TYPE @@ -28,6 +28,8 @@ typedef struct { # Alias ```text +Number `alias Bit[[BIT_ANY | NUMBER]] + Int `alias Bit[[BIT_ANY | INT]] Int_unsiged `alias Bit[[BIT_ANY | INT_UNSIGNED]] diff --git a/docs/type_system/function.md b/docs/type_system/function.md index 129411c..1099a55 100644 --- a/docs/type_system/function.md +++ b/docs/type_system/function.md @@ -7,15 +7,16 @@ STATELESS : NATIVE | NATIVE_INLINE | PROCESS | GENERATOR | REGEX_GENERATOR STATEFUL : TASK | ITERATOR | CLOSURE | BOUND | REGEX -Function[[MODE | STATELESS | STATEFUL]; JIT; IR; Body; RETURN_TYPE; Collection[NAME_LIST; TYPE.SYMBOL]] +Function[[MODE | STATELESS | STATEFUL]; counters; JIT; IR; Body; Parent_Fn; RETURN_TYPE; Collection[NAME_LIST; TYPE.SYMBOL]] ``` ## Type Body Object Definitions ```c typedef struct { + int8_t process_state_id_counter, general_register_id_counter, xmm_register_id_counter, locals_counter; void *jit; - kpl_type *ir, *body, *return_type, *var_list; + kpl_type *ir, *body, *parent_function, *return_type, *var_list; } kpl_type_body_function; ``` @@ -32,6 +33,18 @@ Fn[Generic.T; Collection[VAR_TREE_LIST; TYPE.SYMBOL]] `alias Function[...] ([I64; I64.x; I64.y] x + y) // Fn[I64; I64.x; I64.y] ``` +# Casting To Functions + +```text +body : (x + y) +add_i64 : Fn[I64; I64.x; I64.y] $ body +add_f64 : Fn[F64.x; F64.y] $ body // return type is inferred +``` + +### Copy By Cast + +Casting a list to a function requires a copy of the list made for type checking and evaluation, use inline definitions if the list is meant to be a single function + # Function Classes ## Native @@ -142,4 +155,4 @@ fn `sync args // can be turned into `await fn `async args # Type Inference -The argument types of anonymous functions passed as an argument can be inhered +The argument types of anonymous functions passed as an argument can be inferred diff --git a/docs/type_system/list.md b/docs/type_system/list.md index 22ad03c..38ffe74 100644 --- a/docs/type_system/list.md +++ b/docs/type_system/list.md @@ -3,7 +3,7 @@ --- ```text -List[[STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] PARENT; TARGET; ARG; LOOP; VAR_TREE; Collection[LIST; TYPE]] +List[[STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] TARGET; DEFINED; NAMED; VAR_TREE; Collection[LIST; TYPE]] ``` ## Type Body Object Definitions @@ -13,3 +13,10 @@ typedef struct { kpl_type *target, *defined, *named, *var_tree, *statement_list; } kpl_type_body_list; ``` + +## Lists As Variables + +```test +list : (1; 2; 3) +`log list // List $ (1; 2; 3) +``` |
