]> git.sur5r.net Git - cc65/blobdiff - src/ld65/exports.h
New module strstack
[cc65] / src / ld65 / exports.h
index 46a9646b0e30a95cdce2e09492a1552ef6cfebcc..bfdca3c1f8fcbd60f0104e86aec1fa613e6baa2b 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               Römerstraße 52                                              */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 #include <stdio.h>
 
-#include "../common/exprdefs.h"
-#include "../common/filepos.h"
+/* common */
+#include "cddefs.h"
+#include "exprdefs.h"
+#include "filepos.h"
 
+/* ld65 */
 #include "objdata.h"
 #include "config.h"
 
 
 
 /* Import symbol structure */
-typedef struct Import_ Import;
-struct Import_ {
-    Import*            Next;           /* Single linked list */
-    ObjData*           Obj;            /* Object file that imports the name */
-    FilePos            Pos;            /* File position of reference */
-    union {
-       struct Export_* Exp;            /* Matching export for this import */
-       const char*     Name;           /* Name if not in table */
-    } V;
-    unsigned char      Type;           /* Type of import */
+typedef struct Import Import;
+struct Import {
+    Import*            Next;           /* Single linked list */
+    ObjData*           Obj;            /* Object file that imports the name */
+    FilePos            Pos;            /* File position of reference */
+    struct Export*     Exp;            /* Matching export for this import */
+    unsigned            Name;          /* Name if not in table */
+    unsigned char       Flags;          /* Generic flags */
+    unsigned char      AddrSize;       /* Address size of import */
 };
 
 
 
 /* Export symbol structure */
-typedef struct Export_ Export;
-struct Export_ {
+typedef struct Export Export;
+struct Export {
+    unsigned            Name;                  /* Name */
     Export*                    Next;           /* Hash table link */
-    unsigned           Flags;          /* Generic flags */
-    ObjData*           Obj;            /* Object file that exports the name */
-    unsigned           ImpCount;       /* How many imports for this symbol? */
-    Import*            ImpList;        /* List of imports for this symbol */
-    FilePos            Pos;            /* File position of definition */
+    unsigned           Flags;          /* Generic flags */
+    ObjData*           Obj;            /* Object file that exports the name */
+    unsigned           ImpCount;       /* How many imports for this symbol? */
+    Import*            ImpList;        /* List of imports for this symbol */
+    FilePos            Pos;            /* File position of definition */
     ExprNode*                  Expr;           /* Expression (0 if not def'd) */
     unsigned char      Type;           /* Type of export */
-    char               Name [1];       /* Name - dynamically allocated */
+    unsigned char       AddrSize;       /* Address size of export */
+    unsigned char      ConDes[CD_TYPE_COUNT];  /* Constructor/destructor decls */
 };
 
 
@@ -91,7 +95,7 @@ struct Export_ {
  * resolved, or a value != zero if the symbol could be resolved. The
  * CheckExports routine will print out the missing symbol in the first case.
  */
-typedef int (*ExpCheckFunc) (const char* Name, void* Data);
+typedef int (*ExpCheckFunc) (unsigned Name, void* Data);
 
 
 
@@ -101,27 +105,53 @@ typedef int (*ExpCheckFunc) (const char* Name, void* Data);
 
 
 
+void FreeImport (Import* I);
+/* Free an import. NOTE: This won't remove the import from the exports table,
+ * so it may only be called for unused imports (imports from modules that
+ * aren't referenced).
+ */
+
 Import* ReadImport (FILE* F, ObjData* Obj);
 /* Read an import from a file and insert it into the table */
 
 void InsertImport (Import* I);
 /* Insert an import into the table */
 
+void FreeExport (Export* E);
+/* Free an export. NOTE: This won't remove the export from the exports table,
+ * so it may only be called for unused exports (exports from modules that
+ * aren't referenced).
+ */
+
 Export* ReadExport (FILE* F, ObjData* Obj);
 /* Read an export from a file */
 
 void InsertExport (Export* E);
 /* Insert an exported identifier and check if it's already in the list */
 
-Export* CreateConstExport (const char* Name, long Value);
+Export* CreateConstExport (unsigned Name, long Value);
 /* Create an export for a literal date */
 
-Export* CreateMemExport (const char* Name, Memory* Mem, unsigned long Offs);
+Export* CreateMemoryExport (unsigned Name, Memory* Mem, unsigned long Offs);
 /* Create an relative export for a memory area offset */
 
-int IsUnresolved (const char* Name);
+Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs);
+/* Create a relative export to a segment */
+
+Export* CreateSectionExport (unsigned Name, Section* S, unsigned long Offs);
+/* Create a relative export to a section */
+
+Export* FindExport (unsigned Name);
+/* Check for an identifier in the list. Return 0 if not found, otherwise
+ * return a pointer to the export.
+ */
+
+int IsUnresolved (unsigned Name);
 /* Check if this symbol is an unresolved export */
 
+int IsUnresolvedExport (const Export* E);
+/* Return true if the given export is unresolved */
+
 int IsConstExport (const Export* E);
 /* Return true if the expression associated with this export is const */
 
@@ -159,6 +189,7 @@ void CircularRefError (const Export* E);
 /* End of exports.h */
 
 #endif
+