Skip to content

Commit e474070

Browse files
committed
Add const flag to is_invisible method
1 parent cb62a37 commit e474070

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

ast.hpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace Sass {
122122
virtual operator bool() { return true; }
123123
virtual ~Expression() { }
124124
virtual string type() { return ""; /* TODO: raise an error? */ }
125-
virtual bool is_invisible() { return false; }
125+
virtual bool is_invisible() const { return false; }
126126
static string type_name() { return ""; }
127127
virtual bool is_false() { return false; }
128128
virtual bool operator==( Expression& rhs) const { return false; }
@@ -177,7 +177,7 @@ namespace Sass {
177177
size_t length() const { return elements_.size(); }
178178
bool empty() const { return elements_.empty(); }
179179
T last() { return elements_.back(); }
180-
T first() { return elements_.front(); }
180+
T first() { return elements_.front(); }
181181
T& operator[](size_t i) { return elements_[i]; }
182182
const T& operator[](size_t i) const { return elements_[i]; }
183183
Vectorized& operator<<(T element)
@@ -259,6 +259,12 @@ namespace Sass {
259259
}
260260
const unordered_map<Expression*, Expression*>& pairs() const { return elements_; }
261261
const vector<Expression*>& keys() const { return list_; }
262+
263+
unordered_map<Expression*, Expression*>::iterator end() { return elements_.end(); }
264+
unordered_map<Expression*, Expression*>::iterator begin() { return elements_.begin(); }
265+
unordered_map<Expression*, Expression*>::const_iterator end() const { return elements_.end(); }
266+
unordered_map<Expression*, Expression*>::const_iterator begin() const { return elements_.begin(); }
267+
262268
};
263269
inline Hashed::~Hashed() { }
264270

@@ -292,7 +298,7 @@ namespace Sass {
292298
virtual ~Statement() = 0;
293299
// needed for rearranging nested rulesets during CSS emission
294300
virtual bool is_hoistable() { return false; }
295-
virtual bool is_invisible() { return false; }
301+
virtual bool is_invisible() const { return false; }
296302
virtual bool bubbles() { return false; }
297303
virtual Block* block() { return 0; }
298304
};
@@ -347,7 +353,7 @@ namespace Sass {
347353
Ruleset(ParserState pstate, Selector* s = 0, Block* b = 0)
348354
: Has_Block(pstate, b), selector_(s), at_root_(false)
349355
{ statement_type(RULESET); }
350-
bool is_invisible();
356+
bool is_invisible() const;
351357
// nested rulesets need to be hoisted out of their enclosing blocks
352358
bool is_hoistable() { return true; }
353359
ATTACH_OPERATIONS()
@@ -393,7 +399,7 @@ namespace Sass {
393399
{ statement_type(MEDIA); }
394400
bool bubbles() { return true; }
395401
bool is_hoistable() { return true; }
396-
bool is_invisible() {
402+
bool is_invisible() const {
397403
bool is_invisible = true;
398404
for (size_t i = 0, L = block()->length(); i < L && is_invisible; i++)
399405
is_invisible &= (*block())[i]->is_invisible();
@@ -766,7 +772,7 @@ namespace Sass {
766772
{ concrete_type(LIST); }
767773
string type() { return is_arglist_ ? "arglist" : "list"; }
768774
static string type_name() { return "list"; }
769-
bool is_invisible() { return !length(); }
775+
bool is_invisible() const { return empty(); }
770776
Expression* value_at_index(size_t i);
771777

772778
virtual size_t size() const;
@@ -807,7 +813,7 @@ namespace Sass {
807813
{ concrete_type(MAP); }
808814
string type() { return "map"; }
809815
static string type_name() { return "map"; }
810-
bool is_invisible() { return !length(); }
816+
bool is_invisible() const { return empty(); }
811817

812818
virtual bool operator==(Expression& rhs) const
813819
{
@@ -1553,7 +1559,7 @@ namespace Sass {
15531559
Null(ParserState pstate) : Expression(pstate) { concrete_type(NULL_VAL); }
15541560
string type() { return "null"; }
15551561
static string type_name() { return "null"; }
1556-
bool is_invisible() { return true; }
1562+
bool is_invisible() const { return true; }
15571563
operator bool() { return false; }
15581564
bool is_false() { return true; }
15591565

@@ -2133,7 +2139,7 @@ namespace Sass {
21332139
ATTACH_OPERATIONS()
21342140
};
21352141

2136-
inline bool Ruleset::is_invisible() {
2142+
inline bool Ruleset::is_invisible() const {
21372143
bool is_invisible = true;
21382144
Selector_List* sl = static_cast<Selector_List*>(selector());
21392145
for (size_t i = 0, L = sl->length(); i < L && is_invisible; ++i)

0 commit comments

Comments
 (0)