Commit 974822d7 by Aaron Leung

Environments now store a link to the global env. Makes it easy to handle 2-level…

Environments now store a link to the global env. Makes it easy to handle 2-level scope for mixins and arbitrarily nested scopes for variables.
parent d5440047
......@@ -6,17 +6,17 @@ namespace Sass {
struct Environment {
map<Token, Node> current_frame;
Environment* parent;
Environment* global;
Environment()
: current_frame(map<Token, Node>()), parent(0)
{ }
Environment(Environment* env)
: current_frame(map<Token, Node>()),
parent(env)
: current_frame(map<Token, Node>()), parent(0), global(0)
{ }
void link(Environment& env)
{ parent = &env; }
{
parent = &env;
global = parent->global ? parent->global : parent;
}
bool query(const Token& key) const
{
......
......@@ -277,7 +277,7 @@ namespace Sass {
}
}
// cerr << "BOUND DEFAULT ARGS FOR " << string(mixin[0].token) << endl;
m_env.link(env.parent ? *env.parent : env);
m_env.link(env.global ? *env.global : env);
// cerr << "LINKED ENVIRONMENT FOR " << string(mixin[0].token) << endl << endl;
for (int i = 0; i < body.size(); ++i) {
body[i] = eval(body[i], m_env);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment