Walker::ApplyStatus smp_c_for_statement_walker::operator () (SuifObject *x) { SuifEnv *the_env = get_env(); CForStatement *c_for_stmt = to<CForStatement>(x); BrickAnnote *loop_label_annote = to<BrickAnnote>(c_for_stmt->lookup_annote_by_name("c_for_label")); StringBrick *loop_label_brick = to<StringBrick>(loop_label_annote->get_brick(0)); String current_loop_label = loop_label_brick->get_value(); if (current_loop_label != loop_label_argument) return Walker::Continue; Statement *body = c_for_stmt->get_body(); if (body) { VariableSymbol* loop_counter = get_c_for_basic_induction_variable(c_for_stmt); VariableSymbol* strip_loop_counter = new_anonymous_variable(the_env, find_scope(c_for_stmt), loop_counter->get_type()); name_variable(strip_loop_counter); // step size of the strip is the step size of the original loop int strip_step_size = get_c_for_step(c_for_stmt); c_for_stmt->set_body(0); CForStatement* strip = make_strip(the_env, strip_loop_counter, strip_size, strip_step_size, body); c_for_stmt->set_body(strip); set_c_for_step(c_for_stmt, strip_size); smp_load_variable_expression_walker walker(the_env, loop_counter, strip_loop_counter); body->walk(walker); } return Walker::Truncate; }
Walker::ApplyStatus CollisionAvoider::operator () (SuifObject *x) { Symbol *symbol = to<Symbol>(x); // delete names which mask externals. If we end up with a name that does // not, just return, otherwise create a new name // printf("next symbol is ");printobj(symbol); LString sname = symbol->get_name(); // bool is_key = is_keyword(sname); if (sname == emptyLString) { if (name_all_symbols) name_variable(symbol,& source_file_name); return Walker::Continue; } SymbolTable *scope = symbol->get_symbol_table(); if (!is_keyword(sname)) { bool conflicts = is_var_name_crashd_locally(symbol); if (scope != external_symbol_table) { // if it doesn't conflict in the external symbol table if (external_symbol_table->has_lookup_table_member(sname)) { conflicts = true; } else { if (file_scope_symbol_tables) { // or the file scope tables for (list<SymbolTable*>::iterator iter = file_scope_symbol_tables->begin(); iter != file_scope_symbol_tables->end(); iter++) { SymbolTable *symtab = *iter; if (symtab == scope) continue; if (symtab->has_lookup_table_member(sname)) { conflicts = true; break; } } } if (!conflicts) { SymbolTable *curr_scope = symbol->get_symbol_table()->get_explicit_super_scope(); while (curr_scope && curr_scope->get_explicit_super_scope() != external_symbol_table) { if (curr_scope->has_lookup_table_member(sname )) { conflicts = true; break; } curr_scope = curr_scope->get_explicit_super_scope(); } } } } if (!conflicts) return Walker::Continue; } // TBD: // Actually, we may have to check // for ANY conflict. I.e. for machsuif, // labels conflict with procedures // Added July 29 for Fortran // Make sure names are not common "reserved words" from C // This is lsightly bogus - should be configurable somehow // We only need this because we are generating C out. If we // are going to a code gen, or outputting some other language // this is not needed or needs changing // int no = symbol->num_name_with_key(sname); // while (no > 0) { // printf("conflict found\n"); // symbol->remove_name(sname,--no); // } //} rename_symbol(symbol, emptyLString); // if (name_all_symbols) name_variable(symbol,& source_file_name); return Walker::Continue; }
Walker::ApplyStatus SymbolNamer::operator () (SuifObject *x) { Symbol *symbol = to<Symbol>(x); name_variable(symbol, & source_file_name); return Walker::Continue; }