Commit a597ae8c by Aaron Leung

Converting the quote and unquote built-ins.

parent 097c2a4c
...@@ -80,6 +80,7 @@ namespace Sass { ...@@ -80,6 +80,7 @@ namespace Sass {
return number_name; return number_name;
} break; } break;
case Node::string_t:
case Node::identifier: case Node::identifier:
case Node::value_schema: case Node::value_schema:
case Node::identifier_schema: case Node::identifier_schema:
...@@ -124,6 +125,21 @@ namespace Sass { ...@@ -124,6 +125,21 @@ namespace Sass {
if (the_arg.is_numeric()) return the_arg; if (the_arg.is_numeric()) return the_arg;
} break; } break;
case Node::string_t: {
switch (arg_type)
{
case Node::identifier:
case Node::value_schema:
case Node::identifier_schema:
case Node::string_constant:
case Node::string_schema:
case Node::concatenation: return the_arg;
default: break;
} break;
} break;
case Node::list: { case Node::list: {
if (arg_type == Node::space_list || arg_type == Node::comma_list) return the_arg; if (arg_type == Node::space_list || arg_type == Node::comma_list) return the_arg;
} break; } break;
...@@ -522,7 +538,8 @@ namespace Sass { ...@@ -522,7 +538,8 @@ namespace Sass {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Other Color Functions /////////////////////////////////////////////// // Other Color Functions ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// not worth using the arg(...) functions
extern Signature adjust_color_sig = "adjust-color($color, $red: false, $green: false, $blue: false, $hue: false, $saturation: false, $lightness: false, $alpha: false)"; extern Signature adjust_color_sig = "adjust-color($color, $red: false, $green: false, $blue: false, $hue: false, $saturation: false, $lightness: false, $alpha: false)";
Node adjust_color(const Node parameter_names, Environment& bindings, Node_Factory& new_Node, string& path, size_t line) { Node adjust_color(const Node parameter_names, Environment& bindings, Node_Factory& new_Node, string& path, size_t line) {
Node color(bindings[parameter_names[0].token()]); Node color(bindings[parameter_names[0].token()]);
...@@ -651,36 +668,19 @@ namespace Sass { ...@@ -651,36 +668,19 @@ namespace Sass {
extern Signature unquote_sig = "unquote($string)"; extern Signature unquote_sig = "unquote($string)";
Node unquote(const Node parameter_names, Environment& bindings, Node_Factory& new_Node, string& path, size_t line) { Node unquote(const Node parameter_names, Environment& bindings, Node_Factory& new_Node, string& path, size_t line) {
Node cpy(new_Node(bindings[parameter_names[0].token()])); Node cpy(new_Node(path, line, bindings[parameter_names[0].token()]));
// if (cpy.type() != Node::string_constant /* && cpy.type() != Node::concatenation */) { cpy.is_unquoted() = true; // in case it happens to be a string
// throw_eval_error("argument to unquote must be a string", cpy.path(), cpy.line()); cpy.is_quoted() = false; // in case it happens to be an identifier
// }
cpy.is_unquoted() = true;
cpy.is_quoted() = false;
return cpy; return cpy;
} }
extern Signature quote_sig = "quote($string)"; extern Signature quote_sig = "quote($string)";
Node quote(const Node parameter_names, Environment& bindings, Node_Factory& new_Node, string& path, size_t line) { Node quote(const Node parameter_names, Environment& bindings, Node_Factory& new_Node, string& path, size_t line) {
Node orig(bindings[parameter_names[0].token()]); Node orig(arg(quote_sig, path, line, parameter_names, bindings, 0, Node::string_t));
switch (orig.type()) Node copy(new_Node(path, line, orig));
{ copy.is_unquoted() = false; // in case it happens to be a string
default: { copy.is_quoted() = true; // in case it happens to be an identifier
throw_eval_error("argument to quote must be a string or identifier", orig.path(), orig.line()); return copy;
} break;
case Node::string_constant:
case Node::string_schema:
case Node::identifier:
case Node::identifier_schema:
case Node::concatenation: {
Node cpy(new_Node(orig));
cpy.is_unquoted() = false;
cpy.is_quoted() = true;
return cpy;
} break;
}
return orig;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -72,8 +72,9 @@ namespace Sass { ...@@ -72,8 +72,9 @@ namespace Sass {
enum Type { enum Type {
none, none,
any, any,
list, // space_list or comma_list numeric, // number, numeric_percentage, or numeric_dimension
numeric, // number, numeric_percentage, or numeric_dimension string_t, // string_constant, identifier, concatenation, schemata
list, // space_list or comma_list
comment, comment,
root, root,
......
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