19 int _sem_new_context(
SemTable *sem,
T *definitions) {
21 if (sem->contexts >= MAX_CONTEXTS-1) raise_error(
"no more room in semtable");
22 int idx = sem->contexts++;
24 sem->stores[idx].definitions = definitions;
33 return &sem->stores[c];
36 void _sem_free_context(
SemTable *sem,Context c) {
40 ctx->definitions = NULL;
43 if ((c+1) == sem->contexts)
49 char *_sem_ctx2s(
SemTable *sem,Context c) {
51 case SYS_CONTEXT:
return "SYS_CONTEXT";
52 case COMPOSITORY_CONTEXT:
return "COMPOSITORY_CONTEXT";
53 case DEV_COMPOSITORY_CONTEXT:
return "DEV_COMPOSITORY_CONTEXT";
54 case TEST_CONTEXT:
return "TEST_CONTEXT";
56 sprintf(G_ctx_buf,
"%d",c);
62 T *__sem_get_defs(
SemTable *sem,SemanticType semtype,Context c) {
64 if (!ctx->definitions) raise_error(
"no definitions in context %s",_sem_ctx2s(sem,c));
65 T *defs =
_t_child(ctx->definitions,semtype);
66 if (!defs) raise_error(
"no defs for semtype %d in context %s",semtype,_sem_ctx2s(sem,c));
70 T *__sem_get_def(
SemTable *sem,SemanticType semtype,Context c,SemanticAddr i) {
71 T *defs = __sem_get_defs(sem,semtype,c);
87 if (s.context == SYS_CONTEXT) {
89 case SEM_TYPE_STRUCTURE:
return "NULL_STRUCTURE";
90 case SEM_TYPE_SYMBOL:
return "NULL_SYMBOL";
91 case SEM_TYPE_PROCESS:
return "NULL_PROCESS";
92 case SEM_TYPE_RECEPTOR:
return "SYS_RECEPTOR";
93 default: raise_error(
"bad semtype");
97 raise_error(
"unexpected semantic NULL id!");
100 T *def = _sem_get_def(sem,s);
103 int path[] ={DefLabelIdx,1,TREE_PATH_TERMINATOR};
105 if (!t) raise_error(
"missing label!");
126 raise_error(
"semantic NULL have no defs!");
128 T *def = _sem_get_def(sem,s);
132 label = _t_find(labels,label_type);
133 if (!label) label =
_t_child(labels,1);
149 T *def = _sem_get_def(sem,s);
151 _t_new_str(labels,label_type,label);
155 if (!is_symbol(s)) raise_error(
"Bad symbol: semantic type not SEM_TYPE_SYMBOL");
162 T *d = ctx->definitions;
163 if (!d) raise_error(
"no definitions in context %s",_sem_ctx2s(sem,c));
182 if (!strcmp(label,
"NULL_SYMBOL")) {*sid = NULL_SYMBOL;
return true;}
183 for(i=0;i<sem->contexts;i++)
184 if (__sem_get_by_label(sem,label,sid,i))
return true;
char * _sem_get_name(SemTable *sem, SemanticID s)
header file for symbol and structure definition functions
T * _t_child(T *t, int i)
T * _sem_get_label(SemTable *sem, SemanticID s, Symbol label_type)
Structure __d_get_symbol_structure(T *symbols, Symbol s)
header file for table for coordinating meaning across a vmhost
void _sem_add_label(SemTable *sem, SemanticID s, Symbol label_type, char *label)