aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/type.h
blob: 546a1edc2fbeaa5dfb2b8b72c706d626f575d542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * KPL Types
 * A Type is a declaration of code and data
 */

#pragma once

typedef enum : uint8_t {
    KPL_TYPE_NAME_UNKOWN,
    // VALUES
    KPL_TYPE_NAME_BOOLEAN,
    KPL_TYPE_NAME_INTEGER,
    KPL_TYPE_NAME_U8,
    KPL_TYPE_NAME_U16,
    KPL_TYPE_NAME_U32,
    KPL_TYPE_NAME_U64,
    KPL_TYPE_NAME_I8,
    KPL_TYPE_NAME_I16,
    KPL_TYPE_NAME_I32,
    KPL_TYPE_NAME_I64,
    KPL_TYPE_NAME_FLOAT,
    KPL_TYPE_NAME_F32,
    KPL_TYPE_NAME_F64,
    KPL_TYPE_NAME_CHAR,
    // CONTAINERS
    KPL_TYPE_NAME_STRING,
    KPL_TYPE_NAME_ARRAY,
    KPL_TYPE_NAME_TYPLE,
    KPL_TYPE_NAME_TABLE,
    KPL_TYPE_NAME_MAP,
    KPL_TYPE_NAME_SET,
    KPL_TYPE_NAME_UNION,
    KPL_TYPE_NAME_ANY,
    KPL_TYPE_NAME_NATIVE,
    KPL_TYPE_NAME_ERROR,
    // COROUTINES
    KPL_TYPE_NAME_LAMBDA,
    KPL_TYPE_NAME_GENERATOR,
    KPL_TYPE_NAME_REGEXP,
    // STORAGE
    KPL_TYPE_NAME_MODULE,
    KPL_TYPE_NAME_NAMESPACE
} kpl_type_name;

typedef enum : uint8_t {
    KPL_TYPE_KIND_BASE
} kpl_type_kind;

typedef enum : uint32_t {
    KPL_TYPE_FLAG_EMPTY     = 0
} kpl_type_flags;

// type_kind is for struct polymorphism
// type_specific meaning changes depending on type_name
#define KPL_TYPE_HEADER(STRUCT_NAME) \
    KPL_OBJECT_HEADER(STRUCT_NAME); \
    kpl_type_name type_name; \
    kpl_type_kind type_kind; \
    uint16_t type_specific; \
    uint32_t type_flags

/*
 * Type has no additional information
 */
typedef struct _kpl_type_base {
    KPL_TYPE_HEADER(_kpl_type_base);
} kpl_type_base;