Line | Branch | Exec | Source |
---|---|---|---|
1 | #ifndef DATA_H__ | ||
2 | #define DATA_H__ | ||
3 | |||
4 | #include "script.h" | ||
5 | #include <string> | ||
6 | #include <vector> | ||
7 | |||
8 | enum class TARGET | ||
9 | { | ||
10 | INTERMEDIATE, | ||
11 | CPP, | ||
12 | PY, | ||
13 | LINUX_X86_64, | ||
14 | INVALID | ||
15 | }; | ||
16 | |||
17 | struct issue | ||
18 | { | ||
19 | enum class type | ||
20 | { | ||
21 | INFO, | ||
22 | WARNING, | ||
23 | ERROR | ||
24 | }; | ||
25 | |||
26 | enum class phase | ||
27 | { | ||
28 | PARSING, | ||
29 | OPTIMIZAZION, | ||
30 | CODE_GENERATION, | ||
31 | STORE | ||
32 | }; | ||
33 | |||
34 | type t; | ||
35 | phase p; | ||
36 | std::string msg; | ||
37 | std::string line; | ||
38 | unsigned int number; | ||
39 | }; | ||
40 | |||
41 | using issues = std::vector<issue>; | ||
42 | |||
43 | struct intermediate | ||
44 | { | ||
45 | enum class cmd | ||
46 | { | ||
47 | comment, | ||
48 | text_init_memory, | ||
49 | text_memory, | ||
50 | load_init_memory, | ||
51 | load_memory, | ||
52 | process_memory, | ||
53 | print_memory, | ||
54 | save_memory, | ||
55 | create_file, | ||
56 | |||
57 | // code blocks | ||
58 | |||
59 | print_text, // directly print text | ||
60 | save_text // directy save text to file | ||
61 | }; | ||
62 | |||
63 | cmd command; | ||
64 | std::string operand; | ||
65 | std::string line; | ||
66 | unsigned int number; | ||
67 | std::string operandB; | ||
68 | }; | ||
69 | |||
70 | using code = std::vector<intermediate>; | ||
71 | |||
72 | using generated = std::vector<std::string>; | ||
73 | |||
74 | struct data | ||
75 | { | ||
76 | issues i; | ||
77 | code c; | ||
78 | generated result; | ||
79 | bool success = true; | ||
80 | |||
81 | 24 | void add_issue(issue::type type, issue::phase phase, const std::string& msg, | |
82 | const std::string& line, unsigned int number) | ||
83 | { | ||
84 |
1/2✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
|
24 | i.push_back(issue{type, phase, msg, line, number}); |
85 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 20 times.
|
24 | if (type == issue::type::ERROR) |
86 | 4 | success = false; | |
87 | 24 | } | |
88 | |||
89 | 108 | void add_cmd(intermediate::cmd cmd, const std::string& operand, | |
90 | const std::string& line, unsigned int number) | ||
91 | { | ||
92 |
2/4✓ Branch 4 taken 108 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 108 times.
✗ Branch 8 not taken.
|
108 | c.push_back(intermediate{cmd, operand, line, number, ""}); |
93 | 108 | } | |
94 | |||
95 | void add_cmd(intermediate::cmd cmd, const std::string& operand, | ||
96 | const std::string& line, unsigned int number, | ||
97 | const std::string& operandB) | ||
98 | { | ||
99 | c.push_back(intermediate{cmd, operand, line, number, operandB}); | ||
100 | } | ||
101 | }; | ||
102 | |||
103 | #endif | ||
104 |