本文整理汇总了C++中TypeFunction::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeFunction::getType方法的具体用法?C++ TypeFunction::getType怎么用?C++ TypeFunction::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeFunction
的用法示例。
在下文中一共展示了TypeFunction::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void VisitorNodeTyper::visit(class ExprCall *n) {
ExprSymbol* sym = dynamic_cast<ExprSymbol*>(n->getCallee());
TypeFunction* tf = 0;
// If there are arguments, pass through them to find there types
if (n->getArgs())
{
for (std::vector<Expr*>::iterator it = n->getArgs()->begin(); it != n->getArgs()->end(); it++)
{
(*it)->accept(*this);
}
}
// Set looking for mangled mode to avoid not in symbol table exception
bool old_look_for_mangled = this->look_for_mangled;
this->look_for_mangled = true;
n->getCallee()->accept(*this);
this->look_for_mangled = old_look_for_mangled;
tf = dynamic_cast<TypeFunction*>(n->getCallee()->getType());
std::vector<Signature*>* ss = 0;
Class* cur_class = 0;
if (!tf->getClass())
{
ss = this->sigs[tf->getName()];
}
else
{
std::map<std::string, std::vector<Signature*>* >* spc;
cur_class = tf->getClass();
while (cur_class != 0)
{
spc = this->sigs_per_class[cur_class];
if (spc)
{
ss = (*spc)[tf->getName()];
if (ss)
{
break;
}
}
cur_class = cur_class->getParent();
}
if (!spc)
throw __FILE__ "(" QUOTE(__LINE__) "): No signature table for class " + tf->getClass()->getName() + ".";
}
// TODO optimize
if (!ss)
throw __FILE__ "(" QUOTE(__LINE__) "): Symbol " + tf->getName() + " not in signature tables.";
// Select good function
std::vector<Signature*>::iterator it;
bool insert_this = false;
std::vector<Type*>* choosen_sig = 0;
for (it = ss->begin(); it != ss->end(); it++)
{
// Test for method
if (areCompatible(n->getArgs(), (*it)->getTypes(), true))
{
if (tf->getClass())
{
tf = tf->getClass()->getMethodType((*it)->getMangledName());
n->getCallee()->setType(tf);
}
tf->setName((*it)->getMangledName());
if (choosen_sig)
throw __FILE__ "(" QUOTE(__LINE__) "): Overloading ambiguity !";
tf->setStatic(false);
choosen_sig = (*it)->getTypes();
// Function is non static, get left part of callee and add it on front of arg stack (this)
insert_this = true;
}
// Test for function OR static method
else if(areCompatible(n->getArgs(), (*it)->getTypes()))
{
if (tf->getClass())
{
tf = tf->getClass()->getMethodType((*it)->getMangledName());
n->getCallee()->setType(tf);
}
tf->setName((*it)->getMangledName());
if (choosen_sig)
throw __FILE__ "(" QUOTE(__LINE__) "): Overloading ambiguity !";
choosen_sig = (*it)->getTypes();
tf->setStatic(true);
if (sym)
{
sym->setName((*it)->getMangledName());
}
}
}
if (!choosen_sig)
throw __FILE__ "(" QUOTE(__LINE__) "): No method " + tf->getName()+ " found.";
if (insert_this)
{
ExprOP2* e2 = dynamic_cast<ExprOP2*>(n->getCallee());
//.........这里部分代码省略.........