home *** CD-ROM | disk | FTP | other *** search
- // the node class is central to date representation.
- // Everything it knows is in a node.
-
- enum node_flavor { //state the derived type from a node
- nf_base, nf_type, nf_def
- };
-
- class node {
- protected:
- node();
- virtual ~node();
- public:
- node_flavor flavor;
- virtual void print();
- };
-
- enum primary_t { type_void, type_char, type_int, type_long, type_float, type_double, type_ldouble, type_enum, type_class, type_union, type_pointer, type_reference, type_array, type_function };
-
- class def_node_list; //forward ref
-
- class type_node : public node {
- public:
- type_node* to_what;
- type_node ();
- ~type_node();
- void print();
- unsigned flags;
- primary_t primary;
- node* secondary() { return to_what; }
- atom tag;
- def_node_list* aggr;
- void stuff_primary (int x, atom tagname);
- bool isConst() { return flags&1; }
- bool isVol() { return flags&2; }
- bool isNear() { return flags&4; }
- bool isFar() { return flags&8; }
- bool isUnsigned() { return flags&16; }
- };
-
- class def_node : public node {
- public:
- atom name;
- int storage_class;
- type_node* type;
- void print();
- def_node (atom n, int store, type_node* t);
- };
-
- /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
- /* lists of nodes */
- /* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
-
- class node_list {
- node** list;
- int capacity;
- int count;
- public:
- node_list();
- ~node_list() { delete list; }
- node** access (int x);
- int size() { return count; }
- void add(node* n) { *access(count++) = n; }
- };
-
- #define create_list(TYPE) class TYPE##_node_list : public node_list { \
- public:\
- TYPE##_node*& operator[] (int x) { return *(TYPE##_node **)access(x); } }
-
- create_list (type);
- create_list (def);
-