当前位置: 首页>>代码示例>>C++>>正文


C++ TypeFunction::getClass方法代码示例

本文整理汇总了C++中TypeFunction::getClass方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeFunction::getClass方法的具体用法?C++ TypeFunction::getClass怎么用?C++ TypeFunction::getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeFunction的用法示例。


在下文中一共展示了TypeFunction::getClass方法的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());
//.........这里部分代码省略.........
开发者ID:cybrown,项目名称:CyLang,代码行数:101,代码来源:VisitorNodeTyper.cpp


注:本文中的TypeFunction::getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。