@@ -39,7 +39,7 @@ namespace Sass {
3939 f_env[expr[0 ].to_string ()] = Function (expr);
4040 } break ;
4141
42- case Node::expansion : { // mixin invocation
42+ case Node::mixin_call : { // mixin invocation
4343 Token name (expr[0 ].token ());
4444 Node args (expr[1 ]);
4545 if (!env.query (name)) throw_eval_error (" mixin " + name.to_string () + " is undefined" , expr.path (), expr.line ());
@@ -766,42 +766,44 @@ namespace Sass {
766766 switch (stm.type ())
767767 {
768768 case Node::assignment: {
769- Node val (new_Node (stm[1 ])); // clone the value because it might get mutated in place
769+ Node val (stm[1 ]);
770+ Node newval;
770771 if (val.type () == Node::list) {
772+ newval = new_Node (Node::list, val.path (), val.line (), val.size ());
771773 for (size_t i = 0 , S = val.size (); i < S; ++i) {
772- if (val[i].should_eval ()) val[i] = eval (val[i], Node (), bindings, ctx.function_env , new_Node, ctx);
774+ if (val[i].should_eval ()) newval << eval (val[i], Node (), bindings, ctx.function_env , new_Node, ctx);
775+ else newval << val[i];
773776 }
774777 }
775778 else {
776- val = eval (val, Node (), bindings, ctx.function_env , new_Node, ctx);
779+ newval = eval (val, Node (), bindings, ctx.function_env , new_Node, ctx);
777780 }
778781 Node var (stm[0 ]);
779782 if (stm.is_guarded () && bindings.query (var.token ())) continue ;
780783 // If a binding exists (possibly upframe), then update it.
781784 // Otherwise, make a new one in the current frame.
782785 if (bindings.query (var.token ())) {
783- bindings[var.token ()] = val ;
786+ bindings[var.token ()] = newval ;
784787 }
785788 else {
786- bindings.current_frame [var.token ()] = val ;
789+ bindings.current_frame [var.token ()] = newval ;
787790 }
788791 } break ;
789792
790793 case Node::if_directive: {
791794 for (size_t j = 0 , S = stm.size (); j < S; j += 2 ) {
792795 if (stm[j].type () != Node::block) {
793- Node pred (new_Node (stm[j]));
794- Node predicate_val (eval (pred, Node (), bindings, ctx.function_env , new_Node, ctx));
795- if ((predicate_val.type () != Node::boolean) || predicate_val.boolean_value ()) {
796+ Node predicate_val (eval (stm[j], Node (), bindings, ctx.function_env , new_Node, ctx));
797+ if (!predicate_val.is_false ()) {
796798 Node v (eval_function (name, stm[j+1 ], bindings, new_Node, ctx));
797799 if (v.is_null ()) break ;
798- else return v;
800+ else return v;
799801 }
800802 }
801803 else {
802804 Node v (eval_function (name, stm[j], bindings, new_Node, ctx));
803805 if (v.is_null ()) break ;
804- else return v;
806+ else return v;
805807 }
806808 }
807809 } break ;
@@ -810,8 +812,8 @@ namespace Sass {
810812 case Node::for_to_directive: {
811813 Node::Type for_type = stm.type ();
812814 Node iter_var (stm[0 ]);
813- Node lower_bound (eval (new_Node ( stm[1 ]) , Node (), bindings, ctx.function_env , new_Node, ctx));
814- Node upper_bound (eval (new_Node ( stm[2 ]) , Node (), bindings, ctx.function_env , new_Node, ctx));
815+ Node lower_bound (eval (stm[1 ], Node (), bindings, ctx.function_env , new_Node, ctx));
816+ Node upper_bound (eval (stm[2 ], Node (), bindings, ctx.function_env , new_Node, ctx));
815817 Node for_body (stm[3 ]);
816818 Environment for_env; // re-use this env for each iteration
817819 for_env.link (bindings);
@@ -821,13 +823,13 @@ namespace Sass {
821823 for_env.current_frame [iter_var.token ()] = new_Node (lower_bound.path (), lower_bound.line (), j);
822824 Node v (eval_function (name, for_body, for_env, new_Node, ctx));
823825 if (v.is_null ()) continue ;
824- else return v;
826+ else return v;
825827 }
826828 } break ;
827829
828830 case Node::each_directive: {
829831 Node iter_var (stm[0 ]);
830- Node list (eval (new_Node ( stm[1 ]) , Node (), bindings, ctx.function_env , new_Node, ctx));
832+ Node list (eval (stm[1 ], Node (), bindings, ctx.function_env , new_Node, ctx));
831833 if (list.type () != Node::list) {
832834 list = (new_Node (Node::list, list.path (), list.line (), 1 ) << list);
833835 }
@@ -839,33 +841,30 @@ namespace Sass {
839841 each_env.current_frame [iter_var.token ()] = eval (list[j], Node (), bindings, ctx.function_env , new_Node, ctx);
840842 Node v (eval_function (name, each_body, each_env, new_Node, ctx));
841843 if (v.is_null ()) continue ;
842- else return v;
844+ else return v;
843845 }
844846 } break ;
845847
846848 case Node::while_directive: {
847- Node pred_expr (new_Node ( stm[0 ]) );
849+ Node pred_expr (stm[0 ]);
848850 Node while_body (stm[1 ]);
849851 Environment while_env; // re-use this env for each iteration
850852 while_env.link (bindings);
851853 Node pred_val (eval (pred_expr, Node (), bindings, ctx.function_env , new_Node, ctx));
852- while ((pred_val. type () != Node::boolean) || pred_val.boolean_value ()) {
854+ while (! pred_val.is_false ()) {
853855 Node v (eval_function (name, while_body, while_env, new_Node, ctx));
854856 if (v.is_null ()) {
855- pred_val = eval (new_Node (stm[ 0 ]) , Node (), bindings, ctx.function_env , new_Node, ctx);
857+ pred_val = eval (pred_expr , Node (), bindings, ctx.function_env , new_Node, ctx);
856858 continue ;
857859 }
858860 else return v;
859861 }
860862 } break ;
861863
862864 case Node::warning: {
863- stm = new_Node (stm);
864- stm[0 ] = eval (stm[0 ], Node (), bindings, ctx.function_env , new_Node, ctx);
865-
866865 string prefix (" WARNING: " );
867866 string indent (" " );
868- Node contents (stm[0 ]);
867+ Node contents (eval ( stm[0 ], Node (), bindings, ctx. function_env , new_Node, ctx) );
869868 string result (contents.to_string ());
870869 if (contents.type () == Node::string_constant || contents.type () == Node::string_schema) {
871870 result = result.substr (1 , result.size ()-2 ); // unquote if it's a single string
@@ -877,11 +876,13 @@ namespace Sass {
877876 } break ;
878877
879878 case Node::return_directive: {
880- Node retval (eval (new_Node ( stm[0 ]) , Node (), bindings, ctx.function_env , new_Node, ctx));
879+ Node retval (eval (stm[0 ], Node (), bindings, ctx.function_env , new_Node, ctx));
881880 if (retval.type () == Node::list) {
881+ Node new_list (new_Node (Node::list, retval.path (), retval.line (), retval.size ()));
882882 for (size_t i = 0 , S = retval.size (); i < S; ++i) {
883- retval[i] = eval (retval[i], Node (), bindings, ctx.function_env , new_Node, ctx);
883+ new_list << eval (retval[i], Node (), bindings, ctx.function_env , new_Node, ctx);
884884 }
885+ retval = new_list;
885886 }
886887 return retval;
887888 } break ;
0 commit comments