-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCode.cpp
More file actions
67 lines (51 loc) · 1.19 KB
/
Code.cpp
File metadata and controls
67 lines (51 loc) · 1.19 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
64
65
66
67
#include "Code.h"
#include "direct.h"
#include "Parser.h"
#include "share.h"
#include "IntFunc.h"
//#include <windows.h>
TCode::TCode() {
CG_LOG_BEGIN
name = NULL;
root = new TUnitNode(this);
}
TCode::~TCode() {
if (name)
delete name;
delete root;
CG_LOG_END
}
int TCode::parseUnit(id_element e, const char *unit) {
CG_LOG_BEGIN
name = new char[strlen(unit) + 1];
strcpy(name, unit);
int ret;
*(void**)codePath = e;
cgt->GetParam(PARAM_CODE_PATH, codePath);
std::string fileName("hi");
fileName.append(unit);
CG_LOG_INFO(fileName.c_str())
TParser *parser = new TParser();
parser->createCodeTree(root, codePath, fileName.c_str());
#ifdef DUMP_CODE_TREE
dump();
#endif
if ((ret = parser->errCode))
cgt->trace(parser->errCode);
delete parser;
CG_LOG_RETURN(ret)
}
TValue* TCode::run(id_element e, const char *entry, TArgs *args) {
CG_LOG_BEGIN
Context c(e, entry, args);
TValue *ret = root->run(c);
CG_LOG_RETURN(ret)
}
void TCode::dump() {
CG_LOG_BEGIN
std::string s(codePath);
HANDLE f = fopen(s.append("log/").append(name).append(".log").c_str(), "w+");
root->dump(f, 0);
fclose(f);
CG_LOG_END
}