CUBRID Engine  latest
esql_symbol_table.c File Reference
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include "esql_grammar.h"
#include "misc_string.h"
#include "esql_misc.h"
#include "memory_alloc.h"
Include dependency graph for esql_symbol_table.c:

Go to the source code of this file.

Classes

struct  linkchunk
 

Macros

#define LCHUNK   10
 

Typedefs

typedef struct linkchunk LINKCHUNK
 

Enumerations

enum  esql_err_msg { MSG_ILLEGAL_ARRAY = 1, MSG_UNKNOWN_CLASS = 2, MSG_BAD_NOUN = 3 }
 

Functions

static void es_print_symbol (SYMBOL *sym, FILE *fp)
 
static void es_print_struct (STRUCTDEF *sdef, FILE *fp)
 
SYMTABpp_new_symtab (void)
 
void pp_free_symtab (SYMTAB *symtab, HT_FREE_FN free_fn)
 
SYMBOLpp_new_symbol (const char *name, int scope)
 
void pp_discard_symbol (SYMBOL *sym)
 
void pp_discard_symbol_chain (SYMBOL *sym)
 
LINKpp_new_link (void)
 
void pp_discard_link_chain (LINK *p)
 
void pp_discard_link (LINK *p)
 
STRUCTDEFpp_new_structdef (const char *tag)
 
void pp_discard_structdef (STRUCTDEF *sdef)
 
void pp_discard_structdef_chain (STRUCTDEF *sdef_chain)
 
STRUCTDEFpp_new_pseudo_def (SPECIFIER_NOUN type, const char *subscript)
 
void pp_add_declarator (SYMBOL *sym, int type)
 
SYMBOLpp_clone_symbol (SYMBOL *sym)
 
LINKpp_clone_type (LINK *tchain, LINK **endp)
 
int pp_the_same_type (LINK *p1, LINK *p2, int relax)
 
char * pp_attr_str (LINK *type)
 
const char * pp_type_str (LINK *link)
 
void pp_print_syms (FILE *fp)
 
SYMBOLpp_findsym (SYMTAB *symtab, unsigned char *name)
 
void pp_symbol_init (void)
 
void pp_symbol_finish (void)
 
void pp_symbol_stats (FILE *fp)
 

Variables

SYMTABpp_Symbol_table
 
SYMTABpp_Struct_table
 
static SYMBOLsymbol_free_list
 
static LINKlink_free_list
 
static STRUCTDEFstruct_free_list
 
static const unsigned int SYMTAB_SIZE = 511
 
static LINKCHUNKlink_chunks
 
static int syms_to_free_lists = 1
 
static int syms_allocated = 0
 
static int syms_deallocated = 0
 
static int sdefs_allocated = 0
 
static int sdefs_deallocated = 0
 
static int links_allocated = 0
 
static int links_deallocated = 0
 

Macro Definition Documentation

#define LCHUNK   10

Definition at line 35 of file esql_symbol_table.c.

Referenced by pp_new_link().

Typedef Documentation

typedef struct linkchunk LINKCHUNK

Enumeration Type Documentation

Enumerator
MSG_ILLEGAL_ARRAY 
MSG_UNKNOWN_CLASS 
MSG_BAD_NOUN 

Definition at line 43 of file esql_symbol_table.c.

Function Documentation

static void es_print_struct ( STRUCTDEF sdef,
FILE *  fp 
)
static

Definition at line 781 of file esql_symbol_table.c.

References structdef::fields, symbol::name, symbol::next, pp_type_str(), structdef::tag, symbol::type, and structdef::type_string.

Referenced by pp_print_syms().

Here is the caller graph for this function:

static void es_print_symbol ( SYMBOL sym,
FILE *  fp 
)
static

Definition at line 769 of file esql_symbol_table.c.

References symbol::level, symbol::name, pp_type_str(), and symbol::type.

Referenced by pp_print_syms().

Here is the caller graph for this function:

void pp_add_declarator ( SYMBOL sym,
int  type 
)
char* pp_attr_str ( LINK type)

Definition at line 620 of file esql_symbol_table.c.

References assert, link::decl, specifier::is_long, specifier::is_short, IS_SPECIFIER, specifier::is_unsigned, N_CHR, N_FLOAT, N_INT, specifier::noun, and link::s.

Referenced by pp_type_str().

Here is the caller graph for this function:

SYMBOL* pp_clone_symbol ( SYMBOL sym)

Definition at line 493 of file esql_symbol_table.c.

References symbol::etype, symbol::level, symbol::name, symbol::next, NULL, pp_clone_type(), pp_new_symbol(), and symbol::type.

Referenced by pp_clone_type().

Here is the caller graph for this function:

LINK* pp_clone_type ( LINK tchain,
LINK **  endp 
)
void pp_discard_link_chain ( LINK p)

Definition at line 248 of file esql_symbol_table.c.

References linkchunk::next, link::next, and pp_discard_link().

Referenced by pp_add_typedefed_spec(), pp_discard_symbol(), pp_free_host_var(), and pp_struct_deref().

Here is the caller graph for this function:

