Delete balloon_scope.h

This commit is contained in:
Valk Richard Li 2019-11-13 23:38:29 +08:00 committed by GitHub
parent 61ec20d5b0
commit 52f1b2d784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 111 deletions

View File

@ -1,111 +0,0 @@
#ifndef __BALLOON_SCOPE_H__
#define __BALLOON_SCOPE_H__
class balloon_scope
{
private:
std::list<var> global;
std::list<std::list<std::list<var> > > scope_list;
public:
void set_clear()
{
global.clear();
scope_list.clear();
return;
}
bool search_var(std::string name)
{
if(!scope_list.empty())
{
std::list<std::list<var> >::iterator i=scope_list.back().end();
--i;
for(;;--i)
{
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
if(j->get_name()==name)
return true;
if(i==scope_list.back().begin())
break;
}
}
if(!global.empty())
{
for(std::list<var>::iterator i=global.begin();i!=global.end();++i)
if(i->get_name()==name)
return true;
}
return false;
}
void add_new_var(var t)
{
if(!scope_list.empty())
{
std::list<std::list<var> >::iterator i=scope_list.back().end();
--i;
i->push_back(t);
return;
}
global.push_back(t);
return;
}
var get_var(std::string name)
{
if(!scope_list.empty())
{
std::list<std::list<var> >::iterator i=scope_list.back().end();
--i;
// get the last scope block(std::list<std::list<var> >)
for(;;--i)
{
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
if(j->get_name()==name)
return *j;
if(i==scope_list.back().begin())
break;
}
}
if(!global.empty())
{
for(std::list<var>::iterator i=global.begin();i!=global.end();++i)
if(i->get_name()==name)
return *i;
}
return error_var;
}
void add_new_block_scope()
{
std::list<std::list<var> > new_list;
scope_list.push_back(new_list);
return;
}
void add_new_local_scope()
{
if(!scope_list.empty())
{
std::list<std::list<std::list<var> > >::iterator i=scope_list.end();
--i;
std::list<var> new_list;
i->push_back(new_list);
}
return;
}
void pop_last_block_scope()
{
if(!scope_list.empty())
scope_list.pop_back();
return;
}
void pop_last_local_scope()
{
if(!scope_list.empty())
{
std::list<std::list<var> > temp=scope_list.back();
temp.pop_back();
}
return;
}
};
balloon_scope scope;
#endif