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


C++ AnalysisResultPtr::getCodeError方法代码示例

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


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

示例1: inferTypes

TypePtr NewObjectExpression::inferTypes(AnalysisResultPtr ar, TypePtr type,
                                        bool coerce) {
  reset();
  ConstructPtr self = shared_from_this();
  if (!m_name.empty()) {
    ClassScopePtr cls = ar->resolveClass(m_name);
    if (cls) {
      m_name = cls->getName();
    }
    if (!cls || cls->isRedeclaring()) {
      if (cls) {
        m_redeclared = true;
        ar->getScope()->getVariables()->
          setAttribute(VariableTable::NeedGlobalPointer);
      }
      if (!cls && ar->isFirstPass()) {
        ar->getCodeError()->record(self, CodeError::UnknownClass, self);
      }
      if (m_params) m_params->inferAndCheck(ar, NEW_TYPE(Any), false);
      return NEW_TYPE(Object);
    }
    if (cls->isVolatile()) {
      ar->getScope()->getVariables()->
        setAttribute(VariableTable::NeedGlobalPointer);
    }
    m_dynamic = cls->derivesFromRedeclaring();
    m_validClass = true;
    FunctionScopePtr func = cls->findConstructor(ar, true);
    if (!func) {
      if (m_params) {
        if (!m_dynamic && m_params->getCount()) {
          if (ar->isFirstPass()) {
            ar->getCodeError()->record(self, CodeError::BadConstructorCall,
                                       self);
          }
          m_params->setOutputCount(0);
        }
        m_params->inferAndCheck(ar, NEW_TYPE(Any), false);
      }
    } else {
      m_extraArg = func->inferParamTypes(ar, self, m_params,
                                         m_validClass);
      m_variableArgument = func->isVariableArgument();
    }
    return Type::CreateObjectType(m_name);
  } else {
    ar->containsDynamicClass();
    if (ar->isFirstPass()) {
      ar->getCodeError()->record(self, CodeError::UseDynamicClass,
                                 self);
    }
    if (m_params) {
      m_params->markParams(false);
    }
  }

  m_nameExp->inferAndCheck(ar, Type::String, false);
  if (m_params) m_params->inferAndCheck(ar, NEW_TYPE(Any), false);
  return Type::Variant;//NEW_TYPE(Object);
}
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:60,代码来源:new_object_expression.cpp

示例2: onParse

