forked from sass/libsass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto_c.cpp
47 lines (36 loc) · 1.25 KB
/
to_c.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
#include "to_c.hpp"
#include "ast.hpp"
namespace Sass {
using namespace std;
Sass_Value To_C::fallback_impl(AST_Node* n)
{ return make_sass_null(); }
Sass_Value To_C::operator()(Boolean* b)
{ return make_sass_boolean(b->value()); }
Sass_Value To_C::operator()(Number* n)
{ return make_sass_number(n->value(), n->unit().c_str()); }
Sass_Value To_C::operator()(Color* c)
{ return make_sass_color(c->r(), c->g(), c->b(), c->a()); }
Sass_Value To_C::operator()(String_Constant* s)
{ return make_sass_string(s->value().c_str()); }
Sass_Value To_C::operator()(List* l)
{
Sass_Value v = make_sass_list(l->length(), l->separator() == List::COMMA ? SASS_COMMA : SASS_SPACE);
for (size_t i = 0, L = l->length(); i < L; ++i) {
v.list.values[i] = (*l)[i]->perform(this);
}
return v;
}
Sass_Value To_C::operator()(Arguments* a)
{
Sass_Value v = make_sass_list(a->length(), SASS_COMMA);
for (size_t i = 0, L = a->length(); i < L; ++i) {
v.list.values[i] = (*a)[i]->perform(this);
}
return v;
}
Sass_Value To_C::operator()(Argument* a)
{ return a->value()->perform(this); }
// not strictly necessary because of the fallback
Sass_Value To_C::operator()(Null* n)
{ return make_sass_null(); }
};