Ejemplo n.º 1
0
void add_failed_symbol(symbolt &symbol, contextt &context)
{
  if(!symbol.is_lvalue) return;
  
  if(symbol.type.get("#failed_symbol")!="")
    return;

  if(symbol.type.id()==ID_pointer)
  {
    symbolt new_symbol;
    new_symbol.is_lvalue=true;
    new_symbol.module=symbol.module;
    new_symbol.mode=symbol.mode;
    new_symbol.base_name=id2string(symbol.base_name)+"$object";
    new_symbol.name=failed_symbol_id(symbol.name);
    new_symbol.type=symbol.type.subtype();
    new_symbol.value.make_nil();
    new_symbol.type.set(ID_C_is_failed_symbol, true);
    
    symbol.type.set(ID_C_failed_symbol, new_symbol.name);
    
    if(new_symbol.type.id()==ID_pointer)
      add_failed_symbol(new_symbol, context); // recursive call
        
    context.move(new_symbol);
  }
}
Ejemplo n.º 2
0
void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table)
{
  if(!symbol.is_lvalue) return;
  
  if(symbol.type.get(ID_C_failed_symbol)!="")
    return;

  if(symbol.type.id()==ID_pointer)
  {
    symbolt new_symbol;
    new_symbol.is_lvalue=true;
    new_symbol.module=symbol.module;
    new_symbol.mode=symbol.mode;
    new_symbol.base_name=failed_symbol_id(symbol.base_name);
    new_symbol.name=failed_symbol_id(symbol.name);
    new_symbol.type=symbol.type.subtype();
    new_symbol.value.make_nil();
    new_symbol.type.set(ID_C_is_failed_symbol, true);
    
    symbol.type.set(ID_C_failed_symbol, new_symbol.name);
    
    if(new_symbol.type.id()==ID_pointer)
      add_failed_symbol(new_symbol, symbol_table); // recursive call
        
    symbol_table.move(new_symbol);
  }
}
Ejemplo n.º 3
0
void add_failed_symbols(contextt &context)
{
  // the symbol table iterators are not stable, and
  // we are adding new symbols, this
  // is why we need a list of pointers
  typedef std::list< ::symbolt *> symbol_listt;
  symbol_listt symbol_list;

  Forall_symbols(it, context.symbols)
    symbol_list.push_back(&(it->second));
  
  for(symbol_listt::const_iterator
      it=symbol_list.begin();
      it!=symbol_list.end();
      it++)
  {
    add_failed_symbol(**it, context);
  }
}