From bb912b081ed339e4a5419bd3d2ffd7465f2f72d3 Mon Sep 17 00:00:00 2001 From: nodist Date: Mon, 27 Jul 2026 17:17:56 -0400 Subject: bottom up redesign --- docs/application/type.md | 101 ----------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 docs/application/type.md (limited to 'docs/application/type.md') diff --git a/docs/application/type.md b/docs/application/type.md deleted file mode 100644 index b16b70f..0000000 --- a/docs/application/type.md +++ /dev/null @@ -1,101 +0,0 @@ -# Type - ---- - -## Object Definitions - -```c -typedef enum : uint8_t { - // ... -} kpl_type_template; - -typedef enum : uint8_t { - KPL_TYPE_QUALIFIER_CONST = 1 << 0, - KPL_TYPE_QUALIFIER_EMPTY = 1 << 1, - KPL_TYPE_QUALIFIER_REF = 1 << 2, - KPL_TYPE_QUALIFIER_SHARED = 1 << 3, - KPL_TYPE_QUALIFIER_RETURN = 1 << 4 -} kpl_type_qualifiers; - -typedef struct { - kpl_type_template template; - uint8_t qualifiers; - uint16_t modifiers; -} kpl_type_header; - -typedef struct { - uint16_t length, line; - int32_t position, module_id; -} kpl_token; - -typedef enum { - KPL_NATIVE_STORAGE_NONE, - KPL_NATIVE_STORAGE_GENERAL_REGISTER, - KPL_NATIVE_STORAGE_XMM_REGISTER, - KPL_NATIVE_STORAGE_STACK -} kpl_native_storage; - -typedef struct { - uint8_t storage : 2, id : 6; -} kpl_native_id; - -typedef union { - // 64 Bytes Max -} kpl_type_body; - -typedef struct _kpl_type { - kpl_type_header header; - union { - kpl_token token; - struct { - kpl_native_id native_id; - int8_t process_state_id; // -1 not used - uint16_t tree_weight; - struct _kpl_type *list; - } var; - } meta; - _Atomic ssize_t ref_count; - struct _kpl_type *prev, *next; - kpl_type_body body; -} kpl_type; -``` - -# Type Matching - -For type checking, evaluation and Ir generation - -Match based on the templates, from end of each statement to its start - -## Op Matching - -Each Step is represented as a tree with sequential steps as sub trees - -1. Op Name -2. Op Return Type -3. Op Left -4. Op Right -5. Match Mode (Check, Eval, Ir) - -```c -typedef enum : uint8_t { - KPL_OP_MATCH_CHECK, - KPL_OP_MATCH_EVAL, - KPL_OP_MATCH_IR -} kpl_op_match_mode; - -typedef struct _kpl_op_match { - int32_t tree_weight; - union { - kpl_op_match_mode mode; - kpl_op_name op_name; - kpl_type_header header; - } value; - union { - struct _kpl_op_match *children; - union { - // TODO FUNCTION POINTERS FOR EACH MODE - } fn; - } next; - struct _kpl_op_match *tree_left, *tree_right; -} kpl_op_match; -``` -- cgit v1.2.3