?? global.cpp
字號:
#include "StdAfx.h"
#include ".\global.h"
global::global(void)
{
this->global_type = init;
this->offset = -1;
this->sentence_num = -1;
this->v_table.clear();
this->temp_num = -1;
}
global::~global(void)
{
}
virable_item *global::getVirable(string name)
{
for( int i = 0 ; i < v_table.size() ; i++)
{
if( v_table[i].name.compare(name) == 0 )
return &v_table[i];
}
return NULL;
}
void global::printVTable()
{
output_code<<endl<<endl;
output_code<<"打印符號表:"<<endl;
output_code<<"name"<<"\t"<<"type"<<"\t"<<"address"<<"\t"<<endl;//"value"<<endl;
for( int i = 0 ; i < v_table.size() ; i ++)
{
output_code<<v_table[i].name<<"\t";
if( v_table[i].type == integer )
output_code<<"integer"<<"\t";
else if( v_table[i].type == real )
output_code<<"real"<<"\t";
else if( v_table[i].type == boolean )
output_code<<"boolean"<<"\t";
else if( v_table[i].type == vector_type )
{
if( v_table[i].vectorType == integer )
output_code<<"int vector"<<"\t";
else if( v_table[i].vectorType == real )
output_code<<"real vector"<<"\t";
else if( v_table[i].vectorType == boolean )
output_code<<"bool vector"<<"\t";
}
output_code<<v_table[i].address<<"\t";
output_code<<endl;
}
}
void global::push(string a_n, string c, int a_v, int s_n)
{
attribute *newAttr = new attribute(a_n, c, a_v, s_n);
this->att.push(*newAttr);
}
void global::pushWaiting(string a_n, string c, int a_v, int s_n)
{
attribute *newAttr = new attribute(a_n, c, a_v, s_n);
this->wait.push(*newAttr);
}
void global::getTop(attribute &dst)
{
if( att.empty() )
cout<<"ERROE:THE STACK IS EMPTY!!!!!!"<<endl;
dst = att.top();
}
void global::popTop(attribute &dst)
{
if( att.empty() )
cout<<"ERROE:THE STACK IS EMPTY!!!!!!"<<endl;
dst = att.top();
att.pop();
}
void global::popWaitingTop(attribute &dst)
{
if( wait.empty() )
cout<<"ERROE:THE WAITING STACK IS EMPTY!!!!!!"<<endl;
dst = wait.top();
wait.pop();
}
void global::clearAtt()
{
while( !att.empty())
att.pop();
}
void global::clearWait()
{
while( !wait.empty())
wait.pop();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -