aboutsummaryrefslogtreecommitdiff
path: root/src/analyzer.h
blob: 726b4e55e7f28d19fe717eee392c12129992f3b8 (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
#ifndef ORYX_ANALYZER_H
#define ORYX_ANALYZER_H

#include <stdint.h>

#include "lexer.h"
#include "parser.h"

enum {
	TYPE_UNSET = 0,
	TYPE_CHECKING = 1,
	TYPE_NUM,
	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_");

struct type {
	type_kind_t_ kind;
	uint8_t size  : 6; /* bytes */
	bool issigned : 1;
	bool isfloat  : 1;

	/* For functions */
	const struct type *params, *ret;
	idx_t_ paramcnt;
};

struct type *analyzeprog(struct ast, struct lexemes)
	__attribute__((returns_nonnull));

#endif /* !ORYX_ANALYZER_H */