Blame src/eval.hpp

Packit Service 7770af
#ifndef SASS_EVAL_H
Packit Service 7770af
#define SASS_EVAL_H
Packit Service 7770af
Packit Service 7770af
#include "ast.hpp"
Packit Service 7770af
#include "context.hpp"
Packit Service 7770af
#include "listize.hpp"
Packit Service 7770af
#include "operation.hpp"
Packit Service 7770af
#include "environment.hpp"
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
Packit Service 7770af
  class Expand;
Packit Service 7770af
  class Context;
Packit Service 7770af
Packit Service 7770af
  class Eval : public Operation_CRTP<Expression_Ptr, Eval> {
Packit Service 7770af
Packit Service 7770af
   private:
Packit Service 7770af
    Expression_Ptr fallback_impl(AST_Node_Ptr n);
Packit Service 7770af
Packit Service 7770af
   public:
Packit Service 7770af
    Expand&  exp;
Packit Service 7770af
    Context& ctx;
Packit Service 7770af
    Eval(Expand& exp);
Packit Service 7770af
    ~Eval();
Packit Service 7770af
Packit Service 7770af
    bool force;
Packit Service 7770af
    bool is_in_comment;
Packit Service 7770af
    bool is_in_selector_schema;
Packit Service 7770af
Packit Service 7770af
    Boolean_Obj bool_true;
Packit Service 7770af
    Boolean_Obj bool_false;
Packit Service 7770af
Packit Service 7770af
    Env* environment();
Packit Service 7770af
    Backtrace* backtrace();
Packit Service 7770af
    Selector_List_Obj selector();
Packit Service 7770af
Packit Service 7770af
    // for evaluating function bodies
Packit Service 7770af
    Expression_Ptr operator()(Block_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Assignment_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(If_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(For_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Each_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(While_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Return_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Warning_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Error_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Debug_Ptr);
Packit Service 7770af
Packit Service 7770af
    Expression_Ptr operator()(List_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Map_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Binary_Expression_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Unary_Expression_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Function_Call_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Function_Call_Schema_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Variable_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Number_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Color_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Boolean_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(String_Schema_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(String_Quoted_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(String_Constant_Ptr);
Packit Service 7770af
    // Expression_Ptr operator()(Selector_List_Ptr);
Packit Service 7770af
    Media_Query_Ptr operator()(Media_Query_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Media_Query_Expression_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(At_Root_Query_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Supports_Operator_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Supports_Negation_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Supports_Declaration_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Supports_Interpolation_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Null_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Argument_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Arguments_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Comment_Ptr);
Packit Service 7770af
Packit Service 7770af
    // these will return selectors
Packit Service 7770af
    Selector_List_Ptr operator()(Selector_List_Ptr);
Packit Service 7770af
    Selector_List_Ptr operator()(Complex_Selector_Ptr);
Packit Service 7770af
    Attribute_Selector_Ptr operator()(Attribute_Selector_Ptr);
Packit Service 7770af
    // they don't have any specific implementatio (yet)
Packit Service 7770af
    Element_Selector_Ptr operator()(Element_Selector_Ptr s) { return s; };
Packit Service 7770af
    Pseudo_Selector_Ptr operator()(Pseudo_Selector_Ptr s) { return s; };
Packit Service 7770af
    Wrapped_Selector_Ptr operator()(Wrapped_Selector_Ptr s) { return s; };
Packit Service 7770af
    Class_Selector_Ptr operator()(Class_Selector_Ptr s) { return s; };
Packit Service 7770af
    Id_Selector_Ptr operator()(Id_Selector_Ptr s) { return s; };
Packit Service 7770af
    Placeholder_Selector_Ptr operator()(Placeholder_Selector_Ptr s) { return s; };
Packit Service 7770af
    // actual evaluated selectors
Packit Service 7770af
    Selector_List_Ptr operator()(Selector_Schema_Ptr);
Packit Service 7770af
    Expression_Ptr operator()(Parent_Selector_Ptr);
Packit Service 7770af
Packit Service 7770af
    template <typename U>
Packit Service 7770af
    Expression_Ptr fallback(U x) { return fallback_impl(x); }
Packit Service 7770af
Packit Service 7770af
    // -- only need to define two comparisons, and the rest can be implemented in terms of them
Packit Service 7770af
    static bool eq(Expression_Obj, Expression_Obj);
Packit Service 7770af
    static bool lt(Expression_Obj, Expression_Obj, std::string op);
Packit Service 7770af
    // -- arithmetic on the combinations that matter
Packit Service 7770af
    static Value_Ptr op_numbers(enum Sass_OP, const Number&, const Number&, struct Sass_Inspect_Options opt, const ParserState& pstate);
Packit Service 7770af
    static Value_Ptr op_number_color(enum Sass_OP, const Number&, const Color&, struct Sass_Inspect_Options opt, const ParserState& pstate);
Packit Service 7770af
    static Value_Ptr op_color_number(enum Sass_OP, const Color&, const Number&, struct Sass_Inspect_Options opt, const ParserState& pstate);
Packit Service 7770af
    static Value_Ptr op_colors(enum Sass_OP, const Color&, const Color&, struct Sass_Inspect_Options opt, const ParserState& pstate);
Packit Service 7770af
    static Value_Ptr op_strings(Sass::Operand, Value&, Value&, struct Sass_Inspect_Options opt, const ParserState& pstate, bool interpolant = false);
Packit Service 7770af
Packit Service 7770af
  private:
Packit Service 7770af
    void interpolation(Context& ctx, std::string& res, Expression_Obj ex, bool into_quotes, bool was_itpl = false);
Packit Service 7770af
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
  Expression_Ptr cval_to_astnode(union Sass_Value* v, Backtrace* backtrace, ParserState pstate = ParserState("[AST]"));
Packit Service 7770af
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif