Skip to content

Commit 97e6200

Browse files
committed
Rename Compound_Selector AST node to SimpleSequence_Selector
This better matches the Ruby Sass implementation.
1 parent 21a37a1 commit 97e6200

18 files changed

+151
-151
lines changed

src/ast.cpp

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

src/ast.hpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,12 +1992,12 @@ namespace Sass {
19921992
}
19931993

19941994
virtual ~Simple_Selector() = 0;
1995-
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
1995+
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
19961996
virtual bool has_parent_ref() { return false; };
19971997
virtual bool is_pseudo_element() { return false; }
19981998
virtual bool is_pseudo_class() { return false; }
19991999

2000-
virtual bool is_superselector_of(Compound_Selector* sub) { return false; }
2000+
virtual bool is_superselector_of(SimpleSequence_Selector* sub) { return false; }
20012001

20022002
bool operator==(const Simple_Selector& rhs) const;
20032003
inline bool operator!=(const Simple_Selector& rhs) const { return !(*this == rhs); }
@@ -2013,7 +2013,7 @@ namespace Sass {
20132013
// The Parent Selector Expression.
20142014
//////////////////////////////////
20152015
// parent selectors can occur in selectors but also
2016-
// inside strings in declarations (Compound_Selector).
2016+
// inside strings in declarations (SimpleSequence_Selector).
20172017
// only one simple parent selector means the first case.
20182018
class Parent_Selector : public Simple_Selector {
20192019
public:
@@ -2061,7 +2061,7 @@ namespace Sass {
20612061
else return Constants::Specificity_Element;
20622062
}
20632063
virtual Simple_Selector* unify_with(Simple_Selector*, Context&);
2064-
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
2064+
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
20652065
ATTACH_OPERATIONS()
20662066
};
20672067

@@ -2084,7 +2084,7 @@ namespace Sass {
20842084
if (name()[0] == '.') return Constants::Specificity_Class;
20852085
else return Constants::Specificity_Element;
20862086
}
2087-
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
2087+
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
20882088
ATTACH_OPERATIONS()
20892089
};
20902090

@@ -2180,7 +2180,7 @@ namespace Sass {
21802180
bool operator==(const Pseudo_Selector& rhs) const;
21812181
bool operator<(const Simple_Selector& rhs) const;
21822182
bool operator<(const Pseudo_Selector& rhs) const;
2183-
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
2183+
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
21842184
ATTACH_OPERATIONS()
21852185
};
21862186

