Esempio n. 1
0
  void test_set_sender() {
    Object* sym = state->symbol("blah");
    SendSite* ss = SendSite::create(state, sym);
    TS_ASSERT_EQUALS(ss->sender(), Qnil);

    CompiledMethod* cm = CompiledMethod::create(state);
    TS_ASSERT_EQUALS(ss->set_sender(state, cm), Qnil);
    TS_ASSERT_EQUALS(ss->sender(), cm);
  }
Esempio n. 2
0
 void CompiledMethod::post_marshal(STATE) {
   formalize(state); // side-effect, populates backend_method_
   // Set the sender attribute of all SendSites in this method to this CM
   Tuple *lit = literals();
   for(std::size_t i = 0; i < lit->num_fields(); i++) {
     SendSite *ss = try_as<SendSite>(lit->at(state, i));
     if(ss != NULL) ss->sender(state, this);
   }
 }
Esempio n. 3
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;
  }
Esempio n. 4
0
  void SendSite::Info::show(STATE, Object* self, int level) {
    SendSite* ss = as<SendSite>(self);

    class_header(state, self);
    indent_attribute(++level, "name"); ss->name()->show(state, level);
    indent_attribute(level, "sender"); class_info(state, ss->sender(), true);
    indent_attribute(level, "selector"); class_info(state, ss->selector(), true);
    indent_attribute(level, "hits"); std::cout << ss->hits << std::endl;
    indent_attribute(level, "misses"); std::cout << ss->misses << std::endl;
    indent_attribute(level, "module"); class_info(state, ss->module(), true);
    indent_attribute(level, "method"); class_info(state, ss->method(), true);
    indent_attribute(level, "recv_class"); class_info(state, ss->recv_class(), true);
    close_body(level);
  }
Esempio n. 5
0
  void test_create() {
    Object* sym = state->symbol("blah");
    SendSite* ss = SendSite::create(state, sym);
    TS_ASSERT_EQUALS(ss->name(), sym);
    TS_ASSERT_EQUALS(ss->sender(), Qnil);
    
    Selector* sel = Selector::lookup(state, sym);
    TS_ASSERT_EQUALS(ss->selector(), sel);

    TS_ASSERT(sel->includes_p(state, ss));

    TS_ASSERT_EQUALS(ss->method(), Qnil);
    TS_ASSERT_EQUALS(ss->module(), Qnil);
    TS_ASSERT_EQUALS(ss->recv_class(), Qnil);
  }