diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/application/index.md | 2 | ||||
| -rw-r--r-- | docs/application/namespace.md | 10 | ||||
| -rw-r--r-- | docs/application/type.md | 72 | ||||
| -rw-r--r-- | docs/lifecycle/check.md | 11 | ||||
| -rw-r--r-- | docs/lifecycle/ir.md | 10 | ||||
| -rw-r--r-- | docs/lifecycle/jit.md | 25 | ||||
| -rw-r--r-- | docs/lifecycle/scope.md | 8 | ||||
| -rw-r--r-- | docs/type_system/generic.md | 9 | ||||
| -rw-r--r-- | docs/type_system/ir.md | 4 | ||||
| -rw-r--r-- | docs/type_system/list.md | 4 | ||||
| -rw-r--r-- | docs/type_system/op.md | 5 | ||||
| -rw-r--r-- | docs/type_system/select.md | 4 | ||||
| -rw-r--r-- | docs/type_system/var.md | 2 |
13 files changed, 131 insertions, 35 deletions
diff --git a/docs/application/index.md b/docs/application/index.md index 0dd4b7e..804e952 100644 --- a/docs/application/index.md +++ b/docs/application/index.md @@ -41,6 +41,8 @@ 5. Initialize IO * Size of registered sparse buffers 6. Initialize Jit +7. Initialize Op Matching +8. Initialize Ir Matching ## Main diff --git a/docs/application/namespace.md b/docs/application/namespace.md index cd1f89e..d276fd0 100644 --- a/docs/application/namespace.md +++ b/docs/application/namespace.md @@ -5,21 +5,21 @@ ## Object Definitions ```c -#define KPL_TREE_HEADER() uint32_t tree_weight, module_id; struct _kpl_namespace_tree *tree_left, *tree_right; kpl_buffer *name +#define KPL_TREE_HEADER(STRUCT) uint32_t tree_weight, module_id; STRUCT *tree_left, *tree_right; kpl_buffer *name -typedef struct _kpl_namespace_tree { - KPL_TREE_HEADER(); +typedef struct _kpl_namespace_tree_obj { + KPL_TREE_HEADER(struct _kpl_namespace_tree_obj); } kpl_namespace_tree_obj; typedef struct _kpl_namespace_native { - KPL_TREE_HEADER(); + KPL_TREE_HEADER(struct _kpl_namespace_native); kpl_type *export_var_tree; } kpl_namespace_native; static kpl_namespace_native *namespace_native_tree; typedef struct _kpl_namespace_module { - KPL_TREE_HEADER(); + KPL_TREE_HEADER(struct _kpl_namespace_module); kpl_buffer *body; kpl_type *ast, *export_var_tree; kpl_mutex export_mutex; diff --git a/docs/application/type.md b/docs/application/type.md index 796d848..b16b70f 100644 --- a/docs/application/type.md +++ b/docs/application/type.md @@ -10,16 +10,18 @@ typedef enum : uint8_t { } kpl_type_template; typedef enum : uint8_t { - CONST = 1 << 0, - EMPTY = 1 << 1, - REF = 1 << 2, - SHARED = 1 << 3, - RETURN = 1 << 4 + 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 union { - // 64 Bytes Max -} kpl_type_body; +typedef struct { + kpl_type_template template; + uint8_t qualifiers; + uint16_t modifiers; +} kpl_type_header; typedef struct { uint16_t length, line; @@ -27,20 +29,22 @@ typedef struct { } kpl_token; typedef enum { - NONE, - GENERAL_REGISTER, - XMM_REGISTER, - STACK + 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_template template; - uint8_t qualifiers; - uint16_t modifiers; + kpl_type_header header; union { kpl_token token; struct { @@ -58,4 +62,40 @@ typedef struct _kpl_type { # Type Matching -For type checking and evaluation +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; +``` diff --git a/docs/lifecycle/check.md b/docs/lifecycle/check.md index f556230..cdaea80 100644 --- a/docs/lifecycle/check.md +++ b/docs/lifecycle/check.md @@ -4,8 +4,13 @@ Type checking -## Ops +# Ops -## Actions +# Actions + +## Branches + +# Functions + +## Return Type -## Functions diff --git a/docs/lifecycle/ir.md b/docs/lifecycle/ir.md index 08659f0..376189c 100644 --- a/docs/lifecycle/ir.md +++ b/docs/lifecycle/ir.md @@ -6,8 +6,18 @@ Convert an AST into a list of 6 address instructions # Ops +## Boolean + # Actions +## If + +## Loop + +## Match + +## Mutate + # Process ## Tasks diff --git a/docs/lifecycle/jit.md b/docs/lifecycle/jit.md index 3ff7079..3ef73e0 100644 --- a/docs/lifecycle/jit.md +++ b/docs/lifecycle/jit.md @@ -53,3 +53,28 @@ kpl_x64_inst(INSTRUCTION, [TYPE, VALUE]..., END) kpl_x64_inst_pfx(PREFIX, INSTRUCTION, [TYPE, VALUE]..., END) ``` + +# Ir Matching + +Use tree with sub trees to match Ir operations to JIT functions + +1. Match Name +2. Match Args until None or End +3. Run JIT Fn + +## Object Definitions + +```c +typedef struct _kpl_ir_match { + int32_t tree_weight; + union { + kpl_ir_name ir_name; + kpl_type_header type_header; + } match; + union { + struct _kpl_ir_match *children; + void *jit_fn; // TODO + } next; + struct _kpl_ir_match *tree_left *tree_right; +} kpl_ir_match; +``` diff --git a/docs/lifecycle/scope.md b/docs/lifecycle/scope.md index 68862bc..3310888 100644 --- a/docs/lifecycle/scope.md +++ b/docs/lifecycle/scope.md @@ -4,12 +4,14 @@ ## Initialize Functions +## Type Variables + +## Link Functions Parents + ## Link Function Scopes ## Create Vars -## Link Functions Parents - ## Initialize Actions ## Split Process Into Tasks by `await` @@ -19,3 +21,5 @@ On finding an import node add a register task for the imported string ## Initialize Generics + +## Resolve Unique And Alias Types diff --git a/docs/type_system/generic.md b/docs/type_system/generic.md index 2b9a89f..e028788 100644 --- a/docs/type_system/generic.md +++ b/docs/type_system/generic.md @@ -11,6 +11,7 @@ Generic[[TYPE | SYMBOL] TARGET; Collection[VAR_TREE_LIST; TYPE.SYMBOL]] ```c typedef struct { kpl_type *target, *var_tree, *var_list; + kpl_identifier identifier; } kpl_type_body_generic; ``` @@ -19,14 +20,14 @@ typedef struct { ```text ints : Set[I64] $ () /* -ints -> Name[[DATA] Var[[LOCAL] Generic[[TYPE] REF_SET; Symbol[Void; REF_I64; T]; ints]; ints] -REF_SET -> Name[[ALIAS] Map[Symbol[Void; Generic[[SYMBOL]]; T]; Void]; Set] +ints -> Name[[DATA] Var[[LOCAL] Generic[[TYPE] REF_SET; Var[[GENERIC] REF_I64; T]; ints]; ints] +REF_SET -> Name[[ALIAS] Map[Generic[[SYMBOL] T]; Void]; Set] REF_I64 -> Name[[Alias] Bit[[BIT64 | INT_SIGNED]]; I64] */ floats : Array[F64] $ () /* -floats -> Name[[DATA] Var[[LOCAL] Generic[[TYPE] REF_ARRAY; Symbol[Void; REF_F64; T]; floats]; floats] -REF_ARRAY -> Name[[ALIAS] Buffer[[TYPE] Symbol[Void; Generic[[SYMBOL]]; T]; Array] +floats -> Name[[DATA] Var[[LOCAL] Generic[[TYPE] REF_ARRAY; Var[[GENERIC] REF_F64; T]; floats]; floats] +REF_ARRAY -> Name[[ALIAS] Buffer[[TYPE] Generic[[SYMBOL]; T]; Array] REF_F64 -> Name[[Alias] Bit[BIT64 | FLOAT]; F64] */ ``` diff --git a/docs/type_system/ir.md b/docs/type_system/ir.md index 4b9ea44..9ebfd79 100644 --- a/docs/type_system/ir.md +++ b/docs/type_system/ir.md @@ -15,4 +15,8 @@ typedef struct { ssize_t label; kpl_type *address[6]; } kpl_type_body_ir; + +typedef enum : uint16_t { + +} kpl_ir_name; ``` diff --git a/docs/type_system/list.md b/docs/type_system/list.md index bce9361..958bcfb 100644 --- a/docs/type_system/list.md +++ b/docs/type_system/list.md @@ -3,14 +3,14 @@ --- ```text -List[[STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] TARGET; DEFINED; NAMED; FUNCTION; VAR_TREE; Collection[LIST; TYPE]] +List[[STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] TARGET; DEFINED; NAMED; LIST; FUNCTION; VAR_TREE; Collection[LIST; TYPE]] ``` ## Type Body Object Definitions ```c typedef struct { - kpl_type *target, *defined, *named, *function; *var_tree, *statement_list; + kpl_type *target, *defined, *named, *list, *function; *var_tree, *statement_list; } kpl_type_body_list; ``` diff --git a/docs/type_system/op.md b/docs/type_system/op.md index f5b935a..868c41b 100644 --- a/docs/type_system/op.md +++ b/docs/type_system/op.md @@ -14,3 +14,8 @@ Op[[OP_NAME] RETURN_TYPE; LEFT_TYPE; RIGHT_TYPE] typedef struct { kpl_type *return_type, *statement_left, *statement_right; } kpl_type_body_op; + +typedef enum : uint16_t { + +} kpl_op_name; +``` diff --git a/docs/type_system/select.md b/docs/type_system/select.md index 9218b56..31ad83c 100644 --- a/docs/type_system/select.md +++ b/docs/type_system/select.md @@ -27,6 +27,6 @@ Mask `definition Select[[MASK]; Void; Collection[VAR_TREE_LIST; .symbol]] ## Definition Example ```text -E : Enum[I64; .a; .b; .c] -`log E // Enum[I64; .a : 0; .b : 1; .c : 2] +e : Enum[I64; .a; .b; .c] +`log E // Select[[ENUM] I64; .a : 0; .b : 1; .c : 2] ``` diff --git a/docs/type_system/var.md b/docs/type_system/var.md index 6bf114d..4d88c5b 100644 --- a/docs/type_system/var.md +++ b/docs/type_system/var.md @@ -3,7 +3,7 @@ --- ```text -Var[[SYMBOL | SCOPE | ARG | LOCAL | LOOP | IF | MATCH | MUTATE] TYPE; LEFT_VAR; RIGHT_VAR; IDENTIFIER] +Var[[GENERIC | ARG | LOCAL | LOOP | IF | MATCH | MUTATE] TYPE; LEFT_VAR; RIGHT_VAR; IDENTIFIER] ``` ## Type Body Object Definition |
