本文整理汇总了C++中Iter::current方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::current方法的具体用法?C++ Iter::current怎么用?C++ Iter::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iter
的用法示例。
在下文中一共展示了Iter::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_file_set_block
void MultiDimArrayDismantlerPass::do_file_set_block( FileSetBlock* file_set_block ) {
SuifEnv *env = get_suif_env();
TypeBuilder *type_builder = (TypeBuilder *)
env->get_object_factory(TypeBuilder::get_class_name());
suif_hash_map<MultiDimArrayType *,Type *> type_map;
ReplacingWalker walker(env);
list<MultiDimArrayType *> type_list;
for (Iter<MultiDimArrayType> titer =
object_iterator<MultiDimArrayType>(file_set_block);
titer.is_valid(); titer.next())
{
MultiDimArrayType *type = &titer.current();
type_list.push_back(type);
}
for (list<MultiDimArrayType *>::iterator tliter = type_list.begin();tliter != type_list.end();tliter ++) {
MultiDimArrayType *type = *tliter;
Type *rep_type = disassemble_multi_array_type(env,type_builder,type);
type_map.enter_value(type,rep_type);
to<BasicSymbolTable>(type->get_parent())->remove_symbol_table_object(type);
walker.add_replacement(type,rep_type);
}
for (Iter<MultiDimArrayExpression> iter =
object_iterator<MultiDimArrayExpression>(file_set_block);
iter.is_valid(); iter.next())
{
MultiDimArrayExpression *expr = &iter.current();
dismantle_multi_dim_array_expression(env,expr,type_builder,type_map);
}
file_set_block->walk(walker);
};
示例2: get_object_location
ObjectLocation LocationModule::get_object_location(SuifObject *obj) {
ObjectLocation loc;
if (!obj) {
return(loc);
}
// part of a stmt list: walk from the beginning of the list
// down until we find a line #
const SuifObject* child = NULL;
const SuifObject* parent = obj;
for (; parent != NULL; child = parent, parent = parent->get_parent()) {
loc = read_line_number(obj);
if (loc.get_is_known()) return(loc);
if(is_kind_of<StatementList>(parent)){
StatementList* the_list = to<StatementList>(parent);
for(Iter<Statement*> iter = the_list->get_statement_iterator();
iter.is_valid() && iter.current() != child;
iter.next())
{
loc = read_line_number(iter.current());
// for the original object, if it is a StatementList
// return the first mark found in it.
if (child == NULL && loc.get_is_known())
return(loc);
}
}
if (loc.get_is_known())
return loc;
}
// Now try to just get the input file
return(get_object_filename(obj));
// return(loc);
};
示例3: if
/* Useful for printing annotations as comments. Expects that
* the annotation is a BrickAnnote. */
void
Printer::print_annote(Annote *annote)
{
start_comment();
IdString name = annote->get_name();
if (name != k_comment)
fprintf(out, "[%s", name.chars());
if (is_kind_of<BrickAnnote>(annote)) {
BrickAnnote *an = (BrickAnnote *)(annote);
char *separator = ": ";
for (Iter<SuifBrick*> iter = an->get_brick_iterator();
iter.is_valid(); iter.next())
{
fputs(separator, out);
separator = ", ";
SuifBrick *brick = iter.current();
if (is_a<IntegerBrick>(brick)) {
Integer i = ((IntegerBrick*)iter.current())->get_value();
if (i.is_c_string_int())
fputs(i.chars(), out);
else
fprintf(out, "%ld", i.c_long());
}
else if (is_a<StringBrick>(brick)) {
putc('"', out);
for (const char *p =
((StringBrick*)iter.current())->get_value().c_str();
*p != '\0'; ++p)
{
if (*p == '"' || *p == '\\')
putc('\\', out);
putc(*p, out);
}
putc('"', out);
}
else {
claim(is_a<SuifObjectBrick>(brick));
SuifObject *so = ((SuifObjectBrick*)brick)->get_object();
if (is_kind_of<Type>(so))
fprint(out, (TypeId)so);
else {
const char *kind = so ? get_class_name(so) : "NULL";
fprintf(out, "<<<%s object>>>", kind);
}
}
}
} else {
claim(is_kind_of<GeneralAnnote>(annote), "Unexpected kind of Annote");
}
if (name != k_comment)
fputs("]", out);
fputs("\n", out);
}
示例4: find_field
/** find the field with the name.
*/
static FieldSymbol* find_field(GroupType* gtype, LString field_name)
{
for (Iter<SymbolTableObject*> iter =
gtype->get_group_symbol_table()->get_symbol_table_object_iterator();
iter.is_valid();
iter.next()) {
if (iter.current()->get_name() != field_name) continue;
return to<FieldSymbol>(iter.current());
}
return 0;
}
示例5: CollectInitializations
void ConstantArrayPropagationPass::CollectInitializations()
{
if (!initializations.empty())
{
initializations.clear() ;
}
DefinitionBlock* procDefBlock = procDef->get_definition_block() ;
assert(procDefBlock != NULL) ;
Iter<VariableDefinition*> varDefIter =
procDefBlock->get_variable_definition_iterator() ;
while (varDefIter.is_valid())
{
VariableDefinition* varDef = varDefIter.current() ;
assert(varDef != NULL) ;
VariableSymbol* varSym = varDef->get_variable_symbol() ;
ValueBlock* valBlock = varDef->get_initialization() ;
assert(varSym != NULL) ;
assert(valBlock != NULL) ;
if (ValidSymbol(varSym))
{
initializations[varSym] = valBlock ;
varSym->append_annote(create_brick_annote(theEnv, "ConstPropArray")) ;
}
varDefIter.next() ;
}
}
示例6: dismantle_multi_way_branch_statement
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;
}
示例7:
void NormalizeProcedureReturns::
do_procedure_definition( ProcedureDefinition *pd ) {
ProcedureSymbol *ps = pd->get_procedure_symbol();
if (!ps) return;
ProcedureType *t = to<ProcedureType>(ps->get_type());
if (!is_kind_of<CProcedureType>(t))
return;
CProcedureType *ct = to<CProcedureType>(t);
DataType *result = ct->get_result_type();
bool is_void = is_kind_of<VoidType>(result);
for (Iter<ReturnStatement> iter = object_iterator<ReturnStatement>(pd);
iter.is_valid(); iter.next()) {
ReturnStatement *ret = &iter.current();
if (ret == NULL) continue;
Expression *ret_expr = ret->get_return_value();
if (is_void) {
if (ret_expr != NULL) {
// Should not be here
trash_it(remove_suif_object(ret_expr));
}
} else {
if (ret_expr == NULL) {
// build a NULL expression to match the DataType.
Expression *x = build_empty_expression(result);
ret->set_return_value(x);
}
}
}
}
示例8: get_statement_block_btw_labels
StatementList* get_statement_block_btw_labels(ProcedureDefinition *proc_def, CodeLabelSymbol *start_label_sym,
CodeLabelSymbol *end_label_sym) {
StatementList *stmt_block = create_statement_list(proc_def->get_suif_env());
for(Iter<LabelLocationStatement> iter = object_iterator<LabelLocationStatement>(proc_def->get_body());
iter.is_valid(); iter.next()) {
LabelLocationStatement *start_label_loc_stmt = &iter.current();
if(start_label_loc_stmt->get_defined_label() == start_label_sym) {
Statement *next_stmt = get_next_statement(start_label_loc_stmt);
while(next_stmt != NULL) {
if(is_a<LabelLocationStatement>(next_stmt)) {
if((to<LabelLocationStatement>(next_stmt))->get_defined_label() == end_label_sym)
return stmt_block;
} else if(is_a<JumpStatement>(next_stmt)) {
if((to<JumpStatement>(next_stmt))->get_target() == end_label_sym)
return stmt_block;
}
stmt_block->append_statement(to<Statement>(deep_suif_clone(next_stmt)));
next_stmt = get_next_statement(next_stmt);
}
delete stmt_block;
return NULL;
}
}
delete stmt_block;
return NULL;
}
示例9: handle_static_expression
//
// Here are the visit methods
// for the c-like printing
//
// All of these handle_
// will set the string in the state before returning.
static
String handle_static_expression(CPrintStyleModule *state,
const SuifObject *obj)
{
Expression *expr = to<Expression>(obj);
// Use the iterator over source ops and
// get the classname
String opname = expr->getClassName();
String return_str = String("?") + opname + "(";
bool needs_comma = false;
for (Iter<Expression *> iter = expr->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 += ")";
return(return_str);
}
示例10: handle_static_call_statement
static
String handle_static_call_statement(CPrintStyleModule *state,
const SuifObject *obj)
{
CallStatement *expr =
to<CallStatement>(obj);
String addr = state->print_to_string(expr->get_callee_address());
String return_str;
if (expr->get_destination() != NULL) {
return_str += state->print_to_string(expr->get_destination());
return_str += " = ";
}
return_str += String("(") + addr + ")(";
bool needs_comma = false;
for (Iter<Expression *> iter = expr->get_argument_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 += ")";
return(return_str);
}
示例11: solve_li_statement_list_stmt
void solve_li_statement_list_stmt(Statement *s){
StatementList *stmt_list = to<StatementList>(s);
for (Iter<Statement*> iter = stmt_list->get_child_statement_iterator();
iter.is_valid(); iter.next())
solve_li_statement(iter.current());
}
示例12: 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;
}
示例13: do_procedure_definition
void ConstQualedVarPropagationPass::do_procedure_definition(ProcedureDefinition* proc_def)
{
OutputInformation("Constant qualified variable propagation pass begins");
suif_map<VariableSymbol*, ValueBlock*> temp_const_defs;
if (proc_def){
DefinitionBlock *proc_def_block = proc_def->get_definition_block();
for(Iter<VariableDefinition*> iter = proc_def_block->get_variable_definition_iterator();
iter.is_valid(); iter.next()){
VariableDefinition *var_def = iter.current();
VariableSymbol *var_sym = var_def->get_variable_symbol();
QualifiedType *qualed_var_type = var_sym->get_type();
if(is_a<IntegerType>(qualed_var_type->get_base_type())){
bool found = 0;
for(Iter<LString> iter2 = qualed_var_type->get_qualification_iterator();
iter2.is_valid(); iter2.next())
if(iter2.current() == LString("const"))
found = 1;
if(found){
temp_const_defs.enter_value(var_sym, var_def->get_initialization());
}
}
}
for(Iter<StoreVariableStatement> iter = object_iterator<StoreVariableStatement>(proc_def->get_body());
iter.is_valid(); iter.next()){
StoreVariableStatement *store_var_stmt = &iter.current();
Expression *store_var_value = store_var_stmt->get_value();
if(!is_a<IntConstant>(store_var_value))
continue;
VariableSymbol *store_var_destination = store_var_stmt->get_destination();
if(!is_a<IntegerType>(store_var_destination->get_type()->get_base_type()))
continue;
suif_map<VariableSymbol*,ValueBlock*>::iterator iter2 =
temp_const_defs.find(to<LoadVariableExpression>(store_var_value)->get_source());
if(iter2 != temp_const_defs.end())
const_qualified_scalars.enter_value(store_var_destination, (*iter2).second);
}
cqvp_load_variable_expression_walker walker(get_suif_env());
proc_def->walk(walker);
}
OutputInformation("Constant qualified variable propagation pass ends");
}
示例14: get_src_var
unsigned SemanticHelper::get_src_var(const ExecutionObject* exe,
suif_vector<VariableSymbol*>* var_vect)
{
unsigned cnt = 0;
for (Iter<VariableSymbol*> iter = exe->get_source_var_iterator();
iter.is_valid();
iter.next()) {
cnt++;
if (var_vect != 0)
var_vect->push_back(iter.current());
}
for (Iter<Expression*> siter = exe->get_source_op_iterator();
siter.is_valid();
siter.next()) {
Expression* exp = siter.current();
if (exp == 0) continue;
cnt += get_src_var(exp, var_vect);
}
return cnt;
}
示例15: is_in_lookup_list
static bool is_in_lookup_list( SymbolTableObject *obj,
SymbolTable* symtab)
{
for (Iter<SymbolTable::lookup_table_pair> it =
symtab->get_lookup_table_iterator();
it.is_valid();
it.next()) {
if (obj == it.current().second)
return true;
}
return false;
}