本文整理汇总了C++中Iter::next方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::next方法的具体用法?C++ Iter::next怎么用?C++ Iter::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iter
的用法示例。
在下文中一共展示了Iter::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_file_set_block
void CombinedPass::do_file_set_block( FileSetBlock* file_set_block ) {
list<SymbolTable*> file_scope_tables;
for (Iter<FileBlock*> iter = file_set_block->get_file_block_iterator();
iter.is_valid(); iter.next())
{
file_scope_tables.push_back(iter.current()->get_symbol_table());
}
file_scope_tables.push_back(file_set_block->get_file_set_symbol_table());
CollisionAvoider walker(get_suif_env(),
file_set_block->get_external_symbol_table(),
&file_scope_tables,
(file_set_block->get_file_block(0))->
get_source_file_name(),
true);
file_set_block->walk(walker);
}
示例2: is_var_name_crashd_locally
/* return true if the symbol has a name crash with another symbol in
* its parent (a symbol table).
* This implementation just consider name crashes and ignore the symbol
* type.
*/
static bool is_var_name_crashd_locally(const Symbol* symbol)
{
LString sname = symbol->get_name();
if (sname == emptyLString) return false;
SymbolTable* symtab = to<SymbolTable>(symbol->get_parent());
if (!is_kind_of<VariableSymbol>(symbol)) return false;
for (Iter<SymbolTableObject*> iter =
symtab->get_symbol_table_object_iterator();
iter.is_valid();
iter.next()) {
if (symbol == const_cast<const SymbolTableObject*>(iter.current()))
continue;
if (!is_kind_of<VariableSymbol>(iter.current())) continue;
if (iter.current()->get_name() == sname) {
return true;
}
}
return false;
}
示例3: mangle_fields
void InstanceFieldsLayoutPass::mangle_fields( ClassType* ctype ) {
BasicSymbolTable* symtab =
ctype->get_group_symbol_table();
Iter<SymbolTableObject*> iter =
symtab->get_symbol_table_object_iterator();
while( iter.is_valid() ) {
InstanceFieldSymbol* fsym =
to<InstanceFieldSymbol>( iter.current() );
if ( _verbose ) {
// cout << fsym->get_name().c_str() << " -> "
// << mangled_name(fsym).c_str() << endl;
}
symtab->change_name( fsym, mangled_name(fsym) );
iter.next();
}
}
示例4: form_worklist
void form_worklist(Statement *s){
if(!s) return;
if(is_a<IfStatement>(s)){
form_worklist((to<IfStatement>(s))->get_then_part());
form_worklist((to<IfStatement>(s))->get_else_part());
worklist->push_back(to<IfStatement>(s));
}else if(is_a<CForStatement>(s))
form_worklist((to<CForStatement>(s))->get_body());
else if(is_a<WhileStatement>(s))
form_worklist((to<WhileStatement>(s))->get_body());
else if(is_a<ScopeStatement>(s))
form_worklist((to<ScopeStatement>(s))->get_body());
else if(is_a<StatementList>(s))
for(Iter<Statement*> iter = (to<StatementList>(s))->get_statement_iterator();
iter.is_valid(); iter.next())
form_worklist(iter.current());
}
示例5: if
void
M2c::process_sym_table(SymTable *st)
{
bool st_is_private = is_private(st);
Iter<SymbolTableObject*> iter = st->get_symbol_table_object_iterator();
for (/* iter */; iter.is_valid(); iter.next()) {
SymbolTableObject *the_sto = iter.current();
if (is_kind_of<VariableSymbol>(the_sto)) {
if (is_kind_of<ParameterSymbol>(the_sto))
continue; // don't shadow an arg!
VarSym *v = to<VariableSymbol>(the_sto);
if (!is_global(st)) {
printer->print_var_def(v, false);
}
else if (v->get_definition() != NULL) {
postponed_vars.push_back(v);
printer->print_var_def(v, true);
}
else {
claim(is_external(v));
fprintf(out, "extern ");
printer->print_sym_decl(v);
fprintf(out, ";\n");
}
} else if (is_kind_of<ProcedureSymbol>(the_sto)) {
if (st_is_private) fputs("static ", out);
printer->print_proc_decl(to<ProcedureSymbol>(the_sto));
} else if (is_kind_of<Type>(the_sto)) {
if (is_kind_of<EnumeratedType>(the_sto) ||
(is_kind_of<GroupType>(the_sto) &&
to<GroupType>(the_sto)->get_is_complete())) {
printer->print_type(to<Type>(the_sto));
fprintf(out, ";\n");
}
}
}
}
示例6: assert
void CopyPropagationPass2::RemoveFromStatementList(StatementList* parent,
Statement* child)
{
assert(parent != NULL) ;
assert(child != NULL) ;
// Find the position of statement and remove it
int pos = 0 ;
Iter<Statement*> statementIter = parent->get_statement_iterator() ;
while (statementIter.is_valid())
{
if (statementIter.current() == child)
{
break ;
}
statementIter.next() ;
++pos ;
}
assert(parent->get_statement(pos) == child) ;
parent->remove_statement(pos) ;
}
示例7: fprint
void
Summarize::initialize()
{
DefinitionBlock *db = the_file_block->get_definition_block();
max_event_id = 0;
for (Iter<ProcedureDefinition*> iter = db-> get_procedure_definition_iterator();
iter.is_valid();
iter.next())
{
OptUnit *unit = iter.current();
claim(is_kind_of<Cfg>(get_body(unit)), "Body is not in CFG form");
Cfg *unit_cfg = static_cast<Cfg*>(get_body(unit));
debug(5, "Procedure %s", get_name(unit).chars());
if_debug(5)
fprint(stdout, unit_cfg, true, true); // layout and code
for (int i = 0; i < nodes_size(unit_cfg); ++i)
{
CfgNode *block = get_node(unit_cfg, i);
for (InstrHandle h = start(block); h != end(block); ++h)
if (HaltLabelNote note = get_note(*h, k_halt))
switch (note.get_kind())
{
case halt::CBR:
case halt::MBR:
case halt::ENTRY:
case halt::EXIT:
{
long id = note.get_unique_id();
if (max_event_id <= id)
max_event_id = id + 1;
}
}
}
}
fprintf(out, "%d\n", max_event_id);
}
示例8: is_compact
// now requires compact and ordered.
static bool is_compact(MultiWayBranchStatement *the_case) {
Iter<MultiWayBranchStatement::case_pair > iter = the_case->get_case_iterator();
IInteger low;
IInteger high;
bool first = true;
int count = 0;
while (iter.is_valid()) {
MultiWayBranchStatement::case_pair pair = iter.current();
if (first) {
low =pair.first;
high = pair.first;
first = false;
}
else {
#ifdef COMPACT_ONLY
if (low > pair.first)
low = pair.first;
if (high < pair.first)
high = pair.first;
#else
if (pair.first < low)
return false;
if (pair.first < high)
return false;
high = pair.first;
#endif
}
count ++;
iter.next();
}
if (count == 0)
return false;
double density = (double)count / (high - low + 1).c_double();
return density > 0.9999999999;
}
示例9: handle_static_statement
static
String handle_static_statement(CPrintStyleModule *state,
const SuifObject *obj)
{
Statement *stmt = to<Statement>(obj);
// Use the iterator over
// destination_vars
// source ops
// source variables
// Use the iterator over source ops and
// get the classname
String return_str = "(";
bool needs_comma = false;
{for (Iter<VariableSymbol *> iter = stmt->get_destination_var_iterator();
iter.is_valid();
iter.next()) {
VariableSymbol *var = iter.current();
if (needs_comma) {
return_str += ",";
} else {
needs_comma = true;
}
String op = state->print_to_string(var);
return_str += op;
}
}
return_str += ") = ";
String opname = stmt->getClassName();
return_str += String("?") + opname + "(";
needs_comma = false;
{for (Iter<Expression *> iter = stmt->get_source_op_iterator();
iter.is_valid();
iter.next()) {
Expression *opn = iter.current();
if (needs_comma) {
return_str += ",";
} else {
needs_comma = true;
}
String op = state->print_to_string(opn);
return_str += op;
}}
return_str += ")";
needs_comma = false;
{for (Iter<Statement *> iter = stmt->get_child_statement_iterator();
iter.is_valid();
iter.next()) {
Statement *statement = iter.current();
if (needs_comma) {
return_str += "; ";
} else {
needs_comma = true;
}
String op = state->print_to_string(statement);
return_str += op;
}}
return_str += ";";
return(return_str);
}
示例10: tool_main
//.........这里部分代码省略.........
writer.option("build", "DEBUG");
#else
writer.option("build", "RELEASE");
#endif
// Set texture cache limits if non-default.
for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
#if SK_SUPPORT_GPU
const Config& config = gConfigs[i];
if (Benchmark::kGPU_Backend != config.backend) {
continue;
}
GrContext* context = gContextFactory.get(config.contextType);
if (NULL == context) {
continue;
}
size_t bytes;
int count;
context->getResourceCacheLimits(&count, &bytes);
if (-1 != FLAGS_gpuCacheBytes) {
bytes = static_cast<size_t>(FLAGS_gpuCacheBytes);
}
if (-1 != FLAGS_gpuCacheCount) {
count = FLAGS_gpuCacheCount;
}
context->setResourceCacheLimits(count, bytes);
#endif
}
// Run each bench in each configuration it supports and we asked for.
Iter iter;
Benchmark* bench;
while ((bench = iter.next()) != NULL) {
SkAutoTUnref<Benchmark> benchUnref(bench);
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getName())) {
continue;
}
bench->setForceAlpha(alpha);
bench->setForceAA(FLAGS_forceAA);
bench->setForceFilter(FLAGS_forceFilter);
bench->setDither(dither);
bench->preDraw();
bool loggedBenchName = false;
for (int i = 0; i < configs.count(); ++i) {
const int configIndex = configs[i];
const Config& config = gConfigs[configIndex];
if (!bench->isSuitableFor(config.backend)) {
continue;
}
GrContext* context = NULL;
#if SK_SUPPORT_GPU
SkGLContextHelper* glContext = NULL;
if (Benchmark::kGPU_Backend == config.backend) {
context = gContextFactory.get(config.contextType);
if (NULL == context) {
continue;
}
glContext = gContextFactory.getGLContext(config.contextType);
}
#endif
示例11: if
void CopyPropagationPass2::CollectVariables()
{
assert(procDef != NULL) ;
if (killMap.empty() == false)
{
ClearMap() ;
}
assert(killMap.empty() == true) ;
assert(procDef != NULL) ;
SymbolTable* symTab = procDef->get_symbol_table() ;
Iter<SymbolTableObject*> symIter =
symTab->get_symbol_table_object_iterator() ;
while (symIter.is_valid())
{
if (is_a<VariableSymbol>(symIter.current()))
{
// For each variable symbol, create a new list of statement/int pairs
// and add that to the kill map
list<std::pair<Statement*, int> >* assocList =
new list<std::pair<Statement*, int> > ;
killMap[to<VariableSymbol>(symIter.current())] = assocList ;
}
else if (is_a<ParameterSymbol>(symIter.current()))
{
// If we are compiling a module, we also have to find the argument
// (which should be a struct) and collect all of those variable
// symbols..
ParameterSymbol* nextParm =
dynamic_cast<ParameterSymbol*>(symIter.current()) ;
assert(nextParm != NULL) ;
// Now check that we have a struct type
DataType* parmType = nextParm->get_type()->get_base_type() ;
StructType* parmStructType =
dynamic_cast<StructType*>(parmType) ;
if (parmStructType == NULL)
{
list<std::pair<Statement*, int> >* assocList =
new list<std::pair<Statement*, int> > ;
killMap[dynamic_cast<VariableSymbol*>(symIter.current())] = assocList ;
symIter.next() ;
continue ;
}
// Go through this symbol table, just like the parent table...
SymbolTable* structSymTab = parmStructType->get_group_symbol_table() ;
Iter<SymbolTableObject*> structSymIter =
structSymTab->get_symbol_table_object_iterator() ;
while (structSymIter.is_valid())
{
// These should all be variable symbols!
if (is_a<FieldSymbol>(structSymIter.current()))
{
// For each variable symbol, create a new list of statement/int pairs
// and add that to the killMap.
list<std::pair<Statement*, int> >* assocList =
new list<std::pair<Statement*, int> > ;
killMap[to<VariableSymbol>(structSymIter.current())] = assocList ;
}
else
{
std::cerr << "Non variable symbol inside a struct!" << std::endl ;
assert(0) ;
}
structSymIter.next() ;
}
}
symIter.next() ;
}
}
示例12:
void One2MultiArrayExpressionPass::do_procedure_definition(ProcedureDefinition* proc_def)
{
bool kill_all = !(_preserve_one_dim->is_set());
// access all array type declarations and create corresponding multi array types
SuifEnv* suif_env = proc_def->get_suif_env();
TypeBuilder* tb = (TypeBuilder*)suif_env->
get_object_factory(TypeBuilder::get_class_name());
(void) tb; // avoid warning
#ifdef CONVERT_TYPES
for (Iter<ArrayType> at_iter = object_iterator<ArrayType>(proc_def);
at_iter.is_valid();at_iter.next())
{
MultiDimArrayType* multi_type =
converter->array_type2multi_array_type(&at_iter.current());
}
#endif //CONVERT_TYPES
// collect tops of array access chains into this list
list<ArrayReferenceExpression*> ref_exprs;
for (Iter<ArrayReferenceExpression> are_iter =
object_iterator<ArrayReferenceExpression>(proc_def);
are_iter.is_valid(); are_iter.next())
{
// itself an array and parent is *not* an array
ArrayReferenceExpression* are = &are_iter.current();
if((kill_all || is_kind_of<ArrayReferenceExpression>(are->get_base_array_address())) &&
!is_kind_of<ArrayReferenceExpression>(are->get_parent()))
{
//printf("%p \t", are);are->print_to_default();
ref_exprs.push_back(are);
}
}
// for top all expressions, convert them to multi-exprs
for(list<ArrayReferenceExpression*>::iterator ref_iter = ref_exprs.begin();
ref_iter != ref_exprs.end(); ref_iter++)
{
ArrayReferenceExpression* top_array = *ref_iter;
converter->convert_array_expr2multi_array_expr(top_array);
}
#ifdef CONVERT_TYPES
// replace the types of all array variables
for (Iter<VariableSymbol> iter = object_iterator<VariableSymbol>(proc_def);
iter.is_valid();iter.next())
{
VariableSymbol* vd = &iter.current();
DataType *vtype = tb->unqualify_data_type(vd->get_type());
if (is_kind_of<ArrayType>(vtype)) {
MultiDimArrayType* multi_type =
converter->array_type2multi_array_type(to<ArrayType>(vtype));
vd->replace(vd->get_type(), tb->get_qualified_type(multi_type));
}
}
// remove the remaining one-dim array types
converter->remove_all_one_dim_array_types();
#endif //CONVERT_TYPES
// make sure no traces of single-dim arrays are left
if(kill_all){
{for(Iter<ArrayReferenceExpression> iter =
object_iterator<ArrayReferenceExpression>(proc_def);
iter.is_valid(); iter.next())
{
// ArrayReferenceExpression* are = &iter.current();
//are->print_to_default(); printf("at %p \t", are);
suif_assert_message(false, ("ARE not eliminated"));
}
}
#ifdef CONVERT_TYPES
{for(Iter<ArrayType> iter =
object_iterator<ArrayType>(proc_def);
iter.is_valid(); iter.next())
{suif_assert_message(false, ("ArrayType not eliminated"));}}
#endif
}
}
示例13: operator
Walker::ApplyStatus mdbm_c_for_statement_walker::operator () (SuifObject *x) {
SuifEnv *env = get_env();
CForStatement *c_for_stmt = to<CForStatement>(x);
// if(!is_stmt_within_begin_end_hw_marks(c_for_stmt))
// return Walker::Continue;
Statement *body = c_for_stmt->get_body();
if (body){
Iter<CForStatement> iter_c_for = object_iterator<CForStatement>(body);
if(iter_c_for.is_valid())
return Walker::Continue;
StatementList *stmt_list_body = NULL;
if(is_a<StatementList>(body))
stmt_list_body = to<StatementList>(body);
else{
stmt_list_body = create_statement_list(env);
c_for_stmt->set_body(0);
stmt_list_body->append_statement(body);
c_for_stmt->set_body(stmt_list_body);
}
Iter<Statement*> iter = stmt_list_body->get_statement_iterator();
for( ; iter.is_valid(); iter.next()){
Statement *child_stmt = iter.current();
if(is_a<StoreVariableStatement>(child_stmt)){
Iter<LoadExpression> iter2 = object_iterator<LoadExpression>(child_stmt);
if(!iter2.is_valid())
break;
}else break;
}
MarkStatement *end_of_mem_reads_mark = create_mark_statement(env);
if(iter.is_valid())
insert_statement_before(iter.current(), end_of_mem_reads_mark);
else
stmt_list_body->insert_statement(0, end_of_mem_reads_mark);
BrickAnnote *ba = create_brick_annote(env, "end_of_mem_reads");
ba->append_brick(create_suif_object_brick(env, end_of_mem_reads_mark));
c_for_stmt->append_annote(ba);
for( ; iter.is_valid(); iter.next()){
Statement *child_stmt = iter.current();
if(is_a<StoreStatement>(child_stmt))
break;
}
MarkStatement *beg_of_mem_writes_mark = create_mark_statement(env);
if(iter.is_valid())
insert_statement_before(iter.current(), beg_of_mem_writes_mark);
else
stmt_list_body->append_statement(beg_of_mem_writes_mark);
ba = create_brick_annote(env, "beg_of_mem_writes");
ba->append_brick(create_suif_object_brick(env, beg_of_mem_writes_mark));
c_for_stmt->append_annote(ba);
}
return Walker::Continue;
}
示例14: do_procedure_definition
void EliminateArrayConvertsPass::do_procedure_definition(ProcedureDefinition* proc_def){
suif_hash_map<ParameterSymbol*, Type*> params;
TypeBuilder *tb = (TypeBuilder*)
get_suif_env()->get_object_factory(TypeBuilder::get_class_name());
// collect all procedure parameters of pointer type into params list
for(Iter<ParameterSymbol*> iter = proc_def->get_formal_parameter_iterator();
iter.is_valid(); iter.next())
{
ParameterSymbol* par_sym = iter.current();
Type* par_type = tb->unqualify_type(par_sym->get_type());
if(is_kind_of<PointerType>(par_type)){
// put NULLs into the map at first,
// they will later be overwritten
params[par_sym] = NULL;
}
}
if(params.size()==0) return; // nothing to do
// walk thru all AREs and look for arrays that are in the param list
{for(Iter<ArrayReferenceExpression> iter =
object_iterator<ArrayReferenceExpression>(proc_def);
iter.is_valid(); iter.next())
{
ArrayReferenceExpression* are = &iter.current();
if(is_kind_of<UnaryExpression>(are->get_base_array_address())){
UnaryExpression* ue = to<UnaryExpression>(are->get_base_array_address());
if(ue->get_opcode() == k_convert){
if(is_kind_of<LoadVariableExpression>(ue->get_source())){
LoadVariableExpression* lve =
to<LoadVariableExpression>(ue->get_source());
VariableSymbol* array = lve->get_source();
for(suif_hash_map<ParameterSymbol*, Type*>::iterator iter = params.begin();
iter!=params.end();iter++)
{
ParameterSymbol* par_sym = (*iter).first;
if(par_sym == array){
// match!
Type* array_type;
suif_hash_map<ParameterSymbol*, Type*>::iterator iter =
params.find(par_sym);
if(iter==params.end() || (*iter).second==NULL){
//array_type = to<PointerType>(ue->get_result_type())->get_reference_type();
array_type = tb->get_qualified_type(ue->get_result_type());
params[par_sym] = array_type;
//printf("%s has type ",par_sym->get_name().c_str());
//array_type->print_to_default();
}else{
array_type = params[par_sym].second;
suif_assert(is_kind_of<QualifiedType>(array_type));
}
array->replace(array->get_type(), array_type);
remove_suif_object(ue);
remove_suif_object(lve);
lve->replace(lve->get_result_type(), tb->unqualify_type(array_type));
// put the LoadVar directly under ARE
are->set_base_array_address(lve);
//are->print_to_default();
}
}
} else {
suif_warning(ue->get_source(),
("Expecting a LoadVariableExpression here"));
}
} else {
suif_warning(ue, ("Disallow converts in AREs for "
"things other than procedure parameters"));
}
}
}
}
}
示例15: debug
/*
* layout_frame -- Assign stack frame locations to each variable that needs one.
* Store the offsets in frame_map.
*
* A local variable needs a memory-stack location unless it is never used or it
* is a memory-passed parameter.
*/
void
CodeFinIa64::layout_frame()
{
debug(4, "... determine offsets from $sp for variables");
// Force max_arg_area to be a 16-byte multiple to be sure that the local-
// storage area starts on a 16-byte boundary.
max_arg_area = (max_arg_area + 15) & -16;
// Unless this is a leaf procedure, reserve a 16-byte scratch area for
// callees at the young end of the current frame.
int scratch_area_size = is_leaf ? 0 : 16;
// Frame_offset is the running offset of the current variable in the
// local-storage area. Initialize it to the distance between the young
// end of the frame and the local-storage area.
frame_offset = scratch_area_size + max_arg_area;
SymTable *st = cur_unit->get_symbol_table();
Iter<SymbolTableObject*> iter = st->get_symbol_table_object_iterator();
for ( ; iter.is_valid(); iter.next()) {
SymbolTableObject *sto = iter.current();
if (is_kind_of<VarSym>(sto)) {
VarSym *v = (VarSym*)sto;
if (!is_reg_param(v) && is_a<ParameterSymbol>(v))
continue; // v's in caller's frame
Map<Sym*,int>::iterator v_handle = frame_map.find(v);
if (v_handle == frame_map.end())
continue; // v never used
// Here v is an automatic variable, other than a stack-passed
// parameter, that is actually used in the program. First,
// adjust frame_offset to accommodate v'a alignment. The
// frame_offset is already a multiple of four bytes. An
// alignment value greater than four bytes will itself be a
// multiple of four. Round frame_offset up if necessary to
// satisfy that alignment constraint.
TypeId v_type = get_type(v);
int v_align = get_bit_alignment(v_type) >> 3; // in bytes
if (v_align > 4) {
claim(v_align % 4 == 0);
frame_offset =
((frame_offset + v_align - 1) / v_align) * v_align;
}
(*v_handle).second = frame_offset; // update frame_map
// Now allocate a multiple of four bytes to v.
int v_size = get_bit_size(v_type) >> 3; // v's size in bytes
frame_offset += (v_size + 3) & -4;
}
}
// Compute number of bytes for registers saved in memory between locals
// and the frame base.
save_area_size = saved_reg_set[CLASS_GR].size() * 8 +
saved_reg_set[CLASS_BR].size() * 8 +
saved_reg_set[CLASS_FR].size() * 16;
// The sum of local-area and save-area sizes must be a multiple of 16.
// Frame_offset is now the local-area size. Pad it to make the sum a
// 16-byte multiple. (Hint: save_area_size is already a multiple of 8.)
claim((frame_offset & 3) == 0); // now a 4-byte multiple
frame_offset = (frame_offset + (save_area_size & 15) + 15) & -16;
debug(4, "... determine offsets from $sp for memory-passed parameters");
// Process parameter list in order. Set running offset param_offset for
// memory-passed parameters. Also determine the highest GR arg register
// used.
// FIXME: does not allow for aggregates passed partly in regs and partly
// in memory.
int param_offset = frame_offset + save_area_size;
if (param_offset < (scratch_area_size + 16))
param_offset = (scratch_area_size + 16);
for (int i = 0; i < get_formal_param_count(cur_unit); i++) {
VarSym *p = get_formal_param(cur_unit, i);
// Each parameter consumes a multiple of 8 bytes.
int p_size = get_bit_size(get_type(p)) >> 3; // in bytes
p_size = (p_size + 7) & -8;
//.........这里部分代码省略.........