-
Notifications
You must be signed in to change notification settings - Fork 464
/
ast_supports.hpp
121 lines (108 loc) · 3.81 KB
/
ast_supports.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef SASS_AST_SUPPORTS_H
#define SASS_AST_SUPPORTS_H
// sass.hpp must go before all system headers to get the
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include <set>
#include <deque>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <typeinfo>
#include <algorithm>
#include "sass/base.h"
#include "ast_fwd_decl.hpp"
#include "util.hpp"
#include "units.hpp"
#include "context.hpp"
#include "position.hpp"
#include "constants.hpp"
#include "operation.hpp"
#include "position.hpp"
#include "inspect.hpp"
#include "source_map.hpp"
#include "environment.hpp"
#include "error_handling.hpp"
#include "ast_def_macros.hpp"
#include "ast_fwd_decl.hpp"
#include "source_map.hpp"
#include "fn_utils.hpp"
#include "sass.h"
namespace Sass {
////////////////////
// `@supports` rule.
////////////////////
class Supports_Block : public Has_Block {
ADD_PROPERTY(Supports_Condition_Obj, condition)
public:
Supports_Block(ParserState pstate, Supports_Condition_Obj condition, Block_Obj block = {});
bool bubbles() override;
ATTACH_AST_OPERATIONS(Supports_Block)
ATTACH_CRTP_PERFORM_METHODS()
};
//////////////////////////////////////////////////////
// The abstract superclass of all Supports conditions.
//////////////////////////////////////////////////////
class Supports_Condition : public Expression {
public:
Supports_Condition(ParserState pstate);
virtual bool needs_parens(Supports_Condition_Obj cond) const { return false; }
ATTACH_AST_OPERATIONS(Supports_Condition)
ATTACH_CRTP_PERFORM_METHODS()
};
////////////////////////////////////////////////////////////
// An operator condition (e.g. `CONDITION1 and CONDITION2`).
////////////////////////////////////////////////////////////
class Supports_Operator : public Supports_Condition {
public:
enum Operand { AND, OR };
private:
ADD_PROPERTY(Supports_Condition_Obj, left);
ADD_PROPERTY(Supports_Condition_Obj, right);
ADD_PROPERTY(Operand, operand);
public:
Supports_Operator(ParserState pstate, Supports_Condition_Obj l, Supports_Condition_Obj r, Operand o);
virtual bool needs_parens(Supports_Condition_Obj cond) const override;
ATTACH_AST_OPERATIONS(Supports_Operator)
ATTACH_CRTP_PERFORM_METHODS()
};
//////////////////////////////////////////
// A negation condition (`not CONDITION`).
//////////////////////////////////////////
class Supports_Negation : public Supports_Condition {
private:
ADD_PROPERTY(Supports_Condition_Obj, condition);
public:
Supports_Negation(ParserState pstate, Supports_Condition_Obj c);
virtual bool needs_parens(Supports_Condition_Obj cond) const override;
ATTACH_AST_OPERATIONS(Supports_Negation)
ATTACH_CRTP_PERFORM_METHODS()
};
/////////////////////////////////////////////////////
// A declaration condition (e.g. `(feature: value)`).
/////////////////////////////////////////////////////
class Supports_Declaration : public Supports_Condition {
private:
ADD_PROPERTY(Expression_Obj, feature);
ADD_PROPERTY(Expression_Obj, value);
public:
Supports_Declaration(ParserState pstate, Expression_Obj f, Expression_Obj v);
virtual bool needs_parens(Supports_Condition_Obj cond) const override;
ATTACH_AST_OPERATIONS(Supports_Declaration)
ATTACH_CRTP_PERFORM_METHODS()
};
///////////////////////////////////////////////
// An interpolation condition (e.g. `#{$var}`).
///////////////////////////////////////////////
class Supports_Interpolation : public Supports_Condition {
private:
ADD_PROPERTY(Expression_Obj, value);
public:
Supports_Interpolation(ParserState pstate, Expression_Obj v);
virtual bool needs_parens(Supports_Condition_Obj cond) const override;
ATTACH_AST_OPERATIONS(Supports_Interpolation)
ATTACH_CRTP_PERFORM_METHODS()
};
}
#endif