-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.cpp
68 lines (60 loc) · 1.82 KB
/
output.cpp
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
#include "output.h"
Output::Output() {
if (this->outErrorLevel != NONE)
this->out_error.open(this->output_error, std::ios::out);
if (this->outMipsLevel != NONE)
this->out_mips.open(this->output_mips, std::ios::out);
if (this->outSyntaxLevel != NONE)
this->out_syntax.open(this->output_syntax, std::ios::out);
if (this->outTestInfoLevel != NONE)
this->out_test_info.open(this->output_test_info, std::ios::out);
}
Output::~Output() {
}
void Output::outSyntax(const std::string &outcon) {
switch (this->outSyntaxLevel) {
case CONSOLE:
std::cout << outcon << std::endl;
break;
case OUTFILE:
this->out_syntax << outcon << std::endl;
default:
break;
}
}
void Output::outError(int row, char errorCode) {
switch (this->outErrorLevel) {
case CONSOLE:
std::cout << row << " " << errorCode << std::endl;
break;
case OUTFILE:
this->out_error << row << " " << errorCode << std::endl;
break;
default:
break;
}
}
void Output::outTestInfo(int row, const std::string &outcon) {
switch (this->outTestInfoLevel) {
case CONSOLE:
std::cout << row << " " << outcon << std::endl;
break;
case OUTFILE:
this->out_test_info << row << " " << outcon << std::endl;
break;
default:
break;
}
}
void Output::outMips(const std::string &mips_code) {
switch (this->outMipsLevel) {
case CONSOLE:
std::cout << mips_code << std::endl;
break;
case OUTFILE:
this->out_mips << mips_code << std::endl;
break;
default:
break;
}
}