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
b5a6523b
Commit
b5a6523b
authored
May 29, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commenting the eval/apply functions, since they're getting a bit dense.
parent
809edcde
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
eval_apply.cpp
eval_apply.cpp
+23
-0
No files found.
eval_apply.cpp
View file @
b5a6523b
...
@@ -17,6 +17,8 @@ namespace Sass {
...
@@ -17,6 +17,8 @@ namespace Sass {
throw
Error
(
Error
::
evaluation
,
path
,
line
,
message
);
throw
Error
(
Error
::
evaluation
,
path
,
line
,
message
);
}
}
// Evaluate the parse tree in-place (mostly). Most nodes will be left alone.
Node
eval
(
Node
expr
,
Node
prefix
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
Node
eval
(
Node
expr
,
Node
prefix
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
{
{
switch
(
expr
.
type
())
switch
(
expr
.
type
())
...
@@ -298,6 +300,10 @@ namespace Sass {
...
@@ -298,6 +300,10 @@ namespace Sass {
return
expr
;
return
expr
;
}
}
// Accumulate arithmetic operations. It's done this way because arithmetic
// expressions are stored as vectors of operands with operators interspersed,
// rather than as the usual binary tree.
Node
accumulate
(
Node
::
Type
op
,
Node
acc
,
Node
rhs
,
Node_Factory
&
new_Node
)
Node
accumulate
(
Node
::
Type
op
,
Node
acc
,
Node
rhs
,
Node_Factory
&
new_Node
)
{
{
Node
lhs
(
acc
.
back
());
Node
lhs
(
acc
.
back
());
...
@@ -378,6 +384,8 @@ namespace Sass {
...
@@ -378,6 +384,8 @@ namespace Sass {
return
acc
;
return
acc
;
}
}
// Helper for doing the actual arithmetic.
double
operate
(
Node
::
Type
op
,
double
lhs
,
double
rhs
)
double
operate
(
Node
::
Type
op
,
double
lhs
,
double
rhs
)
{
{
switch
(
op
)
switch
(
op
)
...
@@ -389,6 +397,10 @@ namespace Sass {
...
@@ -389,6 +397,10 @@ namespace Sass {
default:
return
0
;
break
;
default:
return
0
;
break
;
}
}
}
}
// Apply a mixin -- bind the arguments in a new environment, link the new
// environment to the current one, then copy the body and eval in the new
// environment.
Node
apply_mixin
(
Node
mixin
,
const
Node
args
,
Node
prefix
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
Node
apply_mixin
(
Node
mixin
,
const
Node
args
,
Node
prefix
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
{
{
...
@@ -445,6 +457,9 @@ namespace Sass {
...
@@ -445,6 +457,9 @@ namespace Sass {
}
}
return
body
;
return
body
;
}
}
// Apply a function -- bind the arguments and pass them to the underlying
// primitive function implementation, then return its value.
Node
apply_function
(
const
Function
&
f
,
const
Node
args
,
Node
prefix
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
Node
apply_function
(
const
Function
&
f
,
const
Node
args
,
Node
prefix
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
{
{
...
@@ -465,6 +480,12 @@ namespace Sass {
...
@@ -465,6 +480,12 @@ namespace Sass {
return
f
(
bindings
,
new_Node
);
return
f
(
bindings
,
new_Node
);
}
}
// Expand a selector with respect to its prefix/context. Two separate cases:
// when the selector has backrefs, substitute the prefix for each occurrence
// of a backref. When the selector doesn't have backrefs, just prepend the
// prefix. This function needs multiple subsidiary cases in order to properly
// combine the various kinds of selectors.
Node
expand_selector
(
Node
sel
,
Node
pre
,
Node_Factory
&
new_Node
)
Node
expand_selector
(
Node
sel
,
Node
pre
,
Node_Factory
&
new_Node
)
{
{
if
(
pre
.
type
()
==
Node
::
none
)
return
sel
;
if
(
pre
.
type
()
==
Node
::
none
)
return
sel
;
...
@@ -548,6 +569,8 @@ namespace Sass {
...
@@ -548,6 +569,8 @@ namespace Sass {
return
Node
();
return
Node
();
}
}
// Helper for expanding selectors with backrefs.
Node
expand_backref
(
Node
sel
,
Node
pre
)
Node
expand_backref
(
Node
sel
,
Node
pre
)
{
{
switch
(
sel
.
type
())
switch
(
sel
.
type
())
...
...
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