-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.h
More file actions
23 lines (22 loc) · 846 Bytes
/
types.h
File metadata and controls
23 lines (22 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
Bit layout of values
Values are either:
- Integers: end in #b0
- Characters: end in #b01
- True: #b11
- False: #b111
- Eof: #b1011
- Void: #b1111
*/
#define int_shift 1
#define int_type_mask ((1 << int_shift) - 1)
#define int_type_tag (0 << (int_shift - 1))
#define nonint_type_tag (1 << (int_shift - 1))
#define char_shift (int_shift + 1)
#define char_type_mask ((1 << char_shift) - 1)
#define char_type_tag ((0 << (char_shift - 1)) | nonint_type_tag)
#define nonchar_type_tag ((1 << (char_shift - 1)) | nonint_type_tag)
#define val_true ((0 << char_shift) | nonchar_type_tag)
#define val_false ((1 << char_shift) | nonchar_type_tag)
#define val_eof ((2 << char_shift) | nonchar_type_tag)
#define val_void ((3 << char_shift) | nonchar_type_tag)