blob: a1c55f5a52b0f3b78028d61486035fd76f0051f1 (
plain) (
blame)
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
|
#ifndef ORYX_ANALYZER_H
#define ORYX_ANALYZER_H
#include <stdint.h>
#include "alloc.h"
#include "lexer.h"
#include "parser.h"
#include "types.h"
/* The different base types */
enum {
/* No type exists (or hasn’t yet been typechecked) */
TYPE_UNSET,
/* Currently in the process of being typechecked. Useful for
detecting cyclic definitions. */
TYPE_CHECKING,
/* A numeric type */
TYPE_NUM,
/* A function type */
TYPE_FN,
_TYPE_LAST_ENT,
};
typedef uint8_t type_kind_t_;
static_assert(_TYPE_LAST_ENT - 1 <= (type_kind_t_)-1,
"Too many AST tokens to fix in TYPE_KIND_T_");
typedef struct symtab symtab;
struct scope {
idx_t_ up, i;
symtab *map;
};
/* A variable type */
struct type {
type_kind_t_ kind;
union {
struct {
uint8_t size;
bool issigned;
bool isfloat;
};
struct {
const struct type *params, *ret;
idx_t_ paramcnt;
};
};
};
void analyzeprog(struct ast, struct lexemes, arena *, struct type **,
struct scope **)
__attribute__((nonnull));
#endif /* !ORYX_ANALYZER_H */
|