From a3e3f8ad875fb2ea96143e13b1b505fd6108acbd Mon Sep 17 00:00:00 2001 From: Mihail Groza Date: Mon, 20 Feb 2017 13:24:49 +0000 Subject: [PATCH] Minor cosmetic clean-up. --- src/usymtab.c | 101 +++++++++++++++++++++------------------------------------- 1 file changed, 37 insertions(+), 64 deletions(-) diff --git a/src/usymtab.c b/src/usymtab.c index 73155b5..600c9c1 100644 --- a/src/usymtab.c +++ b/src/usymtab.c @@ -292,8 +292,7 @@ static /*@notnull@*/ /*@special@*/ usymtab t->nspace = CBASESIZE; t->entries = (uentry *) dmalloc (sizeof (*t->entries) * CBASESIZE); - /* We only use a reftable for branch-level symbol tables. - */ + /* We only use a reftable for branch-level symbol tables. */ t->reftable = (nextlevel ? NULL @@ -483,8 +482,8 @@ usymtab_addEntryQuiet (/*@notnull@*/ usymtab s, /*@keep@*/ uentry e) llparseerror (cstring_makeLiteral ("Declaration outside function scope")); - llcontbug (message ("usymtab_addEntryQuiet: inconsistent state " - "(lexlevel = %d, modFunction = %s) adding: %q", + llcontbug (message ("%s: inconsistent state (lexlevel = %d, " + "modFunction = %s) adding: %q", cstring_fromChars (__func__), s->lexlevel, bool_unparse (sRef_modInFunction ()), uentry_unparse (e))); sRef_setGlobalScope (); @@ -933,8 +932,8 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st, } else { - llcontbug (message ("usymtab_supEntryAux: inconsistent state " - "(lexlevel = %d, modFunction = %s) adding: %q", + llcontbug (message ("%s: inconsistent state (lexlevel = %d," + " modFunction = %s) adding: %q", cstring_fromChars (__func__), st->lexlevel, bool_unparse (sRef_modInFunction ()), uentry_unparse (e))); @@ -1524,8 +1523,8 @@ usymtab_getEntryAux (/*@notnull@*/ usymtab s, usymId uid) if (uid < 0 || uid >= usymId_fromInt (s->nentries)) { - llcontbug (message ("usymtab_getEntry: out of range: level = %d [%d]", - s->lexlevel, uid)); + llcontbug (message ("%s: out of range: level = %d [%d]", + cstring_fromChars (__func__), s->lexlevel, uid)); return uentry_undefined; } @@ -4442,8 +4441,7 @@ void usymtab_exitScope (exprNode expr) } } - if (utab->kind == US_TBRANCH || utab->kind == US_FBRANCH - || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) + if (usymtab_isBranch (utab)) { if (context_inMacro ()) { @@ -4456,17 +4454,15 @@ void usymtab_exitScope (exprNode expr) "macro definition.", context_inFunctionName ())); - while (utab->kind == US_TBRANCH - || utab->kind == US_FBRANCH - || utab->kind == US_CBRANCH - || utab->kind == US_SWITCH) + while (usymtab_isBranch (utab)) { utab = utab->env; llassert (utab != GLOBAL_ENV); } } else { - llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ())); + llcontbug (message ("%s: in branch: %q", + cstring_fromChars (__func__), usymtab_unparseStack ())); /*@-branchstate@*/ } /*@=branchstate@*/ } @@ -4613,8 +4609,8 @@ usymtab_directParamNo (uentry ue) usymtab s = utab; if (!context_inFunctionLike ()) - llfatalbug (message ("usymtab_getParam: not in function context: %q", - context_unparse ())); + llfatalbug (message ("%s: not in function context: %q", + cstring_fromChars (__func__), context_unparse ())); while (s->lexlevel > paramsScope) { @@ -4648,8 +4644,8 @@ usymtab_getRefTab (/*@notnull@*/ usymtab u, int level, usymId index) if (uentry_isUndefined (ue)) { - llbug (message ("usymtab_getRef: out of range: %d. level = %d", - index, level)); + llbug (message ("%s: out of range: %d. level = %d", + cstring_fromChars (__func__), index, level)); } return ue; @@ -4660,29 +4656,27 @@ static /*@dependent@*/ /*@exposed@*/ usymtab { if (s->kind == US_CBRANCH) { - usymtab t = s; - + /* drop all cases (except in nested scopes) */ do { - t = s; s = s->env; llassert (s != GLOBAL_ENV); } while (s->kind == US_CBRANCH); - /* drop all cases (except in nested scopes */ - - s = t; - llassert (s != GLOBAL_ENV); } - - if (s->kind == US_FBRANCH) + else if (s->kind == US_FBRANCH) { - s = s->env; /* skip the true branch */ - llassert (usymtab_isDefined (s)); + /* skip the true branch */ + s = s->env; + llassert (s != GLOBAL_ENV); llassert (s->kind == US_TBRANCH); - } - llassert (s != GLOBAL_ENV); - s = s->env; + s = s->env; + } + else + { + llassert (s != GLOBAL_ENV); + s = s->env; + } return s; } @@ -4969,30 +4963,14 @@ static uentry usymtab_lookupAux (usymtab s, cstring k) if (usymtab_indexFound (eindex)) { uentry ret = s->entries[eindex]; -# if 0 - - - if (s->kind == US_TBRANCH - || s->kind == US_FBRANCH - || s->kind == US_CBRANCH) - /* uentry_isGlobalVariable (ret) && os->lexlevel > fileScope) */ - { - uentry ret; - DPRINTF (("Adding global ref entry: %s", k)); - ret = usymtab_addRefEntry (os, k); - DPRINTF (("Adding ref entry: %s", uentry_unparseFull (ret))); - return ret; - } - -# endif DPRINTF (("Found: %s", uentry_unparseFull (ret))); return (ret); } - if (s->kind == US_TBRANCH || s->kind == US_FBRANCH - || s->kind == US_CBRANCH) + if (s->kind == US_TBRANCH || + s->kind == US_FBRANCH || + s->kind == US_CBRANCH) /* all branches except US_SWITCH */ { - /* why isn't this os??? */ uentry ret = usymtab_addRefEntry (s, k); DPRINTF (("Adding ref entry: %s", uentry_unparseFull (ret))); return ret; @@ -5088,12 +5066,12 @@ uentry if (uentry_isUndefined (ce)) { - llfatalbug (message ("usymtab_lookup: not found: *%s*", k)); + llfatalbug (message ("%s: not found: *%s*", cstring_fromChars (__func__), k)); } if (uentry_isPriv (ce)) { - llfatalbug (message ("usymtab_lookup: private: *%s*", k)); + llfatalbug (message ("%s: private: *%s*", cstring_fromChars (__func__), k)); } return ce; @@ -5110,10 +5088,10 @@ uentry usymtab_lookupGlob (cstring k) uentry ce = usymtab_lookupAux (globtab, k); if (uentry_isUndefined (ce)) - llfatalbug (message ("usymtab_lookup: not found: %s", k)); + llfatalbug (message ("%s: not found: %s", cstring_fromChars (__func__), k)); if (uentry_isPriv (ce)) - llfatalbug (message ("usymtab_lookup: private: %s", k)); + llfatalbug (message ("%s: private: %s", cstring_fromChars (__func__), k)); DPRINTF (("Lookup global: %s", uentry_unparseFull (ce))); return ce; @@ -5134,7 +5112,7 @@ uentry usymtab_lookupEither (cstring k) uentry ce = usymtab_lookupSafe (k); if (uentry_isUndefined (ce)) - llfatalerror (message ("usymtab_lookup: not found: %s", k)); + llfatalerror (message ("%s: not found: %s", cstring_fromChars (__func__), k)); DPRINTF (("Lookup either: %s", uentry_unparseFull (ce))); return ce; @@ -5148,7 +5126,7 @@ usymtab_lookupType (cstring k) if (typeId_isInvalid (uid)) { - llcontbug (message ("usymtab_lookupType: not found: %s", k)); + llcontbug (message ("%s: not found: %s", cstring_fromChars (__func__), k)); return ctype_unknown; } @@ -5162,7 +5140,7 @@ usymtab_lookupAbstractType (cstring k) /*@globals globtab@*/ if (typeId_isInvalid (uid)) { - llcontbug (message ("usymtab_lookupType: not found: %s", k)); + llcontbug (message ("%s: not found: %s", cstring_fromChars (__func__), k)); return ctype_unknown; } @@ -6443,8 +6421,3 @@ usymtab_checkAllValid () /*@globals utab@*/ } # endif - - - - - -- 2.11.4.GIT