-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprogram_state.h
62 lines (50 loc) · 1.03 KB
/
program_state.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
#ifndef __PROGRAM_STATE_H__
#define __PROGRAM_STATE_H__
#include "common.h"
#include "state.h"
class ProgramState{
public:
ProgramState(){
_state = nullptr;
_line = 0;
}
~ProgramState(){
delete _state;
}
void setState( State *s ){
_state = s;
}
void setLine( int l ){
_line = l;
}
State* getState() const{
return _state;
}
int getLine() const{
return _line;
}
vector< int > asVector() const{
vector< int > res( 1, _line );
auto vars = _state->getStateVars();
for( auto v : vars ){
res.insert( res.end(), v.begin(), v.end() );
}
return res;
}
string toString() const{
string ret = "[PROGRAM STATE]:\nLINE:" + to_string( _line ) + "\n";
if( _state )
ret += _state->toString();
return ret;
}
string toString( StateDescriptor *sd ) const{
string ret = "[PROGRAM STATE]:\nLINE:" + to_string( _line ) + "\n";
if( _state )
ret += _state->toString(sd);
return ret;
}
private:
State *_state;
int _line;
};
#endif