Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit 467c22e

Browse files
author
Aaron Leung
committed
Simplifying the emitter now that selectors are all expanded beforehand.
1 parent bbd04d5 commit 467c22e

File tree

4 files changed

+150
-170
lines changed

4 files changed

+150
-170
lines changed

document.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace Sass {
108108
root.echo(output);
109109
break;
110110
case nested:
111-
root.emit_nested_css(output, 0, vector<string>());
111+
root.emit_nested_css(output, 0);
112112
break;
113113
case expanded:
114114
root.emit_expanded_css(output, "");

eval_apply.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ namespace Sass {
4949
expr[0] = eval(expr[0], prefix, env, f_env, new_Node, ctx);
5050
}
5151
// expand the selector with the prefix and save it in expr[2]
52+
// cerr << "ABOUT TO EXPAND " << expr[0].to_string() << " WITH " << prefix.to_string() << endl;
5253
expr << expand_selector(expr[0], prefix, new_Node);
53-
// cerr << "EXPANDED SELECTOR: " << expr.back().to_string("") << endl;
54+
// cerr << "EXPANDED SELECTOR: " << expr.back().to_string() << endl;
5455
// eval the body with the current selector as the prefix
55-
eval(expr[1], expr[0], env, f_env, new_Node, ctx);
56+
eval(expr[1], expr.back(), env, f_env, new_Node, ctx);
5657
return expr;
5758
} break;
5859

@@ -64,7 +65,7 @@ namespace Sass {
6465
expansion += expr[i].token().unquote();
6566
}
6667
else {
67-
expansion += expr[i].to_string("");
68+
expansion += expr[i].to_string();
6869
}
6970
}
7071
expansion += " {"; // the parser looks for an lbrace to end a selector
@@ -355,7 +356,7 @@ namespace Sass {
355356
acc << new_Node(acc.path(), acc.line(), r, g, b, a);
356357
}
357358
else if (lhs.type() == Node::numeric_color && rhs.type() == Node::numeric_color) {
358-
if (lhs[3].numeric_value() != rhs[3].numeric_value()) throw_eval_error("alpha channels must be equal for " + lhs.to_string("") + " + " + rhs.to_string(""), lhs.path(), lhs.line());
359+
if (lhs[3].numeric_value() != rhs[3].numeric_value()) throw_eval_error("alpha channels must be equal for " + lhs.to_string() + " + " + rhs.to_string(), lhs.path(), lhs.line());
359360
double r = operate(op, lhs[0].numeric_value(), rhs[0].numeric_value());
360361
double g = operate(op, lhs[1].numeric_value(), rhs[1].numeric_value());
361362
double b = operate(op, lhs[2].numeric_value(), rhs[2].numeric_value());
@@ -403,7 +404,7 @@ namespace Sass {
403404
break;
404405
}
405406
}
406-
if (!valid_param) throw_eval_error("mixin " + mixin[0].to_string("") + " has no parameter named " + name.to_string(), arg.path(), arg.line());
407+
if (!valid_param) throw_eval_error("mixin " + mixin[0].to_string() + " has no parameter named " + name.to_string(), arg.path(), arg.line());
407408
if (!bindings.query(name)) {
408409
bindings[name] = eval(arg[1], prefix, env, f_env, new_Node, ctx);
409410
}
@@ -412,7 +413,7 @@ namespace Sass {
412413
// ensure that the number of ordinal args < params.size()
413414
if (j >= params.size()) {
414415
stringstream ss;
415-
ss << "mixin " << mixin[0].to_string("") << " only takes " << params.size() << ((params.size() == 1) ? " argument" : " arguments");
416+
ss << "mixin " << mixin[0].to_string() << " only takes " << params.size() << ((params.size() == 1) ? " argument" : " arguments");
416417
throw_eval_error(ss.str(), args[i].path(), args[i].line());
417418
}
418419
Node param(params[j]);
@@ -496,8 +497,8 @@ namespace Sass {
496497
for (size_t i = 0, S = pre.size(); i < S; ++i) {
497498
for (size_t j = 0, T = sel.size(); j < T; ++j) {
498499
Node new_sel(new_Node(Node::selector, sel.path(), sel.line(), 2));
499-
if (pre[i].type() == Node::selector) new_sel += pre;
500-
else new_sel << pre;
500+
if (pre[i].type() == Node::selector) new_sel += pre[i];
501+
else new_sel << pre[i];
501502
if (sel[j].type() == Node::selector) new_sel += sel[j];
502503
else new_sel << sel[j];
503504
group << new_sel;
@@ -509,8 +510,8 @@ namespace Sass {
509510
Node group(new_Node(Node::selector_group, sel.path(), sel.line(), pre.size()));
510511
for (size_t i = 0, S = pre.size(); i < S; ++i) {
511512
Node new_sel(new_Node(Node::selector, sel.path(), sel.line(), 2));
512-
if (pre[i].type() == Node::selector) new_sel += pre;
513-
else new_sel << pre;
513+
if (pre[i].type() == Node::selector) new_sel += pre[i];
514+
else new_sel << pre[i];
514515
if (sel.type() == Node::selector) new_sel += sel;
515516
else new_sel << sel;
516517
group << new_sel;

node.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,7 @@ namespace Sass {
198198
bool operator>(Node rhs) const;
199199
bool operator>=(Node rhs) const;
200200

201-
string to_string(const string& prefix) const;
202-
void emit_nested_css(stringstream& buf,
203-
size_t depth,
204-
const vector<string>& prefixes);
201+
string to_string() const;
205202
void emit_nested_css(stringstream& buf, size_t depth);
206203
void emit_propset(stringstream& buf, size_t depth, const string& prefix);
207204
void echo(stringstream& buf, size_t depth = 0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy