Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

usymtab_interface.c File Reference

#include "lclintMacros.nf"
#include "llbasic.h"
#include "gram.h"
#include "lclscan.h"
#include "lclsyntable.h"
#include "lslparse.h"
#include "usymtab_interface.h"
#include "structNames.h"

Go to the source code of this file.

Functions

void doDeclareConstant (constDeclarationNode c, bool priv)
void doDeclareVar (varDeclarationNode v, bool priv)
void doDeclareType (typeNode t, bool priv)
void declareIter (iterNode iter)
void doDeclareFcn (fcnNode f, typeId tn, bool priv, bool spec)


Function Documentation

void declareIter ( iterNode iter )
 

Definition at line 1024 of file usymtab_interface.c.

01025 {
01026   fileloc loc = fileloc_fromTok (iter->name);
01027   uentry ue = 
01028     uentry_makeIter (ltoken_unparse (iter->name), 
01029                      ctype_makeFunction 
01030                      (ctype_void,
01031                       paramNodeList_toUentryList (iter->params)), 
01032                      fileloc_copy (loc));
01033   
01034   usymtab_supEntry (ue);
01035   usymtab_supEntry 
01036     (uentry_makeEndIter (ltoken_unparse (iter->name), loc));
01037 }

void doDeclareConstant ( constDeclarationNode c,
bool priv )
 

Definition at line 619 of file usymtab_interface.c.

00620 {
00621   lclTypeSpecNode t;
00622   ctype ctx;
00623   qtype qt;
00624   
00625   if (c == (constDeclarationNode) 0)
00626     {
00627       return;
00628     }
00629 
00630   t = c->type;
00631   qt = convertLclTypeSpecNode (t);
00632 
00633   ctx = qtype_getType (qt);
00634 
00635   initDeclNodeList_elements (c->decls, i)
00636     {
00637       ctype ct = convertTypeExpr (ctx, i->declarator->type);
00638       cstring s = getVarName (i->declarator->type);
00639 
00640       if (ctype_isFunction (ct))
00641         {
00642           fcnNode fcn = fcnNode_fromDeclarator (lclTypeSpecNode_copy (t), 
00643                                                 declaratorNode_copy (i->declarator));
00644 
00645           /* FALSE == unspecified function, only a declaration */
00646 
00647           doDeclareFcn (fcn, typeId_invalid, priv, FALSE);
00648           fcnNode_free (fcn);
00649         }
00650       else
00651         {
00652           uentry ue;
00653           fileloc loc = fileloc_fromTok (i->declarator->id);
00654 
00655           if (i->value != (termNode)0 &&
00656               i->value->kind == TRM_LITERAL)
00657             {
00658               ue = uentry_makeConstantAux (s, ct, loc, priv, 
00659                                            literalValue (ct, i->value->literal));
00660             }
00661           else
00662             {
00663               ue = uentry_makeConstantAux (s, ct, loc, priv, multiVal_unknown ());
00664             }
00665 
00666                   uentry_reflectQualifiers (ue, qtype_getQuals (qt));
00667 
00668           
00669           if (context_inLCLLib () && !priv)
00670             {
00671               uentry_setDefined (ue, loc);
00672             }
00673 
00674           usymtab_supGlobalEntry (ue);
00675         }
00676     } end_initDeclNodeList_elements;
00677 
00678   qtype_free (qt);
00679 }

void doDeclareFcn ( fcnNode f,
typeId tn,
bool priv,
bool spec )
 

Definition at line 1228 of file usymtab_interface.c.

Referenced by doDeclareConstant().

01229 {
01230   qtype qt = convertLclTypeSpecNode (f->typespec);
01231   ctype ct = convertTypeExpr (qtype_getType (qt), f->declarator->type);
01232 
01233     declareFcnAux (f, qt, ct, tn, priv, spec);
01234 }

void doDeclareType ( typeNode t,
bool priv )
 

Definition at line 997 of file usymtab_interface.c.

00998 {
00999   
01000   if (t != (typeNode) 0)
01001     {
01002       switch (t->kind)
01003         {
01004         case TK_ABSTRACT:
01005           declareAbstractType (t->content.abstract, priv);
01006           break;
01007           
01008         case TK_EXPOSED:
01009           declareExposedType (t->content.exposed, priv);
01010           break;
01011           
01012         case TK_UNION:
01013         default:
01014           {
01015             llfatalbug (message ("declareType ERROR: unknown kind: %q",
01016                                  cstring_fromCharsO (FormatInt ((int)t->kind))));
01017           }
01018         }
01019     }
01020   
01021 }

void doDeclareVar ( varDeclarationNode v,
bool priv )
 

Definition at line 711 of file usymtab_interface.c.

00712 {
00713   lclTypeSpecNode t;
00714   qtype c;
00715 
00716   if (v == (varDeclarationNode) 0)
00717     {
00718       return;
00719     }
00720 
00721   t = v->type;
00722   c = convertLclTypeSpecNode (t);
00723 
00724   initDeclNodeList_elements (v->decls, i)
00725     {
00726       ctype ct = convertTypeExpr (qtype_getType (c), i->declarator->type);
00727       cstring s = getVarName (i->declarator->type);
00728 
00729       qtype_setType (c, ct);
00730 
00731       if (ctype_isFunction (ct))
00732         {
00733           fcnNode fcn;
00734 
00735                   
00736           fcn = fcnNode_fromDeclarator (lclTypeSpecNode_copy (t), 
00737                                         declaratorNode_copy (i->declarator));
00738 
00739           /* FALSE == unspecified function, only a declaration */
00740           declareFcnAux (fcn, qtype_unknown (), ct,
00741                          typeId_invalid, priv, FALSE);
00742           fcnNode_free (fcn);
00743         }
00744       else
00745         {
00746           fileloc loc = fileloc_fromTok (i->declarator->id);
00747           uentry le = uentry_makeVariable (s, ct, loc, priv);
00748           
00749           uentry_reflectQualifiers (le, qtype_getQuals (c));
00750           
00751           if (uentry_isCheckedUnknown (le))
00752             {
00753               if (context_getFlag (FLG_IMPCHECKEDSTRICTSPECGLOBALS))
00754                 {
00755                   uentry_setCheckedStrict (le);
00756                 }
00757               else if (context_getFlag (FLG_IMPCHECKEDSPECGLOBALS))
00758                 {
00759                   uentry_setChecked (le);
00760                 }
00761               else if (context_getFlag (FLG_IMPCHECKMODSPECGLOBALS))
00762                 {
00763                   uentry_setCheckMod (le);
00764                 }
00765               else
00766                 {
00767                   ; /* okay */
00768                 }
00769             }
00770 
00771           if (context_inLCLLib () && !priv)
00772             {
00773               uentry_setDefined (le, loc);
00774             }
00775 
00776           if (initDeclNode_isRedeclaration (i))
00777             {
00778               usymtab_replaceEntry (le);
00779             }
00780           else
00781             {
00782               le = usymtab_supEntrySrefReturn (le);
00783             }
00784         }
00785     } end_initDeclNodeList_elements;
00786 
00787   qtype_free (c);
00788 }


Generated at Fri Nov 3 18:58:22 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000