sassc 1.7.1 → 1.8.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.gitignore +10 -6
  4. data/ext/libsass/.travis.yml +4 -1
  5. data/ext/libsass/GNUmakefile.am +88 -0
  6. data/ext/libsass/Makefile +157 -76
  7. data/ext/libsass/Makefile.conf +47 -0
  8. data/ext/libsass/Readme.md +13 -14
  9. data/ext/libsass/appveyor.yml +25 -41
  10. data/ext/libsass/configure.ac +20 -7
  11. data/ext/libsass/contrib/plugin.cpp +1 -1
  12. data/ext/libsass/include/sass.h +15 -0
  13. data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
  14. data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
  15. data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
  16. data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
  17. data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
  18. data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
  19. data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
  20. data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
  21. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
  22. data/ext/libsass/script/ci-build-libsass +67 -23
  23. data/ext/libsass/src/GNUmakefile.am +54 -0
  24. data/ext/libsass/src/ast.cpp +2029 -0
  25. data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
  26. data/ext/libsass/src/ast_def_macros.hpp +47 -0
  27. data/ext/libsass/src/ast_factory.hpp +93 -0
  28. data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
  29. data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
  30. data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
  31. data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
  32. data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
  33. data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
  34. data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
  35. data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
  36. data/ext/libsass/src/c99func.c +54 -0
  37. data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
  38. data/ext/libsass/src/color_maps.cpp +643 -0
  39. data/ext/libsass/src/color_maps.hpp +333 -0
  40. data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
  41. data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
  42. data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
  43. data/ext/libsass/src/context.hpp +150 -0
  44. data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
  45. data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
  46. data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
  47. data/ext/libsass/src/debugger.hpp +683 -0
  48. data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
  49. data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
  50. data/ext/libsass/src/environment.cpp +184 -0
  51. data/ext/libsass/src/environment.hpp +92 -0
  52. data/ext/libsass/src/error_handling.cpp +46 -0
  53. data/ext/libsass/src/error_handling.hpp +34 -0
  54. data/ext/libsass/src/eval.cpp +1462 -0
  55. data/ext/libsass/src/eval.hpp +107 -0
  56. data/ext/libsass/src/expand.cpp +653 -0
  57. data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
  58. data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
  59. data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
  60. data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
  61. data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
  62. data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
  63. data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
  64. data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
  65. data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
  66. data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
  67. data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
  68. data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
  69. data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
  70. data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
  71. data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
  72. data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
  73. data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
  74. data/ext/libsass/src/memory_manager.cpp +76 -0
  75. data/ext/libsass/src/memory_manager.hpp +48 -0
  76. data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
  77. data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
  78. data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
  79. data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
  80. data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
  81. data/ext/libsass/src/parser.cpp +2529 -0
  82. data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
  83. data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
  84. data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
  85. data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
  86. data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
  87. data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
  88. data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
  89. data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
  90. data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
  91. data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
  92. data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
  93. data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
  94. data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
  95. data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
  96. data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
  97. data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
  98. data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
  99. data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
  100. data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
  101. data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
  102. data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
  103. data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
  104. data/ext/libsass/src/to_c.cpp +73 -0
  105. data/ext/libsass/src/to_c.hpp +41 -0
  106. data/ext/libsass/src/to_string.cpp +47 -0
  107. data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
  108. data/ext/libsass/src/to_value.cpp +109 -0
  109. data/ext/libsass/src/to_value.hpp +50 -0
  110. data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
  111. data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
  112. data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
  113. data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
  114. data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
  115. data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
  116. data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
  117. data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
  118. data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
  119. data/ext/libsass/src/util.hpp +59 -0
  120. data/ext/libsass/src/values.cpp +137 -0
  121. data/ext/libsass/src/values.hpp +12 -0
  122. data/ext/libsass/test/test_node.cpp +33 -33
  123. data/ext/libsass/test/test_paths.cpp +5 -6
  124. data/ext/libsass/test/test_selector_difference.cpp +4 -5
  125. data/ext/libsass/test/test_specificity.cpp +4 -5
  126. data/ext/libsass/test/test_subset_map.cpp +91 -91
  127. data/ext/libsass/test/test_superselector.cpp +11 -11
  128. data/ext/libsass/test/test_unification.cpp +4 -4
  129. data/ext/libsass/win/libsass.targets +101 -0
  130. data/ext/libsass/win/libsass.vcxproj +45 -127
  131. data/ext/libsass/win/libsass.vcxproj.filters +303 -0
  132. data/lib/sassc/import_handler.rb +1 -1
  133. data/lib/sassc/native/native_functions_api.rb +3 -3
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/custom_importer_test.rb +1 -4
  136. data/test/functions_test.rb +3 -2
  137. data/test/native_test.rb +4 -3
  138. metadata +117 -110
  139. data/ext/libsass/Makefile.am +0 -146
  140. data/ext/libsass/ast.cpp +0 -945
  141. data/ext/libsass/ast_def_macros.hpp +0 -21
  142. data/ext/libsass/ast_factory.hpp +0 -92
  143. data/ext/libsass/color_names.hpp +0 -327
  144. data/ext/libsass/context.hpp +0 -157
  145. data/ext/libsass/contextualize.cpp +0 -148
  146. data/ext/libsass/contextualize.hpp +0 -46
  147. data/ext/libsass/contextualize_eval.cpp +0 -93
  148. data/ext/libsass/contextualize_eval.hpp +0 -44
  149. data/ext/libsass/debugger.hpp +0 -558
  150. data/ext/libsass/environment.hpp +0 -163
  151. data/ext/libsass/error_handling.cpp +0 -35
  152. data/ext/libsass/error_handling.hpp +0 -32
  153. data/ext/libsass/eval.cpp +0 -1392
  154. data/ext/libsass/eval.hpp +0 -88
  155. data/ext/libsass/expand.cpp +0 -575
  156. data/ext/libsass/memory_manager.hpp +0 -57
  157. data/ext/libsass/parser.cpp +0 -2403
  158. data/ext/libsass/posix/getopt.c +0 -562
  159. data/ext/libsass/posix/getopt.h +0 -95
  160. data/ext/libsass/to_c.cpp +0 -61
  161. data/ext/libsass/to_c.hpp +0 -44
  162. data/ext/libsass/to_string.cpp +0 -34
  163. data/ext/libsass/util.hpp +0 -54
  164. data/ext/libsass/win/libsass.filters +0 -312
