summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2010-03-17 15:41:09 +0100
committerJohannes Weiner <hannes@cmpxchg.org>2010-03-17 15:41:09 +0100
commit95a8a9df4245e6399cdf34ccb73be151abc17882 (patch)
tree1fc5d6c5dc836edc723f9f44e901b88056be287c
parentc76df536143f1b2c7846bb335a176aaaf61f7e48 (diff)
core: evaluate (set) value in own context
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r--sheep/core.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sheep/core.c b/sheep/core.c
index 407f08e..4e389e1 100644
--- a/sheep/core.c
+++ b/sheep/core.c
@@ -390,16 +390,25 @@ static int compile_set(struct sheep_compile *compile,
struct sheep_context *context, struct sheep_list *args)
{
struct sheep_name *name;
+ SHEEP_DEFINE_MAP(env);
+ struct sheep_context block = {
+ .env = &env,
+ .parent = context,
+ };
sheep_t value;
+ int ret = -1;
if (sheep_parse(compile, args, "ne", &name, &value))
- return -1;
+ goto out;
- if (sheep_compile_object(compile, function, context, value))
- return -1;
+ if (sheep_compile_object(compile, function, &block, value))
+ goto out;
- return sheep_compile_set(compile, function, context,
+ ret = sheep_compile_set(compile, function, context,
sheep_list(args->tail)->head);
+out:
+ sheep_map_drain(&env);
+ return ret;
}
/* (load name) */