summaryrefslogtreecommitdiff
path: root/type.c
blob: 4bff103af917aee6fa748ef291817688d42f153f (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
#include "type.h"
#include <stddef.h>

const struct data_type void_type = {
    .name = "void",
    .sz = 0,
    .is_floating = false,
};
const struct data_type char_type = {
    .name = "char",
    .sz = 1,
    .is_floating = false,
};
const struct data_type short_type = {
    .name = "short",
    .sz = 2,
    .is_floating = false,
};
const struct data_type int_type = {
    .name = "int",
    .sz = 4,
    .is_floating = false,
};
const struct data_type long_type = {
    .name = "long",
    .sz = 8,
    .is_floating = false,
};
const struct data_type long_long_type = {
    .name = "long long",
    .sz = 8,
    .is_floating = false,
};
const struct data_type float_type = {
    .name = "float",
    .sz = 4,
    .is_floating = true,
};
const struct data_type double_type = {
    .name = "double",
    .sz = 8,
    .is_floating = true,
};

const struct data_type* primitive_types[] = {
    &void_type, &char_type, &short_type, &int_type, &long_type, &long_long_type,
    &float_type, &double_type,
    NULL
};

const struct type integral_type = {
    .type = TP_DATA,
    .data.data_type = &long_type,
    .data.is_signed = true,
};
const struct type floating_type = {
    .type = TP_DATA,
    .data.data_type = &double_type,
    .data.is_signed = true,
};
const struct type character_type = {
    .type = TP_DATA,
    .data.data_type = &char_type,
    .data.is_signed = true, /* impl defined */
};
const struct type string_type = {
    .type = TP_PTR,
    .pointer.data_type = &char_type,
    .pointer.ptr_level = 1,
};