void ClassVariable::onParse(AnalysisResultPtr ar) {
  ModifierExpressionPtr modifiers =
    ar->getScope()->setModifiers(m_modifiers);

  for (int i = 0; i < m_declaration->getCount(); i++) {
    VariableTablePtr variables = ar->getScope()->getVariables();
    ExpressionPtr exp = (*m_declaration)[i];
    if (exp->is(Expression::KindOfAssignmentExpression)) {
      AssignmentExpressionPtr assignment =
        dynamic_pointer_cast<AssignmentExpression>(exp);
      ExpressionPtr var = assignment->getVariable();
      const std::string &name =
        dynamic_pointer_cast<SimpleVariable>(var)->getName();
      if (variables->isPresent(name)) {
        ar->getCodeError()->record(CodeError::DeclaredVariableTwice, exp);
      }
      IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>(exp);
      ph->onParse(ar);
    } else {
      const std::string &name =
        dynamic_pointer_cast<SimpleVariable>(exp)->getName();
      if (variables->isPresent(name)) {
        ar->getCodeError()->record(CodeError::DeclaredVariableTwice, exp);
      }
      variables->add(name, TypePtr(), false, ar, exp, m_modifiers);
    }
  }

  ar->getScope()->setModifiers(modifiers);
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:30,代码来源:class_variable.cpp

示例3: analyzeInclude

void IncludeExpression::analyzeInclude(AnalysisResultPtr ar,
                                       const std::string &include) {
  ASSERT(ar->getPhase() == AnalysisResult::AnalyzeInclude);
  ConstructPtr self = shared_from_this();
  FileScopePtr file = ar->findFileScope(include, true);
  if (!file) {
    ar->getCodeError()->record(self, CodeError::PHPIncludeFileNotFound, self);
    return;
  }
  if (include.find("compiler/") != 0 ||
      include.find("/compiler/") == string::npos) {
    ar->getCodeError()->record(self, CodeError::PHPIncludeFileNotInLib,
                               self, ConstructPtr(),
                               include.c_str());
  }

  if (!isFileLevel()) { // Not unsupported but potentially bad
    ar->getCodeError()->record(self, CodeError::UseDynamicInclude, self);
  }

  ar->getDependencyGraph()->add
    (DependencyGraph::KindOfProgramMaxInclude,
     ar->getName(), file->getName(), StatementPtr());
  ar->getDependencyGraph()->addParent
    (DependencyGraph::KindOfProgramMinInclude,
     ar->getName(), file->getName(), StatementPtr());
  FunctionScopePtr func = ar->getFunctionScope();
  ar->getFileScope()->addIncludeDependency(ar, m_include,
                                           func && func->isInlined());
}
开发者ID:edv4rd0,项目名称:hiphop-php,代码行数:30,代码来源:include_expression.cpp

示例4: inferTypes

TypePtr DynamicFunctionCall::inferTypes(AnalysisResultPtr ar, TypePtr type,
                                        bool coerce) {
    reset();
    ConstructPtr self = shared_from_this();
    if (!m_className.empty()) {
        ClassScopePtr cls = ar->resolveClass(m_className);
        if (!cls || cls->isRedeclaring()) {
            if (cls) {
                m_redeclared = true;
                ar->getScope()->getVariables()->
                setAttribute(VariableTable::NeedGlobalPointer);
            }
            if (!cls && ar->isFirstPass()) {
                ar->getCodeError()->record(self, CodeError::UnknownClass, self);
            }
        } else {
            m_validClass = true;
        }
    }

    ar->containsDynamicFunctionCall();

    if (ar->isFirstPass()) {
        ar->getCodeError()->record(self, CodeError::UseDynamicFunction, self);
    }
    m_nameExp->inferAndCheck(ar, Type::String, false);
    if (m_params) {
        for (int i = 0; i < m_params->getCount(); i++) {
            (*m_params)[i]->inferAndCheck(ar, Type::Variant, true);
        }
    }
    return Type::Variant;
}
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:33,代码来源:dynamic_function_call.cpp

示例5: inferTypes

void SwitchStatement::inferTypes(AnalysisResultPtr ar) {
  // we optimize the most two common cases of switch statements
  bool allInteger = true;
  bool allString = true;
  if (m_cases && m_cases->getCount()) {
    for (int i = 0; i < m_cases->getCount(); i++) {
      CaseStatementPtr stmt =
        dynamic_pointer_cast<CaseStatement>((*m_cases)[i]);
      if (!stmt->getCondition()) {
        if (m_cases->getCount() == 1) allInteger = allString = false;
      } else {
        if (!stmt->isLiteralInteger()) allInteger = false;
        if (!stmt->isLiteralString()) allString = false;
      }
    }
  }
  if (allInteger && allString) {
    allInteger = allString = false;
  }

  TypePtr ret;
  if (allInteger) {
    ret = m_exp->inferAndCheck(ar, Type::Int64, false);
  } else if (allString) {
    // We're not able to do this, because switch($obj) may work on an object
    // that didn't implement __toString(), throwing an exception, which isn't
    // consistent with PHP.
    //ret = m_exp->inferAndCheck(ar, Type::String, false);
    ret = m_exp->inferAndCheck(ar, NEW_TYPE(Some), false);
  } else {
    ret = m_exp->inferAndCheck(ar, NEW_TYPE(Some), false);
  }
  if (ret->is(Type::KindOfObject) && ret->isSpecificObject()) {
    m_exp->setExpectedType(NEW_TYPE(Object));
  }
  ConstructPtr self = shared_from_this();
  if (m_cases && m_cases->getCount()) {
    bool checking = false;
    vector<int> defaults;
    int defaultCount = 0;
    for (int i = 0; i < m_cases->getCount(); i++) {
      CaseStatementPtr stmt =
        dynamic_pointer_cast<CaseStatement>((*m_cases)[i]);
      stmt->inferAndCheck(ar, NEW_TYPE(Some), false);
      ExpressionPtr cond = stmt->getCondition();
      if (!cond) {
        checking = true;
        defaultCount++;
      } else if (checking && cond && ar->isFirstPass()) {
        defaults.push_back(i);
        ar->getCodeError()->record(self, CodeError::CaseAfterDefault, stmt);
      }
    }
    if (defaultCount > 1 && ar->isFirstPass()) {
      ar->getCodeError()->record(self, CodeError::MoreThanOneDefault, m_cases);
    }
  }
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:58,代码来源:switch_statement.cpp

示例6: onParse

void SimpleFunctionCall::onParse(AnalysisResultPtr ar) {
    if (m_class) return;

    FileScopePtr fs = ar->getFileScope();
    ConstructPtr self = shared_from_this();
    if (m_className.empty()) {
        CodeErrorPtr codeError = ar->getCodeError();
        switch (m_type) {
        case CreateFunction:
            if (m_params->getCount() == 2 &&
                    (*m_params)[0]->isLiteralString() &&
                    (*m_params)[1]->isLiteralString()) {
                FunctionScopePtr func = ar->getFunctionScope();
                if (func) func->disableInline();
                string params = (*m_params)[0]->getLiteralString();
                string body = (*m_params)[1]->getLiteralString();
                m_lambda = CodeGenerator::GetNewLambda();
                string code = "function " + m_lambda + "(" + params + ") "
                              "{" + body + "}";
                ar->appendExtraCode(code);
            }
            break;
        case VariableArgumentFunction:
            ar->getFileScope()->setAttribute(FileScope::VariableArgument);
            break;
        case ExtractFunction:
            ar->getCodeError()->record(self, CodeError::UseExtract, self);
            ar->getFileScope()->setAttribute(FileScope::ContainsLDynamicVariable);
            ar->getFileScope()->setAttribute(FileScope::ContainsExtract);
            break;
        case CompactFunction:
            ar->getFileScope()->setAttribute(FileScope::ContainsDynamicVariable);
            ar->getFileScope()->setAttribute(FileScope::ContainsCompact);
            break;
        case ShellExecFunction:
            ar->getCodeError()->record(self, CodeError::UseShellExec, self);
            break;
        case GetDefinedVarsFunction:
            ar->getFileScope()->setAttribute(FileScope::ContainsGetDefinedVars);
            ar->getFileScope()->setAttribute(FileScope::ContainsCompact);
            break;
        default:
            CHECK_HOOK(onSimpleFunctionCallFuncType);
            break;
        }
    }

    string call = getText();
    string name = m_name;
    if (!m_className.empty()) {
        name = m_className + "::" + name;
    }
    ar->getDependencyGraph()->add(DependencyGraph::KindOfFunctionCall, call,
                                  shared_from_this(), name);
}
开发者ID:sumitk,项目名称:hiphop-php,代码行数:55,代码来源:simple_function_call.cpp

示例7: check

TypePtr ConstantTable::check(const std::string &name, TypePtr type,
                             bool coerce, AnalysisResultPtr ar,
                             ConstructPtr construct,
                             const std::vector<std::string> &bases,
                             BlockScope *&defScope) {
  TypePtr actualType;
  defScope = NULL;
  if (name == "true" || name == "false") {
    actualType = Type::Boolean;
  } else {
    Symbol *sym = getSymbol(name, true);
    if (!sym->valueSet()) {
      if (ar->getPhase() != AnalysisResult::AnalyzeInclude) {
        actualType = checkBases(name, type, coerce, ar, construct,
                                bases, defScope);
        if (defScope) return actualType;
        ar->getCodeError()->record(CodeError::UseUndeclaredConstant,
                                   construct);
        if (m_blockScope.is(BlockScope::ClassScope)) {
          actualType = Type::Variant;
        } else {
          actualType = Type::String;
        }
        setType(ar, sym, actualType, true);
      }
    } else {
      if (sym->getCoerced()) {
        defScope = &m_blockScope;
        actualType = sym->getCoerced();
        if (actualType->is(Type::KindOfSome) ||
            actualType->is(Type::KindOfAny)) {
          setType(ar, sym, type, true);
          return type;
        }
      } else {
        actualType = checkBases(name, type, coerce, ar, construct,
                                bases, defScope);
        if (defScope) return actualType;
        actualType = Type::Some;
        setType(ar, sym, actualType, true);
        sym->setDeclaration(construct);
      }
    }
  }

  if (Type::IsBadTypeConversion(ar, actualType, type, coerce)) {
    ar->getCodeError()->record(construct, type->getKindOf(),
                               actualType->getKindOf());
  }
  return actualType;
}
开发者ID:F4m3uS,项目名称:hiphop-php,代码行数:51,代码来源:constant_table.cpp

示例8: check

TypePtr ConstantTable::check(const std::string &name, TypePtr type,
                             bool coerce, AnalysisResultPtr ar,
                             ConstructPtr construct, bool &present) {
  TypePtr actualType;
  present = true;
  if (name == "true" || name == "false") {
    actualType = Type::Boolean;
  } else if (!ar->isFirstPass() && m_values.find(name) == m_values.end()) {
    ClassScopePtr parent = findParent(ar, name);
    if (parent) {
      return parent->checkConst(name, type, coerce, ar,
                                construct, present);
    }
    ar->getCodeError()->record(CodeError::UseUndeclaredConstant,
                               construct);
    if (m_blockScope.is(BlockScope::ClassScope)) {
      actualType = Type::Variant;
    } else {
      actualType = Type::String;
    }
    setType(ar, name, actualType, true);
    present = false;
  } else {
    StringToTypePtrMap::const_iterator iter = m_coerced.find(name);
    if (iter != m_coerced.end()) {
      actualType = iter->second;
      if (actualType->is(Type::KindOfSome) ||
          actualType->is(Type::KindOfAny)) {
        setType(ar, name, type, true);
        return type;
      }
    } else {
      ClassScopePtr parent = findParent(ar, name);
      if (parent) {
        return parent->checkConst(name, type, coerce, ar,
                                  construct, present);
      }
      present = false;
      actualType = NEW_TYPE(Some);
      setType(ar, name, actualType, true);
      m_declarations[name] = construct;
    }
  }

  if (Type::IsBadTypeConversion(ar, actualType, type, coerce)) {
    ar->getCodeError()->record(construct, type->getKindOf(),
                               actualType->getKindOf());
  }
  return actualType;
}
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:50,代码来源:constant_table.cpp

示例9: analyzeProgramImpl

void ClassStatement::analyzeProgramImpl(AnalysisResultPtr ar) {
  vector<string> bases;
  if (!m_parent.empty()) bases.push_back(m_parent);
  if (m_base) m_base->getStrings(bases);
  for (unsigned int i = 0; i < bases.size(); i++) {
    string className = bases[i];
    addUserClass(ar, bases[i]);
  }

  ClassScopePtr classScope = m_classScope.lock();
  if (hasHphpNote("Volatile")) {
    classScope->setVolatile();
  }

  checkVolatile(ar);

  if (m_stmt) {
    ar->pushScope(classScope);
    m_stmt->analyzeProgram(ar);
    ar->popScope();
  }
  if (ar->getPhase() != AnalysisResult::AnalyzeAll) return;
  DependencyGraphPtr dependencies = ar->getDependencyGraph();
  for (unsigned int i = 0; i < bases.size(); i++) {
    ClassScopePtr cls = ar->findClass(bases[i]);
    if (cls) {
      if ((!cls->isInterface() && (m_parent.empty() || i > 0 )) ||
          (cls->isInterface() && (!m_parent.empty() && i == 0 ))) {
        ar->getCodeError()->record(CodeError::InvalidDerivation,
                                   shared_from_this(), ConstructPtr(),
                                   cls->getOriginalName().c_str());
      }
      if (dependencies->checkCircle(DependencyGraph::KindOfClassDerivation,
                                    m_originalName,
                                    cls->getOriginalName())) {
        ar->getCodeError()->record(CodeError::InvalidDerivation,
                                   shared_from_this(), ConstructPtr(),
                                   cls->getOriginalName().c_str());
        m_parent = "";
        m_base = ExpressionListPtr();
        classScope->clearBases();
      } else if (cls->isUserClass()) {
        dependencies->add(DependencyGraph::KindOfClassDerivation,
                          ar->getName(),
                          m_originalName, shared_from_this(),
                          cls->getOriginalName(), cls->getStmt());
      }
    }
  }
}
开发者ID:GunioRobot,项目名称:hiphop-php,代码行数:50,代码来源:class_statement.cpp

示例10: add

TypePtr ConstantTable::add(const std::string &name, TypePtr type,
                           ExpressionPtr exp, AnalysisResultPtr ar,
                           ConstructPtr construct) {

  if (name == "true" || name == "false") {
    return Type::Boolean;
  }

  StringToConstructPtrMap::const_iterator iter = m_values.find(name);
  if (iter == m_values.end()) {
    setType(ar, name, type, true);
    m_declarations[name] = construct;
    m_values[name] = exp;
    return type;
  }

  if (ar->isFirstPass()) {
    if (exp != iter->second) {
      ar->getCodeError()->record(CodeError::DeclaredConstantTwice, construct,
                                 m_declarations[name]);
      m_dynamic.insert(name);
      type = Type::Variant;
    }
    setType(ar, name, type, true);
  }

  return type;
}
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:28,代码来源:constant_table.cpp

示例11: getTypeSpec

TypePtr ParameterExpression::getTypeSpec(AnalysisResultPtr ar, bool error) {
  TypePtr ret;
  if (m_type.empty() || m_defaultValue) {
    ret = Type::Some;
  } else if (m_type == "array") {
    ret = Type::Array;
  } else {
    ClassScopePtr cls = ar->findClass(m_type);
    if (!cls || cls->isRedeclaring()) {
      if (error && !cls && ar->isFirstPass()) {
        ConstructPtr self = shared_from_this();
        ar->getCodeError()->record(self, CodeError::UnknownClass, self);
      }
      ret = Type::Some;
    } else {
      ret = Type::CreateObjectType(m_type);
    }
  }
  // we still want the above to run, so to record errors and infer defaults
  if (m_ref) {
    ret = Type::Variant;
  }

  return ret;
}
开发者ID:F4m3uS,项目名称:hiphop-php,代码行数:25,代码来源:parameter_expression.cpp

示例12: add

TypePtr ConstantTable::add(const std::string &name, TypePtr type,
                           ExpressionPtr exp, AnalysisResultPtr ar,
                           ConstructPtr construct) {

  if (name == "true" || name == "false") {
    return Type::Boolean;
  }

  Symbol *sym = getSymbol(name, true);
  if (!sym->declarationSet()) {
    setType(ar, sym, type, true);
    sym->setDeclaration(construct);
    sym->setValue(exp);
    return type;
  }

  if (ar->isFirstPass()) {
    if (exp != sym->getValue()) {
      ar->getCodeError()->record(CodeError::DeclaredConstantTwice, construct,
                                 sym->getDeclaration());
      sym->setDynamic();
      m_hasDynamic = true;
      type = Type::Variant;
    }
    setType(ar, sym, type, true);
  }

  return type;
}
开发者ID:F4m3uS,项目名称:hiphop-php,代码行数:29,代码来源:constant_table.cpp

示例13: analyzeProgramImpl

void StatementList::analyzeProgramImpl(AnalysisResultPtr ar) {
  m_included = true;
  for (unsigned int i = 0; i < m_stmts.size(); i++) {
    StatementPtr stmt = m_stmts[i];

    // effect testing
    if (ar->isFirstPass() && !stmt->hasEffect() &&
        !stmt->is(Statement::KindOfStatementList)) {
      ar->getCodeError()->record(shared_from_this(),
                                 CodeError::StatementHasNoEffect, stmt);
    }

    // changing AUTOLOAD to includes
    if (ar->getPhase() == AnalysisResult::AnalyzeInclude &&
        stmt->is(Statement::KindOfExpStatement)) {
      ExpStatementPtr expStmt = dynamic_pointer_cast<ExpStatement>(stmt);
      if (stmt->isFileLevel()) {
        expStmt->analyzeAutoload(ar);
      }
      expStmt->analyzeShortCircuit(ar);
    }

    bool scopeStmt = stmt->is(Statement::KindOfFunctionStatement) ||
      stmt->is(Statement::KindOfClassStatement) ||
      stmt->is(Statement::KindOfInterfaceStatement);
    if (ar->getPhase() != AnalysisResult::AnalyzeTopLevel || !scopeStmt) {
      /* Recurse when analyzing include/all OR when not a scope */
      stmt->analyzeProgram(ar);
    }
  }
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:31,代码来源:statement_list.cpp

示例14: onParse

void UnaryOpExpression::onParse(AnalysisResultPtr ar) {
    if (m_op == T_EVAL) {
        ConstructPtr self = shared_from_this();
        ar->getCodeError()->record(self, CodeError::UseEvaluation, self);
        ar->getFileScope()->setAttribute(FileScope::ContainsLDynamicVariable);
    }
}
开发者ID:sumitk,项目名称:hiphop-php,代码行数:7,代码来源:unary_op_expression.cpp

示例15: checkParamsAndReturn

TypePtr FunctionCall::checkParamsAndReturn(AnalysisResultPtr ar,
                                           TypePtr type, bool coerce,
                                           FunctionScopePtr func) {
  ConstructPtr self = shared_from_this();
  ar->getDependencyGraph()->add(DependencyGraph::KindOfFunctionCall,
                                ar->getName(), getText(),
                                self, func->getFullName(), func->getStmt());
  TypePtr frt = func->getReturnType();
  if (!frt) {
    m_voidReturn = true;
    setActualType(TypePtr());
    if (!type->is(Type::KindOfAny)) {
      if (!m_allowVoidReturn && ar->isSecondPass() && !func->isAbstract()) {
        ar->getCodeError()->record(self, CodeError::UseVoidReturn, self);
      }
      m_voidWrapper = true;
    }
  } else {
    m_voidReturn = false;
    m_voidWrapper = false;
    type = checkTypesImpl(ar, type, frt, coerce);
  }
  m_extraArg = func->inferParamTypes(ar, self, m_params, m_valid);
  m_variableArgument = func->isVariableArgument();
  if (m_valid) {
    m_implementedType.reset();
  } else {
    m_implementedType = Type::Variant;
  }

  return type;
}
开发者ID:sumitk,项目名称:hiphop-php,代码行数:32,代码来源:function_call.cpp


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