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
c28965db
Commit
c28965db
authored
Sep 06, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'func_resolver'
parents
d6ae70ed
74e8c9f1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
82 additions
and
107 deletions
+82
-107
context.cpp
context.cpp
+46
-61
context.hpp
context.hpp
+11
-35
document.hpp
document.hpp
+2
-0
error.hpp
error.hpp
+2
-0
eval_apply.cpp
eval_apply.cpp
+10
-11
eval_apply.hpp
eval_apply.hpp
+2
-0
functions.cpp
functions.cpp
+0
-0
functions.hpp
functions.hpp
+0
-0
node.hpp
node.hpp
+5
-0
node_factory.hpp
node_factory.hpp
+2
-0
sass_interface.h
sass_interface.h
+2
-0
No files found.
context.cpp
View file @
c28965db
#include "context.hpp"
#include <cstring>
#include <iostream>
#include <sstream>
#include <unistd.h>
#include "prelexer.hpp"
#include "color_names.hpp"
...
...
@@ -73,21 +74,20 @@ namespace Sass {
}
delete
[]
image_path
;
new_Node
.
free
();
// cerr << "Deallocated " << i << " source string(s)." << endl;
}
inline
void
Context
::
register_function
(
Function_Descriptor
d
,
Primitive
ip
)
inline
void
Context
::
register_function
(
Signature
sig
,
Primitive
ip
)
{
Function
f
(
d
,
ip
,
new_Node
);
// function_env[pair<string, size_t>(f.name, f.parameters.size())] = f;
Function
f
(
const_cast
<
char
*>
(
sig
),
ip
,
*
this
);
function_env
[
f
.
name
]
=
f
;
}
inline
void
Context
::
register_function
(
Function_Descriptor
d
,
Primitive
ip
,
size_t
arity
)
inline
void
Context
::
register_function
(
Signature
sig
,
Primitive
ip
,
size_t
arity
)
{
Function
f
(
d
,
ip
,
new_Node
);
// function_env[pair<string, size_t>(f.name, arity)] = f;
function_env
[
f
.
name
]
=
f
;
Function
f
(
const_cast
<
char
*>
(
sig
),
ip
,
*
this
);
std
::
stringstream
stub
;
stub
<<
f
.
name
<<
" "
<<
arity
;
function_env
[
stub
.
str
()]
=
f
;
}
inline
void
Context
::
register_overload_stub
(
string
name
)
...
...
@@ -98,68 +98,53 @@ namespace Sass {
void
Context
::
register_functions
()
{
using
namespace
Functions
;
// RGB Functions
register_function
(
rgb_
descriptor
,
rgb
);
register_function
(
rgb_
sig
,
rgb
);
register_overload_stub
(
"rgba"
);
register_function
(
rgba_4_descriptor
,
rgba_4
);
register_function
(
rgba_2_descriptor
,
rgba_2
);
register_function
(
red_descriptor
,
red
);
register_function
(
green_descriptor
,
green
);
register_function
(
blue_descriptor
,
blue
);
register_overload_stub
(
"mix"
);
register_function
(
mix_2_descriptor
,
mix_2
);
register_function
(
mix_3_descriptor
,
mix_3
);
register_function
(
rgba_4_sig
,
rgba_4
,
4
);
register_function
(
rgba_2_sig
,
rgba_2
,
2
);
register_function
(
red_sig
,
red
);
register_function
(
green_sig
,
green
);
register_function
(
blue_sig
,
blue
);
register_function
(
mix_sig
,
mix
);
// HSL Functions
register_function
(
hsla_descriptor
,
hsla
);
register_function
(
hsl_descriptor
,
hsl
);
register_function
(
adjust_hue_descriptor
,
adjust_hue
);
register_function
(
invert_descriptor
,
invert
);
register_function
(
hsla_sig
,
hsla
);
register_function
(
hsl_sig
,
hsl
);
register_function
(
adjust_hue_sig
,
adjust_hue
);
register_function
(
adjust_color_sig
,
adjust_color
);
register_function
(
change_color_sig
,
change_color
);
register_function
(
invert_sig
,
invert
);
// Opacity Functions
register_function
(
alpha_
descriptor
,
alpha
);
register_function
(
opacity_
descriptor
,
alpha
);
register_function
(
opacify_
descriptor
,
opacify
);
register_function
(
fade_in_
descriptor
,
opacify
);
register_function
(
transparentize_
descriptor
,
transparentize
);
register_function
(
fade_out_
descriptor
,
transparentize
);
register_function
(
alpha_
sig
,
alpha
);
register_function
(
opacity_
sig
,
alpha
);
register_function
(
opacify_
sig
,
opacify
);
register_function
(
fade_in_
sig
,
opacify
);
register_function
(
transparentize_
sig
,
transparentize
);
register_function
(
fade_out_
sig
,
transparentize
);
// String Functions
register_function
(
unquote_
descriptor
,
unquote
);
register_function
(
quote_
descriptor
,
quote
);
register_function
(
unquote_
sig
,
unquote
);
register_function
(
quote_
sig
,
quote
);
// Number Functions
register_function
(
percentage_
descriptor
,
percentage
);
register_function
(
round_
descriptor
,
round
);
register_function
(
ceil_
descriptor
,
ceil
);
register_function
(
floor_
descriptor
,
floor
);
register_function
(
abs_
descriptor
,
abs
);
register_function
(
percentage_
sig
,
percentage
);
register_function
(
round_
sig
,
round
);
register_function
(
ceil_
sig
,
ceil
);
register_function
(
floor_
sig
,
floor
);
register_function
(
abs_
sig
,
abs
);
// List Functions
register_function
(
length_descriptor
,
length
);
register_function
(
nth_descriptor
,
nth
);
register_overload_stub
(
"join"
);
register_function
(
join_2_descriptor
,
join_2
);
register_function
(
join_3_descriptor
,
join_3
);
register_overload_stub
(
"append"
);
register_function
(
append_2_descriptor
,
append_2
);
register_function
(
append_3_descriptor
,
append_3
);
register_overload_stub
(
"compact"
);
register_function
(
compact_1_descriptor
,
compact
);
register_function
(
compact_2_descriptor
,
compact
);
register_function
(
compact_3_descriptor
,
compact
);
register_function
(
compact_4_descriptor
,
compact
);
register_function
(
compact_5_descriptor
,
compact
);
register_function
(
compact_6_descriptor
,
compact
);
register_function
(
compact_7_descriptor
,
compact
);
register_function
(
compact_8_descriptor
,
compact
);
register_function
(
compact_9_descriptor
,
compact
);
register_function
(
compact_10_descriptor
,
compact
);
register_function
(
compact_11_descriptor
,
compact
);
register_function
(
compact_12_descriptor
,
compact
);
register_function
(
length_sig
,
length
);
register_function
(
nth_sig
,
nth
);
register_function
(
join_sig
,
join
);
register_function
(
append_sig
,
append
);
register_function
(
compact_sig
,
compact
);
// Introspection Functions
register_function
(
type_of_
descriptor
,
type_of
);
register_function
(
unit_
descriptor
,
unit
);
register_function
(
unitless_
descriptor
,
unitless
);
register_function
(
comparable_
descriptor
,
comparable
);
register_function
(
type_of_
sig
,
type_of
);
register_function
(
unit_
sig
,
unit
);
register_function
(
unitless_
sig
,
unitless
);
register_function
(
comparable_
sig
,
comparable
);
// Boolean Functions
register_function
(
not_
descriptor
,
not_impl
);
register_function
(
if_
descriptor
,
if_impl
);
register_function
(
not_
sig
,
not_impl
);
register_function
(
if_
sig
,
if_impl
);
}
void
Context
::
setup_color_map
()
...
...
context.hpp
View file @
c28965db
#define SASS_CONTEXT
#ifndef SASS_ENVIRONMENT
//
#ifndef SASS_ENVIRONMENT
#include "environment.hpp"
#endif
//
#endif
#include <utility>
#ifndef SASS_NODE_FACTORY
#include "node_factory.hpp"
#endif
#ifndef SASS_FUNCTIONS
#include "functions.hpp"
#endif
namespace
Sass
{
using
std
::
pair
;
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];
// }
// };
struct
Context
{
Environment
global_env
;
map
<
string
,
Function
>
function_env
;
...
...
@@ -61,9 +37,9 @@ namespace Sass {
void
collect_include_paths
(
const
char
*
paths_str
);
Context
(
const
char
*
paths_str
=
0
,
const
char
*
img_path_str
=
0
);
~
Context
();
void
register_function
(
Function_Descriptor
d
,
Primitive
ip
);
void
register_function
(
Function_Descriptor
d
,
Primitive
ip
,
size_t
arity
);
void
register_function
(
Signature
sig
,
Primitive
ip
);
void
register_function
(
Signature
sig
,
Primitive
ip
,
size_t
arity
);
void
register_overload_stub
(
string
name
);
void
register_functions
();
void
setup_color_map
();
...
...
document.hpp
View file @
c28965db
#define SASS_DOCUMENT
#include <map>
#ifndef SASS_PRELEXER
...
...
error.hpp
View file @
c28965db
#define SASS_ERROR
namespace
Sass
{
struct
Error
{
...
...
eval_apply.cpp
View file @
c28965db
...
...
@@ -707,21 +707,20 @@ namespace Sass {
Node
apply_function
(
const
Function
&
f
,
const
Node
args
,
Node
prefix
,
Environment
&
env
,
map
<
string
,
Function
>&
f_env
,
Node_Factory
&
new_Node
,
Context
&
ctx
)
{
if
(
f
.
primitive
)
{
map
<
Token
,
Node
>
bindings
;
// bind arguments
for
(
size_t
i
=
0
,
j
=
0
,
S
=
args
.
size
();
i
<
S
;
++
i
)
{
if
(
args
[
i
].
type
()
==
Node
::
assignment
)
{
Node
arg
(
args
[
i
]);
Token
name
(
arg
[
0
].
token
());
bindings
[
name
]
=
eval
(
arg
[
1
],
prefix
,
env
,
f_env
,
new_Node
,
ctx
);
// evaluate arguments in the current environment
for
(
size_t
i
=
0
,
S
=
args
.
size
();
i
<
S
;
++
i
)
{
if
(
args
[
i
].
type
()
!=
Node
::
assignment
)
{
args
[
i
]
=
eval
(
args
[
i
],
prefix
,
env
,
f_env
,
new_Node
,
ctx
);
}
else
{
// TO DO: ensure (j < f.parameters.size())
bindings
[
f
.
parameters
[
j
].
token
()]
=
eval
(
args
[
i
],
prefix
,
env
,
f_env
,
new_Node
,
ctx
);
++
j
;
args
[
i
][
1
]
=
eval
(
args
[
i
][
1
],
prefix
,
env
,
f_env
,
new_Node
,
ctx
);
}
}
return
f
(
bindings
,
new_Node
);
// bind arguments
Environment
bindings
;
bindings
.
link
(
env
.
global
?
*
env
.
global
:
env
);
bind_arguments
(
"function "
+
f
.
name
,
f
.
parameters
,
args
,
prefix
,
bindings
,
f_env
,
new_Node
,
ctx
);
return
f
.
primitive
(
f
.
parameter_names
,
bindings
,
new_Node
);
}
else
{
Node
params
(
f
.
definition
[
1
]);
...
...
eval_apply.hpp
View file @
c28965db
#define SASS_EVAL_APPLY
#include <map>
#ifndef SASS_NODE
...
...
functions.cpp
View file @
c28965db
This diff is collapsed.
Click to expand it.
functions.hpp
View file @
c28965db
This diff is collapsed.
Click to expand it.
node.hpp
View file @
c28965db
...
...
@@ -8,6 +8,7 @@
namespace
Sass
{
using
namespace
std
;
// Token type for representing lexed chunks of text
struct
Token
{
const
char
*
begin
;
const
char
*
end
;
...
...
@@ -61,6 +62,7 @@ namespace Sass {
struct
Node_Impl
;
// Node type for representing SCSS expression nodes. Really just a handle.
class
Node
{
private
:
friend
class
Node_Factory
;
...
...
@@ -189,6 +191,7 @@ namespace Sass {
bool
is_numeric
()
const
;
bool
is_guarded
()
const
;
bool
&
has_been_extended
()
const
;
bool
is_false
()
const
;
string
&
path
()
const
;
size_t
line
()
const
;
...
...
@@ -237,6 +240,7 @@ namespace Sass {
};
// The actual implementation object for Nodes; Node handles point at these.
struct
Node_Impl
{
union
value_t
{
bool
boolean
;
...
...
@@ -399,6 +403,7 @@ namespace Sass {
inline
bool
Node
::
is_numeric
()
const
{
return
ip_
->
is_numeric
();
}
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
::
is_false
()
const
{
return
(
type
()
==
boolean
)
&&
(
boolean_value
()
==
false
);
}
inline
string
&
Node
::
path
()
const
{
return
ip_
->
path
;
}
inline
size_t
Node
::
line
()
const
{
return
ip_
->
line
;
}
...
...
node_factory.hpp
View file @
c28965db
#define SASS_NODE_FACTORY
#include <vector>
#ifndef SASS_NODE
...
...
sass_interface.h
View file @
c28965db
#define SASS_INTERFACE
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
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