Changeset 0191bd3 in mainline for uspace/app/bithenge/sequence.c


Ignore:
Timestamp:
2012-08-07T04:30:04Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a8be91a
Parents:
f9c314a5
Message:

Bithenge: keep track of outer scopes and find parameters there

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/sequence.c

    rf9c314a5 r0191bd3  
    267267        self->num_ends = 0;
    268268        self->end_on_empty = end_on_empty;
    269         int rc = bithenge_scope_new(&self->scope);
    270         if (rc != EOK) {
    271                 free(self->ends);
    272                 return rc;
    273         }
    274         rc = bithenge_scope_copy(self->scope, scope);
    275         if (rc != EOK) {
    276                 bithenge_scope_dec_ref(self->scope);
    277                 free(self->ends);
    278                 return rc;
    279         }
     269        self->scope = scope;
     270        if (self->scope)
     271                bithenge_scope_inc_ref(self->scope);
    280272        return EOK;
    281273}
     
    468460                return rc;
    469461        }
    470 
    471         rc = seq_node_init(struct_as_seq(node), &struct_node_seq_ops, scope,
     462        bithenge_scope_t *inner;
     463        rc = bithenge_scope_new(&inner, scope);
     464        if (rc != EOK) {
     465                free(node);
     466                return rc;
     467        }
     468        /* We should inc_ref(node) here, but that would make a cycle. Instead,
     469         * we leave it 1 too low, so that when the only remaining use of node
     470         * is the scope, node will be destroyed. Also see the comment in
     471         * struct_node_destroy. */
     472        bithenge_scope_set_current_node(inner, struct_as_node(node));
     473
     474        rc = seq_node_init(struct_as_seq(node), &struct_node_seq_ops, inner,
    472475            blob, self->num_subtransforms, false);
     476        bithenge_scope_dec_ref(inner);
    473477        if (rc != EOK) {
    474478                free(node);
     
    480484        node->prefix = prefix;
    481485        *out = struct_as_node(node);
    482 
    483         /* We should inc_ref(*out) here, but that would make a cycle. Instead,
    484          * we leave it 1 too low, so that when the only remaining use of *out
    485          * is the scope, *out will be destroyed. Also see the comment in
    486          * struct_node_destroy. */
    487         bithenge_scope_set_current_node(seq_node_scope(struct_as_seq(node)),
    488             *out);
    489486
    490487        return EOK;
     
    942939
    943940                bithenge_scope_t *scope;
    944                 rc = bithenge_scope_new(&scope);
     941                rc = bithenge_scope_new(&scope,
     942                    seq_node_scope(do_while_as_seq(self)));
    945943                if (rc != EOK) {
    946944                        bithenge_node_dec_ref(subxform_result);
    947945                        return rc;
    948946                }
    949                 rc = bithenge_scope_copy(scope,
    950                     seq_node_scope(do_while_as_seq(self)));
    951947                bithenge_scope_set_current_node(scope, subxform_result);
    952                 if (rc != EOK) {
    953                         bithenge_scope_dec_ref(scope);
    954                         return rc;
    955                 }
    956948                bithenge_node_t *expr_result;
    957949                rc = bithenge_expression_evaluate(self->expr, scope,
Note: See TracChangeset for help on using the changeset viewer.