-
Notifications
You must be signed in to change notification settings - Fork 0
/
Header_file.h
89 lines (81 loc) · 2.21 KB
/
Header_file.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
enum type_of_statement { declaration = 1, lhs = 2, rhs = 3, if_node = 4, for_node = 5, while_node = 6, switch_node = 7, function_parameter = 8, malloc_node = 9, ifelse_node=10, other = 0}; //Identify different statement types
//Node structure
struct node {
struct node *next[10];
char **symbol;
int type;
int line;
int symbolCount;
char **index;
int indexCount;
};
//Structure for "safe" array
struct safeArray{
char *safe[10];
struct safeArray* nextScope;
struct safeArray* prevScope;
int count;
};
//Structure for "unsafe" array
struct unsafeArray{
char *unsafe[10];
int count;
struct unsafeArray* nextScope;
struct unsafeArray* prevScope;
};
//Structure for dynamically allocated variables
struct malloc {
int index;
int *points;
int count;
int line;
int free;
};
struct stack{
struct node *item;
};
int scope_stack[100];
//Functions used by AST_Traversals.c
void createGraph();
void createIfNode();
void createNode();
void push(struct node *item);
struct node* pop();
void var_array_add(struct node* node);
void push_var_array_stack(int count);
void push_init_array_stack(int count);
int pop_var_array_stack();
int pop_init_array_stack();
void print_init_array(struct node * graph_node);
void print_mem_leaks(struct node* graph_node);
void malloc_array_add(struct node* graph_node);
void remove_malloc_array(char* graph_node);
void check_lhs_for_init_var(struct node* graph_node);
void check_lhs_for_mem_leaks(struct node* graph_node);
int pop_init_var_used_stack();
void push_init_var_used_stack(int var_array_count);
void add_mem_alloc_path_array(struct node* graph_node);
void add_mem_freed_array(int index);
void push_mem_path_array(int index);
int pop_mem_path_array();
//Data structures used
struct malloc* allocation_node[10];
struct node *currentNode;
struct safeArray *currentSafeArray;
struct unsafeArray *currentUnsafeArray;
struct node *currentSelectionNode;
extern int ifFlag;
struct symtab **s;
struct node *startNode;
struct node *stack[100];
char *var_array[100];
int init_array[100];
int var_array_stack[100];
int init_array_stack[100];
int init_var_used_stack[100];
char *malloc_array[100];
extern int line_number;
int init_var_used;
int mem_freed_array[100];
int mem_path_array[100];
char *uninitVarUsed;