From 0c5e27ceb34cf2ac1442d0a0338057ae4d3dc7ec Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sat, 17 Mar 2018 06:09:13 +0100 Subject: [PATCH] Clean up `get_arg_m` in `fn_utils` --- src/bind.cpp | 1 + src/bind.hpp | 3 ++- src/fn_utils.cpp | 18 +++++++----------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/bind.cpp b/src/bind.cpp index c6ad88bd8..1874667a8 100644 --- a/src/bind.cpp +++ b/src/bind.cpp @@ -1,6 +1,7 @@ #include "sass.hpp" #include "bind.hpp" #include "ast.hpp" +#include "backtrace.hpp" #include "context.hpp" #include "expand.hpp" #include "eval.hpp" diff --git a/src/bind.hpp b/src/bind.hpp index 7ad87f8f8..57bcd01f9 100644 --- a/src/bind.hpp +++ b/src/bind.hpp @@ -8,7 +8,8 @@ namespace Sass { - void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces traces); + void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces& traces); + } #endif diff --git a/src/fn_utils.cpp b/src/fn_utils.cpp index b4986037e..7480f030f 100644 --- a/src/fn_utils.cpp +++ b/src/fn_utils.cpp @@ -53,21 +53,17 @@ namespace Sass { Map_Ptr get_arg_m(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtraces traces) { - // Minimal error handling -- the expectation is that built-ins will be written correctly! - Map_Ptr val = Cast(env[argname]); - if (val) return val; - - List_Ptr lval = Cast(env[argname]); - if (lval && lval->length() == 0) return SASS_MEMORY_NEW(Map, pstate, 0); - - // fallback on get_arg for error handling - val = get_arg(argname, env, sig, pstate, traces); - return val; + AST_Node_Ptr value = env[argname]; + if (Map_Ptr map = Cast(value)) return map; + List_Ptr list = Cast(value); + if (list && list->length() == 0) { + return SASS_MEMORY_NEW(Map, pstate, 0); + } + return get_arg(argname, env, sig, pstate, traces); } double get_arg_r(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtraces traces, double lo, double hi) { - // Minimal error handling -- the expectation is that built-ins will be written correctly! Number_Ptr val = get_arg(argname, env, sig, pstate, traces); Number tmpnr(val); tmpnr.reduce();