/* ------------------------------------------------------------------------ * $Id: symbol.c,v 1.3 2003/08/01 14:50:50 panne Exp $ * * Copyright (C) 1995-2000 University of Oxford * * Permission to use, copy, modify, and distribute this software, * and to incorporate it, in whole or in part, into other software, * is hereby granted without fee, provided that * (1) the above copyright notice and this permission notice appear in * all copies of the source code, and the above copyright notice * appear in clearly visible form on all supporting documentation * and distribution media; * (2) modified versions of this software be accompanied by a complete * change history describing author, date, and modifications made; * and * (3) any redistribution of the software, in original or modified * form, be without fee and subject to these same conditions. * --------------------------------------------------------------------- */ #include #include "symbol.h" /* ----------------------------------------------------------------------------- * Data structures * -------------------------------------------------------------------------- */ int symbol_table_next=0; int symbol_table_size=0; name_object *symbol_table=NULL; /* ----------------------------------------------------------------------------- * Create/grow symbol table * -------------------------------------------------------------------------- */ void enlargeSymbolTable() { if (symbol_table_size==0) { symbol_table_next = 0; symbol_table_size = SYMBOL_TABLE_INIT_SIZE; symbol_table = calloc(symbol_table_size,sizeof(name_object)); } else { symbol_table_size += SYMBOL_TABLE_INIT_SIZE; symbol_table = realloc(symbol_table, symbol_table_size*sizeof(name_object)); } if (symbol_table==NULL) { fprintf(stderr,"{enlargeSymbolTable} unable to allocate %d elements", symbol_table_size); exit(1); } } /* ----------------------------------------------------------------------------- * Lookup/add name to symbol table * -------------------------------------------------------------------------- */ name_id lookupSymbolTable(int type,int lineno,char* str) { int i; extern FILE *logFile; for(i=0;i