Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
ec641613
Commit
ec641613
authored
Aug 31, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving the environment definition into its own file so I can eliminate a circular dependency.
parent
b8fd9eb6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
26 deletions
+70
-26
context.hpp
context.hpp
+28
-26
environment.hpp
environment.hpp
+42
-0
No files found.
context.hpp
View file @
ec641613
#define SASS_CONTEXT
#define SASS_CONTEXT
#ifndef SASS_ENVIRONMENT
#include "environment.hpp"
#endif
#include <utility>
#include <utility>
#include <map>
#include "node_factory.hpp"
#include "node_factory.hpp"
#include "functions.hpp"
#include "functions.hpp"
...
@@ -10,35 +12,35 @@ namespace Sass {
...
@@ -10,35 +12,35 @@ namespace Sass {
using
std
::
pair
;
using
std
::
pair
;
using
std
::
map
;
using
std
::
map
;
struct
Environment
{
//
struct Environment {
map
<
Token
,
Node
>
current_frame
;
//
map<Token, Node> current_frame;
Environment
*
parent
;
//
Environment* parent;
Environment
*
global
;
//
Environment* global;
Environment
()
//
Environment()
:
current_frame
(
map
<
Token
,
Node
>
()),
parent
(
0
),
global
(
0
)
//
: current_frame(map<Token, Node>()), parent(0), global(0)
{
}
//
{ }
void
link
(
Environment
&
env
)
//
void link(Environment& env)
{
//
{
parent
=
&
env
;
//
parent = &env;
global
=
parent
->
global
?
parent
->
global
:
parent
;
//
global = parent->global ? parent->global : parent;
}
//
}
bool
query
(
const
Token
&
key
)
const
//
bool query(const Token& key) const
{
//
{
if
(
current_frame
.
count
(
key
))
return
true
;
//
if (current_frame.count(key)) return true;
else
if
(
parent
)
return
parent
->
query
(
key
);
//
else if (parent) return parent->query(key);
else
return
false
;
//
else return false;
}
//
}
Node
&
operator
[](
const
Token
&
key
)
//
Node& operator[](const Token& key)
{
//
{
if
(
current_frame
.
count
(
key
))
return
current_frame
[
key
];
//
if (current_frame.count(key)) return current_frame[key];
else
if
(
parent
)
return
(
*
parent
)[
key
];
//
else if (parent) return (*parent)[key];
else
return
current_frame
[
key
];
//
else return current_frame[key];
}
//
}
};
//
};
struct
Context
{
struct
Context
{
Environment
global_env
;
Environment
global_env
;
...
...
environment.hpp
0 → 100644
View file @
ec641613
#define SASS_ENVIRONMENT
#include <map>
#ifndef SASS_NODE
#include "node.hpp"
#endif
namespace
Sass
{
using
std
::
map
;
struct
Environment
{
map
<
Token
,
Node
>
current_frame
;
Environment
*
parent
;
Environment
*
global
;
Environment
()
:
current_frame
(
map
<
Token
,
Node
>
()),
parent
(
0
),
global
(
0
)
{
}
void
link
(
Environment
&
env
)
{
parent
=
&
env
;
global
=
parent
->
global
?
parent
->
global
:
parent
;
}
bool
query
(
const
Token
&
key
)
const
{
if
(
current_frame
.
count
(
key
))
return
true
;
else
if
(
parent
)
return
parent
->
query
(
key
);
else
return
false
;
}
Node
&
operator
[](
const
Token
&
key
)
{
if
(
current_frame
.
count
(
key
))
return
current_frame
[
key
];
else
if
(
parent
)
return
(
*
parent
)[
key
];
else
return
current_frame
[
key
];
}
};
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment