forked from sass/libsass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It handles all the unit tests except the interpolation one. Still working on that but sending the PR so you all can take a look
- Loading branch information
Eric Kimn
committed
Mar 17, 2015
1 parent
e1f78c0
commit ef73c1b
Showing
21 changed files
with
261 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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::parent; } | ||
|
||
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)); //->with(env, backtrace) | ||
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) { | ||
v = static_cast<String*>(v->perform(eval->with(env, backtrace))); | ||
} | ||
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); | ||
} | ||
|
||
/* | ||
Selector* Contextualize_Eval::operator()(Parent_Selector* p) | ||
{ error("amp", p->pstate()); return p->perform(eval->contextualize); } | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef SASS_CONTEXTUALIZE_EVAL_H | ||
#define SASS_CONTEXTUALIZE_EVAL_H | ||
|
||
#include "eval.hpp" | ||
#include "context.hpp" | ||
#include "operation.hpp" | ||
#include "environment.hpp" | ||
#include "ast_fwd_decl.hpp" | ||
|
||
namespace Sass { | ||
struct Backtrace; | ||
|
||
typedef Environment<AST_Node*> Env; | ||
|
||
class Contextualize_Eval : public Contextualize {//Operation_CRTP<Selector*, Contextualize_Eval> { | ||
|
||
//Context& ctx; | ||
Eval* eval; | ||
//Env* env; | ||
//Backtrace* backtrace; | ||
|
||
Selector* fallback_impl(AST_Node* n); | ||
|
||
public: | ||
Contextualize_Eval(Context&, Eval*, Env*, Backtrace*); | ||
virtual ~Contextualize_Eval(); | ||
Contextualize_Eval* with(Selector*, Env*, Backtrace*, Selector* placeholder = 0, Selector* extender = 0); | ||
using Operation<Selector*>::operator(); | ||
|
||
Selector* operator()(Selector_Schema*); | ||
Selector* operator()(Selector_List*); | ||
Selector* operator()(Complex_Selector*); | ||
Selector* operator()(Compound_Selector*); | ||
Selector* operator()(Wrapped_Selector*); | ||
Selector* operator()(Pseudo_Selector*); | ||
Selector* operator()(Attribute_Selector*); | ||
Selector* operator()(Selector_Qualifier*); | ||
Selector* operator()(Type_Selector*); | ||
Selector* operator()(Selector_Placeholder*); | ||
Selector* operator()(Selector_Reference*); | ||
//Selector* operator()(Parent_Selector* p); | ||
|
||
template <typename U> | ||
Selector* fallback(U x) { return fallback_impl(x); } | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.