From 459bccc750616f07c9d55d6c12211e07c2369f1a Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Wed, 12 May 2021 11:33:31 -0600 Subject: [PATCH] plain env pointer --- src/libexpr/eval.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 531e3f752..3f73c24a1 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -619,18 +619,18 @@ std::optional EvalState::getDoc(Value & v) // typedef std::optional> valmap; typedef const std::map valmap; -static std::unique_ptr map1(const char *name, Value *v) __attribute__((noinline)); -std::unique_ptr map1(const char *name, Value *v) +static valmap* map1(const char *name, Value *v) __attribute__((noinline)); +valmap* map1(const char *name, Value *v) { // return new valmap({{name, v}}); - return std::unique_ptr(new valmap({{name, v}})); + return new valmap({{name, v}}); } -static std::unique_ptr map2(const char *name1, Value *v1, const char *name2, Value *v2) __attribute__((noinline)); -std::unique_ptr map2(const char *name1, Value *v1, const char *name2, Value *v2) +static valmap* map2(const char *name1, Value *v1, const char *name2, Value *v2) __attribute__((noinline)); +valmap* map2(const char *name1, Value *v1, const char *name2, Value *v2) { - return std::unique_ptr(new valmap({{name1, v1}, {name2, v2}})); + return new valmap({{name1, v1}, {name2, v2}}); } /* Every "format" object (even temporary) takes up a few hundred bytes @@ -673,8 +673,9 @@ LocalNoInlineNoReturn(void throwEvalError(const Pos & p1, const char * s, const }); } -LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, std::unique_ptr env)) +LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, valmap* env)) { + auto delenv = std::unique_ptr(env); auto error = TypeError({ .msg = hintfmt(s), .errPos = pos @@ -685,8 +686,9 @@ LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, std:: throw error; } -LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const Value & v, std::unique_ptr env)) +LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const Value & v, valmap* env)) { + auto delenv = std::unique_ptr(env); auto error = TypeError({ .msg = hintfmt(s, v), .errPos = pos @@ -697,8 +699,9 @@ LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const throw error; } -LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const ExprLambda & fun, const Symbol & s2, std::unique_ptr env)) +LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const ExprLambda & fun, const Symbol & s2, valmap* env)) { + auto delenv = std::unique_ptr(env); auto error = TypeError({ .msg = hintfmt(s, fun.showNamePos(), s2), .errPos = pos @@ -727,7 +730,7 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char * }); } -LocalNoInlineNoReturn(void throwMissingArgumentError(const Pos & pos, const char * s, const string & s1, std::unique_ptr env)) +LocalNoInlineNoReturn(void throwMissingArgumentError(const Pos & pos, const char * s, const string & s1, valmap* env)) { auto error = MissingArgumentError({ .msg = hintfmt(s, s1),