当前位置: 首页>>代码示例>>C++>>正文


C++ MethodTableBucket::scope方法代码示例

本文整理汇总了C++中MethodTableBucket::scope方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodTableBucket::scope方法的具体用法?C++ MethodTableBucket::scope怎么用?C++ MethodTableBucket::scope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MethodTableBucket的用法示例。


在下文中一共展示了MethodTableBucket::scope方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: duplicate

  MethodTable* MethodTable::duplicate(STATE) {
    size_t size, i;
    MethodTable* dup = 0;

    utilities::thread::SpinLock::LockGuard lg(lock_);

    size = bins_->to_native();
    dup = MethodTable::create(state, size);

    // Allow for subclassing.
    dup->klass(state, class_object(state));

    size_t num = bins_->to_native();
    for(i = 0; i < num; i++) {
      MethodTableBucket* entry = try_as<MethodTableBucket>(values_->at(state, i));

      while(entry) {
        dup->store(state, entry->name(), entry->method_id(),
            entry->method(), entry->scope(), entry->serial(), entry->visibility());
        entry = try_as<MethodTableBucket>(entry->next());
      }
    }

    return dup;
  }
开发者ID:Red54,项目名称:rubinius,代码行数:25,代码来源:method_table.cpp

示例2: 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;
  }
开发者ID:Red54,项目名称:rubinius,代码行数:59,代码来源:method_table.cpp

示例3: store

  Object* MethodTable::store(STATE, Symbol* name, Object* method_id,
      Object* method, Object* scope, Fixnum* serial, Symbol* visibility)
  {
    check_frozen(state);

    utilities::thread::SpinLock::LockGuard lg(lock_);

    if(!method->nil_p()) {
      if(Alias* stored_alias = try_as<Alias>(method)) {
        lock_.unlock();
        Object* res = alias(state, name, visibility,
                           stored_alias->original_name(),
                           stored_alias->original_exec(),
                           stored_alias->original_module());
        lock_.lock();
        return res;
      }
    }

    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, method_id);
        entry->method(state, method);
        entry->scope(state, scope);
        entry->serial(state, serial);
        entry->visibility(state, visibility);
        return name;
      }

      last = entry;
      entry = try_as<MethodTableBucket>(entry->next());
    }

    if(last) {
      last->next(state, MethodTableBucket::create(
            state, name, method_id, method, scope, serial, visibility));
    } else {
      values_->put(state, bin, MethodTableBucket::create(
            state, name, method_id, method, scope, serial, visibility));
    }

    entries(state, Fixnum::from(num_entries + 1));

    return name;
  }
开发者ID:Red54,项目名称:rubinius,代码行数:57,代码来源:method_table.cpp

示例4: 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;
  }
开发者ID:Red54,项目名称:rubinius,代码行数:15,代码来源:method_table.cpp


注:本文中的MethodTableBucket::scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。