Example #1
0
VarIndex st_addVar(ExprType type)
{
    VarInfo *vi;
    unsigned idx = st_nextVarIdx(&vi);

    vi->name = rss_strdup(util_string());      /* set the name of the var */
    vi->type = type | e_var;          /* set the type of the var */
    vi->value = 0;

    VarIndex ret = {idx, st_nestingOffset() > 0};
    return ret;
}
Example #2
0
size_t st_nextVarIdx(VarInfo **vi)  /* idx of an uninitialized record of a */
{                                   /* variable */

    size_t idx = st_newVarIdx();    /* new variable in local or global tab */
   
                                    /* RBA a pointer to the next VarInfo */
    *vi = st_varTab(st_nestingOffset())->info + idx;  

    *st_newIdxPtr() = idx;          /* create room in the nesting-level 
                                        index vector, assign the idx */

    return idx;                     /* return the index of the next var. */
}