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
8f24d0d8
Commit
8f24d0d8
authored
Jun 01, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More progress on pure-Sass function evaluation.
parent
e6ced9b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
eval_apply.cpp
eval_apply.cpp
+25
-6
eval_apply.hpp
eval_apply.hpp
+1
-1
No files found.
eval_apply.cpp
View file @
8f24d0d8
...
@@ -268,7 +268,7 @@ namespace Sass {
...
@@ -268,7 +268,7 @@ namespace Sass {
case
Node
:
:
function_call
:
{
case
Node
:
:
function_call
:
{
// TO DO: default-constructed Function should be a generic callback (maybe)
// TO DO: default-constructed Function should be a generic callback (maybe)
pair
<
string
,
size_t
>
sig
(
expr
[
0
].
token
().
to_string
(),
expr
[
1
].
size
());
pair
<
string
,
size_t
>
sig
(
expr
[
0
].
token
().
to_string
(),
expr
[
1
].
size
());
if
(
!
f_env
.
count
(
sig
))
return
expr
;
if
(
!
f_env
.
count
(
sig
))
return
expr
;
// TO DO: EVAL THE ARGUMENTS
else
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
prefix
,
env
,
f_env
,
new_Node
,
ctx
);
else
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
prefix
,
env
,
f_env
,
new_Node
,
ctx
);
}
break
;
}
break
;
...
@@ -631,7 +631,7 @@ namespace Sass {
...
@@ -631,7 +631,7 @@ namespace Sass {
}
}
// END ARG-BINDER
// END ARG-BINDER
bindings
.
link
(
env
.
global
?
*
env
.
global
:
env
);
bindings
.
link
(
env
.
global
?
*
env
.
global
:
env
);
return
function_eval
(
body
,
bindings
,
new_Node
,
ctx
);
return
function_eval
(
body
,
bindings
,
new_Node
,
ctx
,
true
);
}
}
}
}
...
@@ -640,8 +640,9 @@ namespace Sass {
...
@@ -640,8 +640,9 @@ namespace Sass {
// executed and a single value needs to be returned directly, rather than
// executed and a single value needs to be returned directly, rather than
// styles being expanded and spliced in place.
// styles being expanded and spliced in place.
Node
function_eval
(
Node
body
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
Node
function_eval
(
Node
body
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
Context
&
ctx
,
bool
toplevel
)
{
{
cerr
<<
"function eval"
<<
endl
;
for
(
size_t
i
=
0
,
S
=
body
.
size
();
i
<
S
;
++
i
)
{
for
(
size_t
i
=
0
,
S
=
body
.
size
();
i
<
S
;
++
i
)
{
Node
stm
(
body
[
i
]);
Node
stm
(
body
[
i
]);
switch
(
stm
.
type
())
switch
(
stm
.
type
())
...
@@ -668,7 +669,23 @@ namespace Sass {
...
@@ -668,7 +669,23 @@ namespace Sass {
}
break
;
}
break
;
case
Node
:
:
if_directive
:
{
case
Node
:
:
if_directive
:
{
for
(
size_t
j
=
0
,
S
=
stm
.
size
();
j
<
S
;
j
+=
2
)
{
if
(
stm
[
j
].
type
()
!=
Node
::
block
)
{
cerr
<<
"consequent "
<<
j
+
1
<<
endl
;
Node
predicate_val
(
eval
(
stm
[
j
],
Node
(),
bindings
,
ctx
.
function_env
,
new_Node
,
ctx
));
if
((
predicate_val
.
type
()
!=
Node
::
boolean
)
||
predicate_val
.
boolean_value
())
{
Node
v
(
function_eval
(
stm
[
j
+
1
],
bindings
,
new_Node
,
ctx
));
if
(
v
.
is_null_ptr
())
break
;
else
return
v
;
}
}
else
{
cerr
<<
"alternative"
<<
endl
;
Node
v
(
function_eval
(
stm
[
j
],
bindings
,
new_Node
,
ctx
));
if
(
v
.
is_null_ptr
())
break
;
else
return
v
;
}
}
}
break
;
}
break
;
case
Node
:
:
for_through_directive
:
case
Node
:
:
for_through_directive
:
...
@@ -685,7 +702,8 @@ namespace Sass {
...
@@ -685,7 +702,8 @@ namespace Sass {
}
break
;
}
break
;
case
Node
:
:
return_directive
:
{
case
Node
:
:
return_directive
:
{
cerr
<<
"blah"
<<
endl
;
return
eval
(
stm
[
0
],
Node
(),
bindings
,
ctx
.
function_env
,
new_Node
,
ctx
);
}
break
;
}
break
;
default:
{
default:
{
...
@@ -693,7 +711,8 @@ namespace Sass {
...
@@ -693,7 +711,8 @@ namespace Sass {
}
break
;
}
break
;
}
}
}
}
return
new_Node
(
Node
::
none
,
""
,
0
,
0
);
if
(
toplevel
)
throw_eval_error
(
"function finished without @return"
,
body
.
path
(),
body
.
line
());
return
Node
();
}
}
// Expand a selector with respect to its prefix/context. Two separate cases:
// Expand a selector with respect to its prefix/context. Two separate cases:
...
...
eval_apply.hpp
View file @
8f24d0d8
...
@@ -12,7 +12,7 @@ namespace Sass {
...
@@ -12,7 +12,7 @@ namespace Sass {
using
std
::
map
;
using
std
::
map
;
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
);
Node
function_eval
(
Node
stm
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
Context
&
ctx
);
Node
function_eval
(
Node
stm
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
Context
&
ctx
,
bool
toplevel
=
false
);
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
);
double
operate
(
Node
::
Type
op
,
double
lhs
,
double
rhs
);
double
operate
(
Node
::
Type
op
,
double
lhs
,
double
rhs
);
...
...
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