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
5419343a
Commit
5419343a
authored
May 25, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The refactor is all debugged now.
parent
f187b3ab
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
55 deletions
+4
-55
document_parser.cpp
document_parser.cpp
+0
-4
eval_apply.cpp
eval_apply.cpp
+2
-42
node_factory.cpp
node_factory.cpp
+1
-8
node_factory.hpp
node_factory.hpp
+1
-1
No files found.
document_parser.cpp
View file @
5419343a
...
...
@@ -765,15 +765,11 @@ namespace Sass {
if
(
p
)
{
if
(
i
<
p
)
{
schema
<<
context
.
new_Node
(
Node
::
identifier
,
path
,
line
,
Token
::
make
(
i
,
p
-
2
));
// accumulate the preceding segment if it's nonempty
// cerr << '[' << Token::make(i,p-2).to_string() << ']' << endl;
}
const
char
*
j
=
find_first_in_interval
<
exactly
<
rbrace
>
>
(
p
,
str
.
end
);
// find the closing brace
if
(
j
)
{
// parse the interpolant and accumulate it
// cerr << '[' << Token::make(p, j-1).to_string() << ']' << endl;
// Document interp_doc(path, line, Token::make(p,j-1), context);
Node
interp_node
(
Document
::
make_from_token
(
context
,
Token
::
make
(
p
,
j
-
1
),
path
,
line
).
parse_list
());
// Node interp_node(interp_doc.parse_list());
interp_node
.
should_eval
()
=
true
;
schema
<<
interp_node
;
i
=
j
;
...
...
eval_apply.cpp
View file @
5419343a
...
...
@@ -30,26 +30,11 @@ namespace Sass {
Node
args
(
expr
[
1
]);
if
(
!
env
.
query
(
name
))
throw_eval_error
(
"mixin "
+
name
.
to_string
()
+
" is undefined"
,
expr
.
path
(),
expr
.
line
());
Node
mixin
(
env
[
name
]);
Node
expansion
(
apply_mixin
(
mixin
,
args
,
env
,
f_env
,
new_Node
));
for
(
size_t
i
=
0
,
S
=
expansion
.
size
();
i
<
S
;
++
i
)
{
// cerr << expansion[i][0].to_string("") << expansion[i][1].to_string("") << endl;
}
expr
.
pop_back
();
expr
.
pop_back
();
expr
+=
expansion
;
for
(
size_t
i
=
0
,
S
=
expr
.
size
();
i
<
S
;
++
i
)
{
// cerr << expr[i][0].to_string("") << expr[i][1].to_string("") << endl;
}
return
expr
;
// Node evaluated_body(apply_mixin(mixin, args, env, f_env, new_Node));
// Node expansion(new_Node(Node::expansion, expr.path(), expr.line(), evaluated_body.size()));
// expansion += evaluated_body;
// return expansion;
}
break
;
case
Node
:
:
propset
:
...
...
@@ -62,11 +47,6 @@ namespace Sass {
for
(
size_t
i
=
0
,
S
=
expr
.
size
();
i
<
S
;
++
i
)
{
eval
(
expr
[
i
],
env
,
f_env
,
new_Node
);
}
// for (size_t i = 0; i < expr.size(); ++i) {
// if (expr[i].type() == Node::expansion) {
// expr.insert(expr.begin() + i + 1, expr[i].begin(), expr[i].end());
// }
// }
return
expr
;
}
break
;
...
...
@@ -76,12 +56,6 @@ namespace Sass {
for
(
size_t
i
=
0
,
S
=
expr
.
size
();
i
<
S
;
++
i
)
{
eval
(
expr
[
i
],
new_frame
,
f_env
,
new_Node
);
}
// for (size_t i = 0; i < expr.size(); ++i) {
// if (expr[i].type() == Node::expansion) {
// expr.insert(expr.begin() + i + 1, expr[i].begin(), expr[i].end());
// }
// }
// cerr << "EVALED?" << expr[1][0][1].to_string("") << endl;
return
expr
;
}
break
;
...
...
@@ -237,12 +211,7 @@ namespace Sass {
case
Node
:
:
function_call
:
{
// TO DO: default-constructed Function should be a generic callback (maybe)
pair
<
string
,
size_t
>
sig
(
expr
[
0
].
token
().
to_string
(),
expr
[
1
].
size
());
if
(
!
f_env
.
count
(
sig
))
{
// stringstream ss;
// ss << "no function named " << expr[0].token().to_string() << " taking " << expr[1].size() << " arguments has been defined";
// eval_error(ss.str(), expr.line(), expr.path());
return
expr
;
}
if
(
!
f_env
.
count
(
sig
))
return
expr
;
return
apply_function
(
f_env
[
sig
],
expr
[
1
],
env
,
f_env
,
new_Node
);
}
break
;
...
...
@@ -270,7 +239,6 @@ namespace Sass {
case
Node
:
:
string_schema
:
case
Node
:
:
value_schema
:
{
// // cerr << "evaluating schema of size " << expr.size() << endl;
for
(
size_t
i
=
0
,
S
=
expr
.
size
();
i
<
S
;
++
i
)
{
expr
[
i
]
=
eval
(
expr
[
i
],
env
,
f_env
,
new_Node
);
}
...
...
@@ -284,7 +252,7 @@ namespace Sass {
default:
{
return
expr
;
}
}
break
;
}
return
expr
;
...
...
@@ -384,12 +352,6 @@ namespace Sass {
Node
apply_mixin
(
Node
&
mixin
,
const
Node
&
args
,
Environment
&
env
,
map
<
pair
<
string
,
size_t
>
,
Function
>&
f_env
,
Node_Factory
&
new_Node
)
{
// cerr << "applying mixin: " << mixin[0].token().to_string() << endl;
// cerr << "arguments:";
for
(
int
i
=
0
,
S
=
args
.
size
();
i
<
S
;
++
i
)
{
// cerr << " " << args[i].token().to_string();
}
// cerr << endl;
Node
params
(
mixin
[
1
]);
Node
body
(
new_Node
(
mixin
[
2
]));
// clone the body
Environment
bindings
;
...
...
@@ -423,7 +385,6 @@ namespace Sass {
Node
param
(
params
[
j
]);
Token
name
(
param
.
type
()
==
Node
::
variable
?
param
.
token
()
:
param
[
0
].
token
());
bindings
[
name
]
=
eval
(
args
[
i
],
env
,
f_env
,
new_Node
);
// cerr << "param " << name.to_string() << ": " << bindings[name].to_string("") << endl;
++
j
;
}
}
...
...
@@ -441,7 +402,6 @@ namespace Sass {
bindings
.
link
(
env
.
global
?
*
env
.
global
:
env
);
for
(
size_t
i
=
0
,
S
=
body
.
size
();
i
<
S
;
++
i
)
{
body
[
i
]
=
eval
(
body
[
i
],
bindings
,
f_env
,
new_Node
);
// cerr << "evaluated rule: " << body[i][0].to_string("") << ": " << body[i][1].to_string("") << endl;
}
return
body
;
}
...
...
node_factory.cpp
View file @
5419343a
...
...
@@ -35,7 +35,7 @@ namespace Sass {
}
// for making leaf nodes out of terminals/tokens
Node
Node_Factory
::
operator
()(
Node
::
Type
type
,
string
path
,
size_t
line
,
Token
&
t
)
Node
Node_Factory
::
operator
()(
Node
::
Type
type
,
string
path
,
size_t
line
,
Token
t
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
type
,
path
,
line
);
ip
->
value
.
token
=
t
;
...
...
@@ -53,13 +53,6 @@ namespace Sass {
return
Node
(
ip
);
}
// Node Node_Factory::operator()(Node::Type type, string path, size_t line, bool b)
// {
// Node_Impl* ip = alloc_Node_Impl(type, path, line);
// ip->content.boolean_value = b;
// return Node(ip);
// }
// for making nodes representing numbers
Node
Node_Factory
::
operator
()(
string
path
,
size_t
line
,
double
v
,
Node
::
Type
type
)
{
...
...
node_factory.hpp
View file @
5419343a
...
...
@@ -19,7 +19,7 @@ namespace Sass {
// for cloning nodes
Node
operator
()(
const
Node
&
n1
);
// for making leaf nodes out of terminals/tokens
Node
operator
()(
Node
::
Type
type
,
string
file
,
size_t
line
,
Token
&
t
);
Node
operator
()(
Node
::
Type
type
,
string
file
,
size_t
line
,
Token
t
);
// for making boolean values or interior nodes that have children
Node
operator
()(
Node
::
Type
type
,
string
file
,
size_t
line
,
size_t
size
);
// // for making nodes representing boolean values
...
...
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