Blame src/to_value.cpp

Packit Service 7770af
#include "sass.hpp"
Packit Service 7770af
#include "ast.hpp"
Packit Service 7770af
#include "to_value.hpp"
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
Packit Service 7770af
  Value_Ptr To_Value::fallback_impl(AST_Node_Ptr n)
Packit Service 7770af
  {
Packit Service 7770af
    // throw a runtime error if this happens
Packit Service 7770af
    // we want a well defined set of possible nodes
Packit Service 7770af
    throw std::runtime_error("invalid node for to_value");
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Custom_Error is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Custom_Error_Ptr e)
Packit Service 7770af
  {
Packit Service 7770af
    return e;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Custom_Warning is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Custom_Warning_Ptr w)
Packit Service 7770af
  {
Packit Service 7770af
    return w;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Boolean is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Boolean_Ptr b)
Packit Service 7770af
  {
Packit Service 7770af
    return b;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Number is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Number_Ptr n)
Packit Service 7770af
  {
Packit Service 7770af
    return n;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Color is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Color_Ptr c)
Packit Service 7770af
  {
Packit Service 7770af
    return c;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // String_Constant is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(String_Constant_Ptr s)
Packit Service 7770af
  {
Packit Service 7770af
    return s;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // String_Quoted is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(String_Quoted_Ptr s)
Packit Service 7770af
  {
Packit Service 7770af
    return s;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // List is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(List_Ptr l)
Packit Service 7770af
  {
Packit Service 7770af
    List_Obj ll = SASS_MEMORY_NEW(List,
Packit Service 7770af
                               l->pstate(),
Packit Service 7770af
                               l->length(),
Packit Service 7770af
                               l->separator(),
Packit Service 7770af
                               l->is_arglist());
Packit Service 7770af
    for (size_t i = 0, L = l->length(); i < L; ++i) {
Packit Service 7770af
      ll->append((*l)[i]->perform(this));
Packit Service 7770af
    }
Packit Service 7770af
    return ll.detach();
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Map is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Map_Ptr m)
Packit Service 7770af
  {
Packit Service 7770af
    return m;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Null is a valid value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Null_Ptr n)
Packit Service 7770af
  {
Packit Service 7770af
    return n;
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Argument returns its value
Packit Service 7770af
  Value_Ptr To_Value::operator()(Argument_Ptr arg)
Packit Service 7770af
  {
Packit Service 7770af
    if (!arg->name().empty()) return 0;
Packit Service 7770af
    return arg->value()->perform(this);
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Selector_List is converted to a string
Packit Service 7770af
  Value_Ptr To_Value::operator()(Selector_List_Ptr s)
Packit Service 7770af
  {
Packit Service 7770af
    return SASS_MEMORY_NEW(String_Quoted,
Packit Service 7770af
                           s->pstate(),
Packit Service 7770af
                           s->to_string(ctx.c_options));
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
  // Binary_Expression is converted to a string
Packit Service 7770af
  Value_Ptr To_Value::operator()(Binary_Expression_Ptr s)
Packit Service 7770af
  {
Packit Service 7770af
    return SASS_MEMORY_NEW(String_Quoted,
Packit Service 7770af
                           s->pstate(),
Packit Service 7770af
                           s->to_string(ctx.c_options));
Packit Service 7770af
  }
Packit Service 7770af
Packit Service 7770af
};