Пример #1
0
  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();

    MethodTableBucket* entry = 0;

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

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

    return dup;
  }
Пример #2
0
  static void hookup_prim(STATE, Symbol* meth, Symbol* prim) {
    MethodTable* tbl = G(rubinius)->metaclass(state)->method_table();

    Executable* oc = Executable::allocate(state, Qnil);
    oc->primitive(state, prim);
    assert(oc->resolve_primitive(state));

    tbl->store(state, meth, oc, G(sym_public));
  }
Пример #3
0
  void System::attach_primitive(STATE, Module* mod, bool meta, Symbol* name, Symbol* prim) {
    MethodTable* tbl;

    if(meta) {
      tbl = mod->singleton_class(state)->method_table();
    } else {
      tbl = mod->method_table();
    }

    Executable* oc = Executable::allocate(state, Qnil);
    oc->primitive(state, prim);
    oc->resolve_primitive(state);

    tbl->store(state, name, oc, G(sym_public));
  }
Пример #4
0
  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;
  }