C:/Users/Dennis/src/lang/russell.orig/src/pass3/hascomp.c

Go to the documentation of this file.
00001 # include "parm.h"
00002 
00003 # include "stree/ststructs.mh"
00004 
00005 # include "is_local.h"
00006 
00007 # ifdef DEBUG
00008 #   define IFDEBUG(x) x
00009 # else
00010 #   define IFDEBUG(x)
00011 # endif
00012 
00013 char * getname();
00014 
00015 /*
00016  *  hascomp(type_signature, string_table_index)
00017  * 
00018  *  Returns either TRUE or FALSE depending on whether the given type
00019  * signature has a component with name pointed to by the string
00020  * table index.
00021  */
00022 
00023 hascomp(sig,ind)
00024 NODE * sig;
00025 int ind;
00026 {
00027     register NODE * p;
00028     register boolean is_char;
00029                             /* ind refers to a single character quoted id */
00030     char * name;            /* identifier name */
00031     char character;         /* identifier name (non-quote char) when      */
00032                             /* is_char is true.                           */
00033     int i;
00034 
00035 #   ifdef DEBUG
00036         if (sig -> kind != TYPESIGNATURE) {
00037             dbgmsg("hascomp: bad type signature\n");
00038             abort();
00039         }
00040 #   endif
00041 
00042     name = getname(ind);
00043     if(is_char = (name[0] == '\'' && name[2] == '\'')) character = name[1];
00044     maplist(p, sig -> ts_clist, {
00045         if (p -> kind == TSCOMPONENT) {
00046             if (p -> tsc_id -> id_str_table_index == ind) {
00047                 return(TRUE);
00048             }
00049         }
00050         /* Check whether it is a character with a default signature */
00051             if(p -> kind == DEFCHARSIGS && is_char) {
00052 
00053                 unsigned word;
00054                 int bitno;
00055                 int wordno;
00056                 unsigned * base = &(p -> dcs_0);
00057                 unsigned * s;
00058 
00059                 wordno = ((int) character) / WORDLENGTH;
00060                 word = *(base + wordno);
00061                 bitno = ((int) character) - wordno * WORDLENGTH;
00062 
00063                 if ( is_char && (((int) word) << bitno) < 0) {
00064                     /* type component appears in this node */
00065                     return(TRUE);
00066                 }
00067             }
00068         IFDEBUG(
00069             if(p -> kind != TSCOMPONENT && p -> kind != DEFCHARSIGS) {
00070                 dbgmsg("hascomp: bad tsc\n");
00071             }
00072         )
00073     });
00074     /* no matching component */
00075     return(FALSE);
00076 }
00077 

Generated on Fri Jan 25 10:39:46 2008 for russell by  doxygen 1.5.4