-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathcontextualize_eval.cpp
93 lines (77 loc) · 2.47 KB
/
contextualize_eval.cpp
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
#include "contextualize_eval.hpp"
#include "ast.hpp"
#include "eval.hpp"
#include "backtrace.hpp"
#include "to_string.hpp"
#include "parser.hpp"
namespace Sass {
Contextualize_Eval::Contextualize_Eval(Context& ctx, Eval* eval, Env* env, Backtrace* bt)
: Contextualize(ctx, env, bt), eval(eval)
{ }
Contextualize_Eval::~Contextualize_Eval() { }
Selector* Contextualize_Eval::fallback_impl(AST_Node* n)
{
return Contextualize::fallback_impl(n);
}
Contextualize_Eval* Contextualize_Eval::with(Selector* s, Env* e, Backtrace* bt, Selector* p, Selector* ex)
{
Contextualize::with(s, e, bt, p, ex);
eval = eval->with(s, e, bt, p, ex);
return this;
}
Selector* Contextualize_Eval::operator()(Selector_Schema* s)
{
To_String to_string;
string result_str(s->contents()->perform(eval)->perform(&to_string));
result_str += '{'; // the parser looks for a brace to end the selector
Selector* result_sel = Parser::from_c_str(result_str.c_str(), ctx, s->pstate()).parse_selector_group();
return result_sel->perform(this);
}
Selector* Contextualize_Eval::operator()(Selector_List* s)
{
return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Complex_Selector* s)
{
return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Compound_Selector* s)
{
return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Wrapped_Selector* s)
{
return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Pseudo_Selector* s)
{
return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Attribute_Selector* s)
{
// the value might be interpolated; evaluate it
String* v = s->value();
if (v && eval) {
Eval* eval_with = eval->with(env, backtrace);
v = static_cast<String*>(v->perform(eval_with));
}
To_String toString;
Attribute_Selector* ss = new (ctx.mem) Attribute_Selector(*s);
ss->value(v);
return ss;
}
Selector* Contextualize_Eval::operator()(Selector_Qualifier* s)
{ return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Type_Selector* s)
{ return Contextualize::operator ()(s);
}
Selector* Contextualize_Eval::operator()(Selector_Placeholder* p)
{
return Contextualize::operator ()(p);
}
Selector* Contextualize_Eval::operator()(Selector_Reference* s)
{
return Contextualize::operator ()(s);
}
}