void pp_discard_structdef ( STRUCTDEF sdef)
void pp_discard_structdef_chain ( STRUCTDEF sdef_chain)

Definition at line 369 of file esql_symbol_table.c.

References linkchunk::next, structdef::next, NULL, and pp_discard_structdef().

Referenced by pp_pop_name_scope().

Here is the caller graph for this function:

void pp_discard_symbol_chain ( SYMBOL sym)

Definition at line 183 of file esql_symbol_table.c.

References symbol::next, p, and pp_discard_symbol().

Referenced by pp_discard_link(), pp_discard_structdef(), pp_discard_symbol(), and pp_pop_name_scope().

Here is the caller graph for this function:

SYMBOL* pp_findsym ( SYMTAB symtab,
unsigned char *  name 
)

Definition at line 831 of file esql_symbol_table.c.

References hash_tab_s::find_symbol, and symbol::name.

Referenced by pp_add_symbols_to_table(), and pp_new_pseudo_def().

Here is the caller graph for this function:

void pp_free_symtab ( SYMTAB symtab,
HT_FREE_FN  free_fn 
)

Definition at line 90 of file esql_symbol_table.c.

References hash_tab_s::free_table.

Referenced by pp_symbol_finish().

Here is the caller graph for this function:

STRUCTDEF* pp_new_structdef ( const char *  tag)
SYMBOL* pp_new_symbol ( const char *  name,
int  scope 
)
SYMTAB* pp_new_symtab ( void  )

Definition at line 78 of file esql_symbol_table.c.

References es_ht_make_table(), pp_generic_cmp(), pp_generic_hash(), and SYMTAB_SIZE.

Referenced by pp_symbol_init().

Here is the caller graph for this function:

void pp_print_syms ( FILE *  fp)

Definition at line 801 of file esql_symbol_table.c.

References es_print_struct(), es_print_symbol(), hash_tab_s::get_symbol_count, NULL, and hash_tab_s::print_table.

Referenced by pp_pop_name_scope().

Here is the caller graph for this function:

void pp_symbol_finish ( void  )

Definition at line 869 of file esql_symbol_table.c.

References es_ht_free_symbol(), free_and_init, linkchunk::next, structdef::next, symbol::next, NULL, pp_discard_structdef(), pp_discard_symbol(), pp_free_symtab(), and syms_to_free_lists.

Referenced by pp_finish().

Here is the caller graph for this function:

void pp_symbol_init ( void  )

Definition at line 844 of file esql_symbol_table.c.

References links_allocated, links_deallocated, NULL, pp_new_symtab(), sdefs_allocated, sdefs_deallocated, syms_allocated, syms_deallocated, and syms_to_free_lists.

Referenced by pp_startup().

Here is the caller graph for this function:

void pp_symbol_stats ( FILE *  fp)

Definition at line 921 of file esql_symbol_table.c.

References links_allocated, links_deallocated, pp_dump_malloc_info, sdefs_allocated, sdefs_deallocated, syms_allocated, and syms_deallocated.

Referenced by pp_finish().

Here is the caller graph for this function:

Variable Documentation

LINKCHUNK* link_chunks
static

Definition at line 58 of file esql_symbol_table.c.

Referenced by pp_new_link().

LINK* link_free_list
static

Definition at line 54 of file esql_symbol_table.c.

Referenced by pp_discard_link(), and pp_new_link().

int links_allocated = 0
static

Definition at line 67 of file esql_symbol_table.c.

Referenced by pp_new_link(), pp_symbol_init(), and pp_symbol_stats().

int links_deallocated = 0
static

Definition at line 68 of file esql_symbol_table.c.

Referenced by pp_discard_link(), pp_symbol_init(), and pp_symbol_stats().

SYMTAB* pp_Struct_table

Definition at line 51 of file esql_symbol_table.c.

Referenced by pp_add_dummy_structdef(), and pp_remove_structdefs_from_table().

int sdefs_allocated = 0
static

Definition at line 65 of file esql_symbol_table.c.

Referenced by pp_new_structdef(), pp_symbol_init(), and pp_symbol_stats().

int sdefs_deallocated = 0
static

Definition at line 66 of file esql_symbol_table.c.

Referenced by pp_discard_structdef(), pp_symbol_init(), and pp_symbol_stats().

STRUCTDEF* struct_free_list
static

Definition at line 55 of file esql_symbol_table.c.

Referenced by pp_discard_structdef(), and pp_new_structdef().

SYMBOL* symbol_free_list
static

Definition at line 53 of file esql_symbol_table.c.

Referenced by pp_discard_symbol(), and pp_new_symbol().

int syms_allocated = 0
static

Definition at line 63 of file esql_symbol_table.c.

Referenced by pp_new_symbol(), pp_symbol_init(), and pp_symbol_stats().

int syms_deallocated = 0
static

Definition at line 64 of file esql_symbol_table.c.

Referenced by pp_discard_symbol(), pp_symbol_init(), and pp_symbol_stats().

int syms_to_free_lists = 1
static
const unsigned int SYMTAB_SIZE = 511
static

Definition at line 57 of file esql_symbol_table.c.

Referenced by pp_new_symtab().