/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Bell Laboratories25*26* hash table library27*/2829#include "hashlib.h"3031/*32* push/pop/query hash table scope33*34* bot==0 pop top scope35* bot==top query36* bot!=0 push top on bot37*38* scope table pointer returned39*/4041Hash_table_t*42hashview(Hash_table_t* top, Hash_table_t* bot)43{44register Hash_bucket_t* b;45register Hash_bucket_t* p;46register Hash_bucket_t** sp;47register Hash_bucket_t** sx;4849if (!top || top->frozen)50bot = 0;51else if (top == bot)52bot = top->scope;53else if (bot)54{55if (top->scope)56bot = 0;57else58{59sx = &top->table[top->size];60sp = &top->table[0];61while (sp < sx)62for (b = *sp++; b; b = b->next)63if (p = (Hash_bucket_t*)hashlook(bot, b->name, HASH_LOOKUP, NiL))64{65b->name = (p->hash & HASH_HIDES) ? p->name : (char*)b;66b->hash |= HASH_HIDES;67}68top->scope = bot;69bot->frozen++;70}71}72else if (bot = top->scope)73{74sx = &top->table[top->size];75sp = &top->table[0];76while (sp < sx)77for (b = *sp++; b; b = b->next)78if (b->hash & HASH_HIDES)79{80b->hash &= ~HASH_HIDES;81b->name = ((Hash_bucket_t*)b->name)->name;82}83top->scope = 0;84bot->frozen--;85}86return(bot);87}888990