C:/Users/Dennis/src/lang/russell.orig/src/pass3/hasstring.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 extern int indx_sconc, indx_pconc, indx_empty;
00008 
00009 /*
00010  *  hasstring(type_signature, string)
00011  * 
00012  *  Returns either TRUE or FALSE depending on whether the given type
00013  * signature has all components required for expansion of the given
00014  * string.  String is a pointer to a QSTR or UQSTR node.
00015  *  It is assumed that the type signature has been converted to
00016  * normal form.
00017  */
00018 
00019 hasstring(sig,string)
00020 NODE * sig;
00021 NODE * string;
00022 {
00023     register NODE * p;
00024     register char * curr_char;  /* character currently being checked for */
00025     boolean has_empty;
00026     NODE * const_node;
00027 
00028     int i;
00029 
00030 #   ifdef DEBUG
00031         if (sig -> kind != TYPESIGNATURE) {
00032             dbgmsg("hasstring: bad type signature\n");
00033             abort();
00034         }
00035 #   endif
00036 
00037     switch(string -> kind) {
00038         case QSTR:
00039             if(!hascomp(sig, indx_sconc)) {
00040                 return(FALSE);
00041             }
00042             /* check whether sig has a constant '' */
00043                 has_empty = FALSE;
00044                 maplist(p, sig -> ts_clist, {
00045                     if (p -> kind == TSCOMPONENT) {
00046                         if (p -> tsc_id -> id_str_table_index == indx_empty) {
00047                              if (is_const(p->tsc_signature,sig))
00048                                 has_empty = TRUE;
00049                         }
00050                     }
00051                 });
00052                 if (!has_empty) return(FALSE);
00053             break;
00054         case UQSTR:
00055             if(!hascomp(sig, indx_pconc)) {
00056                 return(FALSE);
00057             }
00058             break;
00059 #       ifdef DEBUG
00060             default:
00061                 dbgmsg("hasstring: bad string\n");
00062 #       endif
00063     }
00064 
00065     /* check that all characters are present as constants in the type */
00066         const_node = first(sig -> ts_clist);
00067 #       ifdef DEBUG
00068             if(const_node -> kind != DEFCHARSIGS) {
00069                 dbgmsg("hasstring: Unnormalized type signature\n");
00070             }
00071 #       endif
00072         for (curr_char = string -> str_string; *curr_char != '\0'; curr_char++) {
00073             /* Check whether the character is present in const_node */
00074                 unsigned word;
00075                 int bitno;
00076                 int wordno;
00077                 unsigned * base = &(const_node -> dcs_0);
00078 
00079                 wordno = ((int) *curr_char) / WORDLENGTH;
00080                 word = *(base + wordno);
00081                 bitno = ((int) *curr_char) - wordno * WORDLENGTH;
00082 
00083                 if ( (((int) word) << bitno) >= 0) {
00084                     /* constant does not appear */
00085                         return(FALSE);
00086                 }
00087         }
00088     return(TRUE);
00089 }
00090 

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