ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
def.h
Go to the documentation of this file.
1 
14 #ifndef _CEPTR_DEF_H
15 #define _CEPTR_DEF_H
16 
17 #include "tree.h"
18 #include <stdarg.h>
19 
20 // structure position index enums to make code more readable
21 // @todo figure out a better way to handle this... like put defs like these
22 // into the symbol gen code (talk about a semantic muddle! If only I had ceptr...)
23 // Note, that I tried that and it's hard!
24 enum {ReceptorInstanceInstOfIdx=1,ReceptorInstanceContextNumIdx,ReceptorInstanceParentContextIdx,ReceptorInstanceStateIdx};
25 enum {ReceptorDefinitionLabelIdx=1,ReceptorDefinitionDefsIdx};
26 enum {ReceptorFluxIdx=1,ReceptorPendingSignalsIdx,ReceptorPendingResponsesIdx,ReceptorConversationsIdx,ReceptorElapsedTimeIdx};
27 enum {SignalEnvelopeIdx=1,SignalMessageIdx};
28 enum {MessageHeadIdx=1,MessageBodyIdx};
29 enum {HeadFromIdx=1,HeadToIdx,HeadAspectIdx,HeadCarrierIdx,HeadOptionalsIdx};
30 enum {EnvelopeSignalUUIDIdx=1};
31 enum {PendingResponseUUIDIdx=1,PendingResponseCarrierIdx,PendingResponseWakeupIdx,PendingResponseEndCondsIdx,PendingResponseConversationIdentIdx};
32 enum {WakeupReferenceProcessIdentIdx=1,WakeupReferenceCodePathIdx};
33 enum {ExpectationCarrierIdx=1,ExpectationPatternIdx,ExpectationActionIdx,ExpectationParamsIdx,ExpectationEndCondsIdx,ExpectationOptionalsIdx};
34 enum DATEIndexes {dateYearIdx=1,dateMonthIdx,dateDayIdx};
35 enum TIMEIndexes {timeHourIdx=1,timeMinuteIdx,timeSecondIdx};
36 enum TIMESTAMPIndexes {timestampTodayIdx=1,timestampNowIdx};
37 enum ASPECTIndexes {aspectExpectationsIdx=1,aspectSignalsIdx};
38 enum {ExpectRoleIdx=1,ExpectSourceIdx,ExpectPatternIdx,ExpectActionIdx,ExpectParamsIdx};
39 enum {InitiateRoleIdx=1,InitiateDestinationIdx,InitiateActionIdx};
40 enum {SourceRoleIdx=1};
41 enum {DefLabelIdx=1,SymbolDefStructureIdx};
42 enum {StructureDefLabelIdx=1,StructureDefDefIdx};
43 enum {ProcessDefNameIdx=1,ProcessDefIntentionIdx,ProcessDefCodeIdx,ProcessDefSignatureIdx,ProcessDefLinkIdx};
44 enum {SignatureOutputSigIdx=1};
45 enum {InputSigLabelIdx=1,InputSigSemVariantsIdx,InputSigOptionalIdx};
46 enum {ProtocolDefNameIdx=1,ProtocolDefSemanticsIdx,ProtocolDefOptionalsIdx};
47 enum {RuntreeCodeIdx=1,RunTreeParamsIdx,RunTreeErrorCodeIdx,RunTreeErrorParamsIdx};
48 enum {ResolutionWhichIdx=1};
49 enum {ConnectionWhichIdx=1};
50 enum {SemtrexMatchSymbolIdx=1,SemtrexMatchPathIdx,SemtrexMatchSibsIdx};
51 enum {InclusionPnameIdx=1};
52 enum {SemanticMapSemanticRefIdx=1,SemanticMapReplacementValIdx};
53 enum {SlotSemanticRefIdx=1,SlotValueOfIdx};
54 enum {ParameterReferenceIdx=1,ParameterResultIdx=2};
55 enum {InstanceStoreInstancesIdx=1,InstanceStoreTokensIdx=2};
56 enum {InstanceTokensLastTokenIdx=1};
57 enum {ConversationIdentIdx=1,ConversationUntilIdx,ConversationConversationsIdx,ConversationWakeupIdx};
58 enum {ConversationIdentUUIDIdx=1,ConversationIdentOptionalsIdx};
59 
60 T *G_cursor; // used in _t_dump to highlight a particular node
61 
62 #define ST(r,name,num,...) name = _r_define_structure(r,"" #name "",num,__VA_ARGS__)
63 #define SY(r,name,str) name = _r_define_symbol(r,str,"" #name "")
64 #define SP(r,code,name,intention,signature,link) name = _r_define_process(r,code,"" #name "",intention,signature,link)
65 
66 int semeq(SemanticID s1,SemanticID s2);
67 SemanticID _d_define(SemTable *sem,T *def,SemanticType semtype,Context c);
68 void __d_validate_symbol(SemTable *sem,Symbol s,char *n);
69 void __d_validate_structure(SemTable *sem,Structure s,char *n);
70 void __d_set_symbol_structure(T *symbols,Symbol sym,Structure s);
71 SemanticAddr _d_get_def_addr(T *def);
72 Symbol _d_define_symbol(SemTable *sem,Structure s,char *label,Context c);
73 Structure _d_define_structure(SemTable *sem,char *label,T *structure_def,Context c);
74 Structure _d_define_structure_v(SemTable *sem,char *label,Context c,int num_params,...);
75 T * _d_make_vstruc_def(SemTable *sem,char *label,int num_params,va_list params);
77 size_t _d_get_symbol_size(SemTable *sem,Symbol s,void *surface);
78 size_t _d_get_structure_size(SemTable *sem,Symbol s,void *surface);
79 T *_d_make_process_def(T *code,char *name,char *intention,T *signature,T *link);
80 Process _d_define_process(SemTable *sem,T *code,char *name,char *intention,T *signature,T *link,Context c);
81 Protocol _d_define_protocol(SemTable *sem,T *def,Context c);
82 T *_d_make_protocol_def(SemTable *sem,char *label,...);
83 T * _d_build_def_semtrex(SemTable *sem,Symbol s,T *parent);
84 size_t _sys_structure_size(int id,void *surface);
85 SemanticID _d_define_receptor(SemTable *sem,char *label,T *definitions,Context c);
86 SemanticID __d_define_receptor(SemTable *sem,T *def,Context c);
87 Context _d_get_receptor_context(SemTable *sem,SemanticID r);
88 
89 enum{NO_INDENT=0,INDENT=-1};
90 #define t2s(t) _t2s(G_sem,t)
91 #define t2sp(t) __t2s(G_sem,t,INDENT)
92 #define _t2s(d,t) __t2s(d,t,NO_INDENT)
93 char * __t2s(SemTable *sem,T *t,int indent);
94 char *_indent_line(int level,char *buf);
95 char * __t_dump(SemTable *sem,T *t,int level,char *buf);
96 
97 #define _d_get_def(defs,s) _t_child(defs,(s).id);
98 #define _d_get_process_code(processes,p) _d_get_def(processes,p)
99 #define _d_get_symbol_def(symbols,s) _d_get_def(symbols,s)
100 #define _d_get_structure_def(structures,s) _d_get_def(structures,s)
101 
102 #define spec_is_sem_equal(got, expected) spec_total++; if (semeq(expected,got)){putchar('.');} else {putchar('F');sprintf(failures[spec_failures++],"%s:%d expected %s to be %d.%d.%d but was %d.%d.%d",__FUNCTION__,__LINE__,#got,(expected).context,(expected).semtype,(expected).id,(got).context,(got).semtype,(got).id);}
103 
104 SemTable *def_sys();
105 void sys_free(SemTable *sem);
106 #endif
107 
Definition: ceptr_types.h:114
Process _d_define_process(SemTable *sem, T *code, char *name, char *intention, T *signature, T *link, Context c)
Definition: def.c:336
SemanticID _d_define_receptor(SemTable *sem, char *label, T *definitions, Context c)
Definition: def.c:457
semantic trees header file
T * _d_build_def_semtrex(SemTable *sem, Symbol s, T *parent)
Definition: def.c:433
Structure _d_define_structure(SemTable *sem, char *label, T *structure_def, Context c)
Definition: def.c:104
size_t _d_get_symbol_size(SemTable *sem, Symbol s, void *surface)
Definition: def.c:178
Structure __d_get_symbol_structure(T *symbols, Symbol s)
Definition: def.c:156
size_t _d_get_structure_size(SemTable *sem, Symbol s, void *surface)
Definition: def.c:218
Symbol _d_define_symbol(SemTable *sem, Structure s, char *label, Context c)
Definition: def.c:83
T * _d_make_process_def(T *code, char *name, char *intention, T *signature, T *link)
Definition: def.c:302
char * __t2s(SemTable *sem, T *t, int indent)
Definition: def.c:518
SemanticID __d_define_receptor(SemTable *sem, T *def, Context c)
Definition: def.c:478
Protocol _d_define_protocol(SemTable *sem, T *def, Context c)
Definition: def.c:357
Structure _d_define_structure_v(SemTable *sem, char *label, Context c, int num_params,...)
Definition: def.c:124