コード例 #1
0
void
rename_if_collision(SymbolTableObject *sto, SymbolTable *new_st)
{
    LString orig = sto->get_name();
    if (orig == emptyLString || !new_st->has_lookup_table_member(orig))
      return;

    for (IInteger serial = 0; ; ++serial) {
      String suffix;
      serial.write(suffix, 10);
      LString trial(orig + suffix);
      if (!new_st->has_lookup_table_member(trial)) {
          sto->set_name(trial);
          return;
      }
    }
}
コード例 #2
0
ファイル: bit_vector.cpp プロジェクト: JehandadKhan/roccc-2.0
void BitVector::from_i_integer(IInteger new_value)
  {
    if (new_value < 0)
      {
        from_i_integer(~new_value);
        *this = invert();
        return;
      }
    IInteger ii_hex_length = new_value.written_length(16);
    if (!ii_hex_length.is_c_size_t())
        suif_error("out of memory address space");
    size_t hex_length = ii_hex_length.c_size_t();
    char *buffer = new char[hex_length + 3];
    buffer[0] = '0';
    buffer[1] = 'x';
    new_value.write(&(buffer[2]), 16);
    read(buffer);
    delete[] buffer;
  }