本文整理汇总了C++中MethodTableBucket::name方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodTableBucket::name方法的具体用法?C++ MethodTableBucket::name怎么用?C++ MethodTableBucket::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodTableBucket
的用法示例。
在下文中一共展示了MethodTableBucket::name方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: redistribute
void MethodTable::redistribute(STATE, size_t size) {
size_t num = bins_->to_native();
Tuple* new_values = Tuple::create(state, size);
for(size_t i = 0; i < num; i++) {
MethodTableBucket* entry = try_as<MethodTableBucket>(values_->at(state, i));
while(entry) {
MethodTableBucket* link = try_as<MethodTableBucket>(entry->next());
entry->next(state, reinterpret_cast<MethodTableBucket *>(Qnil));
size_t bin = find_bin(key_hash(entry->name()), size);
MethodTableBucket* slot = try_as<MethodTableBucket>(new_values->at(state, bin));
if(slot) {
slot->append(state, entry);
} else {
new_values->put(state, bin, entry);
}
entry = link;
}
}
values(state, new_values);
bins(state, Fixnum::from(size));
}
示例2: remove
Executable* MethodTable::remove(STATE, Symbol* name) {
hashval bin;
MethodTableBucket* entry;
MethodTableBucket* last = NULL;
size_t num_entries = entries_->to_native();
size_t num_bins = bins_->to_native();
if(min_density_p(num_entries, num_bins) && (num_bins >> 1) >= METHODTABLE_MIN_SIZE) {
redistribute(state, num_bins >>= 1);
}
bin = find_bin(key_hash(name), num_bins);
entry = try_as<MethodTableBucket>(values_->at(state, bin));
while(entry) {
if(entry->name() == name) {
Executable* val = entry->method();
if(last) {
last->next(state, entry->next());
} else {
values_->put(state, bin, entry->next());
}
entries(state, Fixnum::from(entries_->to_native() - 1));
return val;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
return reinterpret_cast<Executable*>(Qnil);
}
示例3: alias
Object* MethodTable::alias(STATE, Symbol* name, Symbol* vis,
Symbol* orig_name, Object* orig_method,
Module* orig_mod)
{
check_frozen(state);
utilities::thread::SpinLock::LockGuard lg(lock_);
Executable* orig_exec;
if(Alias* alias = try_as<Alias>(orig_method)) {
orig_exec = alias->original_exec();
orig_mod = alias->original_module();
orig_name = alias->original_name();
} else if(orig_method->nil_p()) {
orig_exec = nil<Executable>();
} else {
orig_exec = as<Executable>(orig_method);
}
Alias* method = Alias::create(state, orig_name, orig_mod, orig_exec);
native_int num_entries = entries_->to_native();
native_int num_bins = bins_->to_native();
if(max_density_p(num_entries, num_bins)) {
redistribute(state, num_bins <<= 1);
}
native_int bin = find_bin(key_hash(name), num_bins);
MethodTableBucket* entry = try_as<MethodTableBucket>(values_->at(state, bin));
MethodTableBucket* last = NULL;
while(entry) {
if(entry->name() == name) {
entry->method_id(state, nil<String>());
entry->method(state, method);
entry->scope(state, cNil);
entry->serial(state, Fixnum::from(0));
entry->visibility(state, vis);
return name;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
if(last) {
last->next(state, MethodTableBucket::create(
state, name, nil<String>(), method, cNil, Fixnum::from(0), vis));
} else {
values_->put(state, bin, MethodTableBucket::create(
state, name, nil<String>(), method, cNil, Fixnum::from(0), vis));
}
entries(state, Fixnum::from(num_entries + 1));
return name;
}
示例4: store
Object* MethodTable::store(STATE, Symbol* name, Object* exec, Symbol* vis)
{
check_frozen(state);
utilities::thread::SpinLock::LockGuard lg(lock_);
Executable* method;
if(exec->nil_p()) {
method = nil<Executable>();
} else {
if(Alias* stored_alias = try_as<Alias>(exec)) {
lock_.unlock();
Object* res = alias(state, name, vis,
stored_alias->original_name(),
stored_alias->original_exec(),
stored_alias->original_module());
lock_.lock();
return res;
} else {
method = as<Executable>(exec);
}
}
native_int num_entries = entries_->to_native();
native_int num_bins = bins_->to_native();
if(max_density_p(num_entries, num_bins)) {
redistribute(state, num_bins <<= 1);
}
native_int bin = find_bin(key_hash(name), num_bins);
MethodTableBucket* entry = try_as<MethodTableBucket>(values_->at(state, bin));
MethodTableBucket* last = NULL;
while(entry) {
if(entry->name() == name) {
entry->method(state, method);
entry->visibility(state, vis);
return name;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
if(last) {
last->next(state, MethodTableBucket::create(state, name, method, vis));
} else {
values_->put(state, bin,
MethodTableBucket::create(state, name, method, vis));
}
entries(state, Fixnum::from(num_entries + 1));
return name;
}
示例5: create
MethodTableBucket* MethodTableBucket::create(STATE, Symbol* name,
Executable* method, Symbol* vis)
{
MethodTableBucket *entry =
state->new_object<MethodTableBucket>(G(methtblbucket));
entry->name(state, name);
entry->method(state, method);
entry->visibility(state, vis);
return entry;
}
示例6: create
MethodTableBucket* MethodTableBucket::create(STATE, Symbol* name, Object* method_id,
Object* method, Object* scope, Fixnum* serial, Symbol* vis)
{
MethodTableBucket *entry =
state->new_object<MethodTableBucket>(G(methtblbucket));
entry->name(state, name);
entry->method_id(state, method_id);
entry->method(state, method);
entry->scope(state, scope);
entry->serial(state, serial);
entry->visibility(state, vis);
return entry;
}
示例7: find_entry
MethodTableBucket* MethodTable::find_entry(Symbol* name) {
unsigned int bin;
bin = find_bin(key_hash(name), bins_->to_native());
MethodTableBucket *entry = try_as<MethodTableBucket>(values_->at(bin));
while(entry) {
if(entry->name() == name) {
return entry;
}
entry = try_as<MethodTableBucket>(entry->next());
}
return 0;
}
示例8: find_entry
MethodTableBucket* MethodTable::find_entry(Symbol* name) {
unsigned int bin;
utilities::thread::SpinLock::LockGuard lg(lock_);
bin = find_bin(key_hash(name), bins_->to_native());
MethodTableBucket *entry = try_as<MethodTableBucket>(values_->at(bin));
while(entry) {
if(entry->name() == name) {
return entry;
}
entry = try_as<MethodTableBucket>(entry->next());
}
return 0;
}
示例9: store
Object* MethodTable::store(STATE, Symbol* name, Object* exec, Symbol* vis) {
unsigned int num_entries, num_bins, bin;
MethodTableBucket* entry;
MethodTableBucket* last = NULL;
Executable* method;
if(exec->nil_p()) {
method = reinterpret_cast<Executable*>(Qnil);
} else {
if(Alias* alias = try_as<Alias>(exec)) {
method = alias->original_exec();
} else {
method = as<Executable>(exec);
}
}
num_entries = entries_->to_native();
num_bins = bins_->to_native();
if(max_density_p(num_entries, num_bins)) {
redistribute(state, num_bins <<= 1);
}
bin = find_bin(key_hash(name), num_bins);
entry = try_as<MethodTableBucket>(values_->at(state, bin));
while(entry) {
if(entry->name() == name) {
entry->method(state, method);
entry->visibility(state, vis);
return name;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
if(last) {
last->next(state, MethodTableBucket::create(state, name, method, vis));
} else {
values_->put(state, bin, MethodTableBucket::create(state, name, method, vis));
}
entries(state, Fixnum::from(num_entries + 1));
return name;
}
示例10: alias
Object* MethodTable::alias(STATE, Symbol* name, Symbol* vis,
Symbol* orig_name, Executable* orig_method,
Module* orig_mod)
{
unsigned int num_entries, num_bins, bin;
MethodTableBucket* entry;
MethodTableBucket* last = NULL;
if(Alias* alias = try_as<Alias>(orig_method)) {
orig_method = alias->original_exec();
orig_mod = alias->original_module();
orig_name = alias->original_name();
}
Alias* method = Alias::create(state, orig_name, orig_mod, orig_method);
num_entries = entries_->to_native();
num_bins = bins_->to_native();
if(max_density_p(num_entries, num_bins)) {
redistribute(state, num_bins <<= 1);
}
bin = find_bin(key_hash(name), num_bins);
entry = try_as<MethodTableBucket>(values_->at(state, bin));
while(entry) {
if(entry->name() == name) {
entry->method(state, method);
entry->visibility(state, vis);
return name;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
if(last) {
last->next(state, MethodTableBucket::create(state, name, method, vis));
} else {
values_->put(state, bin, MethodTableBucket::create(state, name, method, vis));
}
entries(state, Fixnum::from(num_entries + 1));
return name;
}
示例11: duplicate
MethodTable* MethodTable::duplicate(STATE) {
size_t size, i;
MethodTable *dup;
size = bins_->to_native();
dup = MethodTable::create(state, size);
// Allow for subclassing.
dup->klass(state, class_object(state));
size_t num = entries_->to_native();
Array* entries = all_entries(state);
for(i = 0; i < num; i++) {
MethodTableBucket* entry = as<MethodTableBucket>(entries->get(state, i));
dup->store(state, entry->name(), entry->method(), entry->visibility());
}
return dup;
}
示例12: remove
Executable* MethodTable::remove(STATE, Symbol* name) {
check_frozen(state);
utilities::thread::SpinLock::LockGuard lg(lock_);
native_int num_entries = entries_->to_native();
native_int num_bins = bins_->to_native();
if(min_density_p(num_entries, num_bins) &&
(num_bins >> 1) >= METHODTABLE_MIN_SIZE) {
redistribute(state, num_bins >>= 1);
}
native_int bin = find_bin(key_hash(name), num_bins);
MethodTableBucket* entry = try_as<MethodTableBucket>(values_->at(state, bin));
MethodTableBucket* last = NULL;
while(entry) {
if(entry->name() == name) {
Executable* val = entry->method();
if(last) {
last->next(state, entry->next());
} else {
values_->put(state, bin, entry->next());
}
entries(state, Fixnum::from(entries_->to_native() - 1));
return val;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
return nil<Executable>();
}