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


C++ StatementList类代码示例

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


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

示例1: create_statement_list

Statement* multi_way_branch_statement_walker::dismantle_multi_way_branch_statement(MultiWayBranchStatement *the_case){
    StatementList *replacement = create_statement_list(the_case->get_suif_env());

    Expression *operand = the_case->get_decision_operand ();
    remove_suif_object(operand);

    DataType *type = operand->get_result_type();

    CodeLabelSymbol *default_lab =  the_case->get_default_target();
    the_case->set_default_target(0);
    Iter<MultiWayBranchStatement::case_pair > iter = the_case->get_case_iterator();
    while (iter.is_valid()) {
	MultiWayBranchStatement::case_pair pair = iter.current();
	IInteger value = pair.first;
	CodeLabelSymbol *lab = pair.second;
	IntConstant *exp = create_int_constant(the_case->get_suif_env(),type, value);
//	Expression *exp = create_load_constant_expression(get_env(),type,iconst);
	TypeBuilder *type_builder = (TypeBuilder *)
          the_case->get_suif_env()->get_object_factory(TypeBuilder::get_class_name());
	Expression *compare =  
	  create_binary_expression(the_case->get_suif_env(),type_builder->get_boolean_type(),
				   k_is_equal_to,
				   deep_suif_clone(operand),
				   exp);
	replacement->append_statement(create_branch_statement(the_case->get_suif_env(),compare,lab));
	iter.next();
	}
    delete operand;
    replacement->append_statement(create_jump_statement(the_case->get_suif_env(),default_lab));
    the_case->get_parent()->replace(the_case,replacement);
    return replacement;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:32,代码来源:statement_dismantlers.cpp

示例2: gen_block

void GenTree::gen_block( const StatementList &list, int depth, const char *prefix )
{
   if( list.empty() )
      return;

   if ( prefix != 0 ) {
      String line;
      line.writeNumber( (int64) list.front()->line() );
      int pos = 0;
      while( pos + line.length() < 5 )
      {
         m_out->writeString( " " );
         pos++;
      }
      m_out->writeString( line + " : " );
      for (int i = 0; i < depth; i++ )
         m_out->writeString( " " );
      m_out->writeString( prefix );
      m_out->writeString(  "\n" );
   }

   const Statement *stmt = list.front();
   while( stmt != 0 ) {
      generate( stmt, 0, false, depth + 1 );
      stmt = static_cast<const Statement *>(stmt->next());
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:27,代码来源:gentree.cpp

示例3: StatementList

void CodeGenVisitor::JIT(Expression* e) {
	StatementList* sl = new StatementList();
	sl->addStatement(new ReturnStatement(e));
	FunctionDefinition* fd = new FunctionDefinition(Type::INT, "", new ParameterList(), sl);

	value_ = 0;
	fd->accept(this);

	if (!value_) {
		delete fd;
		throw "error evaluating expression";
	}

	llvm::Function* f = dynamic_cast<llvm::Function*>(value_);

	void* fPtr = ee_->getPointerToFunction(f);

	// some casting ... because we like magic
	int (*fP)() = (int (*)())(intptr_t)fPtr;

	std::cout << "Evaluated to: " << fP() << std::endl;

	// throw it away
	f->eraseFromParent();
}
开发者ID:catdog2,项目名称:scully,代码行数:25,代码来源:CodeGenVisitor.cpp

示例4: assert

void TransformSystemsToModules::ReplaceUses(VariableSymbol* original,
					    VariableSymbol* replacement)
{
  assert(procDef != NULL) ;

  StatementList* bodyList = dynamic_cast<StatementList*>(procDef->get_body()) ;
  assert(bodyList != NULL) ;

  for (int i = 0 ; i < bodyList->get_statement_count() ; ++i)
  {
    list<LoadVariableExpression*>* allLoads = 
      collect_objects<LoadVariableExpression>(bodyList->get_statement(i)) ;

    list<LoadVariableExpression*>::iterator loadIter = allLoads->begin() ;
    while (loadIter != allLoads->end())
    {
      if ((*loadIter)->get_source() == original)
      {
	(*loadIter)->set_source(replacement) ;
      }
      ++loadIter ;
    }

    delete allLoads ;

    if (IsDefinition(bodyList->get_statement(i), original))
    {
      // We no longer have to replace the value
      return ;
    }
  }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:32,代码来源:transform_systems_to_modules.cpp

示例5: CorrectTypes

bool IfConversionPass2::VerifyIf(IfStatement* toConvert)
{
  Statement* thenPart = toConvert->get_then_part() ;
  Statement* elsePart = toConvert->get_else_part() ;

  if (thenPart == NULL || elsePart == NULL)
  {
    return false ;
  }

  StatementList* thenList = dynamic_cast<StatementList*>(thenPart) ;
  StatementList* elseList = dynamic_cast<StatementList*>(elsePart) ;
  
  if (thenList != NULL && thenList->get_statement_count() != 1)
  {
    return false ;
  }
  
  if (elseList != NULL && elseList->get_statement_count() != 1)
  {
    return false ;
  }

  thenPart = Denormalize(thenPart) ;
  elsePart = Denormalize(elsePart) ;

  return CorrectTypes(thenPart, elsePart) ;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:28,代码来源:if_conversion_pass2.cpp

示例6: makeIsect

void StatementList::makeIsect(StatementList &a, LocationSet &b)
{
    if (this == &a) { // *this = *this isect b
        for (auto it = a.begin(); it != a.end();) {
            assert((*it)->isAssignment());
            Assignment *as = static_cast<Assignment *>(*it);

            if (!b.contains(as->getLeft())) {
                it = m_list.erase(it);
            }
            else {
                it++;
            }
        }
    }
    else { // normal assignment
        clear();
        for (Statement *stmt : a) {
            assert(stmt->isAssignment());
            Assignment *as = static_cast<Assignment *>(stmt);

            if (b.contains(as->getLeft())) {
                append(as);
            }
        }
    }
}
开发者ID:nemerle,项目名称:boomerang,代码行数:27,代码来源:StatementList.cpp

示例7:

void
SemanticAnalysis::visitBlockStatement(BlockStatement *node)
{
    StatementList *stmts = node->statements();
    for (size_t i = 0; i < stmts->length(); i++) {
        Statement *stmt = stmts->at(i);
        stmt->accept(this);
    }
}
开发者ID:jaredballou,项目名称:sourcepawn,代码行数:9,代码来源:semantic-analysis.cpp

示例8: getLibraryDefines

// Return a list of locations defined by library calls
void PPCSignature::getLibraryDefines(StatementList &defs)
{
    if (defs.size() > 0) {
        return; // Do only once
    }

    for (int r = REG_PPC_G3; r <= REG_PPC_G12; ++r) {
        defs.append(
            new ImplicitAssign(Location::regOf(r))); // Registers 3-12 are volatile (caller save)
    }
}
开发者ID:nemerle,项目名称:boomerang,代码行数:12,代码来源:PPCSignature.cpp

示例9: removeRedundantBlocks

 void removeRedundantBlocks(BlockPtr b) {
     StatementList& children = b->getChildren();
     for (size_t i = 0; i < children.size(); ++i) {
         if (REN_DYNAMIC_CAST_PTR(ib, Block, children[i])) {
             removeRedundantBlocks(ib);
             StatementList sl = ib->getChildren();
             children.erase(children.begin() + i);
             children.insert(children.begin() + i, sl.begin(), sl.end());
             --i;
         }
     }
 }
开发者ID:chadaustin,项目名称:renaissance,代码行数:12,代码来源:GLSLShader.cpp

示例10: find_scope

Walker::ApplyStatus multi_way_branch_statement_compactor::operator () (SuifObject *x)
    {
    MultiWayBranchStatement *the_case = to<MultiWayBranchStatement>(x);

    // is the table already compact?

    if (is_compact(the_case))
       return Walker::Continue;

    SymbolTable *scope = find_scope(x);
    if (!scope)
	return Walker::Continue;

    CodeLabelSymbol *default_lab =  the_case->get_default_target();

    // very special case - the case list is empty, so just jump to the default label

    if (the_case->get_case_count() == 0) {
	Statement *replacement = create_jump_statement(get_env(),default_lab);
	the_case->get_parent()->replace(the_case,replacement);
    	set_address(replacement);
    	return Walker::Replaced;
	}

    StatementList *replacement = create_statement_list(get_env());

    Expression *operand = the_case->get_decision_operand ();

    remove_suif_object(operand);

    DataType *type = operand->get_result_type();
    VariableSymbol *decision = create_variable_symbol(get_env(),get_type_builder(get_env())->get_qualified_type(type));
    scope->add_symbol(decision);

    replacement->append_statement(create_store_variable_statement(get_env(),decision,operand));

    the_case->set_default_target(0);
    MultiWayGroupList jump_list(get_env(),default_lab,decision);;
    
    Iter<MultiWayBranchStatement::case_pair > iter = the_case->get_case_iterator();
    while (iter.is_valid()) {
	MultiWayBranchStatement::case_pair pair = iter.current();
	jump_list.add_element(pair.first,pair.second);
	iter.next();
	}
    // we have built the new structure, now need to generate code for it

    jump_list.generate_code(replacement);
    
    the_case->get_parent()->replace(the_case,replacement);
    set_address(replacement);
    return Walker::Replaced;
    }
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:53,代码来源:statement_dismantlers.cpp

示例11: assert

Statement* IfConversionPass2::Denormalize(Statement* x)
{
  if (dynamic_cast<StatementList*>(x) != NULL)
  {
    StatementList* theList = dynamic_cast<StatementList*>(x) ;
    assert(theList->get_statement_count() == 1 && "Unsupported if detected!") ;
    return theList->get_statement(0) ;
  }
  else
  {
    return x ;
  }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:13,代码来源:if_conversion_pass2.cpp

示例12: append

void StatementList::append(const StatementList &sl)
{
    if (&sl == this) {
        const size_t oldSize = m_list.size();
        auto it              = m_list.begin();
        for (size_t i = 0; i < oldSize; i++) {
            m_list.push_back(*it++);
        }
    }
    else {
        m_list.insert(end(), sl.begin(), sl.end());
    }
}
开发者ID:nemerle,项目名称:boomerang,代码行数:13,代码来源:StatementList.cpp

示例13: main

int main(int argc, char **argv)
{
    vector<Token> tokens = lexerFile(argv[1]);

    Parser parser(tokens, &std::cout);
    StatementList * list = parser.file();

    Printer p(std::cout);
    cout << "Statements " << list->size() << endl;
    for( Statement *s : *list )
        s->print(p);

    return 0;
}
开发者ID:kravemir,项目名称:HCLang,代码行数:14,代码来源:pardebug_main.cpp

示例14: Assign

void RtlTest::testSetConscripts()
{
  // m[1000] = m[1000] + 1000
  Statement* s1 = new Assign(
                    Location::memOf(
                      new Const(1000), 0),
                    new Binary(opPlus,
                               Location::memOf(
                                 new Const(1000), NULL),
                               new Const(1000)));

  // "printf("max is %d", (local0 > 0) ? local0 : global1)
  CallStatement* s2 = new CallStatement();
  std::string name("printf");
  Proc* proc = new UserProc(new Prog(), name, 0x2000);	// Making a true LibProc is problematic
  s2->setDestProc(proc);
  s2->setCalleeReturn(new ReturnStatement);		// So it's not a childless call
  Exp* e1 = new Const("max is %d");
  Exp* e2 = new Ternary(opTern,
                        new Binary(opGtr,
                                   Location::local("local0", NULL),
                                   new Const(0)),
                        Location::local("local0", NULL),
                        Location::global("global1", NULL));
  StatementList args;
  args.append(new Assign(Location::regOf(8), e1));
  args.append(new Assign(Location::regOf(9), e2));
  s2->setArguments(args);

  std::list<Statement*> list;
  list.push_back(s1);
  list.push_back(s2);
  RTL* rtl = new RTL(0x1000, &list);
  rtl->setConscripts(0, false);
  std::string expected(
    "00001000    0 *v* m[1000\\1\\] := m[1000\\2\\] + 1000\\3\\\n"
    "            0 CALL printf(\n"
    "                *v* r8 := \"max is %d\"\\4\\\n"
    "                *v* r9 := (local0 > 0\\5\\) ? local0 : global1\n"
    "              )\n"
    "              Reaching definitions: \n"
    "              Live variables: \n");

  std::ostringstream ost;
  rtl->print(ost);
  std::string actual = ost.str();
  CPPUNIT_ASSERT_EQUAL(expected, actual);
}
开发者ID:zecke,项目名称:boomerang,代码行数:48,代码来源:RtlTest.cpp

示例15: findInterpolatable

    CodeNodePtr findInterpolatable(StatementPtr stmt) {
        if (CodeNodePtr e = stmt->getExpression()) {
            if (CodeNodePtr f = findInterpolatable(e)) {
                return f;
            }
        }

        StatementList children = stmt->getChildren();
        for (size_t i = 0; i < children.size(); ++i) {
            if (CodeNodePtr f = findInterpolatable(children[i])) {
                return f;
            }
        }

        return CodeNodePtr();        
    }
开发者ID:chadaustin,项目名称:renaissance,代码行数:16,代码来源:GLSLShader.cpp


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