diff options
Diffstat (limited to 'docs/application/type.md')
| -rw-r--r-- | docs/application/type.md | 72 |
1 files changed, 56 insertions, 16 deletions
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; +``` |
