summaryrefslogtreecommitdiff
path: root/docs/type_system/bit.md
blob: 26d5a98a94d928f8d1a1feba74209e2bb49da09b (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Bit

---

A sequence of bits that can fit into a general register

```text
SIZE_FLAGS : BIT_ANY | BIT8 | BIT16 | BIT32 | BIT64

REPRESENTATION_FLAGS : INT | INT_UNSIGNED | INT_SIGNED | FLOAT |
    UTF8 | UTF16 | UTF32 |
    BOOL |
    TYPE

Bit[[SIZE_FLAGS | REPRESENTATION_FLAGS]]
```

## Type Body Object Definitions

```c
typedef struct {
    kpl_interface *interface;
} kpl_type_body_bit;
```

# Casting

# Alias

```text
Int `alias Bit[[BIT_ANY | INT]]

Int_unsiged `alias Bit[[BIT_ANY | INT_UNSIGNED]]

U8 `alias Bit[[BIT8 | INT_UNSIGNED]]
U16 `alias Bit[[BIT16 | INT_UNSIGNED]]
U32 `alias Bit[[BIT32 | INT_UNSIGNED]]
U64 `alias Bit[[BIT64 | INT_UNSIGED]]

Int_signed `alias Bit[[BIT_ANY | INT_SIGNED]]

I8 `alias Bit[[BIT8 | INT_SIGNED]]
I16 `alias Bit[[BIT16 | INT_SIGNED]]
I32 `alias Bit[[BIT32 | INT_SIGNED]]
I64 `alias Bit[[BIT64 | INT_SIGNED]]

Float `alias Bit[[BIT_ANY | FLOAT]]

F32 `alias Bit[[BIT32 | FLOAT]]
F64 `alias Bit[[BIT64 | FLOAT]]

Char `alias Bit[[BIT32 | UTF8]]

Bool `alias Bit[[BIT8 | BOOL]]

Type `alias Bit[[BIT64 | TYPE]]
```

# Operators

## Arithmetic

### Add `+`

### Sub `-`

### Mul `*`

### Div `/`

### ``mod`

### ``exp`

### ``ln`

## Boolean

### ``true`

### ``false`

### Not `!`

### Equal `=`

### Not Equal `!=`

### And `&`

### Or `|`

### Greater `>`

### Greater Equal `>=`

### Less `<`

### Less Equal `<=`

## Bitwise

### ``bit_not`

### ``bit_and`

### ``bit_or`

### ``bit_xor`

### ``bit_ls`

### ``bit_rs`

## Other

### Compare `<=>`

```c
typedef ssize_t kpl_interface_compare(const kpl_any any_a, const kpl_any any_b);
```

# Char

```text
c : 'Σ'
`log c // Char $ 'Σ'
```

# Type

KPL Types as values