@@ -673,11 +673,11 @@ namespace Sass {
673673 // Apply a mixin -- bind the arguments in a new environment, link the new
674674 // environment to the current one, then copy the body and eval in the new
675675 // environment.
676- Node apply_mixin (Node mixin, const Node args , Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, bool dynamic_scope)
676+ Node apply_mixin (Node mixin, const Node aargs , Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, bool dynamic_scope)
677677 {
678678 Node params (mixin[1 ]);
679679 Node body (new_Node (mixin[2 ])); // clone the body
680-
680+ Node args = new_Node (aargs);
681681 // evaluate arguments in the current environment
682682 for (size_t i = 0 , S = args.size (); i < S; ++i) {
683683 if (args[i].type () != Node::assignment) {
@@ -687,6 +687,17 @@ namespace Sass {
687687 args[i][1 ] = eval (args[i][1 ], prefix, env, f_env, new_Node, ctx);
688688 }
689689 }
690+ // need to eval twice because some expressions get delayed
691+ // for (size_t i = 0, S = args.size(); i < S; ++i) {
692+ // if (args[i].type() != Node::assignment) {
693+ // args[i].should_eval() = true;
694+ // args[i] = eval(args[i], prefix, env, f_env, new_Node, ctx);
695+ // }
696+ // else {
697+ // args[i][1].should_eval() = true;
698+ // args[i][1] = eval(args[i][1], prefix, env, f_env, new_Node, ctx);
699+ // }
700+ // }
690701
691702 // Create a new environment for the mixin and link it to the appropriate parent
692703 Environment bindings;
@@ -713,46 +724,42 @@ namespace Sass {
713724
714725 // Apply a function -- bind the arguments and pass them to the underlying
715726 // primitive function implementation, then return its value.
716- Node apply_function (const Function& f, const Node args , Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, string& path, size_t line)
727+ Node apply_function (const Function& f, const Node aargs , Node prefix, Environment& env, map<string, Function>& f_env, Node_Factory& new_Node, Context& ctx, string& path, size_t line)
717728 {
718- if (f.primitive ) {
719- // evaluate arguments in the current environment
720- for (size_t i = 0 , S = args.size (); i < S; ++i) {
721- if (args[i].type () != Node::assignment) {
722- args[i] = eval (args[i], prefix, env, f_env, new_Node, ctx);
723- }
724- else {
725- args[i][1 ] = eval (args[i][1 ], prefix, env, f_env, new_Node, ctx);
726- }
729+ Node args = new_Node (aargs);
730+ // evaluate arguments in the current environment
731+ for (size_t i = 0 , S = args.size (); i < S; ++i) {
732+ if (args[i].type () != Node::assignment) {
733+ args[i] = eval (args[i], prefix, env, f_env, new_Node, ctx);
734+ }
735+ else {
736+ args[i][1 ] = eval (args[i][1 ], prefix, env, f_env, new_Node, ctx);
727737 }
728- // bind arguments
729- Environment bindings;
730- bindings.link (env.global ? *env.global : env);
731- bind_arguments (" function " + f.name , f.parameters , args, prefix, bindings, f_env, new_Node, ctx);
732- return f.primitive (f.parameter_names , bindings, new_Node, path, line);
733738 }
734- else {
735- Node params (f.definition [1 ]);
736- Node body (new_Node (f.definition [2 ]));
739+ // need to eval twice because some expressions get delayed
740+ // for (size_t i = 0, S = args.size(); i < S; ++i) {
741+ // if (args[i].type() != Node::assignment) {
742+ // args[i].should_eval() = true;
743+ // args[i] = eval(args[i], prefix, env, f_env, new_Node, ctx);
744+ // }
745+ // else {
746+ // args[i][1].should_eval() = true;
747+ // args[i][1] = eval(args[i][1], prefix, env, f_env, new_Node, ctx);
748+ // }
749+ // }
737750
738- // evaluate arguments in the current environment
739- for (size_t i = 0 , S = args.size (); i < S; ++i) {
740- if (args[i].type () != Node::assignment) {
741- args[i] = eval (args[i], prefix, env, f_env, new_Node, ctx);
742- }
743- else {
744- args[i][1 ] = eval (args[i][1 ], prefix, env, f_env, new_Node, ctx);
745- }
746- }
751+ // bind arguments
752+ Environment bindings;
753+ Node params (f.primitive ? f.parameters : f.definition [1 ]);
754+ bindings.link (env.global ? *env.global : env);
755+ bind_arguments (" function " + f.name , params, args, prefix, bindings, f_env, new_Node, ctx);
747756
748- // create a new environment for the function and link it to the global env
749- // (C-style scope -- no full-blown lexical scope yet)
750- Environment bindings;
751- bindings.link (env.global ? *env.global : env);
752- // bind the arguments
753- bind_arguments (" function " + f.name , params, args, prefix, bindings, f_env, new_Node, ctx);
754- // TO DO: consider cloning the function body
755- return function_eval (f.name , body, bindings, new_Node, ctx, true );
757+ if (f.primitive ) {
758+ return f.primitive (f.parameter_names , bindings, new_Node, path, line);
759+ }
760+ else {
761+ // TO DO: consider cloning the function body?
762+ return function_eval (f.name , f.definition [2 ], bindings, new_Node, ctx, true );
756763 }
757764 }
758765
0 commit comments