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


C++ StatementPtr类代码示例

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


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

示例1: setVolatile

void FunctionScope::init(AnalysisResultConstPtr ar) {
    m_dynamicInvoke = false;

    if (isNamed("__autoload")) {
        setVolatile();
    }

    // FileScope's flags are from parser, but VariableTable has more flags
    // coming from type inference phase. So we are tranferring these flags
    // just for better modularization between FileScope and VariableTable.
    if (m_attribute & FileScope::ContainsDynamicVariable) {
        m_variables->setAttribute(VariableTable::ContainsDynamicVariable);
    }
    if (m_attribute & FileScope::ContainsLDynamicVariable) {
        m_variables->setAttribute(VariableTable::ContainsLDynamicVariable);
    }
    if (m_attribute & FileScope::ContainsExtract) {
        m_variables->setAttribute(VariableTable::ContainsExtract);
    }
    if (m_attribute & FileScope::ContainsAssert) {
        m_variables->setAttribute(VariableTable::ContainsAssert);
    }
    if (m_attribute & FileScope::ContainsCompact) {
        m_variables->setAttribute(VariableTable::ContainsCompact);
    }
    if (m_attribute & FileScope::ContainsUnset) {
        m_variables->setAttribute(VariableTable::ContainsUnset);
    }
    if (m_attribute & FileScope::ContainsGetDefinedVars) {
        m_variables->setAttribute(VariableTable::ContainsGetDefinedVars);
    }

    if (m_stmt && Option::AllVolatile && !m_pseudoMain && !m_method) {
        m_volatile = true;
    }

    if (!m_method && Option::DynamicInvokeFunctions.find(m_scopeName) !=
            Option::DynamicInvokeFunctions.end()) {
        setDynamicInvoke();
    }
    if (m_modifiers) {
        m_virtual = m_modifiers->isAbstract();
    }

    if (m_stmt) {
        MethodStatementPtr stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
        StatementListPtr stmts = stmt->getStmts();
        if (stmts) {
            for (int i = 0; i < stmts->getCount(); i++) {
                StatementPtr stmt = (*stmts)[i];
                stmt->setFileLevel();
                if (stmt->is(Statement::KindOfExpStatement)) {
                    ExpStatementPtr expStmt = dynamic_pointer_cast<ExpStatement>(stmt);
                    ExpressionPtr exp = expStmt->getExpression();
                    exp->setTopLevel();
                }
            }
        }
    }
}
开发者ID:Globalcherry,项目名称:hhvm,代码行数:60,代码来源:function_scope.cpp

示例2: outputPHP

void StatementList::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) {
  for (unsigned int i = 0; i < m_stmts.size(); i++) {
    StatementPtr stmt = m_stmts[i];

    switch (cg.getContext()) {
    case CodeGenerator::NoContext:
      stmt->outputPHP(cg, ar);
      break;
    case CodeGenerator::PhpDeclaration:
      if (stmt->is(Statement::KindOfFunctionStatement) ||
          stmt->is(Statement::KindOfClassStatement) ||
          stmt->is(Statement::KindOfInterfaceStatement)) {
        cg.setContext(CodeGenerator::PhpImplementation);
        stmt->outputPHP(cg, ar);
        cg.setContext(CodeGenerator::PhpDeclaration);
      }
      break;
    case CodeGenerator::PhpImplementation:
      if (!stmt->is(Statement::KindOfFunctionStatement) &&
          !stmt->is(Statement::KindOfClassStatement) &&
          !stmt->is(Statement::KindOfInterfaceStatement)) {
        stmt->outputPHP(cg, ar);
      }
      break;
    default:
      ASSERT(false);
    }
  }
}
开发者ID:eliotsolomon,项目名称:hiphop-php,代码行数:29,代码来源:statement_list.cpp

示例3: getFunctionScope

void StatementList::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
  FunctionScopePtr func = getFunctionScope();

  for (unsigned int i = 0; i < m_stmts.size(); i++) {
    StatementPtr stmt = m_stmts[i];
    stmt->outputCPP(cg, ar);
    if (stmt->is(Statement::KindOfMethodStatement)) {
      MethodStatementPtr methodStmt =
        dynamic_pointer_cast<MethodStatement>(stmt);
      std::string methodName = methodStmt->getName();
      if (methodName == "offsetget") {
        ClassScopePtr cls = getClassScope();
        std::string arrayAccess("arrayaccess");
        if (cls->derivesFrom(ar, arrayAccess, false, false)) {
          FunctionScopePtr funcScope = methodStmt->getFunctionScope();
          std::string name = funcScope->getName();
          funcScope->setName("__offsetget_lval");
          methodStmt->setName("__offsetget_lval");
          methodStmt->outputCPP(cg, ar);
          funcScope->setName(name);
          methodStmt->setName("offsetget");
        }
      }
    }
  }
}
开发者ID:Jostein,项目名称:hiphop-php,代码行数:26,代码来源:statement_list.cpp