@@ -2233,7 +2233,7 @@ namespace Sass {
22332233
// any parent references or placeholders, to simplify expansion.
22342234
////////////////////////////////////////////////////////////////////////////
22352235
typedef std::set<Sequence_Selector*, Sequence_Selector_Pointer_Compare> SourcesSet;
2236-
class Compound_Selector : public Selector, public Vectorized<Simple_Selector*> {
2236+
class SimpleSequence_Selector : public Selector, public Vectorized<Simple_Selector*> {
22372237
private:
22382238
SourcesSet sources_;
22392239
ADD_PROPERTY(bool, extended);
@@ -2245,7 +2245,7 @@ namespace Sass {
22452245
if (s->has_placeholder()) has_placeholder(true);
22462246
}
22472247
public:
2248-
Compound_Selector(ParserState pstate, size_t s = 0)
2248+
SimpleSequence_Selector(ParserState pstate, size_t s = 0)
22492249
: Selector(pstate),
22502250
Vectorized<Simple_Selector*>(s),
22512251
extended_(false),
@@ -2264,13 +2264,13 @@ namespace Sass {
22642264
}
22652265

22662266
Sequence_Selector* to_complex(Memory_Manager& mem);
2267-
Compound_Selector* unify_with(Compound_Selector* rhs, Context& ctx);
2267+
SimpleSequence_Selector* unify_with(SimpleSequence_Selector* rhs, Context& ctx);
22682268
// virtual Placeholder_Selector* find_placeholder();
22692269
virtual bool has_parent_ref();
22702270
Simple_Selector* base()
22712271
{
22722272
// Implement non-const in terms of const. Safe to const_cast since this method is non-const
2273-
return const_cast<Simple_Selector*>(static_cast<const Compound_Selector*>(this)->base());
2273+
return const_cast<Simple_Selector*>(static_cast<const SimpleSequence_Selector*>(this)->base());
22742274
}
22752275
const Simple_Selector* base() const {
22762276
if (length() == 0) return 0;
@@ -2279,7 +2279,7 @@ namespace Sass {
22792279
return (*this)[0];
22802280
return 0;
22812281
}
2282-
virtual bool is_superselector_of(Compound_Selector* sub, std::string wrapped = "");
2282+
virtual bool is_superselector_of(SimpleSequence_Selector* sub, std::string wrapped = "");
22832283
virtual bool is_superselector_of(Sequence_Selector* sub, std::string wrapped = "");
22842284
virtual bool is_superselector_of(CommaSequence_Selector* sub, std::string wrapped = "");
22852285
virtual size_t hash()
@@ -2314,18 +2314,18 @@ namespace Sass {
23142314
}
23152315
std::vector<std::string> to_str_vec(); // sometimes need to convert to a flat "by-value" data structure
23162316

2317-
bool operator<(const Compound_Selector& rhs) const;
2317+
bool operator<(const SimpleSequence_Selector& rhs) const;
23182318

2319-
bool operator==(const Compound_Selector& rhs) const;
2320-
inline bool operator!=(const Compound_Selector& rhs) const { return !(*this == rhs); }
2319+
bool operator==(const SimpleSequence_Selector& rhs) const;
2320+
inline bool operator!=(const SimpleSequence_Selector& rhs) const { return !(*this == rhs); }
23212321

23222322
SourcesSet& sources() { return sources_; }
23232323
void clearSources() { sources_.clear(); }
23242324
void mergeSources(SourcesSet& sources, Context& ctx);
23252325

2326-
Compound_Selector* clone(Context&) const; // does not clone the Simple_Selector*s
2326+
SimpleSequence_Selector* clone(Context&) const; // does not clone the Simple_Selector*s
23272327

2328-
Compound_Selector* minus(Compound_Selector* rhs, Context& ctx);
2328+
SimpleSequence_Selector* minus(SimpleSequence_Selector* rhs, Context& ctx);
23292329
ATTACH_OPERATIONS()
23302330
};
23312331

@@ -2339,7 +2339,7 @@ namespace Sass {
23392339
enum Combinator { ANCESTOR_OF, PARENT_OF, PRECEDES, ADJACENT_TO, REFERENCE };
23402340
private:
23412341
ADD_PROPERTY(Combinator, combinator)
2342-
ADD_PROPERTY(Compound_Selector*, head)
2342+
ADD_PROPERTY(SimpleSequence_Selector*, head)
23432343
ADD_PROPERTY(Sequence_Selector*, tail)
23442344
ADD_PROPERTY(String*, reference);
23452345
public:
@@ -2350,7 +2350,7 @@ namespace Sass {
23502350
};
23512351
Sequence_Selector(ParserState pstate,
23522352
Combinator c = ANCESTOR_OF,
2353-
Compound_Selector* h = 0,
2353+
SimpleSequence_Selector* h = 0,
23542354
Sequence_Selector* t = 0,
23552355
String* r = 0)
23562356
: Selector(pstate),
@@ -2405,7 +2405,7 @@ namespace Sass {
24052405

24062406
size_t length() const;
24072407
CommaSequence_Selector* resolve_parent_refs(Context& ctx, CommaSequence_Selector* parents, bool implicit_parent);
2408-
virtual bool is_superselector_of(Compound_Selector* sub, std::string wrapping = "");
2408+
virtual bool is_superselector_of(SimpleSequence_Selector* sub, std::string wrapping = "");
24092409
virtual bool is_superselector_of(Sequence_Selector* sub, std::string wrapping = "");
24102410
virtual bool is_superselector_of(CommaSequence_Selector* sub, std::string wrapping = "");
24112411
// virtual Placeholder_Selector* find_placeholder();
@@ -2451,7 +2451,7 @@ namespace Sass {
24512451

24522452
SourcesSet srcs;
24532453

2454-
Compound_Selector* pHead = head();
2454+
SimpleSequence_Selector* pHead = head();
24552455
Sequence_Selector* pTail = tail();
24562456

24572457
if (pHead) {
@@ -2470,7 +2470,7 @@ namespace Sass {
24702470
// members.map! {|m| m.is_a?(SimpleSequence) ? m.with_more_sources(sources) : m}
24712471
Sequence_Selector* pIter = this;
24722472
while (pIter) {
2473-
Compound_Selector* pHead = pIter->head();
2473+
SimpleSequence_Selector* pHead = pIter->head();
24742474

24752475
if (pHead) {
24762476
pHead->mergeSources(sources, ctx);
@@ -2482,7 +2482,7 @@ namespace Sass {
24822482
void clearSources() {
24832483
Sequence_Selector* pIter = this;
24842484
while (pIter) {
2485-
Compound_Selector* pHead = pIter->head();
2485+
SimpleSequence_Selector* pHead = pIter->head();
24862486

24872487
if (pHead) {
24882488
pHead->clearSources();
@@ -2491,14 +2491,14 @@ namespace Sass {
24912491
pIter = pIter->tail();
24922492
}
24932493
}
2494-
Sequence_Selector* clone(Context&) const; // does not clone Compound_Selector*s
2495-
Sequence_Selector* cloneFully(Context&) const; // clones Compound_Selector*s
2496-
// std::vector<Compound_Selector*> to_vector();
2494+
Sequence_Selector* clone(Context&) const; // does not clone SimpleSequence_Selector*s
2495+
Sequence_Selector* cloneFully(Context&) const; // clones SimpleSequence_Selector*s
2496+
// std::vector<SimpleSequence_Selector*> to_vector();
24972497
ATTACH_OPERATIONS()
24982498
};
24992499

25002500
typedef std::deque<Sequence_Selector*> ComplexSelectorDeque;
2501-
typedef Subset_Map<std::string, std::pair<Sequence_Selector*, Compound_Selector*> > ExtensionSubsetMap;
2501+
typedef Subset_Map<std::string, std::pair<Sequence_Selector*, SimpleSequence_Selector*> > ExtensionSubsetMap;
25022502

25032503
///////////////////////////////////
25042504
// Comma-separated selector groups.
@@ -2518,7 +2518,7 @@ namespace Sass {
25182518
void remove_parent_selectors();
25192519
// virtual Placeholder_Selector* find_placeholder();
25202520
CommaSequence_Selector* resolve_parent_refs(Context& ctx, CommaSequence_Selector* parents, bool implicit_parent = true);
2521-
virtual bool is_superselector_of(Compound_Selector* sub, std::string wrapping = "");
2521+
virtual bool is_superselector_of(SimpleSequence_Selector* sub, std::string wrapping = "");
25222522
virtual bool is_superselector_of(Sequence_Selector* sub, std::string wrapping = "");
25232523
virtual bool is_superselector_of(CommaSequence_Selector* sub, std::string wrapping = "");
25242524
CommaSequence_Selector* unify_with(CommaSequence_Selector*, Context&);
@@ -2554,8 +2554,8 @@ namespace Sass {
25542554
}
25552555
return false;
25562556
}
2557-
CommaSequence_Selector* clone(Context&) const; // does not clone Compound_Selector*s
2558-
CommaSequence_Selector* cloneFully(Context&) const; // clones Compound_Selector*s
2557+
CommaSequence_Selector* clone(Context&) const; // does not clone SimpleSequence_Selector*s
2558+
CommaSequence_Selector* cloneFully(Context&) const; // clones SimpleSequence_Selector*s
25592559
virtual bool operator==(const Selector& rhs) const;
25602560
virtual bool operator==(const CommaSequence_Selector& rhs) const;
25612561
// Selector Lists can be compared to comma lists
@@ -2570,10 +2570,10 @@ namespace Sass {
25702570
// is required for proper stl collection ordering) is implemented using string comparision. This gives stable sorting
25712571
// behavior, and can be used to determine if the selectors would have exactly idential output. operator== matches the
25722572
// ruby sass implementations for eql, which sometimes perform order independent comparisions (like set comparisons of the
2573-
// members of a SimpleSequence (Compound_Selector)).
2573+
// members of a SimpleSequence (SimpleSequence_Selector)).
25742574
//
25752575
// Due to the reliance on operator== and operater< behavior, this templated method is currently only intended for
2576-
// use with Compound_Selector and Sequence_Selector objects.
2576+
// use with SimpleSequence_Selector and Sequence_Selector objects.
25772577
if (simpleSelectorOrderDependent) {
25782578
return !(one < two) && !(two < one);
25792579
} else {
@@ -2583,7 +2583,7 @@ namespace Sass {
25832583

25842584
// compare function for sorting and probably other other uses
25852585
struct cmp_complex_selector { inline bool operator() (const Sequence_Selector* l, const Sequence_Selector* r) { return (*l < *r); } };
2586-
struct cmp_compound_selector { inline bool operator() (const Compound_Selector* l, const Compound_Selector* r) { return (*l < *r); } };
2586+
struct cmp_compound_selector { inline bool operator() (const SimpleSequence_Selector* l, const SimpleSequence_Selector* r) { return (*l < *r); } };
25872587
struct cmp_simple_selector { inline bool operator() (const Simple_Selector* l, const Simple_Selector* r) { return (*l < *r); } };
25882588

25892589
}

src/ast_factory.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ namespace Sass {
8383
Placeholder_Selector* new_Placeholder_Selector(std::string p, size_t l, std::string n);
8484
Pseudo_Selector* new_Pseudo_Selector(std::string p, size_t l, std::string n, Expression* expr = 0);
8585
Wrapped_Selector* new_Wrapped_Selector(std::string p, size_t l, std::string n, Simple_Base* sel);
86-
Compound_Selector* new_Compound_Selector(std::string p, size_t l, size_t s = 0);
87-
Sequence_Selector* new_Sequence_Selector(std::string p, size_t l, Sequence_Selector::Combinator c, Sequence_Selector* ctx, Compound_Selector* sel);
86+
SimpleSequence_Selector* new_SimpleSequence_Selector(std::string p, size_t l, size_t s = 0);
87+
Sequence_Selector* new_Sequence_Selector(std::string p, size_t l, Sequence_Selector::Combinator c, Sequence_Selector* ctx, SimpleSequence_Selector* sel);
8888
CommaSequence_Selector* new_CommaSequence_Selector(std::string p, size_t l, size_t s = 0);
8989
};
9090
}

src/ast_fwd_decl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace Sass {
7979
class Attribute_Selector;
8080
class Pseudo_Selector;
8181
class Wrapped_Selector;
82-
class Compound_Selector;
82+
class SimpleSequence_Selector;
8383
class Sequence_Selector;
8484
class CommaSequence_Selector;
8585

src/context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace Sass {
5050
std::vector<char*> strings;
5151
std::vector<Resource> resources;
5252
std::map<const std::string, const StyleSheet> sheets;
53-
Subset_Map<std::string, std::pair<Sequence_Selector*, Compound_Selector*> > subset_map;
53+
Subset_Map<std::string, std::pair<Sequence_Selector*, SimpleSequence_Selector*> > subset_map;
5454
std::vector<Sass_Import_Entry> import_stack;
5555

5656
struct Sass_Compiler* c_compiler;

src/debugger.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
138138
}
139139
SourcesSet set = selector->sources();
140140
// debug_sources_set(set, ind + " @--> ");
141-
} else if (dynamic_cast<Compound_Selector*>(node)) {
142-
Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node);
143-
std::cerr << ind << "Compound_Selector " << selector;
141+
} else if (dynamic_cast<SimpleSequence_Selector*>(node)) {
142+
SimpleSequence_Selector* selector = dynamic_cast<SimpleSequence_Selector*>(node);
143+
std::cerr << ind << "SimpleSequence_Selector " << selector;
144144
std::cerr << " (" << pstate_source_position(node) << ")";
145145
std::cerr << " <" << selector->hash() << ">";
146146
std::cerr << " [weight:" << longToHex(selector->specificity()) << "]";
@@ -742,7 +742,7 @@ inline void debug_subset_map(Sass::ExtensionSubsetMap& map, std::string ind = ""
742742
if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
743743
}
744744

745-
typedef std::pair<Sequence_Selector*, Compound_Selector*> ExtensionPair;
745+
typedef std::pair<Sequence_Selector*, SimpleSequence_Selector*> ExtensionPair;
746746
typedef std::vector<ExtensionPair> SubsetMapEntries;
747747

748748
inline void debug_subset_entries(SubsetMapEntries* entries, std::string ind = "")

src/expand.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,14 +577,14 @@ namespace Sass {
577577
std::string sel_str(contextualized->to_string(ctx.c_options));
578578
error("Can't extend " + sel_str + ": can't extend nested selectors", c->pstate(), backtrace());
579579
}
580-
Compound_Selector* placeholder = c->head();
580+
SimpleSequence_Selector* placeholder = c->head();
581581
if (contextualized->is_optional()) placeholder->is_optional(true);
582582
for (size_t i = 0, L = extender->length(); i < L; ++i) {
583583
Sequence_Selector* sel = (*extender)[i];
584584
if (!(sel->head() && sel->head()->length() > 0 &&
585585
dynamic_cast<Parent_Selector*>((*sel->head())[0])))
586586
{
587-
Compound_Selector* hh = SASS_MEMORY_NEW(ctx.mem, Compound_Selector, (*extender)[i]->pstate());
587+
SimpleSequence_Selector* hh = SASS_MEMORY_NEW(ctx.mem, SimpleSequence_Selector, (*extender)[i]->pstate());
588588
hh->media_block((*extender)[i]->media_block());
589589
Sequence_Selector* ssel = SASS_MEMORY_NEW(ctx.mem, Sequence_Selector, (*extender)[i]->pstate());
590590
ssel->media_block((*extender)[i]->media_block());

0 commit comments

Comments
 (0)