Skip to content

Commit

Permalink
Rename element to type selector and type enums
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Nov 29, 2018
1 parent 7a29ca8 commit 80fd573
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 71 deletions.
12 changes: 6 additions & 6 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace Sass {
//////////////////////////////////////////////////////////////////////
class Expression : public AST_Node {
public:
enum Concrete_Type {
enum Type {
NONE,
BOOLEAN,
NUMBER,
Expand All @@ -153,10 +153,10 @@ namespace Sass {
ADD_PROPERTY(bool, is_delayed)
ADD_PROPERTY(bool, is_expanded)
ADD_PROPERTY(bool, is_interpolant)
ADD_PROPERTY(Concrete_Type, concrete_type)
ADD_PROPERTY(Type, concrete_type)
public:
Expression(ParserState pstate,
bool d = false, bool e = false, bool i = false, Concrete_Type ct = NONE)
bool d = false, bool e = false, bool i = false, Type ct = NONE)
: AST_Node(pstate),
is_delayed_(d),
is_expanded_(e),
Expand Down Expand Up @@ -359,7 +359,7 @@ namespace Sass {
/////////////////////////////////////////////////////////////////////////
class Statement : public AST_Node {
public:
enum Statement_Type {
enum Type {
NONE,
RULESET,
MEDIA,
Expand All @@ -385,11 +385,11 @@ namespace Sass {
IF
};
private:
ADD_PROPERTY(Statement_Type, statement_type)
ADD_PROPERTY(Type, statement_type)
ADD_PROPERTY(size_t, tabs)
ADD_PROPERTY(bool, group_end)
public:
Statement(ParserState pstate, Statement_Type st = NONE, size_t t = 0)
Statement(ParserState pstate, Type st = NONE, size_t t = 0)
: AST_Node(pstate), statement_type_(st), tabs_(t), group_end_(false)
{ }
Statement(const Statement* ptr)
Expand Down
8 changes: 4 additions & 4 deletions src/ast_fwd_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ namespace Sass {
class Placeholder_Selector;
typedef Placeholder_Selector* Placeholder_Selector_Ptr;
typedef Placeholder_Selector const* Placeholder_Selector_Ptr_Const;
class Element_Selector;
typedef Element_Selector* Element_Selector_Ptr;
typedef Element_Selector const* Element_Selector_Ptr_Const;
class Type_Selector;
typedef Type_Selector* Type_Selector_Ptr;
typedef Type_Selector const* Type_Selector_Ptr_Const;
class Class_Selector;
typedef Class_Selector* Class_Selector_Ptr;
typedef Class_Selector const* Class_Selector_Ptr_Const;
Expand Down Expand Up @@ -345,7 +345,7 @@ namespace Sass {
IMPL_MEM_OBJ(Selector_Schema);
IMPL_MEM_OBJ(Simple_Selector);
IMPL_MEM_OBJ(Placeholder_Selector);
IMPL_MEM_OBJ(Element_Selector);
IMPL_MEM_OBJ(Type_Selector);
IMPL_MEM_OBJ(Class_Selector);
IMPL_MEM_OBJ(Id_Selector);
IMPL_MEM_OBJ(Attribute_Selector);
Expand Down
18 changes: 9 additions & 9 deletions src/ast_sel_cmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ namespace Sass {
{
switch (simple_type()) {
case ID_SEL: return (const Id_Selector&) *this == rhs; break;
case TYPE_SEL: return (const Element_Selector&) *this == rhs; break;
case TYPE_SEL: return (const Type_Selector&) *this == rhs; break;
case CLASS_SEL: return (const Class_Selector&) *this == rhs; break;
case PARENT_SEL: return (const Parent_Selector&) *this == rhs; break;
case PSEUDO_SEL: return (const Pseudo_Selector&) *this == rhs; break;
Expand All @@ -555,9 +555,9 @@ namespace Sass {
return sel ? *this == *sel : false;
}

bool Element_Selector::operator== (const Simple_Selector& rhs) const
bool Type_Selector::operator== (const Simple_Selector& rhs) const
{
auto sel = Cast<Element_Selector>(&rhs);
auto sel = Cast<Type_Selector>(&rhs);
return sel ? *this == *sel : false;
}

Expand Down Expand Up @@ -606,7 +606,7 @@ namespace Sass {
return name() == rhs.name();
}

bool Element_Selector::operator== (const Element_Selector& rhs) const
bool Type_Selector::operator== (const Type_Selector& rhs) const
{
return is_ns_eq(rhs) && name() == rhs.name();
}
Expand Down Expand Up @@ -688,7 +688,7 @@ namespace Sass {
{
switch (simple_type()) {
case ID_SEL: return (const Id_Selector&) *this < rhs; break;
case TYPE_SEL: return (const Element_Selector&) *this < rhs; break;
case TYPE_SEL: return (const Type_Selector&) *this < rhs; break;
case CLASS_SEL: return (const Class_Selector&) *this < rhs; break;
case PARENT_SEL: return (const Parent_Selector&) *this < rhs; break;
case PSEUDO_SEL: return (const Pseudo_Selector&) *this < rhs; break;
Expand Down Expand Up @@ -719,7 +719,7 @@ namespace Sass {
return *this < sel;
}

bool Element_Selector::operator< (const Simple_Selector& rhs) const
bool Type_Selector::operator< (const Simple_Selector& rhs) const
{
switch (rhs.simple_type()) {
case ID_SEL: return 'e' < '#'; break;
Expand All @@ -731,8 +731,8 @@ namespace Sass {
case PLACEHOLDER_SEL: return 'e' < '%'; break;
case TYPE_SEL: /* let if fall through */ break;
}
const Element_Selector& sel =
(const Element_Selector&) rhs;
const Type_Selector& sel =
(const Type_Selector&) rhs;
return *this < sel;
}

Expand Down Expand Up @@ -847,7 +847,7 @@ namespace Sass {
return name() < rhs.name();
}

bool Element_Selector::operator< (const Element_Selector& rhs) const
bool Type_Selector::operator< (const Type_Selector& rhs) const
{
if (is_ns_eq(rhs))
{
Expand Down
11 changes: 5 additions & 6 deletions src/ast_sel_unify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ namespace Sass {
return rhs;
}


Simple_Selector_Ptr Element_Selector::unify_with(Simple_Selector_Ptr rhs)
Simple_Selector_Ptr Type_Selector::unify_with(Simple_Selector_Ptr rhs)
{
// check if ns can be extended
// true for no ns or universal
Expand Down Expand Up @@ -75,7 +74,7 @@ namespace Sass {
return this;
}

Compound_Selector_Ptr Element_Selector::unify_with(Compound_Selector_Ptr rhs)
Compound_Selector_Ptr Type_Selector::unify_with(Compound_Selector_Ptr rhs)
{
// TODO: handle namespaces

Expand All @@ -89,10 +88,10 @@ namespace Sass {
// otherwise, this is a tag name
if (name() == "*")
{
if (typeid(*rhs_0) == typeid(Element_Selector))
if (typeid(*rhs_0) == typeid(Type_Selector))
{
// if rhs is universal, just return this tagname + rhs's qualifiers
Element_Selector_Ptr ts = Cast<Element_Selector>(rhs_0);
Type_Selector_Ptr ts = Cast<Type_Selector>(rhs_0);
rhs->at(0) = this->unify_with(ts);
return rhs;
}
Expand All @@ -107,7 +106,7 @@ namespace Sass {
return rhs;
}

if (typeid(*rhs_0) == typeid(Element_Selector))
if (typeid(*rhs_0) == typeid(Type_Selector))
{
// if rhs is universal, just return this tagname + rhs's qualifiers
if (rhs_0->name() != "*" && rhs_0->ns() != "*" && rhs_0->name() != name()) return 0;
Expand Down
8 changes: 4 additions & 4 deletions src/ast_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ namespace Sass {
Compound_Selector_Obj rh = last()->head();
size_t i;
size_t L = h->length();
if (Cast<Element_Selector>(h->first())) {
if (Cast<Type_Selector>(h->first())) {
if (Class_Selector_Ptr cs = Cast<Class_Selector>(rh->last())) {
Class_Selector_Ptr sqs = SASS_MEMORY_COPY(cs);
sqs->name(sqs->name() + (*h)[0]->name());
Expand All @@ -376,8 +376,8 @@ namespace Sass {
(*rh)[rh->length()-1] = sqs;
rh->pstate(h->pstate());
for (i = 1; i < L; ++i) rh->append((*h)[i]);
} else if (Element_Selector_Ptr ts = Cast<Element_Selector>(rh->last())) {
Element_Selector_Ptr tss = SASS_MEMORY_COPY(ts);
} else if (Type_Selector_Ptr ts = Cast<Type_Selector>(rh->last())) {
Type_Selector_Ptr tss = SASS_MEMORY_COPY(ts);
tss->name(tss->name() + (*h)[0]->name());
tss->pstate((*h)[0]->pstate());
(*rh)[rh->length()-1] = tss;
Expand Down Expand Up @@ -899,7 +899,7 @@ namespace Sass {
IMPLEMENT_AST_OPERATORS(Attribute_Selector);
IMPLEMENT_AST_OPERATORS(Compound_Selector);
IMPLEMENT_AST_OPERATORS(Complex_Selector);
IMPLEMENT_AST_OPERATORS(Element_Selector);
IMPLEMENT_AST_OPERATORS(Type_Selector);
IMPLEMENT_AST_OPERATORS(Class_Selector);
IMPLEMENT_AST_OPERATORS(Id_Selector);
IMPLEMENT_AST_OPERATORS(Pseudo_Selector);
Expand Down
16 changes: 8 additions & 8 deletions src/ast_selectors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,14 @@ namespace Sass {
};

/////////////////////////////////////////////////////////////////////
// Element selectors (and the universal selector) -- e.g., div, span, *.
// Type selectors (and the universal selector) -- e.g., div, span, *.
/////////////////////////////////////////////////////////////////////
class Element_Selector final : public Simple_Selector {
class Type_Selector final : public Simple_Selector {
public:
Element_Selector(ParserState pstate, std::string n)
Type_Selector(ParserState pstate, std::string n)
: Simple_Selector(pstate, n)
{ simple_type(TYPE_SEL); }
Element_Selector(const Element_Selector* ptr)
Type_Selector(const Type_Selector* ptr)
: Simple_Selector(ptr)
{ simple_type(TYPE_SEL); }
unsigned long specificity() const override
Expand All @@ -342,9 +342,9 @@ namespace Sass {
Compound_Selector_Ptr unify_with(Compound_Selector_Ptr) override;
bool operator<(const Simple_Selector& rhs) const final override;
bool operator==(const Simple_Selector& rhs) const final override;
bool operator<(const Element_Selector& rhs) const;
bool operator==(const Element_Selector& rhs) const;
ATTACH_AST_OPERATIONS(Element_Selector)
bool operator<(const Type_Selector& rhs) const;
bool operator==(const Type_Selector& rhs) const;
ATTACH_AST_OPERATIONS(Type_Selector)
ATTACH_CRTP_PERFORM_METHODS()
};

Expand Down Expand Up @@ -599,7 +599,7 @@ namespace Sass {
Simple_Selector_Ptr base() const {
if (length() == 0) return 0;
// ToDo: why is this needed?
if (Cast<Element_Selector>((*this)[0]))
if (Cast<Type_Selector>((*this)[0]))
return (*this)[0];
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ast_values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Sass {
class PreValue : public Expression {
public:
PreValue(ParserState pstate,
bool d = false, bool e = false, bool i = false, Concrete_Type ct = NONE)
bool d = false, bool e = false, bool i = false, Type ct = NONE)
: Expression(pstate, d, e, i, ct)
{ }
PreValue(const PreValue* ptr)
Expand All @@ -55,7 +55,7 @@ namespace Sass {
class Value : public PreValue {
public:
Value(ParserState pstate,
bool d = false, bool e = false, bool i = false, Concrete_Type ct = NONE)
bool d = false, bool e = false, bool i = false, Type ct = NONE)
: PreValue(pstate, d, e, i, ct)
{ }
Value(const Value* ptr)
Expand Down Expand Up @@ -530,7 +530,7 @@ namespace Sass {
static std::string type_name() { return "string"; }
virtual ~String() = 0;
virtual void rtrim() = 0;
virtual bool operator<(const Expression& rhs) const {
virtual bool operator<(const Expression& rhs) const override {
return this->to_string() < rhs.to_string();
};
ATTACH_VIRTUAL_AST_OPERATIONS(String);
Expand Down
36 changes: 18 additions & 18 deletions src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
std::cerr << (selector->has_line_break() ? " [line-break]": " -");
std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
std::cerr << std::endl;
} else if (Cast<Element_Selector>(node)) {
Element_Selector_Ptr selector = Cast<Element_Selector>(node);
std::cerr << ind << "Element_Selector " << selector;
} else if (Cast<Type_Selector>(node)) {
Type_Selector_Ptr selector = Cast<Type_Selector>(node);
std::cerr << ind << "Type_Selector " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
std::cerr << " <<" << selector->ns_name() << ">>";
Expand Down Expand Up @@ -682,21 +682,21 @@ inline void debug_ast(AST_Node_Ptr node, std::string ind, Env* env)
std::cerr << ind << "Expression " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
switch (expression->concrete_type()) {
case Expression::Concrete_Type::NONE: std::cerr << " [NONE]"; break;
case Expression::Concrete_Type::BOOLEAN: std::cerr << " [BOOLEAN]"; break;
case Expression::Concrete_Type::NUMBER: std::cerr << " [NUMBER]"; break;
case Expression::Concrete_Type::COLOR: std::cerr << " [COLOR]"; break;
case Expression::Concrete_Type::STRING: std::cerr << " [STRING]"; break;
case Expression::Concrete_Type::LIST: std::cerr << " [LIST]"; break;
case Expression::Concrete_Type::MAP: std::cerr << " [MAP]"; break;
case Expression::Concrete_Type::SELECTOR: std::cerr << " [SELECTOR]"; break;
case Expression::Concrete_Type::NULL_VAL: std::cerr << " [NULL_VAL]"; break;
case Expression::Concrete_Type::C_WARNING: std::cerr << " [C_WARNING]"; break;
case Expression::Concrete_Type::C_ERROR: std::cerr << " [C_ERROR]"; break;
case Expression::Concrete_Type::FUNCTION: std::cerr << " [FUNCTION]"; break;
case Expression::Concrete_Type::NUM_TYPES: std::cerr << " [NUM_TYPES]"; break;
case Expression::Concrete_Type::VARIABLE: std::cerr << " [VARIABLE]"; break;
case Expression::Concrete_Type::FUNCTION_VAL: std::cerr << " [FUNCTION_VAL]"; break;
case Expression::Type::NONE: std::cerr << " [NONE]"; break;
case Expression::Type::BOOLEAN: std::cerr << " [BOOLEAN]"; break;
case Expression::Type::NUMBER: std::cerr << " [NUMBER]"; break;
case Expression::Type::COLOR: std::cerr << " [COLOR]"; break;
case Expression::Type::STRING: std::cerr << " [STRING]"; break;
case Expression::Type::LIST: std::cerr << " [LIST]"; break;
case Expression::Type::MAP: std::cerr << " [MAP]"; break;
case Expression::Type::SELECTOR: std::cerr << " [SELECTOR]"; break;
case Expression::Type::NULL_VAL: std::cerr << " [NULL_VAL]"; break;
case Expression::Type::C_WARNING: std::cerr << " [C_WARNING]"; break;
case Expression::Type::C_ERROR: std::cerr << " [C_ERROR]"; break;
case Expression::Type::FUNCTION: std::cerr << " [FUNCTION]"; break;
case Expression::Type::NUM_TYPES: std::cerr << " [NUM_TYPES]"; break;
case Expression::Type::VARIABLE: std::cerr << " [VARIABLE]"; break;
case Expression::Type::FUNCTION_VAL: std::cerr << " [FUNCTION_VAL]"; break;
case Expression::Type::PARENT: std::cerr << " [PARENT]"; break;
}
std::cerr << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,8 @@ namespace Sass {
AST_Node_Obj lu = lhs;
AST_Node_Obj ru = rhs;

Expression::Concrete_Type l_type;
Expression::Concrete_Type r_type;
Expression::Type l_type;
Expression::Type r_type;

// Is one of the operands an interpolant?
String_Schema_Obj s1 = Cast<String_Schema>(b->left());
Expand Down
2 changes: 1 addition & 1 deletion src/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace Sass {
Id_Selector_Ptr operator()(Id_Selector_Ptr s) { return s; };
Class_Selector_Ptr operator()(Class_Selector_Ptr s) { return s; };
Pseudo_Selector_Ptr operator()(Pseudo_Selector_Ptr s) { return s; };
Element_Selector_Ptr operator()(Element_Selector_Ptr s) { return s; };
Type_Selector_Ptr operator()(Type_Selector_Ptr s) { return s; };
Attribute_Selector_Ptr operator()(Attribute_Selector_Ptr s) { return s; };
Placeholder_Selector_Ptr operator()(Placeholder_Selector_Ptr s) { return s; };

Expand Down
6 changes: 3 additions & 3 deletions src/extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ namespace Sass {
static bool parentSuperselector(Complex_Selector_Ptr pOne, Complex_Selector_Ptr pTwo) {
// TODO: figure out a better way to create a Complex_Selector from scratch
// TODO: There's got to be a better way. This got ugly quick...
Element_Selector_Obj fakeParent = SASS_MEMORY_NEW(Element_Selector, ParserState("[FAKE]"), "temp");
Type_Selector_Obj fakeParent = SASS_MEMORY_NEW(Type_Selector, ParserState("[FAKE]"), "temp");
Compound_Selector_Obj fakeHead = SASS_MEMORY_NEW(Compound_Selector, ParserState("[FAKE]"), 1 /*size*/);
fakeHead->elements().push_back(fakeParent);
Complex_Selector_Obj fakeParentContainer = SASS_MEMORY_NEW(Complex_Selector, ParserState("[FAKE]"), Complex_Selector::ANCESTOR_OF, fakeHead /*head*/, {} /*tail*/);
Expand Down Expand Up @@ -643,7 +643,7 @@ namespace Sass {
static bool parentSuperselector(const Node& one, const Node& two) {
// TODO: figure out a better way to create a Complex_Selector from scratch
// TODO: There's got to be a better way. This got ugly quick...
Element_Selector_Obj fakeParent = SASS_MEMORY_NEW(Element_Selector, ParserState("[FAKE]"), "temp");
Type_Selector_Obj fakeParent = SASS_MEMORY_NEW(Type_Selector, ParserState("[FAKE]"), "temp");
Compound_Selector_Obj fakeHead = SASS_MEMORY_NEW(Compound_Selector, ParserState("[FAKE]"), 1 /*size*/);
fakeHead->elements().push_back(fakeParent);
Complex_Selector_Obj fakeParentContainer = SASS_MEMORY_NEW(Complex_Selector, ParserState("[FAKE]"), Complex_Selector::ANCESTOR_OF, fakeHead /*head*/, {} /*tail*/);
Expand Down Expand Up @@ -1943,7 +1943,7 @@ namespace Sass {
// special case for ruby ass
if (sl->empty()) {
// this seems inconsistent but it is how ruby sass seems to remove parentheses
cpy_head->append(SASS_MEMORY_NEW(Element_Selector, hs->pstate(), ws->name()));
cpy_head->append(SASS_MEMORY_NEW(Type_Selector, hs->pstate(), ws->name()));
}
// has wrapped not selectors
else if (ws->name() == ":not") {
Expand Down
2 changes: 1 addition & 1 deletion src/fn_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace Sass {
}

// Cannot be a Universal selector
Element_Selector_Obj pType = Cast<Element_Selector>(childSeq->head()->first());
Type_Selector_Obj pType = Cast<Type_Selector>(childSeq->head()->first());
if(pType && pType->name() == "*") {
std::string msg("Can't append \"");
msg += childSeq->to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ namespace Sass {

}

void Inspect::operator()(Element_Selector_Ptr s)
void Inspect::operator()(Type_Selector_Ptr s)
{
append_token(s->ns_name(), s);
}
Expand Down
2 changes: 1 addition & 1 deletion src/inspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace Sass {
// selectors
virtual void operator()(Selector_Schema_Ptr);
virtual void operator()(Placeholder_Selector_Ptr);
virtual void operator()(Element_Selector_Ptr);
virtual void operator()(Type_Selector_Ptr);
virtual void operator()(Class_Selector_Ptr);
virtual void operator()(Id_Selector_Ptr);
virtual void operator()(Attribute_Selector_Ptr);
Expand Down
Loading

0 comments on commit 80fd573

Please sign in to comment.