]> git.sur5r.net Git - cc65/commitdiff
Prepare for separate ASM name in symbol table entry
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 18 Mar 2002 20:04:03 +0000 (20:04 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 18 Mar 2002 20:04:03 +0000 (20:04 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1202 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/expr.c
src/cc65/symentry.c
src/cc65/symentry.h

index 57d3ca89e4b6ce85f2d4079926563a6af0308a8f..dd2469387b9668c8a26c67c928f4bd0e5ba9f39d 100644 (file)
@@ -832,8 +832,9 @@ static int primary (ExprDesc* lval)
 {
     int k;
 
-    /* not a test at all, yet */
-    lval->Test = 0;
+    /* Initialize fields in the expression stucture */
+    lval->Test = 0;             /* No test */
+    lval->Sym  = 0;             /* Symbol unknown */
 
     /* Character and integer constants. */
     if (CurTok.Tok == TOK_ICONST || CurTok.Tok == TOK_CCONST) {
@@ -872,7 +873,7 @@ static int primary (ExprDesc* lval)
        ident Ident;
 
        /* Get a pointer to the symbol table entry */
-               Sym = FindSym (CurTok.Ident);
+               Sym = lval->Sym = FindSym (CurTok.Ident);
 
        /* Is the symbol known? */
        if (Sym) {
@@ -2283,7 +2284,7 @@ static void parsesub (int k, ExprDesc* lval)
                if (TypeCmp (Indirect (lhst), Indirect (rhst)) < TC_QUAL_DIFF) {
                    Error ("Incompatible pointer types");
                } else {
-                   lval->ConstVal = (lval->ConstVal - lval2.ConstVal) / 
+                   lval->ConstVal = (lval->ConstVal - lval2.ConstVal) /
                                       CheckedPSizeOf (lhst);
                }
                /* Operate on pointers, result type is an integer */
index ff292a70412ffde2204b2457d025dbd9a82ae799..578c6c0054d38ef9e11e20fbc5197a83e7a77d7f 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -66,6 +66,7 @@ SymEntry* NewSymEntry (const char* Name, unsigned Flags)
     E->Owner   = 0;
     E->Flags   = Flags;
     E->Type    = 0;
+    E->AsmName  = 0;
     memcpy (E->Name, Name, Len+1);
 
     /* Return the new entry */
@@ -78,6 +79,7 @@ void FreeSymEntry (SymEntry* E)
 /* Free a symbol entry */
 {
     TypeFree (E->Type);
+    xfree (E->AsmName);
     xfree (E);
 }
 
@@ -87,19 +89,19 @@ void DumpSymEntry (FILE* F, const SymEntry* E)
 /* Dump the given symbol table entry to the file in readable form */
 {
     static const struct {
-       const char*         Name;
-       unsigned            Val;
+       const char*         Name;
+       unsigned            Val;
     } Flags [] = {
        /* Beware: Order is important! */
        { "SC_TYPEDEF",     SC_TYPEDEF  },
-       { "SC_SFLD",        SC_SFLD     },
-       { "SC_STRUCT",      SC_STRUCT   },
+       { "SC_SFLD",        SC_SFLD     },
+       { "SC_STRUCT",      SC_STRUCT   },
        { "SC_AUTO",        SC_AUTO     },
        { "SC_REGISTER",    SC_REGISTER },
        { "SC_STATIC",      SC_STATIC   },
-       { "SC_EXTERN",      SC_EXTERN   },
-       { "SC_ENUM",        SC_ENUM     },
-       { "SC_CONST",       SC_CONST    },
+       { "SC_EXTERN",      SC_EXTERN   },
+       { "SC_ENUM",        SC_ENUM     },
+       { "SC_CONST",       SC_CONST    },
        { "SC_LABEL",       SC_LABEL    },
        { "SC_PARAM",       SC_PARAM    },
        { "SC_FUNC",        SC_FUNC     },
@@ -115,6 +117,11 @@ void DumpSymEntry (FILE* F, const SymEntry* E)
     /* Print the name */
     fprintf (F, "%s:\n", E->Name);
 
+    /* Print the assembler name if we have one */
+    if (E->AsmName) {
+        fprintf (F, "    AsmName: %s\n", E->AsmName);
+    }
+
     /* Print the flags */
     SymFlags = E->Flags;
     fprintf (F, "    Flags: ");
@@ -158,4 +165,12 @@ void ChangeSymType (SymEntry* Entry, type* Type)
 
 
 
+void ChangeAsmName (SymEntry* Entry, const char* NewAsmName)
+/* Change the assembler name of the symbol */              
+{
+    xfree (Entry->AsmName);
+    Entry->AsmName = xstrdup (NewAsmName);
+}
+
+
 
index 6fe4ce7f04515e1532805227dc9ec598da9b3214..ba87236441fcd578921c9d364430821493666c2b 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/* (C) 2000-2002 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
 /* EMail:        uz@cc65.org                                                 */
@@ -98,6 +98,7 @@ struct SymEntry {
     struct SymTable*           Owner;    /* Symbol table the symbol is in */
     unsigned                           Flags;    /* Symbol flags */
     type*                              Type;     /* Symbol type */
+    char*                       AsmName;  /* Assembler name if any */
 
     /* Data that differs for the different symbol types */
     union {
@@ -150,6 +151,9 @@ int IsTypeDef (const SymEntry* E);
 void ChangeSymType (SymEntry* Entry, type* Type);
 /* Change the type of the given symbol */
 
+void ChangeAsmName (SymEntry* Entry, const char* NewAsmName);
+/* Change the assembler name of the symbol */
+
 
 
 /* End of symentry.h */