next up previous contents
Next: Strings Up: Identifiers Previous: Identifiers

Implementation

Depending on a compiler flag BITF setting, one of the below given definition is performed. They differ only in the second field. In the first one the field Xattr is masked explicitly with some selecting bytes to fetch out the attribute bits. In the second this is done using the bit slicing property of the C language. The alternatives exist, since, some compilers generate inefficient codes for bit slicing.

An identifier can have several attributes, like being a global or fluid, used as a name of interpretively defined function etc. Some of the bits in the second field of this structure is deviced for this purpose, the remaining bits are left unused.

As known in LISP each identifier has an associated:

printname
which is the way the identifier is recognized in input and output.
value
cell where you can assign any SEXPR or can be left unassigned.
property-list
where you can store several properties under indicators, or flag the identifier with to possess a property. This is a list of SEXPRs.

Therefore it is trivial that the internal data structure will have fields to accommodate these associated quantities. You will realize that a field named Xhashlink exists. In our implementation identifiers are chained together through this field, provided they belong to the same hash-bucket. The hash-number of an identifier is determined by summing up the ascii codes of its printname characters and then taking this number modulo 128. So there are 128 number of hash-buckets. A new created identifier, upon the decision of his hash-number is chained into the link of the identifiers with the same hash-number (we call this chain a hash-bucket) via this Xhashlink field. The entry points of these buckets are kept in an array named hashtab.

    struct Xid { char Xtype;
                 unsigned Xisinheap : 1;
                 unsigned Xisglobal : 1;
                 unsigned Xisfluid  : 1;
                 unsigned Xisfunction : 1;
                 unsigned Xisinoblist : 1;
                 unsigned Xisdclfluid : 1;
                 struct Xid *Xhashlink;
                 PSEXP Xvalue;
                 PSEXP Xproplist;
                 char *Xpname; } ;


    struct Xid { char Xtype;
                 char Xattr;
                 struct Xid *Xhashlink;
                 PSEXP Xvalue;
                 PSEXP Xproplist;
                 char *Xpname; } ;

figure198


next up previous contents
Next: Strings Up: Identifiers Previous: Identifiers

Gokturk UCOLUK
Fri Nov 1 21:52:13 EET 1996