本文整理汇总了C++中SymTab::insert_in_parent_scope方法的典型用法代码示例。如果您正苦于以下问题:C++ SymTab::insert_in_parent_scope方法的具体用法?C++ SymTab::insert_in_parent_scope怎么用?C++ SymTab::insert_in_parent_scope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymTab
的用法示例。
在下文中一共展示了SymTab::insert_in_parent_scope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}