]> git.sur5r.net Git - cc65/blobdiff - src/ca65/objfile.c
Finished implemenation of commands to delete macros. Added the new commands to
[cc65] / src / ca65 / objfile.c
index 50bcafcf475b00930a8775fc310c7f5bf190fe3b..f9fba1521141de0c06e30920ad7acf52e4217392 100644 (file)
@@ -7,7 +7,7 @@
 /*                                                                           */
 /*                                                                           */
 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
+/*               Römerstraße 52                                              */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
@@ -83,7 +83,9 @@ static ObjHeader Header = {
     0,                  /* 32: Offset to string pool */
     0,                  /* 32: Size of string pool */
     0,                  /* 32: Offset to assertion table */
-    0                   /* 32: Size of assertion table */
+    0,                  /* 32: Size of assertion table */
+    0,                  /* 32: Offset into scope table */
+    0,                  /* 32: Size of scope table */
 };
 
 
@@ -109,7 +111,7 @@ static void ObjWriteError (void)
     remove (OutFile);
 
     /* Now abort with a fatal error */
-    Fatal (FAT_CANNOT_WRITE_OUTPUT, OutFile, strerror (Error));
+    Fatal ("Cannot write to output file `%s': %s", OutFile, strerror (Error));
 }
 
 
@@ -138,6 +140,8 @@ static void ObjWriteHeader (void)
     ObjWrite32 (Header.StrPoolSize);
     ObjWrite32 (Header.AssertOffs);
     ObjWrite32 (Header.AssertSize);
+    ObjWrite32 (Header.ScopeOffs);
+    ObjWrite32 (Header.ScopeSize);
 }
 
 
@@ -162,7 +166,7 @@ void ObjOpen (void)
     /* Create the output file */
     F = fopen (OutFile, "w+b");
     if (F == 0) {
-       Fatal (FAT_CANNOT_OPEN_OUTPUT, OutFile, strerror (errno));
+       Fatal ("Cannot open output file `%s': %s", OutFile, strerror (errno));
     }
 
     /* Write a dummy header */
@@ -292,6 +296,19 @@ void ObjWriteStr (const char* S)
 
 
 
+void ObjWriteBuf (const StrBuf* S)
+/* Write a string to the object file */
+{
+    /* Write the string with the length preceeded (this is easier for
+     * the reading routine than the C format since the length is known in
+     * advance).
+     */
+    ObjWriteVar (SB_GetLen (S));
+    ObjWriteData (SB_GetConstBuf (S), SB_GetLen (S));    
+}
+
+
+
 void ObjWriteData (const void* Data, unsigned Size)
 /* Write literal data to the file */
 {
@@ -462,3 +479,19 @@ void ObjEndAssertions (void)
 
 
 
+void ObjStartScopes (void)
+/* Mark the start of the scope table */
+{
+    Header.ScopeOffs = ftell (F);
+}
+
+
+
+void ObjEndScopes (void)
+/* Mark the end of the scope table */
+{
+    Header.ScopeSize = ftell (F) - Header.ScopeOffs;
+}
+
+
+