@@ -0,0 +1,47 @@
1
+ #ifndef SASS_AST_DEF_MACROS_H
2
+ #define SASS_AST_DEF_MACROS_H
3
+
4
+ // Helper class to switch a flag and revert once we go out of scope
5
+ template <class T>
6
+ class LocalOption {
7
+ private:
8
+ T* var; // pointer to original variable
9
+ T orig; // copy of the original option
10
+ public:
11
+ LocalOption(T& var)
12
+ {
13
+ this->var = &var;
14
+ this->orig = var;
15
+ }
16
+ LocalOption(T& var, T orig)
17
+ {
18
+ this->var = &var;
19
+ this->orig = var;
20
+ *(this->var) = orig;
21
+ }
22
+ ~LocalOption() {
23
+ *(this->var) = this->orig;
24
+ }
25
+ };
26
+
27
+ #define LOCAL_FLAG(name,opt) LocalOption<bool> flag_##name(name, opt)
28
+
29
+ #define ATTACH_OPERATIONS()\
30
+ virtual void perform(Operation<void>* op) { (*op)(this); }\
31
+ virtual AST_Node* perform(Operation<AST_Node*>* op) { return (*op)(this); }\
32
+ virtual Statement* perform(Operation<Statement*>* op) { return (*op)(this); }\
33
+ virtual Expression* perform(Operation<Expression*>* op) { return (*op)(this); }\
34
+ virtual Selector* perform(Operation<Selector*>* op) { return (*op)(this); }\
35
+ virtual std::string perform(Operation<std::string>* op) { return (*op)(this); }\
36
+ virtual union Sass_Value* perform(Operation<union Sass_Value*>* op) { return (*op)(this); }\
37
+ virtual Value* perform(Operation<Value*>* op) { return (*op)(this); }
38
+
39
+ #define ADD_PROPERTY(type, name)\
40
+ protected:\
41
+ type name##_;\
42
+ public:\
43
+ type name() const { return name##_; }\
44
+ type name(type name##__) { return name##_ = name##__; }\
45
+ private:
46
+
47
+ #endif
@@ -0,0 +1,93 @@
1
+ #ifndef SASS_AST_FACTORY_H
2
+ #define SASS_AST_FACTORY_H
3
+
4
+ #include <vector>
5
+
6
+ #include "ast.hpp"
7
+
8
+ namespace Sass {
9
+
10
+ class AST_Factory {
11
+ std::vector<AST_Node*> nodes;
12
+ public:
13
+ // statements
14
+ Block* new_Block(std::string p, size_t l, size_t s = 0, bool r = false);
15
+ Ruleset* new_Ruleset(std::string p, size_t l, Selector* s, Block* b);
16
+ Propset* new_Propset(std::string p, size_t l, String* pf, Block* b);
17
+ Supports_Query* new_Supports_Query(std::string p, size_t l, Supports_Query* f, Block* b);
18
+ Media_Query* new_Media_Query(std::string p, size_t l, List* q, Block* b);
19
+ At_Root_Block* new_At_Root_Block(std::string p, size_t l, Selector* sel, Block* b);
20
+ At_Rule* new_At_Rule(std::string p, size_t l, std::string kwd, Selector* sel, Block* b);
21
+ Keyframe_Rule* new_Keyframe_Rule(std::string p, size_t l, Block* b);
22
+ Declaration* new_Declaration(std::string p, size_t l, String* prop, List* vals);
23
+ Assignment* new_Assignment(std::string p, size_t l, std::string var, Expression* val, bool guarded = false);
24
+ Import<Function_Call*>* new_CSS_Import(std::string p, size_t l, Function_Call* loc);
25
+ Import<String*>* new_SASS_Import(std::string p, size_t l, String* loc);
26
+ Custom_Warning* new_Custom_Warning(std::string msg, size_t l, std::string msg);
27
+ Custom_Error* new_Custom_Error(std::string p, size_t l, std::string msg);
28
+ Warning* new_Warning(std::string p, size_t l, Expression* msg);
29
+ Error* new_Error(std::string p, size_t l, Expression* msg);
30
+ Debug* new_Debug(std::string p, size_t l, Expression* val);
31
+ Comment* new_Comment(std::string p, size_t l, String* txt);
32
+ If* new_If(std::string p, size_t l, Expression* pred, Block* con, Block* alt = 0);
33
+ For* new_For(std::string p, size_t l, std::string var, Expression* lo, Expression* hi, Block* b, bool inc);
34
+ Each* new_Each(std::string p, size_t l, std::vector<std::string> vars, Expression* lst, Block* b);
35
+ While* new_While(std::string p, size_t l, Expression* pred, Block* b);
36
+ Extension* new_Extension(std::string p, size_t l, Selector* s);
37
+ Definition<MIXIN>* new_Mixin_Definition(std::string p, size_t l, std::string n, Parameters* params, Block* b);
38
+ Definition<FUNCTION>* new_Function_Definition(std::string p, size_t l, std::string n, Parameters* params, Block* b);
39
+ Mixin_Call* new_Mixin_Call(std::string p, size_t l, std::string n, Arguments* args, Block* b = 0);
40
+ // expressions
41
+ List* new_List(std::string p, size_t l, size_t size = 0, enum Sass_Separator sep = List::space, bool argl = false);
42
+ Map* new_Map(std::string p, size_t l, size_t size = 0);
43
+ Binary_Expression<AND>* new_And(std::string p, size_t l, Expression* lhs, Expression* rhs);
44
+ Binary_Expression<OR>* new_Or(std::string p, size_t l, Expression* lhs, Expression* rhs);
45
+ Binary_Expression<EQ>* new_Eq(std::string p, size_t l, Expression* lhs, Expression* rhs);
46
+ Binary_Expression<NEQ>* new_Neq(std::string p, size_t l, Expression* lhs, Expression* rhs);
47
+ Binary_Expression<GT>* new_Gt(std::string p, size_t l, Expression* lhs, Expression* rhs);
48
+ Binary_Expression<GTE>* new_Gte(std::string p, size_t l, Expression* lhs, Expression* rhs);
49
+ Binary_Expression<LT>* new_Lt(std::string p, size_t l, Expression* lhs, Expression* rhs);
50
+ Binary_Expression<LTE>* new_Lte(std::string p, size_t l, Expression* lhs, Expression* rhs);
51
+ Binary_Expression<ADD>* new_Add(std::string p, size_t l, Expression* lhs, Expression* rhs);
52
+ Binary_Expression<SUB>* new_Sub(std::string p, size_t l, Expression* lhs, Expression* rhs);
53
+ Binary_Expression<MUL>* new_Mul(std::string p, size_t l, Expression* lhs, Expression* rhs);
54
+ Binary_Expression<DIV>* new_Div(std::string p, size_t l, Expression* lhs, Expression* rhs);
55
+ Negation* new_Negation(std::string p, size_t l, Expression* o);
56
+ Function_Call* new_Function_Call(std::string p, size_t l, String* n, Arguments* args);
57
+ Variable* new_Variable(std::string p, size_t l, std::string n);
58
+ Textual<NUMBER>* new_Textual_Number(std::string p, size_t l, std::string val);
59
+ Textual<PERCENTAGE>* new_Textual_Percentage(std::string p, size_t l, std::string val);
60
+ Textual<DIMENSION>* new_Textual_Dimension(std::string p, size_t l, std::string val);
61
+ Textual<HEX>* new_Textual_Hex(std::string p, size_t l, std::string val);
62
+ Number* new_Number(std::string p, size_t l, double val);
63
+ Percentage* new_Percentage(std::string p, size_t l, double val);
64
+ Dimension* new_Dimension(std::string p, size_t l, double val, std::string unit);
65
+ Color* new_Color(std::string p, size_t l, double r, double g, double b, double a = 1, std::string disp = "");
66
+ Boolean* new_Boolean(std::string p, size_t l, bool val);
67
+ String_Schema* new_String_Schema(std::string p, size_t l, size_t size = 0);
68
+ String_Constant* new_String_Constant(std::string p, size_t l, std::string val);
69
+ String_Constant* new_String_Constant(std::string p, size_t l, const char* beg);
70
+ String_Constant* new_String_Constant(std::string p, size_t l, const char* beg, const char* end);
71
+ Supports_Condition* new_Supports_Condition(std::string p, size_t l, String* f, Expression* v);
72
+ Media_Expression* new_Media_Expression(std::string p, size_t l, String* f, Expression* v);
73
+ Parent_Selector* new_Parent_Selector(std::string p, size_t l, Selector* s);
74
+ // parameters and arguments
75
+ Parameter* new_Parameter(std::string p, size_t l, std::string n, Expression* def = 0, bool rest = false);
76
+ Parameters* new_Parameters(std::string p, size_t l);
77
+ Argument* new_Argument(std::string p, size_t l, Expression* val, std::string n = "", bool rest = false);
78
+ Arguments* new_Arguments(std::string p, size_t l);
79
+ // selectors
80
+ Selector_Schema* new_Selector_Schema(std::string p, size_t l, String* c);
81
+ Attribute_Selector* new_Attribute_Selector(std::string p, size_t l, std::string n, std::string m, String* v);
82
+ Simple_Selector* new_Simple_Selector(std::string p, size_t l, std::string c);
83
+ Reference_Selector* new_Reference_Selector(std::string p, size_t l);
84
+ Placeholder_Selector* new_Placeholder_Selector(std::string p, size_t l, std::string n);
85
+ Pseudo_Selector* new_Pseudo_Selector(std::string p, size_t l, std::string n, Expression* expr = 0);
86
+ Wrapped_Selector* new_Wrapped_Selector(std::string p, size_t l, std::string n, Simple_Base* sel);
87
+ Compound_Selector* new_Compound_Selector(std::string p, size_t l, size_t s = 0);
88
+ Complex_Selector* new_Complex_Selector(std::string p, size_t l, Complex_Selector::Combinator c, Complex_Selector* ctx, Compound_Selector* sel);
89
+ Selector_List* new_Selector_List(std::string p, size_t l, size_t s = 0);
90
+ };
91
+ }
92
+
93
+ #endif
@@ -16,7 +16,7 @@ namespace Sass {
16
16
  class Propset;
17
17
  class Bubble;
18
18
  class Media_Block;
19
- class Feature_Block;
19
+ class Supports_Block;
20
20
  class At_Rule;
21
21
  class Keyframe_Rule;
22
22
  class At_Root_Block;
@@ -38,6 +38,7 @@ namespace Sass {
38
38
  class Definition;
39
39
  class Mixin_Call;
40
40
  // expressions
41
+ class Value;
41
42
  class Expression;
42
43
  class List;
43
44
  class Map;
@@ -45,6 +46,8 @@ namespace Sass {
45
46
  class Unary_Expression;
46
47
  class Function_Call;
47
48
  class Function_Call_Schema;
49
+ class Custom_Warning;
50
+ class Custom_Error;
48
51
  class Variable;
49
52
  class Textual;
50
53
  class Number;
@@ -56,8 +59,11 @@ namespace Sass {
56
59
  class String_Quoted;
57
60
  class Media_Query;
58
61
  class Media_Query_Expression;
59
- class Feature_Query;
60
- class Feature_Query_Condition;
62
+ class Supports_Condition;
63
+ class Supports_Operator;
64
+ class Supports_Negation;
65
+ class Supports_Declaration;
66
+ class Supports_Interpolation;
61
67
  class At_Root_Expression;
62
68
  class Null;
63
69
  class Parent_Selector;
@@ -69,7 +75,6 @@ namespace Sass {
69
75
  // selectors
70
76
  class Selector;
71
77
  class Selector_Schema;
72
- class Selector_Reference;
73
78
  class Selector_Placeholder;
74
79
  class Type_Selector;
75
80
  class Selector_Qualifier;
@@ -10,7 +10,7 @@ For details, see http://sourceforge.net/projects/libb64
10
10
 
11
11
  typedef enum
12
12
  {
13
- step_A, step_B, step_C
13
+ step_A, step_B, step_C
14
14
  } base64_encodestep;
15
15
 
16
16
  typedef struct
File without changes
@@ -8,36 +8,35 @@
8
8
 
9
9
  namespace Sass {
10
10
 
11
- using namespace std;
12
11
 
13
12
  struct Backtrace {
14
13
 
15
14
  Backtrace* parent;
16
15
  ParserState pstate;
17
- string caller;
16
+ std::string caller;
18
17
 
19
- Backtrace(Backtrace* prn, ParserState pstate, string c)
18
+ Backtrace(Backtrace* prn, ParserState pstate, std::string c)
20
19
  : parent(prn),
21
20
  pstate(pstate),
22
21
  caller(c)
23
22
  { }
24
23
 
25
- string to_string(bool warning = false)
24
+ std::string to_string(bool warning = false)
26
25
  {
27
26
  size_t i = -1;
28
- stringstream ss;
29
- string cwd(Sass::File::get_cwd());
27
+ std::stringstream ss;
28
+ std::string cwd(Sass::File::get_cwd());
30
29
  Backtrace* this_point = this;
31
30
 
32
- if (!warning) ss << endl << "Backtrace:";
31
+ if (!warning) ss << std::endl << "Backtrace:";
33
32
  // the first tracepoint (which is parent-less) is an empty placeholder
34
33
  while (this_point->parent) {
35
34
 
36
35
  // make path relative to the current directory
37
- string rel_path(Sass::File::resolve_relative_path(this_point->pstate.path, cwd, cwd));
36
+ std::string rel_path(Sass::File::resolve_relative_path(this_point->pstate.path, cwd, cwd));
38
37
 
39
38
  if (warning) {
40
- ss << endl
39
+ ss << std::endl
41
40
  << "\t"
42
41
  << (++i == 0 ? "on" : "from")
43
42
  << " line "
@@ -45,7 +44,7 @@ namespace Sass {
45
44
  << " of "
46
45
  << rel_path;
47
46
  } else {
48
- ss << endl
47
+ ss << std::endl
49
48
  << "\t"
50
49
  << rel_path
51
50
  << ":"
@@ -2,9 +2,9 @@
2
2
 
3
3
  namespace Sass {
4
4
 
5
- string Base64VLQ::encode(const int number) const
5
+ std::string Base64VLQ::encode(const int number) const
6
6
  {
7
- string encoded = "";
7
+ std::string encoded = "";
8
8
 
9
9
  int vlq = to_vlq_signed(number);
10
10
 
@@ -4,13 +4,12 @@
4
4
  #include <string>
5
5
 
6
6
  namespace Sass {
7
- using std::string;
8
7
 
9
8
  class Base64VLQ {
10
9
 
11
10
  public:
12
11
 
13
- string encode(const int number) const;
12
+ std::string encode(const int number) const;
14
13
 
15
14
  private:
16
15
 
@@ -8,11 +8,21 @@
8
8
  #include "to_string.hpp"
9
9
 
10
10
  namespace Sass {
11
- using namespace std;
12
11
 
13
- void bind(string callee, Parameters* ps, Arguments* as, Context& ctx, Env* env, Eval* eval)
12
+ void bind(std::string callee, Parameters* ps, Arguments* as, Context& ctx, Env* env, Eval* eval)
14
13
  {
15
- map<string, Parameter*> param_map;
14
+ Listize listize(ctx);
15
+ std::map<std::string, Parameter*> param_map;
16
+
17
+ for (size_t i = 0, L = as->length(); i < L; ++i) {
18
+ if (auto str = dynamic_cast<String_Quoted*>((*as)[i]->value())) {
19
+ // force optional quotes (only if needed)
20
+ if (str->quote_mark()) {
21
+ str->quote_mark('*');
22
+ str->is_delayed(true);
23
+ }
24
+ }
25
+ }
16
26
 
17
27
  // Set up a map to ensure named arguments refer to actual parameters. Also
18
28
  // eval each default value left-to-right, wrt env, populating env as we go.
@@ -29,6 +39,8 @@ namespace Sass {
29
39
  size_t ia = 0, LA = as->length();
30
40
  while (ia < LA) {
31
41
  Argument* a = (*as)[ia];
42
+ // this is only needed for selectors
43
+ a->value(a->value()->perform(&listize));
32
44
  if (ip >= LP) {
33
45
  // skip empty rest arguments
34
46
  if (a->is_rest_argument()) {
@@ -38,7 +50,7 @@ namespace Sass {
38
50
  }
39
51
  }
40
52
  }
41
- stringstream msg;
53
+ std::stringstream msg;
42
54
  msg << callee << " only takes " << LP << " arguments; "
43
55
  << "given " << LA;
44
56
  error(msg.str(), as->pstate());
@@ -62,17 +74,19 @@ namespace Sass {
62
74
  // otherwise we will not be able to fetch it again
63
75
  else {
64
76
  // create a new list object for wrapped items
65
- List* arglist = new (ctx.mem) List(p->pstate(),
66
- 0,
67
- rest->separator(),
68
- true);
77
+ List* arglist = SASS_MEMORY_NEW(ctx.mem, List,
78
+ p->pstate(),
79
+ 0,
80
+ rest->separator(),
81
+ true);
69
82
  // wrap each item from list as an argument
70
83
  for (Expression* item : rest->elements()) {
71
- (*arglist) << new (ctx.mem) Argument(item->pstate(),
72
- item,
73
- "",
74
- false,
75
- false);
84
+ (*arglist) << SASS_MEMORY_NEW(ctx.mem, Argument,
85
+ item->pstate(),
86
+ item,
87
+ "",
88
+ false,
89
+ false);
76
90
  }
77
91
  // assign new arglist to environment
78
92
  env->local_frame()[p->name()] = arglist;
@@ -80,40 +94,71 @@ namespace Sass {
80
94
  }
81
95
  // invalid state
82
96
  else {
83
- throw runtime_error("invalid state");
97
+ throw std::runtime_error("invalid state");
84
98
  }
85
99
  } else if (a->is_keyword_argument()) {
86
100
 
87
101
  // expand keyword arguments into their parameters
88
- List* arglist = new (ctx.mem) List(p->pstate(), 0, List::COMMA, true);
102
+ List* arglist = SASS_MEMORY_NEW(ctx.mem, List, p->pstate(), 0, SASS_COMMA, true);
89
103
  env->local_frame()[p->name()] = arglist;
90
104
  Map* argmap = static_cast<Map*>(a->value());
91
105
  for (auto key : argmap->keys()) {
92
- string name = unquote(static_cast<String_Constant*>(key)->value());
93
- (*arglist) << new (ctx.mem) Argument(key->pstate(),
94
- argmap->at(key),
95
- name,
96
- false,
97
- false);
106
+ std::string name = unquote(static_cast<String_Constant*>(key)->value());
107
+ (*arglist) << SASS_MEMORY_NEW(ctx.mem, Argument,
108
+ key->pstate(),
109
+ argmap->at(key),
110
+ "$" + name,
111
+ false,
112
+ false);
98
113
  }
99
114
 
100
115
  } else {
101
116
 
102
117
  // create a new list object for wrapped items
103
- List* arglist = new (ctx.mem) List(p->pstate(),
104
- 0,
105
- List::COMMA,
106
- true);
118
+ List* arglist = SASS_MEMORY_NEW(ctx.mem, List,
119
+ p->pstate(),
120
+ 0,
121
+ SASS_COMMA,
122
+ true);
107
123
  // consume the next args
108
124
  while (ia < LA) {
109
125
  // get and post inc
110
126
  a = (*as)[ia++];
111
- // wrap current argument into new object
112
- (*arglist) << new (ctx.mem) Argument(a->pstate(),
113
- a->value(),
114
- a->name(),
115
- false,
116
- false);
127
+ // maybe we have another list as argument
128
+ List* ls = dynamic_cast<List*>(a->value());
129
+ // skip any list completely if empty
130
+ if (ls && ls->empty()) continue;
131
+ // flatten all nested arglists
132
+ if (ls && ls->is_arglist()) {
133
+ for (size_t i = 0, L = ls->size(); i < L; ++i) {
134
+ // already have a wrapped argument
135
+ if (Argument* arg = dynamic_cast<Argument*>((*ls)[i])) {
136
+ (*arglist) << SASS_MEMORY_NEW(ctx.mem, Argument, *arg);
137
+ }
138
+ // wrap all other value types into Argument
139
+ else {
140
+ (*arglist) << SASS_MEMORY_NEW(ctx.mem, Argument,
141
+ (*ls)[i]->pstate(),
142
+ (*ls)[i],
143
+ "",
144
+ false,
145
+ false);
146
+ }
147
+ }
148
+ }
149
+ // already have a wrapped argument
150
+ else if (Argument* arg = dynamic_cast<Argument*>(a->value())) {
151
+ (*arglist) << SASS_MEMORY_NEW(ctx.mem, Argument, *arg);
152
+ }
153
+ // wrap all other value types into Argument
154
+ else {
155
+ (*arglist) << SASS_MEMORY_NEW(ctx.mem, Argument,
156
+ a->pstate(),
157
+ a->value(),
158
+ a->name(),
159
+ false,
160
+ false);
161
+ }
117
162
  // check if we have rest argument
118
163
  if (a->is_rest_argument()) {
119
164
  // preserve the list separator from rest args
@@ -142,15 +187,14 @@ namespace Sass {
142
187
  break;
143
188
  }
144
189
  // otherwise move one of the rest args into the param, converting to argument if necessary
145
- if (arglist->is_arglist()) {
146
- a = static_cast<Argument*>((*arglist)[0]);
147
- } else {
190
+ if (!(a = dynamic_cast<Argument*>((*arglist)[0]))) {
148
191
  Expression* a_to_convert = (*arglist)[0];
149
- a = new (ctx.mem) Argument(a_to_convert->pstate(),
150
- a_to_convert,
151
- "",
152
- false,
153
- false);
192
+ a = SASS_MEMORY_NEW(ctx.mem, Argument,
193
+ a_to_convert->pstate(),
194
+ a_to_convert,
195
+ "",
196
+ false,
197
+ false);
154
198
  }
155
199
  arglist->elements().erase(arglist->elements().begin());
156
200
  if (!arglist->length() || (!arglist->is_arglist() && ip + 1 == LP)) {
@@ -160,10 +204,10 @@ namespace Sass {
160
204
  Map* argmap = static_cast<Map*>(a->value());
161
205
 
162
206
  for (auto key : argmap->keys()) {
163
- string name = "$" + unquote(static_cast<String_Constant*>(key)->value());
207
+ std::string name = "$" + unquote(static_cast<String_Constant*>(key)->value());
164
208
 
165
209
  if (!param_map.count(name)) {
166
- stringstream msg;
210
+ std::stringstream msg;
167
211
  msg << callee << " has no parameter named " << name;
168
212
  error(msg.str(), a->pstate());
169
213
  }
@@ -177,7 +221,7 @@ namespace Sass {
177
221
 
178
222
  if (a->name().empty()) {
179
223
  if (env->has_local(p->name())) {
180
- stringstream msg;
224
+ std::stringstream msg;
181
225
  msg << "parameter " << p->name()
182
226
  << " provided more than once in call to " << callee;
183
227
  error(msg.str(), a->pstate());
@@ -189,18 +233,18 @@ namespace Sass {
189
233
  else {
190
234
  // named arg -- bind it to the appropriately named param
191
235
  if (!param_map.count(a->name())) {
192
- stringstream msg;
236
+ std::stringstream msg;
193
237
  msg << callee << " has no parameter named " << a->name();
194
238
  error(msg.str(), a->pstate());
195
239
  }
196
240
  if (param_map[a->name()]->is_rest_parameter()) {
197
- stringstream msg;
241
+ std::stringstream msg;
198
242
  msg << "argument " << a->name() << " of " << callee
199
243
  << "cannot be used as named argument";
200
244
  error(msg.str(), a->pstate());
201
245
  }
202
246
  if (env->has_local(a->name())) {
203
- stringstream msg;
247
+ std::stringstream msg;
204
248
  msg << "parameter " << p->name()
205
249
  << "provided more than once in call to " << callee;
206
250
  error(msg.str(), a->pstate());
@@ -221,26 +265,19 @@ namespace Sass {
221
265
  // cerr << "********" << endl;
222
266
  if (!env->has_local(leftover->name())) {
223
267
  if (leftover->is_rest_parameter()) {
224
- env->local_frame()[leftover->name()] = new (ctx.mem) List(leftover->pstate(),
225
- 0,
226
- List::COMMA,
227
- true);
268
+ env->local_frame()[leftover->name()] = SASS_MEMORY_NEW(ctx.mem, List,
269
+ leftover->pstate(),
270
+ 0,
271
+ SASS_COMMA,
272
+ true);
228
273
  }
229
274
  else if (leftover->default_value()) {
230
- // make sure to eval the default value in the env that we've been populating
231
- Env* old_env = eval->env;
232
- Backtrace* old_bt = eval->backtrace;
233
- Contextualize* old_context = eval->contextualize;
234
- Expression* dv = leftover->default_value()->perform(eval->with(env, eval->backtrace));
235
- eval->env = old_env;
236
- eval->backtrace = old_bt;
237
- eval->contextualize = old_context;
238
- // dv->perform(&to_string);
275
+ Expression* dv = leftover->default_value()->perform(eval);
239
276
  env->local_frame()[leftover->name()] = dv;
240
277
  }
241
278
  else {
242
279
  // param is unbound and has no default value -- error
243
- stringstream msg;
280
+ std::stringstream msg;
244
281
  msg << "required parameter " << leftover->name()
245
282
  << " is missing in call to " << callee;
246
283
  error(msg.str(), as->pstate());