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


C++ FunctionScopePtr::setStaticMethodAutoFixed方法代码示例

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


在下文中一共展示了FunctionScopePtr::setStaticMethodAutoFixed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: inferAndCheck

TypePtr SimpleFunctionCall::inferAndCheck(AnalysisResultPtr ar, TypePtr type,
        bool coerce) {
    reset();

    ConstructPtr self = shared_from_this();

    // handling define("CONSTANT", ...);
    if (!m_class && m_className.empty()) {
        if (m_type == DefineFunction && m_params && m_params->getCount() >= 2) {
            ScalarExpressionPtr name =
                dynamic_pointer_cast<ScalarExpression>((*m_params)[0]);
            string varName;
            if (name) {
                varName = name->getIdentifier();
                if (!varName.empty()) {
                    ExpressionPtr value = (*m_params)[1];
                    TypePtr varType = value->inferAndCheck(ar, NEW_TYPE(Some), false);
                    ar->getDependencyGraph()->
                    addParent(DependencyGraph::KindOfConstant,
                              ar->getName(), varName, self);
                    ConstantTablePtr constants =
                        ar->findConstantDeclarer(varName)->getConstants();
                    if (constants != ar->getConstants()) {
                        if (value && !value->isScalar()) {
                            constants->setDynamic(ar, varName);
                            varType = Type::Variant;
                        }
                        if (constants->isDynamic(varName)) {
                            m_dynamicConstant = true;
                            ar->getScope()->getVariables()->
                            setAttribute(VariableTable::NeedGlobalPointer);
                        } else {
                            constants->setType(ar, varName, varType, true);
                        }
                        // in case the old 'value' has been optimized
                        constants->setValue(ar, varName, value);
                    }
                    return checkTypesImpl(ar, type, Type::Boolean, coerce);
                }
            }
            if (varName.empty() && ar->isFirstPass()) {
                ar->getCodeError()->record(self, CodeError::BadDefine, self);
            }
        } else if (m_type == ExtractFunction) {
            ar->getScope()->getVariables()->forceVariants(ar);
        }
    }

    FunctionScopePtr func;

    // avoid raising both MissingObjectContext and UnknownFunction
    bool errorFlagged = false;

    if (!m_class && m_className.empty()) {
        func = ar->findFunction(m_name);
    } else {
        ClassScopePtr cls = ar->resolveClass(m_className);
        if (cls && cls->isVolatile()) {
            ar->getScope()->getVariables()
            ->setAttribute(VariableTable::NeedGlobalPointer);
        }
        if (!cls || cls->isRedeclaring()) {
            if (cls) {
                m_redeclaredClass = true;
            }
            if (!cls && ar->isFirstPass()) {
                ar->getCodeError()->record(self, CodeError::UnknownClass, self);
            }
            if (m_params) {
                m_params->inferAndCheck(ar, NEW_TYPE(Some), false);
            }
            return checkTypesImpl(ar, type, Type::Variant, coerce);
        }
        m_derivedFromRedeclaring = cls->derivesFromRedeclaring();
        m_validClass = true;

        if (m_name == "__construct") {
            // if the class is known, php will try to identify class-name ctor
            func = cls->findConstructor(ar, true);
        }
        else {
            func = cls->findFunction(ar, m_name, true, true);
        }

        if (func && !func->isStatic()) {
            ClassScopePtr clsThis = ar->getClassScope();
            FunctionScopePtr funcThis = ar->getFunctionScope();
            if (!clsThis ||
                    (clsThis->getName() != m_className &&
                     !clsThis->derivesFrom(ar, m_className)) ||
                    funcThis->isStatic()) {
                // set the method static to avoid "unknown method" runtime exception
                if (Option::StaticMethodAutoFix && !func->containsThis()) {
                    func->setStaticMethodAutoFixed();
                }
                if (ar->isFirstPass()) {
                    ar->getCodeError()->record(self, CodeError::MissingObjectContext,
                                               self);
                    errorFlagged = true;
                }
//.........这里部分代码省略.........
开发者ID:sumitk,项目名称:hiphop-php,代码行数:101,代码来源:simple_function_call.cpp


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