mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-26 21:08:45 +08:00
add more notes
This commit is contained in:
+12
-7
@@ -25,6 +25,7 @@ class balloon_scope
|
|||||||
{
|
{
|
||||||
if(!scope_list.empty() && !scope_list.back().empty())
|
if(!scope_list.empty() && !scope_list.back().empty())
|
||||||
{
|
{
|
||||||
|
// check the last scope
|
||||||
std::list<std::list<var> >::iterator i=scope_list.back().end();
|
std::list<std::list<var> >::iterator i=scope_list.back().end();
|
||||||
--i;
|
--i;
|
||||||
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
||||||
@@ -49,7 +50,7 @@ class balloon_scope
|
|||||||
--i;
|
--i;
|
||||||
for(;;--i)
|
for(;;--i)
|
||||||
{
|
{
|
||||||
if(!i->empty())
|
if(!i->empty())// avoid sigsegv
|
||||||
{
|
{
|
||||||
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
||||||
if(j->get_name()==name)
|
if(j->get_name()==name)
|
||||||
@@ -88,7 +89,7 @@ class balloon_scope
|
|||||||
// get the last scope block(std::list<std::list<var> >)
|
// get the last scope block(std::list<std::list<var> >)
|
||||||
for(;;--i)
|
for(;;--i)
|
||||||
{
|
{
|
||||||
if(!i->empty())
|
if(!i->empty())// avoid sigsegv
|
||||||
{
|
{
|
||||||
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
||||||
std::cout<<j->get_name()<<std::endl;
|
std::cout<<j->get_name()<<std::endl;
|
||||||
@@ -109,7 +110,7 @@ class balloon_scope
|
|||||||
// get the last scope block(std::list<std::list<var> >)
|
// get the last scope block(std::list<std::list<var> >)
|
||||||
for(;;--i)
|
for(;;--i)
|
||||||
{
|
{
|
||||||
if(!i->empty())
|
if(!i->empty())// avoid sigsegv
|
||||||
{
|
{
|
||||||
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
||||||
if(j->get_name()==name)
|
if(j->get_name()==name)
|
||||||
@@ -133,17 +134,21 @@ class balloon_scope
|
|||||||
if(!scope_list.empty())
|
if(!scope_list.empty())
|
||||||
{
|
{
|
||||||
int cnt=1;
|
int cnt=1;
|
||||||
|
// append function will get array's address from parameters' scope so the last two blocks will be checked
|
||||||
|
// because when calling a function,a new block scope will be created.
|
||||||
|
// but the array does not exist in this block,
|
||||||
|
// so you must find the block before this block.
|
||||||
std::list<std::list<std::list<var> > >::iterator blk=scope_list.end();
|
std::list<std::list<std::list<var> > >::iterator blk=scope_list.end();
|
||||||
--blk;
|
--blk;
|
||||||
for(;;--blk,++cnt)
|
for(;;--blk,++cnt)
|
||||||
{
|
{
|
||||||
if(!blk->empty())
|
if(!blk->empty())// avoid sigsegv
|
||||||
{
|
{
|
||||||
std::list<std::list<var> >::iterator i=blk->end();
|
std::list<std::list<var> >::iterator i=blk->end();
|
||||||
--i;
|
--i;
|
||||||
for(;;--i)
|
for(;;--i)
|
||||||
{
|
{
|
||||||
if(!i->empty())
|
if(!i->empty())// avoid sigsegv
|
||||||
{
|
{
|
||||||
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
||||||
if(j->get_name()==name)
|
if(j->get_name()==name)
|
||||||
@@ -160,7 +165,7 @@ class balloon_scope
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!global.empty())
|
if(!global.empty())// if can't find array's address,find the global scope
|
||||||
{
|
{
|
||||||
for(std::list<var>::iterator i=global.begin();i!=global.end();++i)
|
for(std::list<var>::iterator i=global.begin();i!=global.end();++i)
|
||||||
if(i->get_name()==name)
|
if(i->get_name()==name)
|
||||||
@@ -180,7 +185,7 @@ class balloon_scope
|
|||||||
--i;
|
--i;
|
||||||
for(;;--i)
|
for(;;--i)
|
||||||
{
|
{
|
||||||
if(!i->empty())
|
if(!i->empty())// avoid sigsegv
|
||||||
{
|
{
|
||||||
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
for(std::list<var>::iterator j=i->begin();j!=i->end();++j)
|
||||||
if(j->get_name()==name)
|
if(j->get_name()==name)
|
||||||
|
|||||||
Reference in New Issue
Block a user