gnupic: Local symbols


Previous by date: 7 Nov 2004 01:43:27 +0000 Re: hyperterminal equivalent for linux?, David McNab
Next by date: 7 Nov 2004 01:43:27 +0000 Re: PICs on Linux, easlab.absamail.co.za
Previous in thread: 7 Nov 2004 01:43:27 +0000 Re: Local symbols, Craig Franklin
Next in thread: 7 Nov 2004 01:43:27 +0000 Re: Local symbols, Vangelis Rokas

Subject: Local symbols
From: "George M. Gallant" ####@####.####
Date: 7 Nov 2004 01:43:27 +0000
Message-Id: <418D7DAD.6020401@comcast.net>

Craig,

Have you been able to look at the local symbols patch? I have a number of
math routines to check into the pc16 port of sdcc which use local symbols.
Vangelis Roakes just released a file that uses the "@xxx" notation but not
quite as I envision.

George

--- gputils-0.12.3/gplink/map.c	2004-07-24 22:06:06.000000000 -0400
+++ gputils-20040917/gplink/map.c	2004-09-19 15:39:10.000000000 -0400
@@ -222,7 +222,8 @@
         storage = "static";
       }
 
-      map_line("%25s   %#08x %10s %10s %s",
+      if (strstr(symbol->name, "_@") != NULL)
+        map_line("%25s   %#08x %10s %10s %s",
                symbol->name,
                symbol->value,
                location,
--- gputils-0.12.3/libgputils/gpsymbol.c	2004-01-07 01:35:54.000000000 -0500
+++ gputils-20040917/libgputils/gpsymbol.c	2004-09-19 15:30:57.000000000 -0400
@@ -21,6 +21,34 @@
 
 #include "stdhdr.h"
 #include "libgputils.h"
+/*
+ * Function to convert a local symbol name starting with a '@' into
+ * a unique name based on the previous regular name
+ *
+ * "last_perm_name"_"sym_name"
+ *
+ * gmg 09/19/04
+ */
+
+char *last_perm_sym = "";
+
+char *make_local_name(char *sym_name)
+{
+  static char tmp_name[256];
+
+  if (*sym_name == '@')
+  {
+    strcpy(tmp_name, last_perm_sym);
+    strcat(tmp_name, "_");
+    strcat(tmp_name, sym_name);
+  }
+  else
+  {
+    strcpy(tmp_name, sym_name);
+  }
+  return(tmp_name);
+}
+
 
 /* Base the hash func on the 1st, 2nd, 3rd and last characters of the
    string, and its length. */
@@ -78,15 +106,19 @@
 struct symbol *add_symbol(struct symbol_table *table, char *name)
 {
   struct symbol *r;
-  int index = hashfunc(table, name);
+  int index;
+  char *tmp_name;
+  
+  tmp_name = make_local_name(name);
+  index = hashfunc(table, tmp_name);
 
   r = table->hash_table[index];
-  while (r && ((*table->compare)(name, r->name) != 0))
+  while (r && ((*table->compare)(tmp_name, r->name) != 0))
     r = r->next;
 
   if (!r) {     /* No match */
     r = malloc(sizeof(*r));
-    r->name = strdup(name);
+    r->name = strdup(tmp_name);
     r->next = table->hash_table[index];
     r->annotation = NULL;
     table->hash_table[index] = r;
@@ -103,9 +135,12 @@
 {
   struct symbol *r = NULL; 
   struct symbol *last = NULL;
-  int index = hashfunc(table, name);
+  int index;
   int found_symbol = 0;
 
+  name = make_local_name(name);
+  index = hashfunc(table, name);
+
   /* Search for the symbol */
   if (table != NULL) {
     r = table->hash_table[index];
@@ -134,12 +169,15 @@
 struct symbol *get_symbol(struct symbol_table *table, char *name)
 {
   struct symbol *r = NULL;
+  char *tmp_name;
+
+  tmp_name = make_local_name(name);
 
   if (table != NULL) {
-    int index = hashfunc(table, name);
+    int index = hashfunc(table, tmp_name);
 
     r = table->hash_table[index];
-    while (r && ((*table->compare)(name, r->name) != 0))
+    while (r && ((*table->compare)(tmp_name, r->name) != 0))
       r = r->next;
 
     /* If r is still NULL, we didn't match.  Try the prev table on the stack */
@@ -157,7 +195,15 @@
 
 char *get_symbol_name(struct symbol *s)
 {
-  return s->name;
+  char
+    *cp;
+
+  cp = strstr(s->name, "_@");
+  if (cp == NULL)
+    cp = s->name;
+  else
+    cp++;				/* get past the '_' character */
+  return(cp);
 }
 
 void *get_symbol_annotation(struct symbol *s)

Previous by date: 7 Nov 2004 01:43:27 +0000 Re: hyperterminal equivalent for linux?, David McNab
Next by date: 7 Nov 2004 01:43:27 +0000 Re: PICs on Linux, easlab.absamail.co.za
Previous in thread: 7 Nov 2004 01:43:27 +0000 Re: Local symbols, Craig Franklin
Next in thread: 7 Nov 2004 01:43:27 +0000 Re: Local symbols, Vangelis Rokas


Powered by ezmlm-browse 0.20.