コード例 #1
0
  void test_all_keys() {
    Object* k1 = Fixnum::from(4);

    tbl->store(state, k1, cTrue);
    Array* ary = tbl->all_keys(state);

    TS_ASSERT_EQUALS(ary->total()->to_native(), 1);
    TS_ASSERT_EQUALS(ary->get(state, 0), k1);
  }
コード例 #2
0
ファイル: packed_object.cpp プロジェクト: atoulme/rubinius
  void PackedObject::add_packed_ivars(STATE, Array* ary) {
    LookupTable* tbl = this->reference_class()->packed_ivar_info();
    assert(tbl && !tbl->nil_p());

    Array* keys = tbl->all_keys(state);

    for(size_t i = 0; i < keys->size(); i++) {
      Object* key = keys->get(state, i);
      if(Fixnum* which = try_as<Fixnum>(tbl->fetch(state, key))) {
        if(body_as_array()[which->to_native()] != Qundef) {
          ary->append(state, key);
        }
      }
    }
  }
コード例 #3
0
ファイル: lookuptable.cpp プロジェクト: marnen/rubinius
  void LookupTable::Info::show(STATE, Object* self, int level) {
    LookupTable* tbl = as<LookupTable>(self);
    size_t size = tbl->entries()->to_native();
    Array* keys = tbl->all_keys(state);

    if(size == 0) {
      class_info(state, self, true);
      return;
    }

    class_info(state, self);
    std::cout << ": " << size << std::endl;
    indent(++level);
    for(size_t i = 0; i < size; i++) {
      std::cout << ":" << as<Symbol>(keys->get(state, i))->c_str(state);
      if(i < size - 1) std::cout << ", ";
    }
    std::cout << std::endl;
    close_body(level);
  }