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
929307e8
Commit
929307e8
authored
Jun 27, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing some quoting/unquoting and equality stuff.
parent
74629fb4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
8 deletions
+51
-8
functions.cpp
functions.cpp
+18
-5
node.cpp
node.cpp
+20
-2
node.hpp
node.hpp
+7
-1
node_emitters.cpp
node_emitters.cpp
+6
-0
No files found.
functions.cpp
View file @
929307e8
...
@@ -257,6 +257,7 @@ namespace Sass {
...
@@ -257,6 +257,7 @@ namespace Sass {
// throw_eval_error("argument to unquote must be a string", cpy.path(), cpy.line());
// throw_eval_error("argument to unquote must be a string", cpy.path(), cpy.line());
// }
// }
cpy
.
is_unquoted
()
=
true
;
cpy
.
is_unquoted
()
=
true
;
cpy
.
is_quoted
()
=
false
;
return
cpy
;
return
cpy
;
}
}
...
@@ -264,12 +265,24 @@ namespace Sass {
...
@@ -264,12 +265,24 @@ namespace Sass {
{
"quote"
,
"$string"
,
0
};
{
"quote"
,
"$string"
,
0
};
Node
quote
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
,
Node_Factory
&
new_Node
)
{
Node
quote
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
,
Node_Factory
&
new_Node
)
{
Node
orig
(
bindings
[
parameters
[
0
]]);
Node
orig
(
bindings
[
parameters
[
0
]]);
if
(
orig
.
type
()
!=
Node
::
string_constant
&&
orig
.
type
()
!=
Node
::
identifier
)
{
switch
(
orig
.
type
())
throw_eval_error
(
"argument to quote must be a string or identifier"
,
orig
.
path
(),
orig
.
line
());
{
default:
{
throw_eval_error
(
"argument to quote must be a string or identifier"
,
orig
.
path
(),
orig
.
line
());
}
break
;
case
Node
:
:
string_constant
:
case
Node
:
:
string_schema
:
case
Node
:
:
identifier
:
case
Node
:
:
identifier_schema
:
case
Node
:
:
concatenation
:
{
Node
cpy
(
new_Node
(
orig
));
cpy
.
is_unquoted
()
=
false
;
cpy
.
is_quoted
()
=
true
;
return
cpy
;
}
break
;
}
}
Node
cpy
(
new_Node
(
orig
));
return
orig
;
cpy
.
is_unquoted
()
=
false
;
return
cpy
;
}
}
// Number Functions ////////////////////////////////////////////////////
// Number Functions ////////////////////////////////////////////////////
...
...
node.cpp
View file @
929307e8
...
@@ -55,10 +55,28 @@ namespace Sass {
...
@@ -55,10 +55,28 @@ namespace Sass {
}
}
}
}
string
Node
::
unquote
()
const
{
string
intermediate
(
to_string
());
if
(
!
intermediate
.
empty
()
&&
(
intermediate
[
0
]
==
'"'
||
intermediate
[
0
]
==
'\''
))
{
return
intermediate
.
substr
(
1
,
intermediate
.
length
()
-
2
);
}
else
{
return
intermediate
;
}
}
bool
Node
::
operator
==
(
Node
rhs
)
const
bool
Node
::
operator
==
(
Node
rhs
)
const
{
{
Type
t
=
type
();
Type
t
=
type
(),
u
=
rhs
.
type
();
if
(
t
!=
rhs
.
type
())
return
false
;
if
((
t
==
identifier
||
t
==
string_constant
||
t
==
string_schema
||
t
==
concatenation
)
&&
(
u
==
identifier
||
u
==
string_constant
||
u
==
string_schema
||
u
==
concatenation
))
{
return
unquote
()
==
rhs
.
unquote
();
}
else
if
(
t
!=
u
)
{
return
false
;
}
switch
(
t
)
switch
(
t
)
{
{
...
...
node.hpp
View file @
929307e8
...
@@ -183,6 +183,7 @@ namespace Sass {
...
@@ -183,6 +183,7 @@ namespace Sass {
bool
from_variable
()
const
;
bool
from_variable
()
const
;
bool
&
should_eval
()
const
;
bool
&
should_eval
()
const
;
bool
&
is_unquoted
()
const
;
bool
&
is_unquoted
()
const
;
bool
&
is_quoted
()
const
;
bool
is_numeric
()
const
;
bool
is_numeric
()
const
;
bool
is_guarded
()
const
;
bool
is_guarded
()
const
;
bool
&
has_been_extended
()
const
;
bool
&
has_been_extended
()
const
;
...
@@ -216,6 +217,8 @@ namespace Sass {
...
@@ -216,6 +217,8 @@ namespace Sass {
bool
is
(
Node
n
)
const
{
return
ip_
==
n
.
ip_
;
}
bool
is
(
Node
n
)
const
{
return
ip_
==
n
.
ip_
;
}
void
flatten
();
void
flatten
();
string
unquote
()
const
;
bool
operator
==
(
Node
rhs
)
const
;
bool
operator
==
(
Node
rhs
)
const
;
bool
operator
!=
(
Node
rhs
)
const
;
bool
operator
!=
(
Node
rhs
)
const
;
...
@@ -256,6 +259,7 @@ namespace Sass {
...
@@ -256,6 +259,7 @@ namespace Sass {
bool
from_variable
;
bool
from_variable
;
bool
should_eval
;
bool
should_eval
;
bool
is_unquoted
;
bool
is_unquoted
;
bool
is_quoted
;
bool
has_been_extended
;
bool
has_been_extended
;
Node_Impl
()
Node_Impl
()
...
@@ -271,7 +275,8 @@ namespace Sass {
...
@@ -271,7 +275,8 @@ namespace Sass {
has_backref
(
false
),
has_backref
(
false
),
from_variable
(
false
),
from_variable
(
false
),
should_eval
(
false
),
should_eval
(
false
),
is_unquoted
(
false
),
is_unquoted
(
false
),
// for strings
is_quoted
(
false
),
// for identifiers -- yeah, it's hacky for now
has_been_extended
(
false
)
has_been_extended
(
false
)
{
}
{
}
...
@@ -387,6 +392,7 @@ namespace Sass {
...
@@ -387,6 +392,7 @@ namespace Sass {
inline
bool
Node
::
from_variable
()
const
{
return
ip_
->
from_variable
;
}
inline
bool
Node
::
from_variable
()
const
{
return
ip_
->
from_variable
;
}
inline
bool
&
Node
::
should_eval
()
const
{
return
ip_
->
should_eval
;
}
inline
bool
&
Node
::
should_eval
()
const
{
return
ip_
->
should_eval
;
}
inline
bool
&
Node
::
is_unquoted
()
const
{
return
ip_
->
is_unquoted
;
}
inline
bool
&
Node
::
is_unquoted
()
const
{
return
ip_
->
is_unquoted
;
}
inline
bool
&
Node
::
is_quoted
()
const
{
return
ip_
->
is_quoted
;
}
inline
bool
Node
::
is_numeric
()
const
{
return
ip_
->
is_numeric
();
}
inline
bool
Node
::
is_numeric
()
const
{
return
ip_
->
is_numeric
();
}
inline
bool
Node
::
is_guarded
()
const
{
return
(
type
()
==
assignment
)
&&
(
size
()
==
3
);
}
inline
bool
Node
::
is_guarded
()
const
{
return
(
type
()
==
assignment
)
&&
(
size
()
==
3
);
}
inline
bool
&
Node
::
has_been_extended
()
const
{
return
ip_
->
has_been_extended
;
}
inline
bool
&
Node
::
has_been_extended
()
const
{
return
ip_
->
has_been_extended
;
}
...
...
node_emitters.cpp
View file @
929307e8
...
@@ -286,6 +286,12 @@ namespace Sass {
...
@@ -286,6 +286,12 @@ namespace Sass {
else
return
result
;
else
return
result
;
}
}
}
break
;
}
break
;
case
identifier
:
{
string
result
(
token
().
to_string
());
if
(
is_quoted
())
return
"
\"
"
+
result
+
"
\"
"
;
else
return
result
;
}
break
;
case
boolean
:
{
case
boolean
:
{
if
(
boolean_value
())
return
"true"
;
if
(
boolean_value
())
return
"true"
;
...
...
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