Statement* Expand::operator()(Extension* e) { To_String to_string; Selector_List* extender = static_cast<Selector_List*>(selector_stack.back()); if (!extender) return 0; Selector_List* extendee = static_cast<Selector_List*>(e->selector()->perform(contextualize->with(0, env, backtrace))); if (extendee->length() != 1) { error("selector groups may not be extended", extendee->path(), extendee->position(), backtrace); } Complex_Selector* c = (*extendee)[0]; if (!c->head() || c->tail()) { error("nested selectors may not be extended", c->path(), c->position(), backtrace); } Compound_Selector* s = c->head(); // // need to convert the compound selector into a by-value data structure // vector<string> target_vec; // for (size_t i = 0, L = s->length(); i < L; ++i) // { target_vec.push_back((*s)[i]->perform(&to_string)); } for (size_t i = 0, L = extender->length(); i < L; ++i) { ctx.extensions.insert(make_pair(*s, (*extender)[i])); // let's test this out // cerr << "REGISTERING EXTENSION REQUEST: " << (*extender)[i]->perform(&to_string) << " <- " << s->perform(&to_string) << endl; ctx.subset_map.put(s->to_str_vec(), make_pair((*extender)[i], s)); } return 0; }
Statement* Expand::operator()(Extension* e) { Selector_List* extender = static_cast<Selector_List*>(selector_stack.back()); if (!extender) return 0; Selector_List* extendee = static_cast<Selector_List*>(e->selector()->perform(contextualize->with(0, env, backtrace))); if (extendee->length() != 1) { error("selector groups may not be extended", extendee->path(), extendee->position(), backtrace); } Complex_Selector* c = (*extendee)[0]; if (!c->head() || c->tail()) { error("nested selectors may not be extended", c->path(), c->position(), backtrace); } Compound_Selector* s = c->head(); for (size_t i = 0, L = extender->length(); i < L; ++i) { extensions.insert(make_pair(*s, (*extender)[i])); To_String to_string; } return 0; }