1 | // sass.hpp must go before all system headers to get the |
---|---|
2 | // __EXTENSIONS__ fix on Solaris. |
3 | #include "sass.hpp" |
4 | #include "expand.hpp" |
5 | #include "eval.hpp" |
6 | #include "ast.hpp" |
7 | |
8 | |
9 | namespace Sass { |
10 | |
11 | SelectorList* Eval::operator()(SelectorList* s) |
12 | { |
13 | sass::vector<SelectorListObj> rv; |
14 | SelectorListObj sl = SASS_MEMORY_NEW(SelectorList, s->pstate()); |
15 | for (size_t i = 0, iL = s->length(); i < iL; ++i) { |
16 | rv.push_back(x: operator()(s->get(i))); |
17 | } |
18 | |
19 | // we should actually permutate parent first |
20 | // but here we have permutated the selector first |
21 | size_t round = 0; |
22 | while (round != sass::string::npos) { |
23 | bool abort = true; |
24 | for (size_t i = 0, iL = rv.size(); i < iL; ++i) { |
25 | if (rv[i]->length() > round) { |
26 | sl->append(element: (*rv[i])[round]); |
27 | abort = false; |
28 | } |
29 | } |
30 | if (abort) { |
31 | round = sass::string::npos; |
32 | } |
33 | else { |
34 | ++round; |
35 | } |
36 | |
37 | } |
38 | return sl.detach(); |
39 | } |
40 | |
41 | SelectorComponent* Eval::operator()(SelectorComponent* s) |
42 | { |
43 | return {}; |
44 | } |
45 | |
46 | SelectorList* Eval::operator()(ComplexSelector* s) |
47 | { |
48 | bool implicit_parent = !exp.old_at_root_without_rule; |
49 | if (is_in_selector_schema) exp.pushNullSelector(); |
50 | SelectorListObj other = s->resolve_parent_refs( |
51 | pstack: exp.getOriginalStack(), traces, implicit_parent); |
52 | if (is_in_selector_schema) exp.popNullSelector(); |
53 | |
54 | for (size_t i = 0; i < other->length(); i++) { |
55 | ComplexSelectorObj sel = other->at(i); |
56 | for (size_t n = 0; n < sel->length(); n++) { |
57 | if (CompoundSelectorObj comp = Cast<CompoundSelector>(ptr: sel->at(i: n))) { |
58 | sel->at(i: n) = operator()(comp); |
59 | } |
60 | } |
61 | } |
62 | |
63 | return other.detach(); |
64 | } |
65 | |
66 | CompoundSelector* Eval::operator()(CompoundSelector* s) |
67 | { |
68 | for (size_t i = 0; i < s->length(); i++) { |
69 | SimpleSelector* ss = s->at(i); |
70 | // skip parents here (called via resolve_parent_refs) |
71 | s->at(i) = Cast<SimpleSelector>(ptr: ss->perform(op: this)); |
72 | } |
73 | return s; |
74 | } |
75 | } |
76 |