本文整理汇总了C++中SymTab::close_scope方法的典型用法代码示例。如果您正苦于以下问题:C++ SymTab::close_scope方法的具体用法?C++ SymTab::close_scope怎么用?C++ SymTab::close_scope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymTab
的用法示例。
在下文中一共展示了SymTab::close_scope方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visitFuncImpl
void visitFuncImpl(FuncImpl * p)
{
p->m_attribute.m_scope = m_st->get_scope();
p->m_type->accept(this);
add_func_symbol(p);
m_st->open_scope();
p->visit_children(this);
m_st->close_scope();
check_return_type(p);
}
示例2: visitClassImpl
void visitClassImpl(ClassImpl *p) {
int stop;
m_symboltable->open_scope();
Symbol * symPtr = new Symbol;
// = new ClassNode;
Symbol * symp;// = new Symbol;
ClassIDImpl * ClassIdP = dynamic_cast<ClassIDImpl*>(p->m_classid_1);
ClassIDImpl * ClassIdP2 = dynamic_cast<ClassIDImpl*>(p->m_classid_2);
char * key1 = strdup(ClassIdP->m_classname->spelling());
symPtr->classType.classID = ClassIdP->m_classname->spelling();
char * progFinder = strdup("Program");
ClassName * nm = new ClassName(key1);
if(progger == true){
t_error(no_program, p->m_attribute);
}
if(std::string(key1) == std::string(progFinder)){
progger = true;
}
//char * key2 = strdup(ClassIdP2->m_classname->spelling());
if(m_classtable->exist(key1)){
t_error(dup_ident_name, p->m_attribute);
}
else{
if(ClassIdP2->m_classname != NULL){
char * key2 = strdup(ClassIdP2->m_classname->spelling());
ClassName * nm2 = new ClassName(key2);
// cout<<"inserted class: " <<key1 <<" from :"<<key2 <<endl;
m_classtable->insert(nm, nm2, p, m_symboltable->get_scope());
ClassNode * clasp = m_classtable->getParentOf(key2);
// cout<<"Class: " <<key1 <<", Super class: "<<clasp->name->spelling()<<endl;
}
else{
// cout<< "instered this in class table: "<< key1 <<endl;
m_classtable->insert(nm, NULL, p, m_symboltable->get_scope());
}
}
m_symboltable->insert((char *)"xxx", symPtr);
p->visit_children(this);
m_symboltable->close_scope();
//WRITE ME
}
示例3: visitMethodImpl
void visitMethodImpl(MethodImpl *p) {
m_symboltable->open_scope();
if (p->m_type != NULL) {
p->m_type->accept( this );
} else {
this->visitNullPointer();
}
// cout<<"my type: "<<p->m_type->m_attribute.m_type.baseType<<endl;
Symbol *symp = new Symbol;
Symbol *Msymp = new Symbol;
Symbol *test;
MethodIDImpl * MethIdP = dynamic_cast<MethodIDImpl*>(p->m_methodid);
p->m_attribute.m_type.baseType = p->m_type->m_attribute.m_type.baseType;
//this is dealing with duplicate method names
char * key = strdup(MethIdP->m_symname->spelling());//~!~!~!~!~!~!~!~ place here
test = InScope(key);
if(test != NULL){//change this make Msymp = my function
t_error(dup_ident_name, p->m_attribute);
}
else{
CompoundType arg;
p->visit_children(this);
//Adding parameters to sym table and each argument to method vector
typename std::list<Parameter_ptr>::iterator it = p->m_parameter_list->begin();
for( ; it != p->m_parameter_list->end(); ++it) {
ParameterImpl * Pimp = dynamic_cast<ParameterImpl *> (*it);
VariableIDImpl * VarIdP = dynamic_cast<VariableIDImpl*>(Pimp->m_variableid);
//char * key = strdup(VarIdP->m_symname->spelling());
arg.baseType = Pimp->m_type->m_attribute.m_type.baseType;
Msymp->methodType.argsType.push_back(arg);
}
Msymp->methodType.returnType.baseType = p->m_type->m_attribute.m_type.baseType;
Msymp->baseType = p->m_type->m_attribute.m_type.baseType;
m_symboltable->insert_in_parent_scope(key, Msymp);
}
if(p->m_type->m_attribute.m_type.baseType != p->m_methodbody->m_attribute.m_type.baseType){
t_error(ret_type_mismatch, p->m_attribute);
}
m_symboltable->close_scope();
//WRITE ME
}