SymEntry* FindStructField (const Type* T, const char* Name) /* Find a struct field in the fields list */ { SymEntry* Field = 0; /* The given type may actually be a pointer to struct */ if (IsTypePtr (T)) { ++T; } /* Non-structs do not have any struct fields... */ if (IsClassStruct (T)) { /* Get a pointer to the struct/union type */ const SymEntry* Struct = GetSymEntry (T); CHECK (Struct != 0); /* Now search in the struct symbol table. Beware: The table may not ** exist. */ if (Struct->V.S.SymTab) { Field = FindSymInTable (Struct->V.S.SymTab, Name, HashStr (Name)); } } return Field; }
void SetSymEntry (Type* T, SymEntry* S) /* Set the SymEntry pointer for a type */ { /* Only structs or unions have a SymEntry attribute */ CHECK (IsClassStruct (T)); /* Set the attribute */ T->A.P = S; }
SymEntry* GetSymEntry (const Type* T) /* Return a SymEntry pointer from a type */ { /* Only structs or unions have a SymEntry attribute */ CHECK (IsClassStruct (T)); /* Return the attribute */ return T->A.P; }
int TypeHasAttr (const Type* T) /* Return true if the given type has attribute data */ { return IsClassStruct (T) || IsTypeArray (T) || IsClassFunc (T); }