From 88646efb1c2615e6d8ff0a2eae047a5ed2a31dd4 Mon Sep 17 00:00:00 2001 From: nodist Date: Thu, 25 Jun 2026 15:27:38 -0400 Subject: all names will live on global trie --- docs/application/index.md | 2 +- docs/application/interface.md | 6 ++++++ docs/application/memory.md | 2 +- docs/application/name.md | 27 ++++++++++++++++++++++++--- docs/application/namespace.md | 12 ++++++------ docs/application/type.md | 14 +++----------- docs/lifecycle/parse.md | 2 ++ docs/lifecycle/register.md | 7 ++++--- docs/lifecycle/scan.md | 5 +++++ mkdocs.yml | 1 + 10 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 docs/lifecycle/scan.md diff --git a/docs/application/index.md b/docs/application/index.md index c6153b6..e31ecff 100644 --- a/docs/application/index.md +++ b/docs/application/index.md @@ -42,7 +42,7 @@ 1. ##### [Register](../lifecycle/register.md) 2. ##### [Parse](../lifecycle/parse.md) -3. ##### Scan +3. ##### [Scan](../lifecycle/scan.md) 4. ##### Scope 5. ##### Import 6. ##### Check diff --git a/docs/application/interface.md b/docs/application/interface.md index b60da5e..6f33f61 100644 --- a/docs/application/interface.md +++ b/docs/application/interface.md @@ -42,4 +42,10 @@ typedef struct { typedef struct { any value, info; } kpl_result; + +typdef struct { + uint16_t slab_index, array_index; +} kpl_ptr; + +#define KPL_PTR_NULL (kpl_ptr) { .slab_index = UINT16_MAX, .array_index = UINT16_MAX } ``` diff --git a/docs/application/memory.md b/docs/application/memory.md index a7eab83..f5f457c 100644 --- a/docs/application/memory.md +++ b/docs/application/memory.md @@ -50,7 +50,7 @@ typedef struct _kpl_slab { uint32_t obj_size, byte_index; kpl_slab_obj *pool; kpl_mutex mutex; - uint8_t byte_array[MAX_SIZE]; + uint8_t byte_array[]; } kpl_slab; ``` diff --git a/docs/application/name.md b/docs/application/name.md index 3c00aa0..d605b81 100644 --- a/docs/application/name.md +++ b/docs/application/name.md @@ -7,8 +7,29 @@ Each word representing a var, symbol or type gets an `NAME_IDENTIFIER` -> `kpl_n ## Object Definitions ```c -typedef struct _kpl_name { - KPL_ALLOC_TREE_HEADER(struct _kpl_name); - char c_str[]; +#define KPL_LETTER_COUNT 26 + +#define KPL_NAME_COUNT 43 + +#define KPL_NAME_SIZE 44 + +typedef struct { + kpl_ptr underscore, lowercase[KPL_LETTER_COUNT], uppercase[KPL_LETTER_COUNT]; + char name[KPL_NAME_SIZE]; +} kpl_name_node; + +typedef strcut { + kpl_name_node array[UINT16_MAX]; +} kpl_name_array; + +typedef strcut { + uint16_t slab_index, array_index; + kpl_mutex mutex; + kpl_ptr root; + kpl_name_array *slab[UINT16_MAX]; } kpl_name; ``` + +## Usage + +The only operation into the trie is a findsert with a pointer to a string and its length, returning a pointer to the found or inserted node diff --git a/docs/application/namespace.md b/docs/application/namespace.md index cbf768d..7cb6a3c 100644 --- a/docs/application/namespace.md +++ b/docs/application/namespace.md @@ -25,10 +25,10 @@ typedef enum : uint8_t { typedef struct _kpl_namespace_module { KPL_SLAB_TREE_HEADER(struct _kpl_namespace_module); kpl_type_ptr ast; - kpl_name *name_tree; kpl_buffer *module_name, *module_string; + kpl_task *_Atomic task; kpl_export *export_tree; - kpl_mutex mutex; + kpl_mutex export_mutex; } kpl_namespace_module; static kpl_namespace_module *namespace_module_tree; @@ -37,9 +37,8 @@ kpl_mutex namespace_module_mutex; typedef struct _kpl_namespace_string { kpl_type_ptr ast; - kpl_name *name_tree; kpl_buffer *string; - kpl_mutex mutex; + kpl_task *_Atomic task; } kpl_namespace_string; static kpl_namespace_string namespace_string @@ -98,5 +97,6 @@ Since the native modules are loaded statically the `native_module_tree` becomes ### Import ``import` 1. Add find namespace task to the `namespace_module_mutex`, the namespace not existing is an error -2. Add task to the namespaces `mutex` -3. The task will resume the importer +2. Add a get export task to the namespaces `export_mutex` +3. The `export_mutex` will not start processing it's queue until the `task` field is `NULL` +4. The importer will get a copy of the read only `export_tree` diff --git a/docs/application/type.md b/docs/application/type.md index c985b35..5377cf6 100644 --- a/docs/application/type.md +++ b/docs/application/type.md @@ -5,16 +5,6 @@ ## Object Definitions ```c -#define KPL_TYPE_BLOCK_ARRAY_SIZE UINT16_MAX - -#define KPL_TYPE_BLOCKS_SIZE UINT16_MAX - -typedef struct { - uint16_t slab_index, slab_array_index; -} kpl_type_ptr; - -static const kpl_type_ptr kpl_type_ptr_null = { UINT16_MAX, UINT16_MAX }; - typedef enum : uint8_t { // ... } kpl_type_template; @@ -35,9 +25,11 @@ typedef struct { uint8_t qualifiers; uint16_t modifiers; _Atomic int32_t ref_count; + kpl_namespace_module *module; + uint32_t token_line, token_position, token_length; kpl_ptr self; kpl_type_body body; } kpl_type; -// TODO slab store for kpl_type_ptr +// TODO SLAB WITH POOL ``` diff --git a/docs/lifecycle/parse.md b/docs/lifecycle/parse.md index 458ba97..94fd76e 100644 --- a/docs/lifecycle/parse.md +++ b/docs/lifecycle/parse.md @@ -1,3 +1,5 @@ # Parse --- + +Build initial AST diff --git a/docs/lifecycle/register.md b/docs/lifecycle/register.md index 1de8cdc..f5b15a2 100644 --- a/docs/lifecycle/register.md +++ b/docs/lifecycle/register.md @@ -5,11 +5,12 @@ ## Module 1. Add findsert task to `namespace_module_mutex` - * If found end findsert task + * If found, stop 2. Create the namespace and add to namespace tree -3. Create task on the new namespaces `mutex` to read the file into a string +3. Create task on the new namespaces to read the file into a string 4. On completion of the read task add a parse task into the namespace mutex ## String -1. Add run task with new `kpl_buffer` to `kpl_name_string`'s `mutex` +1. Add task to set new `kpl_buffer` to `kpl_name_string`'s +2. The set task will add a parse task to the `kpl_name_string` diff --git a/docs/lifecycle/scan.md b/docs/lifecycle/scan.md new file mode 100644 index 0000000..55b62bc --- /dev/null +++ b/docs/lifecycle/scan.md @@ -0,0 +1,5 @@ +# Scan + +--- + +Register modules and assign identifiers to names diff --git a/mkdocs.yml b/mkdocs.yml index f715fa2..9a70a99 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -59,3 +59,4 @@ nav: - Life Cycle: - Register: 'lifecycle/register.md' - Parse: 'lifecycle/parse.md' + - Scan: 'lifecycle/scan.md' -- cgit v1.2.3