0424f6ff0c7f1018ca8610570b45ea5a198d9adf
[henge/webcc.git] / src / apc / ir.h
1 /*!@file
2 \brief Intermediate Representation (IR) between Directory Structure and Engine Grammar
3 \details The IR serves as a storage structure that is populated during the
4 parsing of the input directory structure. After parsing is complete,
5 the IR will be condensed (removed of excess allocated space) and then
6 output as the Engine Grammar. In this file we describe the semantic actions
7 that are called at each step, and the memory buffers that they populate.
8 See parser.y for the description on how the input grammar is constructed,
9 and where/when semantic actions are called.
10 TODO: or just write it here.
11 \author Jordan Lavatai
12 \date Aug 2016
13 ----------------------------------------------------------------------------*/
14
15
16 #include <stdint.h>
17
18 #define BUF_SIZE 256
19 #define MAX_SETS 256
20 #define MAX_ELES 256
21 #define MAX_QUADS 256
22 #define MAX_MODELS 256
23 #define MAX_POSTS 256
24 #define MAX_CLASS_DEPTH 256
25 #define MAX_CLASSES 256
26 #define MAX_FRAMES 256
27 #define PTRS_IN_PAGE 1024
28
29 /* Called after the cdat open operator has been recognized in grammar. Allocates
30 the space for a cdat on the cdat_buf, pushes that pointer onto
31 the cdat_stack */
32 void
33 push_cdat(char*);
34
35 /* Called after a cdat end operator has been recognized in grammar. Sets
36 top stack cdat ** to null and decrements stack pointer */
37 void
38 pop_cdat(void);
39
40 /* Called after an odat has been populated. Allocates memory for
41 the next odat. */
42
43 void
44 insert_set_label(char*, uint64_t);
45
46 /* Populate the sets representation in CURR_CDAT with a ref_id and insert a link
47 into the link_buf that will resolve the ref_id to an actual odat after parse time. */
48 void
49 insert_set_olink(uint64_t);
50
51 /* Put the vlink in the link_buf to be processed after parsetime */
52 void
53 insert_set_vlink(uint64_t, char*);
54
55 /* Put svlink in the link_buf to be processed after parsetime */
56 void
57 insert_set_svlink(uint64_t);
58
59 /* Called for every set reduction except for sets with olinks. Populates the
60 set data structures in the CDAT and in the ODAT. Uses the name and ref_id
61 from insert_set_label. Also inserts a ref into the ref_buf with the CURR_ODAT
62 pointer so that we can also resolve the odat from its ref_id. */
63 void
64 insert_set(void);
65
66 /* Insertion of eles is practically equivalent to how sets are inserted because both
67 share the same data type (ODAT). Like sets, eles have links, labels
68 and odats. Eles have the added notion of a parent set, and so must be inserted
69 into said parent set, but this is the only place they truly differ from sets. */
70
71 void
72 insert_ele_label(char*, uint64_t);
73
74 /* Insert an ele olink into the CURR_ODAT */
75 void
76 insert_ele_olink(uint64_t);
77
78 /* Insert a ele vlink into CURR_ODAT*/
79 void
80 insert_ele_vlink(uint64_t, char*);
81
82 /* Inserts an ele short vlink into CURR_ODAT*/
83 void
84 insert_ele_svlink(uint64_t);
85
86 /* inserts ele into CURR_CLASS and CURR_ODAT */
87 void
88 insert_ele(void);
89
90 void
91 insert_vdat(void);
92
93 /* Inserts the hitbox into the CURR_ODAT */
94 void
95 insert_hitbox(int);
96
97 /* Inserts the root into the CURR_ODAT */
98 void
99 insert_root(int, int, int);
100
101 /* Inserts a quad into the CURR_ODAT */
102 void
103 insert_quad(int, int, int, uint64_t);
104
105 void
106 insert_model(void);
107
108 void
109 insert_framesheet(char, char*, uint64_t, int, int, int);
110
111 void
112 insert_frame_pointer(char, void*);
113