X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fecoli_node_expr.c;h=c92749ef6014fc6575df2a33b4c39cc2d89ab923;hb=765ebfc0b57ea5ddcd5079fce261c05c1eeb0f65;hp=41a14bb74b28a7d0470e94497d473682dfa2d714;hpb=1d655de6043b607f39888c1bb88f72d071f2d49a;p=protos%2Flibecoli.git diff --git a/lib/ecoli_node_expr.c b/lib/ecoli_node_expr.c index 41a14bb..c92749e 100644 --- a/lib/ecoli_node_expr.c +++ b/lib/ecoli_node_expr.c @@ -21,7 +21,6 @@ #include #include #include -#include #include EC_LOG_TYPE_REGISTER(node_expr); @@ -104,8 +103,8 @@ static void ec_node_expr_free_priv(struct ec_node *gen_node) static int ec_node_expr_build(struct ec_node_expr *node) { struct ec_node *term = NULL, *expr = NULL, *next = NULL, - *pre_op = NULL, *post_op = NULL, - *post = NULL, *weak = NULL; + *pre_op = NULL, *post_op = NULL, *ref = NULL, + *post = NULL; unsigned int i; ec_node_free(node->child); @@ -136,10 +135,9 @@ static int ec_node_expr_build(struct ec_node_expr *node) * expr = sum */ - /* create the object, we will initialize it later: this is - * needed because we have a circular dependency */ - weak = ec_node("weakref", "weak"); - if (weak == NULL) + /* we use this as a ref, will be set later */ + ref = ec_node("seq", "ref"); + if (ref == NULL) return -1; /* prefix unary operators */ @@ -168,12 +166,12 @@ static int ec_node_expr_build(struct ec_node_expr *node) if (ec_node_or_add(post, EC_NODE_SEQ(EC_NO_ID, ec_node_clone(pre_op), - ec_node_clone(weak))) < 0) + ec_node_clone(ref))) < 0) goto fail; for (i = 0; i < node->paren_len; i++) { if (ec_node_or_add(post, EC_NODE_SEQ(EC_NO_ID, ec_node_clone(node->open_ops[i]), - ec_node_clone(weak), + ec_node_clone(ref), ec_node_clone(node->close_ops[i]))) < 0) goto fail; } @@ -211,11 +209,10 @@ static int ec_node_expr_build(struct ec_node_expr *node) ec_node_free(post); post = NULL; - /* no need to clone here, the node is not consumed */ - if (ec_node_weakref_set(weak, expr) < 0) + if (ec_node_seq_add(ref, ec_node_clone(expr)) < 0) goto fail; - ec_node_free(weak); - weak = NULL; + ec_node_free(ref); + ref = NULL; node->child = expr; @@ -227,7 +224,7 @@ fail: ec_node_free(pre_op); ec_node_free(post_op); ec_node_free(post); - ec_node_free(weak); + ec_node_free(ref); return -1; }