Commit 6eb7c4ed by Aaron Leung

Overhauled the implementation of arithmetic. Much less janky now.

parent 4aaa7c96
......@@ -15,8 +15,9 @@ namespace Sass {
Node eval(Node expr, Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, bool function_name = false);
Node function_eval(string name, Node stm, Environment& bindings, Node_Factory& new_Node, Context& ctx, bool toplevel = false);
Node reduce(Node list, size_t head, Node acc, Node_Factory& new_Node);
Node accumulate(Node::Type op, Node acc, Node rhs, Node_Factory& new_Node);
double operate(Node::Type op, double lhs, double rhs);
double operate(Node op, double lhs, double rhs);
Node apply_mixin(Node mixin, const Node args, Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, bool dynamic_scope = false);
Node apply_function(const Function& f, const Node args, Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, string& path, size_t line);
......
......@@ -182,7 +182,7 @@ namespace Sass {
Type type() const;
bool is_stub() const;
bool is_none() const;
bool has_children() const;
bool has_statements() const;
bool has_blocks() const;
......@@ -416,7 +416,7 @@ namespace Sass {
inline Node::Type Node::type() const { return ip_->type; }
inline bool Node::is_stub() const { return !ip_; }
inline bool Node::is_none() const { return !ip_; }
inline bool Node::has_children() const { return ip_->has_children; }
inline bool Node::has_statements() const { return ip_->has_statements; }
inline bool Node::has_blocks() const { return ip_->has_blocks; }
......
......@@ -140,6 +140,7 @@ namespace Sass {
return result;
} break;
// still necessary for unevaluated expressions
case expression:
case term: {
string result(at(0).to_string());
......@@ -348,12 +349,20 @@ namespace Sass {
case concatenation: {
string result;
bool quoted = (at(0).type() == string_constant || at(0).type() == string_schema) ? true : false;
for (size_t i = 0, S = size(); i < S; ++i) {
result += at(i).to_string().substr(1, at(i).token().length()-2);
// result += at(i).to_string().substr(1, at(i).token().length()-2);
Node::Type itype = at(i).type();
if (itype == Node::string_constant || itype == Node::string_schema) {
result += at(i).unquote();
}
else {
result += at(i).to_string();
}
}
// if (inside_of == identifier_schema || inside_of == property) return result;
// else return "\"" + result + "\"";
if (!(inside_of == identifier_schema || inside_of == property) && !is_unquoted()) {
if (!(inside_of == identifier_schema || inside_of == property) && quoted && !is_unquoted()) {
result = "\"" + result + "\"";
}
return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment