Commit 0e87917a by Aaron Leung

Clone function for nodes.

parent c8b93644
...@@ -15,6 +15,31 @@ namespace Sass { ...@@ -15,6 +15,31 @@ namespace Sass {
size_t Node::fresh = 0; size_t Node::fresh = 0;
size_t Node::copied = 0; size_t Node::copied = 0;
Node Node::clone() const
{
Node n;
n.line_number = line_number;
n.token = token;
n.numeric_value = numeric_value;
n.type = type;
n.has_rules_or_comments = has_rules_or_comments;
n.has_rulesets = has_rulesets;
n.has_propsets = has_propsets;
n.has_backref = has_backref;
n.from_variable = from_variable;
n.eval_me = eval_me;
n.is_hex = is_hex;
if (children) {
n.children = new vector<Node>();
n.children->reserve(size());
for (int i = 0; i < size(); ++i) {
n << at(i);
}
}
++fresh;
return n;
}
string Node::to_string(const string& prefix) const string Node::to_string(const string& prefix) const
{ {
switch (type) switch (type)
......
...@@ -266,11 +266,13 @@ namespace Sass { ...@@ -266,11 +266,13 @@ namespace Sass {
void release() const { children = 0; } void release() const { children = 0; }
Node clone() const;
void echo(stringstream& buf, size_t depth = 0); void echo(stringstream& buf, size_t depth = 0);
void emit_nested_css(stringstream& buf, void emit_nested_css(stringstream& buf,
size_t depth, size_t depth,
const vector<string>& prefixes); const vector<string>& prefixes);
void emit_nested_css(stringstream& buf, size_t depth); void emit_nested_css(stringstream& buf, size_t depth);
void emit_expanded_css(stringstream& buf, const string& prefix); void emit_expanded_css(stringstream& buf, const string& prefix);
}; };
} }
\ No newline at end of file
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