示例4: CONSTANT

void MethodStatement::inferTypes(AnalysisResultPtr ar) {
  FunctionScopePtr funcScope = m_funcScope.lock();
  if (ar->getPhase() == AnalysisResult::FirstInference && m_stmt) {
    if (m_stmt->hasRetExp() ||
        funcScope->inPseudoMain() ||
        funcScope->getReturnType()) {
      bool lastIsReturn = false;
      if (m_stmt->getCount()) {
        StatementPtr lastStmt = (*m_stmt)[m_stmt->getCount()-1];
        if (lastStmt->is(Statement::KindOfReturnStatement)) {
          lastIsReturn = true;
        }
      }
      if (!lastIsReturn &&
          !(funcScope->inPseudoMain() && !Option::GenerateCPPMain)) {
        ExpressionPtr constant =
          funcScope->inPseudoMain() ? CONSTANT("true") : CONSTANT("null");
        ReturnStatementPtr returnStmt =
          ReturnStatementPtr(new ReturnStatement(getLocation(),
            Statement::KindOfReturnStatement, constant));
        m_stmt->addElement(returnStmt);
      }
    }
  }
  ar->pushScope(funcScope);
  if (m_params) {
    m_params->inferAndCheck(ar, NEW_TYPE(Any), false);
  }
  if (m_stmt) {
    m_stmt->inferTypes(ar);
  }
  ar->popScope();
}
开发者ID:yigithub,项目名称:hiphop-php,代码行数:33,代码来源:method_statement.cpp

示例5: getFunctionScope

void MethodStatement::inferFunctionTypes(AnalysisResultPtr ar) {
  FunctionScopeRawPtr funcScope = getFunctionScope();
  bool pseudoMain = funcScope->inPseudoMain();

  if (m_stmt && funcScope->isFirstPass()) {
    if (m_stmt->hasRetExp() ||
        pseudoMain ||
        funcScope->getReturnType()) {
      bool lastIsReturn = false;
      if (m_stmt->getCount()) {
        StatementPtr lastStmt = (*m_stmt)[m_stmt->getCount()-1];
        if (lastStmt->is(Statement::KindOfReturnStatement)) {
          lastIsReturn = true;
        }
      }
      if (!lastIsReturn && (!pseudoMain || Option::GenerateCPPMain)) {
        ExpressionPtr constant =
          makeConstant(ar, funcScope->inPseudoMain() ? "true" : "null");
        ReturnStatementPtr returnStmt =
          ReturnStatementPtr(new ReturnStatement(getScope(), getLocation(),
            Statement::KindOfReturnStatement, constant));
        m_stmt->addElement(returnStmt);
      }
    }
  }

  if (m_params) {
    m_params->inferAndCheck(ar, Type::Any, false);
  }
  if (m_stmt) {
    m_stmt->inferTypes(ar);
  }
}
开发者ID:ckwalsh,项目名称:hiphop-php,代码行数:33,代码来源:method_statement.cpp

示例6: toLower

bool AnalysisResult::checkClassPresent(ConstructPtr cs,
                                       const std::string &name) const {
  if (name == "self" || name == "parent") return true;
  std::string lowerName = toLower(name);
  if (ClassScopePtr currentCls = cs->getClassScope()) {
    if (lowerName == currentCls->getName() ||
        currentCls->derivesFrom(shared_from_this(), lowerName,
                                true, false)) {
      return true;
    }
  }
  if (FileScopePtr currentFile = cs->getFileScope()) {
    StatementList &stmts = *currentFile->getStmt();
    for (int i = stmts.getCount(); i--; ) {
      StatementPtr s = stmts[i];
      if (s && s->is(Statement::KindOfClassStatement)) {
        ClassScopePtr scope =
          static_pointer_cast<ClassStatement>(s)->getClassScope();
        if (lowerName == scope->getName()) {
          return true;
        }
        if (scope->derivesFrom(shared_from_this(), lowerName,
                               true, false)) {
          return true;
        }
      }
    }
  }
  return false;
}
开发者ID:atdt,项目名称:hhvm,代码行数:30,代码来源:analysis_result.cpp

示例7: query

