22 const Symbol NULL_SYMBOL = {0,SEM_TYPE_SYMBOL,0};
23 const Structure NULL_STRUCTURE = {0,SEM_TYPE_STRUCTURE,0};
24 const Process NULL_PROCESS = {0,SEM_TYPE_PROCESS,0};
26 #define _sd(s,c,t,i); s.context = c;s.semtype=t;s.id=i;
37 _sd(DEFINITIONS,SYS_CONTEXT,SEM_TYPE_SYMBOL,DEFINITIONS_ID);
38 _sd(STRUCTURES,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURES_ID);
39 _sd(STRUCTURE_DEFINITION,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_DEFINITION_ID);
40 _sd(STRUCTURE_LABEL,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_LABEL_ID);
41 _sd(STRUCTURE_SEQUENCE,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_SEQUENCE_ID);
42 _sd(STRUCTURE_SYMBOL,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_SYMBOL_ID);
43 _sd(STRUCTURE_OR,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_OR_ID);
44 _sd(STRUCTURE_ZERO_OR_MORE,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_ZERO_OR_MORE_ID);
45 _sd(STRUCTURE_ONE_OR_MORE,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_ONE_OR_MORE_ID);
46 _sd(STRUCTURE_ZERO_OR_ONE,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_ZERO_OR_ONE_ID);
47 _sd(STRUCTURE_STRUCTURE,SYS_CONTEXT,SEM_TYPE_SYMBOL,STRUCTURE_STRUCTURE_ID);
48 _sd(SYMBOLS,SYS_CONTEXT,SEM_TYPE_SYMBOL,SYMBOLS_ID);
49 _sd(PROCESSES,SYS_CONTEXT,SEM_TYPE_SYMBOL,PROCESSES_ID);
50 _sd(PROTOCOLS,SYS_CONTEXT,SEM_TYPE_SYMBOL,PROTOCOLS_ID);
51 _sd(RECEPTORS,SYS_CONTEXT,SEM_TYPE_SYMBOL,RECEPTORS_ID);
52 _sd(SCAPES,SYS_CONTEXT,SEM_TYPE_SYMBOL,SCAPES_ID);
53 _sd(SYMBOL_DEFINITION,SYS_CONTEXT,SEM_TYPE_SYMBOL,SYMBOL_DEFINITION_ID);
54 _sd(SYMBOL_STRUCTURE,SYS_CONTEXT,SEM_TYPE_SYMBOL,SYMBOL_STRUCTURE_ID);
55 _sd(SYMBOL_LABEL,SYS_CONTEXT,SEM_TYPE_SYMBOL,SYMBOL_LABEL_ID);
56 _sd(RECEPTOR_DEFINITION,SYS_CONTEXT,SEM_TYPE_SYMBOL,RECEPTOR_DEFINITION_ID);
57 _sd(RECEPTOR_LABEL,SYS_CONTEXT,SEM_TYPE_SYMBOL,RECEPTOR_LABEL_ID);
58 _sd(ENGLISH_LABEL,SYS_CONTEXT,SEM_TYPE_SYMBOL,ENGLISH_LABEL_ID);
65 _r_defineClockReceptor(sem);
80 T *set = _t_newr(0,sym);
81 va_start(params,num_params);
83 for(i=0;i<num_params;i++) {
84 T * t = va_arg(params,
T *);
85 if (semeq(
_t_symbol(t),STRUCTURE_SYMBOL)) {
87 if (is_structure(ss)) {
88 T *structures = _sem_get_defs(sem,ss);
91 raise_error(
"Structure used in %s definition is undefined!",G_label);
98 else if (ss.id == -1) {raise_error(
"Symbol used in %s definition is undefined!",G_label);}
112 x = glob(
"contexts/*.cptr", 0, NULL, &paths);
117 for (p=paths.gl_pathv; *p != NULL; ++p)
124 void load_context(
char *path,
Receptor *parent) {
126 debug(D_BOOT,
"loading %s\n",path);
128 size_t l = strlen(path);
132 while (i-- > 0 && *s !=
'/' ) s--;
136 name[strlen(name)-5]=0;
144 char *code_text = readFile(path,&l);
158 if (p ==
'\n' && c ==
'-') {
162 while((c=*s++) && c !=
'\n') *t++ = c;
171 if (ctx[0] && strcmp(ctx,name)) {
177 if (_sem_get_by_label(sem,name,&rsid)) {
178 debug(D_BOOT,
"found existing context: %s\n",name);
179 if (!is_receptor(rsid)) raise_error(
"%s is not a receptor!",name);
182 debug(D_BOOT,
"creating context: %s\n",name);
183 T *def =
_t_parse(sem,0,
"(RECEPTOR_DEFINITION (RECEPTOR_LABEL %) (DEFINITIONS (STRUCTURES) (SYMBOLS) (PROCESSES) (RECEPTORS) (PROTOCOLS) (SCAPES)))",_t_new_str(0,ENGLISH_LABEL,name));
188 debug(D_BOOT,
"executing into %s:\n%s\n",name,start);
192 T *run_tree = __p_build_run_tree(code,0);
194 Qe *e = _p_addrt2q(q,run_tree);
196 debug(D_BOOT,
"results in: %s\n",_t2s(sem,run_tree));
header file for symbol and structure definition functions
void _r_free(Receptor *r)
semantic trees header file
T * _t_child(T *t, int i)
Context context
the context this receptor's definition creates
receptor implementation header file
Receptor * _r_new(SemTable *sem, SemanticID r)
Creates a new receptor.
SemTable * sem
pointer back to the genotype table for this receptor's vmhost instance
SemanticID __d_define_receptor(SemTable *sem, T *def, Context c)
T * _t_parse(SemTable *sem, T *parent, char *s,...)
auto-generated system definitions