/* */
/* */
/* */
-/* (C) 2000-2002 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@cc65.org */
+/* (C) 2000-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* cc65 */
#include "anonname.h"
+#include "declare.h"
+#include "error.h"
#include "symentry.h"
E->Owner = 0;
E->Flags = Flags;
E->Type = 0;
+ E->Attr = 0;
E->AsmName = 0;
memcpy (E->Name, Name, Len+1);
} Flags [] = {
/* Beware: Order is important! */
{ "SC_TYPEDEF", SC_TYPEDEF },
+ { "SC_BITFIELD", SC_BITFIELD },
{ "SC_STRUCTFIELD", SC_STRUCTFIELD },
{ "SC_STRUCT", SC_STRUCT },
{ "SC_AUTO", SC_AUTO },
+int SymIsOutputFunc (const SymEntry* Sym)
+/* Return true if this is a function that must be output */
+{
+ /* Symbol must be a function which is defined and either extern or
+ * static and referenced.
+ */
+ return IsTypeFunc (Sym->Type) &&
+ SymIsDef (Sym) &&
+ (Sym->Flags & (SC_REF | SC_EXTERN));
+}
+
+
+
+const DeclAttr* SymGetAttr (const SymEntry* Sym, DeclAttrType AttrType)
+/* Return an attribute for this symbol or NULL if the attribute does not exist */
+{
+ /* Beware: We may not even have a collection */
+ if (Sym->Attr) {
+ unsigned I;
+ for (I = 0; I < CollCount (Sym->Attr); ++I) {
+
+ /* Get the next attribute */
+ const DeclAttr* A = CollConstAt (Sym->Attr, I);
+
+ /* If this is the one we're searching for, return it */
+ if (A->AttrType == AttrType) {
+ return A;
+ }
+ }
+ }
+
+ /* Not found */
+ return 0;
+}
+
+
+
+void SymUseAttr (SymEntry* Sym, struct Declaration* D)
+/* Use the attributes from the declaration for this symbol */
+{
+ /* We cannot specify attributes twice */
+ if ((Sym->Flags & SC_HAVEATTR) != 0) {
+ if (D->Attributes != 0) {
+ Error ("Attributes must be specified in the first declaration");
+ }
+ return;
+ }
+
+ /* Move the attributes */
+ Sym->Attr = D->Attributes;
+ D->Attributes = 0;
+ Sym->Flags |= SC_HAVEATTR;
+}
+
+
+
void CvtRegVarToAuto (SymEntry* Sym)
/* Convert a register variable to an auto variable */
{
-void ChangeSymType (SymEntry* Entry, type* Type)
+void ChangeSymType (SymEntry* Entry, Type* T)
/* Change the type of the given symbol */
{
TypeFree (Entry->Type);
- Entry->Type = TypeDup (Type);
+ Entry->Type = TypeDup (T);
}