void	PartTable::repo(long projectid, long partno, long repoid) {
	std::string	query(	"update part set repoid = ? "
				"where project = ? and partno = ?");
	StatementPtr	stmt = database()->statement(query);
	FieldValueFactory	factory;
	stmt->bind(0, factory.get((int)repoid));
	stmt->bind(1, factory.get((int)projectid));
	stmt->bind(2, factory.get((int)partno));
	stmt->execute();
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:10,代码来源:ProjectTable.cpp

示例8: 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

示例9: 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->getPhase() == AnalysisResult::AnalyzeAll) {
      if (!stmt->hasEffect() && !stmt->hasDecl() &&
          !stmt->is(Statement::KindOfStatementList)) {
        Compiler::Error(Compiler::StatementHasNoEffect, stmt);
      }

      if (stmt->is(Statement::KindOfExpStatement)) {
        static_pointer_cast<ExpStatement>(stmt)->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:Jostein,项目名称:hiphop-php,代码行数:26,代码来源:statement_list.cpp

示例10: printStatementVector

void CodeGenerator::printStatementVector(StatementPtr s) {
  if (s == nullptr) {
    printf("V:9:\"HH\\Vector\":0:{}");
  } else if (s->is(Statement::KindOfStatementList)) {
    auto sl = static_pointer_cast<StatementList>(s);
    printStatementVector(sl);
  } else {
    printf("V:9:\"HH\\Vector\":1:{");
    s->outputCodeModel(*this);
    printf("}");
  }
}
开发者ID:aetherson,项目名称:hhvm,代码行数:12,代码来源:code_generator.cpp

示例11: add

void DependencyGraph::add(KindOf kindOf, const std::string &program,
                          const std::string &parent, StatementPtr stmt) {
  ASSERT(kindOf == KindOfProgramMaxInclude ||
         kindOf == KindOfProgramMinInclude ||
         kindOf == KindOfProgramUserFunction ||
         kindOf == KindOfProgramUserClass);
  add(kindOf, program, program, ConstructPtr(), parent, ConstructPtr());
  if ((kindOf == KindOfProgramUserFunction ||
       kindOf == KindOfProgramUserClass) && *stmt->getLocation()->file) {
    add(KindOfProgramMinInclude, program, program, ConstructPtr(),
        stmt->getLocation()->file, ConstructPtr());
  }
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:13,代码来源:dependency_graph.cpp

示例12: deleteVal

void deleteVal(ConnectionPtr & conn, const char * b)
{
	string insert("delete from dpak where col2=");
	insert += string("'") + string(b) + string("'");
	try
	{
		StatementPtr stmt = conn->createStatement();
		int rows = stmt->executeUpdate(insert.c_str());
		cerr << "Number of rows delete: " << rows << endl;
	}catch(BaseException & e){
		cerr << "BaseException: " << e.getMessage() << endl;
	}
}
开发者ID:mgrosso,项目名称:cplusql,代码行数:13,代码来源:pgdbtest.cpp

示例13: build

void Dictionary::build(StatementPtr stmt) {
  for (int i = 0, n = stmt->getKidCount(); i < n; i++) {
    if (ConstructPtr kid = stmt->getNthKid(i)) {
      if (StatementPtr s = boost::dynamic_pointer_cast<Statement>(kid)) {
        if (FunctionWalker::SkipRecurse(s)) continue;
        build(s);
      } else {
        ExpressionPtr e = boost::dynamic_pointer_cast<Expression>(kid);
        build(e);
      }
    }
  }
}
开发者ID:524777134,项目名称:hiphop-php,代码行数:13,代码来源:dictionary.cpp

示例14: onTry

void Parser::onTry(Token *out, Token *tryStmt, Token *className, Token *var,
                   Token *catchStmt, Token *catches) {
  StatementPtr stmtList;
  if (catches->stmt) {
    stmtList = catches->stmt;
  } else {
    stmtList = NEW_STMT0(StatementList);
  }
  stmtList->insertElement(NEW_STMT(CatchStatement, className->text(),
                                   var->text(), catchStmt->stmt));
  out->stmt = NEW_STMT(TryStatement, tryStmt->stmt,
                       dynamic_pointer_cast<StatementList>(stmtList));
}
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:13,代码来源:parser.cpp

示例15: ASSERT

void UnaryOpExpression::analyzeProgram(AnalysisResultPtr ar) {
  if (ar->getPhase() == AnalysisResult::AnalyzeFinal && m_op == '@') {
    StatementPtr stmt = ar->getStatementForSilencer();
    ASSERT(stmt);
    m_silencer = stmt->requireSilencers(1);
  }
  if (m_exp) m_exp->analyzeProgram(ar);
  if (ar->getPhase() == AnalysisResult::AnalyzeFinal && m_op == '@') {
    StatementPtr stmt = ar->getStatementForSilencer();
    ASSERT(stmt);
    stmt->endRequireSilencers(m_silencer);
  }
}
开发者ID:dipjyotighosh,项目名称:hiphop-php,代码行数:13,代码来源:unary_op_expression.cpp


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