1 //
2 //  Copyright (C) 2013-2016  Nick Gasson
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef _PRIM_H
19 #define _PRIM_H
20 
21 #include <stdint.h>
22 #include <stddef.h>
23 
24 typedef struct trie *ident_t;
25 
26 typedef struct loc {
27    unsigned    first_line : 20;
28    unsigned    first_column : 12;
29    unsigned    last_line : 20;
30    unsigned    last_column : 12;
31    ident_t     file;
32    const char *linebuf;
33 } loc_t;
34 
35 #define LINE_INVALID   0xfffff
36 #define COLUMN_INVALID 0xfff
37 
38 static const loc_t LOC_INVALID = {
39    LINE_INVALID,
40    COLUMN_INVALID,
41    LINE_INVALID,
42    COLUMN_INVALID,
43    NULL,
44    NULL
45 };
46 
47 typedef struct tree *tree_t;
48 typedef struct type *type_t;
49 
50 typedef enum {
51    RANGE_TO,
52    RANGE_DOWNTO,
53    RANGE_EXPR,
54    RANGE_DYN,
55    RANGE_RDYN
56 } range_kind_t;
57 
58 typedef struct range {
59    tree_t       left;
60    tree_t       right;
61    range_kind_t kind;
62 } range_t;
63 
64 typedef struct tree_wr_ctx *tree_wr_ctx_t;
65 typedef struct tree_rd_ctx *tree_rd_ctx_t;
66 
67 typedef struct vcode_unit *vcode_unit_t;
68 
69 typedef uint32_t netid_t;
70 
71 #define NETID_INVALID UINT32_MAX
72 
73 #endif  // _PRIM_H
74