Пример #1
0
  void Selector::clear(STATE) {
    size_t sz = send_sites_->size();
    SendSite* ss;

    for(size_t i = 0; i < sz; i++) {
      ss = (SendSite*)send_sites_->get(state, i);
      ss->initialize(state);
    }
  }
Пример #2
0
  SendSite* SendSite::create(STATE, Object* name) {
    SendSite* ss = (SendSite*)state->new_struct(G(send_site), sizeof(SendSite));
    ss->name(state, (Symbol*)name);
    ss->sender(state, (CompiledMethod*)Qnil);
    ss->selector(state, Selector::lookup(state, name));

    ss->initialize(state);
    ss->selector()->associate(state, ss);

    return ss;
  }
Пример #3
0
  void test_initialize() {
    Object* sym = state->symbol("blah");
    SendSite* ss = SendSite::create(state, sym);
    CompiledMethod* cm = CompiledMethod::create(state);
    MethodResolver fake = (MethodResolver)Qnil;

    ss->resolver = fake;
    ss->recv_class(state, G(object));
    ss->method(state, cm);
    ss->module(state, G(object)->metaclass(state));
    TS_ASSERT_EQUALS(fake, ss->resolver);

    ss->initialize(state);
    TS_ASSERT_EQUALS(MonomorphicInlineCacheResolver::resolve, ss->resolver);
    TS_ASSERT(ss->recv_class()->nil_p());
    TS_ASSERT(ss->method()->nil_p());
    TS_ASSERT(ss->module()->nil_p());
  }