Skip to content

Commit

Permalink
Merge pull request sass#654 from xzyfer/fix/maps-numbers-as-keys
Browse files Browse the repository at this point in the history
Add support for numbers as map keys
  • Loading branch information
xzyfer committed Nov 17, 2014
2 parents 3e38944 + 11ec9bb commit 4cd5034
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,10 +980,32 @@ namespace Sass {
private:
ADD_PROPERTY(Type, type);
ADD_PROPERTY(string, value);
size_t hash_;
public:
Textual(string path, Position position, Type t, string val)
: Expression(path, position, true), type_(t), value_(val)
: Expression(path, position, true), type_(t), value_(val),
hash_(0)
{ }

virtual bool operator==(Expression& rhs) const
{
try
{
Textual& e = dynamic_cast<Textual&>(rhs);
return e && value() == e.value() && type() == e.type();
}
catch (std::bad_cast&)
{
return false;
}
}

virtual size_t hash()
{
if (hash_ == 0) hash_ = std::hash<string>()(value_) ^ std::hash<int>()(type_);
return hash_;
}

ATTACH_OPERATIONS();
};

Expand Down

0 comments on commit 4cd5034

Please # to comment.