-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstack_manager.cpp
More file actions
50 lines (45 loc) · 1.05 KB
/
stack_manager.cpp
File metadata and controls
50 lines (45 loc) · 1.05 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
#include ".\stack_manager.h"
#include "configuration.h"
#include "state.h"
#include "exceptions.h"
#include <iostream>
stack_manager::stack_manager(void):_max_stack(0),_cur_stack(0)
{
_max_stack=configuration::instance().intvalue(config::max_stack,"misc");
}
stack_manager::~stack_manager(void)
{
}
void stack_manager::init()
{
_cur_stack=0;
}
void stack_manager::push_it()
{
if(_cur_stack > _max_stack)
{
_cur_stack=0;
//std::cout << "push_it -> illegal operand\n";
throw new p_exception(excp::STACK_OVERFLOW);
}
_cur_stack++;
//std::cout << "_cur_stack -> " << _cur_stack << std::endl;
}
void stack_manager::pop_it()
{
if(_cur_stack>0)
{
_cur_stack--;
//std::cout << "_cur_stack -> " << _cur_stack << std::endl;
}
}
void stack_manager::till_pop_it()
{
// A bug that appear when we call pop_it directly...we enter in a endless loop
if(_cur_stack>0)
{
//std::cout << "_cur_stack till_pop_it -> " << _cur_stack << std::endl;
state::instance().flush_till_push();
//std::cout << "_cur_stack till_pop_it -> " << _cur_stack << std::endl;
}
}