]> git.sur5r.net Git - cc65/blobdiff - src/ld65/objdata.h
Add translation from PETSCII to screen codes.
[cc65] / src / ld65 / objdata.h
index 92202977fc4f8c7136a9dde9d28bfa8e07d644a5..554fe0c6bbfc302b96603f89820bef91f5429b26 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                objdata.h                                 */
+/*                                 objdata.h                                 */
 /*                                                                           */
-/*              Handling object file data for the ld65 linker               */
+/*               Handling object file data for the ld65 linker               */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2011, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 /* common */
+#include "coll.h"
+#include "inline.h"
 #include "objdefs.h"
 
 
 
 /*****************************************************************************/
-/*                                          Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
 
-/* Values for the Flags field */
-#define        OBJ_REF         0x0001          /* We have a reference to this file */
-#define OBJ_HAVEDATA   0x0002          /* We have this object file already */
-#define OBJ_MARKED             0x0004          /* Generic marker bit */
+/* Forwards */
+struct Export;
+struct Import;
+struct Library;
+struct Scope;
+struct Section;
+struct StrBuf;
 
+/* Values for the Flags field */
+#define OBJ_REF         0x0001          /* We have a reference to this file */
 
 /* Internal structure holding object file data */
 typedef struct ObjData ObjData;
 struct ObjData {
-    ObjData*           Next;           /* Linked list of all objects */
-    char*              Name;           /* Module name */
-    char*                      LibName;        /* Name of library */
-    ObjHeader          Header;         /* Header of file */
-    unsigned long      Start;          /* Start offset of data in library */
-    unsigned           Flags;
-    unsigned           FileCount;      /* Input file count */
-    char**             Files;          /* List of input files */
-    unsigned           SectionCount;   /* Count of sections in this object */
-    struct Section**   Sections;       /* List of all sections */
-    unsigned           ExportCount;    /* Count of exports */
-    struct Export**    Exports;        /* List of all exports */
-    unsigned           ImportCount;    /* Count of imports */
-    struct Import**    Imports;        /* List of all imports */
-    unsigned           DbgSymCount;    /* Count of debug symbols */
-    struct DbgSym**    DbgSyms;        /* List of debug symbols */
+    ObjData*            Next;           /* Linked list of all objects */
+    unsigned            Id;             /* Id of this module */
+    unsigned            Name;           /* Module name */
+    struct Library*     Lib;            /* Library where module comes from */
+    unsigned long       MTime;          /* Time of last modification */
+    ObjHeader           Header;         /* Header of file */
+    unsigned long       Start;          /* Start offset of data in library */
+    unsigned            Flags;
+
+    unsigned            HLLSymBaseId;   /* Debug info base id for hll symbols */
+    unsigned            SymBaseId;      /* Debug info base id for symbols */
+    unsigned            ScopeBaseId;    /* Debug info base id for scopes */
+    unsigned            SpanBaseId;     /* Debug info base id for spans */
+
+    Collection          Files;          /* List of input files */
+    Collection          Sections;       /* List of all sections */
+    Collection          Exports;        /* List of all exports */
+    Collection          Imports;        /* List of all imports */
+    Collection          DbgSyms;        /* List of debug symbols */
+    Collection          HLLDbgSyms;     /* List of hll debug symbols */
+    Collection          LineInfos;      /* List of line infos */
+    unsigned            StringCount;    /* Count of strings */
+    unsigned*           Strings;        /* List of global string indices */
+    Collection          Assertions;     /* List of module assertions */
+    Collection          Scopes;         /* List of scopes */
+    Collection          Spans;          /* List of spans */
 };
 
 
 
-/* Object data list management */
-extern unsigned                ObjCount;       /* Count of files in the list */
-extern ObjData*                ObjRoot;        /* List of object files */
-extern ObjData*                ObjLast;        /* Last entry in list */
+/* Collection containing used ObjData objects */
+extern Collection       ObjDataList;
 
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -95,24 +110,68 @@ ObjData* NewObjData (void);
 /* Allocate a new structure on the heap, insert it into the list, return it */
 
 void FreeObjData (ObjData* O);
-/* Free a complete struct */
+/* Free an ObjData object. NOTE: This function works only for unused object
+** data, that is, ObjData objects that aren't used because they aren't
+** referenced.
+*/
+
+void FreeObjStrings (ObjData* O);
+/* Free the module string data. Used once the object file is loaded completely
+** when all strings are converted to global strings.
+*/
+
+void InsertObjData (ObjData* O);
+/* Insert the ObjData object into the collection of used ObjData objects. */
+
+void InsertObjGlobals (ObjData* O);
+/* Insert imports and exports from the object file into the global import and
+** export lists.
+*/
+
+unsigned MakeGlobalStringId (const ObjData* O, unsigned Index);
+/* Convert a local string id into a global one and return it. */
 
 const char* GetObjFileName (const ObjData* O);
-/* Get the name of the object file. Return "(linker generated)" if the object
- * file is NULL.
- */
+/* Get the name of the object file. Return "[linker generated]" if the object
+** file is NULL.
+*/
+
+#if defined(HAVE_INLINE)
+INLINE int ObjHasFiles (const ObjData* O)
+/* Return true if the files list does exist */
+{
+    return (O != 0 && CollCount (&O->Files) != 0);
+}
+#else
+#  define ObjHasFiles(O)       ((O) != 0 && CollCount (&(O)->Files) != 0)
+#endif
 
-const char* GetSourceFileName (const ObjData* O, unsigned Index);
-/* Get the name of the source file with the given index. If O is NULL, return
- * "(linker generated)" as the file name.
- */
+const struct StrBuf* GetObjString (const ObjData* Obj, unsigned Id);
+/* Get a string from an object file checking for an invalid index */
 
+struct Section* GetObjSection (const ObjData* Obj, unsigned Id);
+/* Get a section from an object file checking for a valid index */
 
+struct Import* GetObjImport (const ObjData* Obj, unsigned Id);
+/* Get an import from an object file checking for a valid index */
 
-/* End of objdata.h */
+struct Export* GetObjExport (const ObjData* Obj, unsigned Id);
+/* Get an export from an object file checking for a valid index */
 
-#endif
+struct DbgSym* GetObjDbgSym (const ObjData* Obj, unsigned Id);
+/* Get a debug symbol from an object file checking for a valid index */
+
+struct Scope* GetObjScope (const ObjData* Obj, unsigned Id);
+/* Get a scope from an object file checking for a valid index */
+
+unsigned ObjDataCount (void);
+/* Return the total number of modules */
 
+void PrintDbgModules (FILE* F);
+/* Output the modules to a debug info file */
 
 
 
+/* End of objdata.h */
+
+#endif