Skip to content

Commit 0c5e27c

Browse files
committed
Clean up get_arg_m in fn_utils
1 parent 025dc4e commit 0c5e27c

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/bind.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "sass.hpp"
22
#include "bind.hpp"
33
#include "ast.hpp"
4+
#include "backtrace.hpp"
45
#include "context.hpp"
56
#include "expand.hpp"
67
#include "eval.hpp"

src/bind.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
namespace Sass {
1010

11-
void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces traces);
11+
void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces& traces);
12+
1213
}
1314

1415
#endif

src/fn_utils.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,17 @@ namespace Sass {
5353

5454
Map_Ptr get_arg_m(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtraces traces)
5555
{
56-
// Minimal error handling -- the expectation is that built-ins will be written correctly!
57-
Map_Ptr val = Cast<Map>(env[argname]);
58-
if (val) return val;
59-
60-
List_Ptr lval = Cast<List>(env[argname]);
61-
if (lval && lval->length() == 0) return SASS_MEMORY_NEW(Map, pstate, 0);
62-
63-
// fallback on get_arg for error handling
64-
val = get_arg<Map>(argname, env, sig, pstate, traces);
65-
return val;
56+
AST_Node_Ptr value = env[argname];
57+
if (Map_Ptr map = Cast<Map>(value)) return map;
58+
List_Ptr list = Cast<List>(value);
59+
if (list && list->length() == 0) {
60+
return SASS_MEMORY_NEW(Map, pstate, 0);
61+
}
62+
return get_arg<Map>(argname, env, sig, pstate, traces);
6663
}
6764

6865
double get_arg_r(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtraces traces, double lo, double hi)
6966
{
70-
// Minimal error handling -- the expectation is that built-ins will be written correctly!
7167
Number_Ptr val = get_arg<Number>(argname, env, sig, pstate, traces);
7268
Number tmpnr(val);
7369
tmpnr.reduce();

0 commit comments

Comments
 (0)