Changeset f85ca3f in mainline for uspace/app/bithenge/transform.h


Ignore:
Timestamp:
2012-07-28T21:25:49Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
84e8a70
Parents:
32eb01b
Message:

Bithenge: add expressions that use the current node being created

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/transform.h

    r32eb01b rf85ca3f  
    5252typedef struct {
    5353        /** @privatesection */
     54        int num_params;
    5455        bithenge_node_t **params;
    55         int num_params;
     56        bithenge_node_t *current_node;
    5657} bithenge_scope_t;
    5758
     
    7475static inline void bithenge_scope_init(bithenge_scope_t *scope)
    7576{
     77        scope->num_params = 0;
    7678        scope->params = NULL;
    77         scope->num_params = 0;
     79        scope->current_node = NULL;
    7880}
    7981
     
    8385static inline void bithenge_scope_destroy(bithenge_scope_t *scope)
    8486{
     87        bithenge_node_dec_ref(scope->current_node);
    8588        for (int i = 0; i < scope->num_params; i++)
    8689                bithenge_node_dec_ref(scope->params[i]);
     
    104107        for (int i = 0; i < out->num_params; i++)
    105108                bithenge_node_inc_ref(out->params[i]);
    106         return EOK;
     109        out->current_node = scope->current_node;
     110        if (out->current_node)
     111                bithenge_node_inc_ref(out->current_node);
     112        return EOK;
     113}
     114
     115/** Set the current node being created. Takes a reference to @a node.
     116 * @param scope The scope to set the current node in.
     117 * @param node The current node being created.
     118 * @return EOK on success or an error code from errno.h. */
     119static inline void bithenge_scope_set_current_node(bithenge_scope_t *scope,
     120    bithenge_node_t *node)
     121{
     122        bithenge_node_dec_ref(scope->current_node);
     123        scope->current_node = node;
     124}
     125
     126/** Get the current node being created, which may be NULL.
     127 * @param scope The scope to get the current node from.
     128 * @return The node being created, or NULL. */
     129static inline bithenge_node_t *bithenge_scope_get_current_node(
     130    bithenge_scope_t *scope)
     131{
     132        if (scope->current_node)
     133                bithenge_node_inc_ref(scope->current_node);
     134        return scope->current_node;
    107135}
    108136
    109137/** Allocate parameters. The parameters must then be set with @a
    110  * bithenge_scope_set_param.
     138 * bithenge_scope_set_param. This must not be called on a scope that already
     139 * has parameters.
    111140 * @param scope The scope in which to allocate parameters.
    112141 * @param num_params The number of parameters to allocate.
Note: See TracChangeset for help on using the changeset viewer.