Repository navigation
Expand file tree
/
Copy pathstackIf.h
More file actions
63 lines (49 loc) · 1.52 KB
/
Copy pathstackIf.h
File metadata and controls
63 lines (49 loc) · 1.52 KB
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
/**
* @file stackIf.h
* @author Jakub Vlk (xvlkja07@stud.fit.vutbr.cz)
* @brief Wrapper pro stack.
* Generates unique labels for jumps and memorizes state using stack
*/
#ifndef IFJ22_STACKIF_H
#define IFJ22_STACKIF_H
#include "dynstring.h"
#include "stack.h"
#include <string.h>
typedef enum {
while_type,
if_type,
} typeOfIfStackMem;
typedef struct {
typeOfIfStackMem type;
// for if
bool inIfbranch;
bool isEndingGenerated;
bool expectinElse;
bool inElse;
//for while
bool inWhileBody;
bool endOfWhile;
dynStr_t *endlabel; // ending label for label
dynStr_t *elselabel; // label else label
dynStr_t *startlabel;// label else label
} ifsState;
genericStack *ifS_Init();
// next if id :) unique id
void ifS_newIf(genericStack *stack);
void ifS_newWhile(genericStack *stack);
void ifS_old(genericStack *stack);
dynStr_t *ifS_ending(genericStack *stack);
dynStr_t *ifS_else(genericStack *stack);
dynStr_t *ifS_start(genericStack *stack);
bool ifS_isEndingGenerated(genericStack *stack);
void ifS_isSetEndingGenerated(genericStack *stack, bool end);
bool ifS_expectingElse(genericStack *stack);
void ifS_SetExpectingElse(genericStack *stack, bool end);
bool ifS_inElse(genericStack *stack);
void ifS_SetsinElse(genericStack *stack, bool end);
bool ifS_inIfbranch(genericStack *stack);
void ifS_SetinIfbranch(genericStack *stack, bool end);
bool ifS_isEmpty(genericStack *stack);
typeOfIfStackMem ifs_getType(genericStack *stack);
void printifState(void *p);
#endif//IFJ22_STACKIF_H