pcc/ internals/ node structure

The main data structure used through the whole compiler is the NODE. The parse trees are built out of NODEs and it is the underlying data structure when generating code.

The NODE structure contains lots of fields in unions to kefep the size down of the struct. Different NODE types uses different elements in the structure. The NODE struct is declared like this:

typedef struct node {
    int     n_op;
    int     n_rall;
    TWORD   n_type;
    TWORD   n_qual;
    int     n_su;
    union {
            char *  _name;
            int     _stsize;
            union   dimfun *_df;
    } n_5;
    union {
            int     _label;
            int     _stalign;
            struct  suedef *_sue;
    } n_6;
    union {
            struct {
                    union {
                            struct node *_left;
                            CONSZ _lval;
#ifdef SPECIAL_INTEGERS
                            SPECLVAL _slval;
#endif
                    } n_l;
                    union {
                            struct node *_right;
                            int _rval;
                            struct symtab *_sp;
                    } n_r;
            } n_u;
            long double     _dcon;
    } n_f;
} NODE;

#define n_name  n_5._name
#define n_stsize n_5._stsize
#define n_df    n_5._df

#define n_label n_6._label
#define n_stalign n_6._stalign
#define n_sue   n_6._sue

#define n_left  n_f.n_u.n_l._left
#define n_lval  n_f.n_u.n_l._lval
#define n_slval n_f.n_u.n_l._slval
#define n_right n_f.n_u.n_r._right
#define n_rval  n_f.n_u.n_r._rval
#define n_sp    n_f.n_u.n_r._sp
#define n_dcon  n_f._dcon

NODE fields

All Nodes

The fields that are valid in all nodes are:

Leaf Nodes

Unary Nodes

The node leg is always the left leg.