Esempio n. 1
0
/**
 * get the structure for a given symbol
 *
 * @param[in] symbols a symbol def tree containing symbol definitions
 * @param[in] s the symbol
 * @returns a Structure
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testGetSymbolStructure
 */
Structure _d_get_symbol_structure(T *symbols,Symbol s) {
    if (is_sys_symbol(s) || is_sys_test_symbol(s))
        symbols = G_sys_defs.symbols;
    T *def = _t_child(symbols,s.id);
    T *t = _t_child(def,2); // second child of the def is the structure
    return *(Structure *)_t_surface(t);
}
Esempio n. 2
0
/**
 * scaffolding function for signal delivery
 */
void _v_deliver_signals(VMHost *v, Receptor *sender) {
    T *signals = sender->pending_signals;

    while(_t_children(signals)>0) {
        T *s = _t_detach_by_idx(signals,1);
        T *envelope = _t_child(s,1);
        //      T *contents = _t_child(s,2);
        ReceptorAddress *toP = (ReceptorAddress *)_t_surface(_t_child(_t_child(envelope,EnvelopeToIdx),1));
        ReceptorAddress *fromP = (ReceptorAddress *)_t_surface(_t_child(_t_child(envelope,EnvelopeFromIdx),1));

        // if the from or to address is "self" (-1) we find the senders self
        // fix the values in the signal we are about to deliver.

        if (fromP->addr == SELF_RECEPTOR_ADDR) {
            *fromP = __r_get_self_address(sender);
        }

        Receptor *r;
        if (toP->addr == SELF_RECEPTOR_ADDR) {
            *toP = __r_get_self_address(sender);
        }
        else  {
            if (toP->addr >= v->receptor_count) {
                raise_error("to address: %d doesn't exist!",toP->addr);
            }
            r = v->routing_table[toP->addr].r;
        }

        Error err = _r_deliver(r,s);
        if (err) {
            raise_error("delivery error: %d",err);
        }
    }
}
Esempio n. 3
0
T *sT_(SemTable *sem,Symbol sym,int num_params,...){
    va_list params;
    T *set = _t_newr(0,sym);
    va_start(params,num_params);
    int i;
    for(i=0;i<num_params;i++) {
        T * t = va_arg(params,T *);
        if (semeq(_t_symbol(t),STRUCTURE_SYMBOL)) {
            Symbol ss = *(Symbol *)_t_surface(t);
            if (is_structure(ss)) {
                T *structures = _sem_get_defs(G_sem,ss);
                T *st = _t_child(structures,ss.id);
                if (!st) {
                    raise_error("Structure used in %s definition is undefined!",G_label);
                }
                else {
                    _t_free(t);
                    t = _t_clone(_t_child(st,2));
                }
            }
            else if (ss.id == -1) {raise_error("Symbol used in %s definition is undefined!",G_label);}
        }
        _t_add(set,t);
    }
    va_end(params);
    return set;
}
Esempio n. 4
0
// this is used to reset the structure of a symbol that has been pre declared as NULL_SYMBOL
// to it's actual value.
void __d_set_symbol_structure(T *symbols,Symbol sym,Structure s) {
    T *t = _t_child(symbols,sym.id);
    if (!t) raise_error("def not found!");
    T * structure_def = _t_child(t,SymbolDefStructureIdx);
    if (!semeq(NULL_STRUCTURE,*(Symbol *)_t_surface(structure_def)))
        raise_error("Symbol already defined");
    *(Symbol *)_t_surface(structure_def) = s;
}
Esempio n. 5
0
/**
 * get the structure for a given symbol
 *
 * @param[in] symbols a symbol def tree containing symbol definitions
 * @param[in] s the symbol
 * @returns a Structure
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testGetSymbolStructure
 */
Structure __d_get_symbol_structure(T *symbols,Symbol s) {
    T *def = _t_child(symbols,s.id);
    if (!def) {
        raise_error("Bad symbol:%d.%d.%d-- only %d symbols in decl list",s.context,s.semtype,s.id,_t_children(symbols));
    }
    T *t = _t_child(def,SymbolDefStructureIdx);
    return *(Structure *)_t_surface(t);
}
Esempio n. 6
0
/**
 * get one of a symbol's labels
 *
 * @param[in] sem is the semantic table where symbols and structures are define
 * @param[in] s the Symbol to return the label of
 * @param[in] s the Symbol to return the label of
 * @returns label or NULL if the definition couldn't be found
 *
 * @note the label returned is a pointer to the actual label in the definition. it must not be changed or modified!  Clone it if you need to.
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/semtable_spec.h testSemTableGetLabel
 */
T * _sem_get_label(SemTable *sem,SemanticID s,Symbol label_type) {
    if (s.id == 0) {
        raise_error("semantic NULL have no defs!");
    }
    T *def = _sem_get_def(sem,s);
    T *label = NULL;
    if (def) {
        T *labels = _t_child(def,DefLabelIdx);
        label = _t_find(labels,label_type);
        if (!label) label = _t_child(labels,1);
    }
    return label;
}
Esempio n. 7
0
/**
 * get structure's label
 *
 * @param[in] structures a structre def tree containing structure definitions
 * @param[in] s the Structure to return the name for
 * @returns char * pointing to label
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testStructureGetName
 */
char *_d_get_structure_name(T *structures,Structure s) {
    if (is_sys_structure(s)) {
        if (s.id == 0) return "NULL_STRUCTURE";
        structures = G_sys_defs.structures;
    }
    if (structures) {
        T *def = _t_child(structures,s.id);
        T *l = _t_child(def,1);
        return (char *)_t_surface(l);
    }
    sprintf(__d_extra_buf,"<unknown structure:%d.%d.%d>",s.context,s.flags,s.id);
    return __d_extra_buf;
}
Esempio n. 8
0
/**
 * get processes's label
 *
 * @param[in] processes a process def tree containing structure definitions
 * @param[in] p the Process to return the name for
 * @returns char * pointing to label
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testProcessGetName
 */
char *_d_get_process_name(T *processes,Process p) {
    if (is_sys_process(p)) {
        if (p.id == 0) return "NULL_PROCESS";
        processes = G_sys_defs.processes;
    }
    if (processes) {
        T *def = _t_child(processes,p.id);
        if (def) {
            T *l = _t_child(def,1);
            return (char *)_t_surface(l);
        }
    }
    sprintf(__d_extra_buf,"<unknown process:%d.%d.%d>",p.context,p.flags,p.id);
    return __d_extra_buf;
}
Esempio n. 9
0
/**
 * get the size of a structure
 *
 * @param[in] symbols a symbol def tree containing symbol definitions
 * @param[in] structures a structure def tree containing structure definitions
 * @param[in] s the structure
 * @param[in] surface the surface of the structure (may be necessary beause some structures have length info in the data)
 * @returns size of the structure
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testGetSize
 */
size_t _d_get_structure_size(T *symbols,T *structures,Structure s,void *surface) {
    size_t size = 0;
    if (is_sys_structure(s)) {
        size = _sys_structure_size(s.id,surface);
        if (size == -1) {
            raise_error2("DON'T HAVE A SIZE FOR STRUCTURE '%s' (%d)",_d_get_structure_name(structures,s),s.id);
        }
    }
    else {
        T *structure = _t_child(structures,s.id);
        T *parts = _t_child(structure,2);
        DO_KIDS(parts,
            T *p = _t_child(parts,i);
            size += _d_get_symbol_size(symbols,structures,*(Symbol *)_t_surface(p),surface +size);
                );
    }
Esempio n. 10
0
/**
 * Build a run tree from a code tree and params
 *
 * @param[in] processes processes trees
 * @param[in] process Process tree node to be turned into run tree
 * @param[in] num_params the number of parameters to add to the parameters child
 * @param[in] ... T params
 * @returns T RUN_TREE tree
 */
T *_p_make_run_tree(T *processes,T *process,int num_params,...) {

    T *t = NULL;
    va_list params;

    Process p = *(Process *)_t_surface(process);
    if (!is_process(p)) {
        raise_error("%s is not a Process",_d_get_process_name(processes,p));
    }
    if (is_sys_process(p)) {
        t =  _t_new_root(RUN_TREE);
        // if it's a sys process we add the parameters directly as children to the process
        // because no sys-processes refer to PARAMS by path
        // this also means we need rclone them instead of clone them because they
        // will actually need to have space for the status marks by the processing code
        T *c = __t_new(t,p,0,0,sizeof(rT));

        va_start(params,num_params);
        int i;
        for(i=0;i<num_params;i++) {
            _t_add(c,_t_rclone(va_arg(params,T *)));
        }
        va_end(params);
    }
    else {
        T *code_def = _d_get_process_code(processes,p);
        T *code = _t_child(code_def,3);

        va_list params;
        va_start(params,num_params);
        t = __p_build_run_tree_va(code,num_params,params);
        va_end(params);
    }
    return t;
}
Esempio n. 11
0
// get the definitions for the semantic type of the semid
T *__sem_get_defs(SemTable *sem,SemanticType semtype,Context c) {
    ContextStore *ctx = __sem_context(sem,c);
    if (!ctx->definitions) raise_error("no definitions in context %s",_sem_ctx2s(sem,c));
    T *defs = _t_child(ctx->definitions,semtype);
    if (!defs) raise_error("no defs for semtype %d in context %s",semtype,_sem_ctx2s(sem,c));
    return defs;
}
Esempio n. 12
0
// helper function to recursively travers a ttree and build an mtree out of it
// used by _m_new_from_t
H __mnft(H parent,T *t) {
    int i, c = _t_children(t);
    H h = _m_new(parent,_t_symbol(t),_t_surface(t),_t_size(t));
    for(i=1;i<=c;i++) {
    __mnft(h,_t_child(t,i));
    }
    return h;
}
Esempio n. 13
0
/**
 * implements the INTERPOLATE_FROM_MATCH process
 *
 * replaces the interpolation tree with the matched sub-parts from a semtrex match results tree
 *
 * @param[in] t interpolation tree to be scanned for INTERPOLATE_SYMBOL nodes
 * @param[in] match_results SEMTREX_MATCH_RESULTS tree
 * @param[in] match_tree original tree that was matched (needed to grab the data to interpolate)
 * @todo what to do if match has sibs??
 */
void _p_interpolate_from_match(T *t,T *match_results,T *match_tree) {
    if (semeq(_t_symbol(t),INTERPOLATE_SYMBOL)) {
        Symbol s = *(Symbol *)_t_surface(t);
        T *m = _t_get_match(match_results,s);
        if (!m) {
            raise_error0("expected to have match!");
        }
        int *path = (int *)_t_surface(_t_child(m,2));
        int sibs = *(int*)_t_surface(_t_child(m,3));
        T *x = _t_get(match_tree,path);

        if (!x) {
            raise_error0("expecting to get a value from match!!");
        }
        _t_morph(t,x);
    }
    DO_KIDS(t,_p_interpolate_from_match(_t_child(t,i),match_results,match_tree));
}
Esempio n. 14
0
// @todo, convert this to hash table label table!!
bool __sem_get_by_label(SemTable *sem,char *label,SemanticID *sid,Context c) {
    ContextStore *ctx = __sem_context(sem,c);
    T *d = ctx->definitions;
    if (!d) raise_error("no definitions in context %s",_sem_ctx2s(sem,c));
    int i,j;
    for(i=1;i<=_t_children(d);i++) {
        T *defs = _t_child(d,i);
        for(j=1;j<=_t_children(defs);j++) {
            T *def = _t_child(defs,j);
            if (strcmp(label,(char *)_t_surface(_t_child(_t_child(def,DefLabelIdx),1)))==0) {
                sid->semtype = i;
                sid->id = j;
                sid->context = c;
                return true;
            }
        }
    }
    return false;
}
Esempio n. 15
0
/**
 * get symbol's label
 *
 * @param[in] symbols a symbol def tree containing symbol definitions
 * @param[in] s the Symbol to return the name for
 * @returns char * pointing to label
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testSymbolGetName
 */
char *_d_get_symbol_name(T *symbols,Symbol s) {
    if (is_sys_symbol(s)) {
        if (s.id == 0) return "NULL_SYMBOL";
        symbols = G_sys_defs.symbols;
    }
    if (is_sys_test_symbol(s))
        symbols = G_sys_defs.symbols;
    if (symbols) {
        int c = _t_children(symbols);
        if (s.id > c || s.id < 1)  {
            raise_error2("Bad symbol:%d--%d symbols in decl list",s.id,c);
        }
        T *def = _t_child(symbols,s.id);
        T *l = _t_child(def,1);
        return (char *)_t_surface(_t_child(def,1));
    }
    sprintf(__d_extra_buf,"<unknown symbol:%d.%d.%d>",s.context,s.flags,s.id);
    return __d_extra_buf;
}
Esempio n. 16
0
/**
 * check a group of parameters to see if they match a process input signature
 *
 * @param[in] defs definition trees needed for the checking
 * @param[in] p the Process we are checking against
 * @param[in] params list of parameters
 *
 * @returns Error code
 *
 * @todo add SIGNATURE_SYMBOL for setting up process signatures by Symbol not just Structure
 */
Error __p_check_signature(Defs *defs,Process p,T *params) {
    T *def = _d_get_process_code(defs->processes,p);
    T *input = _t_child(def,4);
    int i = _t_children(input);
    int c = _t_children(params);
    if (i > c) return tooFewParamsReductionErr;
    if (i < c) return tooManyParamsReductionErr;
    for(i=1;i<=c;i++) {
        T *sig = _t_child(_t_child(input,i),1);
        if(semeq(_t_symbol(sig),SIGNATURE_STRUCTURE)) {
            Structure ss = *(Symbol *)_t_surface(sig);
            if (!semeq(_d_get_symbol_structure(defs->symbols,_t_symbol(_t_child(params,i))),ss) && !semeq(ss,TREE))
                return signatureMismatchReductionErr;
        }
        else {
            raise_error("unknown signature checking symbol: %s",_d_get_symbol_name(0,_t_symbol(sig)));
        }
    }
    return 0;
}
Esempio n. 17
0
/**
 * @brief Creates a new receptor from a receptor package
 *
 * allocates all the memory needed in the heap, cloning the various parts from the package
 * and binding the new receptor to the provided bindings
 *
 * @param[in] s symbol for this receptor
 * @returns pointer to a newly allocated Receptor
 * @todo implement bindings
 */
Receptor *_r_new_receptor_from_package(SemTable *sem,Symbol s,T *p,T *bindings) {
    T *defs = _t_clone(_t_child(p,3));
    //    T *aspects = _t_clone(_t_child(p,4));  @todo this should be inside the defs allready
    raise_error("fix receptor address");
    Receptor *r = _r_new(sem,s);

    //@todo fix this because it relies on SemanticTypes value matching the index order in the definitions.
    //    DO_KIDS(defs,__r_set_labels(r,_t_child(defs,i),i));

    return r;
}
Esempio n. 18
0
/*
  special runtree builder that uses the actual params tree node.  This is used
  in the process of reduction because we don't have to clone the param values, we
  can use the actual tree nodes that are being reduced as they are already rT nodes
  and they are only used once, i.e. in this reduction
*/
T *__p_make_run_tree(T *processes,Process p,T *params) {
    T *code_def = _d_get_process_code(processes,p);
    T *code = _t_child(code_def,3);
    T *t = _t_new_root(RUN_TREE);
    T *c = _t_rclone(code);
    _t_add(t,c);
    T *ps = _t_newr(t,PARAMS);
    int i,num_params = _t_children(params);
    for(i=1;i<=num_params;i++) {
        _t_add(ps,_t_detach_by_idx(params,1));
    }
    return t;}
Esempio n. 19
0
/**
 * create a run-tree execution context.
 */
R *__p_make_context(T *run_tree,R *caller) {
    R *context = malloc(sizeof(R));
    context->state = Eval;
    context->err = 0;
    context->run_tree = run_tree;
    // start with the node_pointer at the first child of the run_tree
    context->node_pointer = _t_child(run_tree,1);
    context->parent = run_tree;
    context->idx = 1;
    context->caller = caller;
    if (caller) caller->callee = context;
    return context;
}
Esempio n. 20
0
/* set up the c structures for a receptor from a semantic tree */
Receptor * __r_init(T *t) {
    Receptor *r = malloc(sizeof(Receptor));
    r->root = t;
    r->table = NULL;
    r->instances = NULL;
    r->q = _p_newq(r);
    r->state = Alive;  //@todo, check if this is true on unserialize

    T *defs = _t_child(t,1);
    r->defs.structures = _t_child(defs,1);
    r->defs.symbols = _t_child(defs,2);
    r->defs.processes = _t_child(defs,3);
    r->defs.protocols = _t_child(defs,4);
    r->defs.scapes = _t_child(defs,5);
    r->flux = _t_child(t,3);
    r->pending_signals = _t_child(t,5);
    r->pending_responses = _t_child(t,6);
    return r;
}
Esempio n. 21
0
/**
 * get the size of a structure
 *
 * @param[in] sem is the semantic table where symbols and structures are defined
 * @param[in] s the structure
 * @param[in] surface the surface of the structure (may be necessary beause some structures have length info in the data)
 * @returns size of the structure
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/def_spec.h testGetSize
 */
size_t _d_get_structure_size(SemTable *sem,Structure s,void *surface) {
    size_t size = 0;
    T *structures = _sem_get_defs(sem,s);

    if (is_sys_structure(s)) {
        size = _sys_structure_size(s.id,surface);
        if (size == -1) {
            raise_error("DON'T HAVE A SIZE FOR STRUCTURE '%s' (%d)",_sem_get_name(sem,s),s.id);
        }
    }
    else {
        T *structure = _t_child(structures,s.id);
        T *parts = _t_child(structure,2);
        if (semeq(_t_symbol(parts),STRUCTURE_SEQUENCE)) {
            DO_KIDS(parts,
                    T *p = _t_child(parts,i);
                    if (!semeq(_t_symbol(p),STRUCTURE_SYMBOL)) {
                        raise_error("CAN'T GET SIZE FOR VARIABLE STRUCTURES '%s' (%d)",_sem_get_name(sem,s),s.id);
                    }
                    size += _d_get_symbol_size(sem,*(Symbol *)_t_surface(p),surface +size);
                    );
        }
        else if (semeq(_t_symbol(parts),STRUCTURE_SYMBOL)) {
Esempio n. 22
0
/**
 * install a receptor into vmhost, creating a symbol for it
 *
 * @param[in] v VMHost in which to install the receptor
 * @param[in] package xaddr of package to install
 * @param[in] bindings completed manifest which specifies how the receptor will be installed
 * @param[in] label label to be used for the semantic name for this receptor
 * @returns Xaddr of the instance
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/vmhost_spec.h testVMHostInstallReceptor
 */
Xaddr _v_install_r(VMHost *v,Xaddr package,T *bindings,char *label) {
    raise_error("not implemented");
    T *p;// = _r_get_instance(v->c,package);
    T *id = _t_child(p,2);
    TreeHash h = _t_hash(v->r->sem,id);

    // make sure we aren't re-installing an already installed receptor
    Xaddr x = _s_get(v->installed_receptors,h);
    if (!(is_null_xaddr(x))) return G_null_xaddr;
    _s_add(v->installed_receptors,h,package);

    // confirm that the bindings match the manifest
    /// @todo expand the manifest to allow optional binding, etc, using semtrex to do the matching instead of assuming positional matching
    if (bindings) {
        T *m = _t_child(p,1);
        int c = _t_children(m);
        if (c%2) {raise_error("manifest must have even number of children!");}
        int i;
        for(i=1;i<=c;i++) {
            T *mp = _t_child(m,i);
            T *s = _t_child(mp,2);
            T *bp = _t_child(bindings,i);
            if (!bp) {
                raise_error("missing binding for %s",(char *)_t_surface(_t_child(mp,1)));
            }
            T *vb = _t_child(bp,2);
            Symbol spec = *(Symbol *)_t_surface(s);
            if (semeq(_t_symbol(vb),spec)) {
                T *symbols = _t_child(p,3);
                raise_error("bindings symbol %s doesn't match spec %s",_sem_get_name(v->r->sem,_t_symbol(vb)),_sem_get_name(v->r->sem,spec));
            }
        }
    }

    Symbol s = _r_define_symbol(v->r,RECEPTOR,label);

    raise_error("fix semtable");
    Receptor *r = _r_new_receptor_from_package(NULL,s,p,bindings);
    return _v_new_receptor(v,v->r,s,r);
}
Esempio n. 23
0
/* set up the c structures for a receptor from a semantic tree */
Receptor * __r_init(T *t,SemTable *sem) {
    Receptor *r = malloc(sizeof(Receptor));
    r->root = t;
    r->parent = *(int *)_t_surface(_t_child(t,ReceptorInstanceParentContextIdx));
    r->context = *(int *)_t_surface(_t_child(t,ReceptorInstanceContextNumIdx));
    r->addr.addr = r->context;  //@fixme!! for now these are the same, but this needs to get fixed
    r->sem = sem;
    r->instances = NULL;
    r->q = _p_newq(r);
    r->state = Alive;  //@todo, check if this is true on unserialize

    T *state = _t_child(t,ReceptorInstanceStateIdx);
    r->flux = _t_child(state,ReceptorFluxIdx);
    r->pending_signals = _t_child(state,ReceptorPendingSignalsIdx);
    r->pending_responses = _t_child(state,ReceptorPendingResponsesIdx);
    r->conversations = _t_child(state,ReceptorConversationsIdx);
    r->edge = NULL;
    return r;
}
Esempio n. 24
0
// helper function to recursively traverse a ttree and build an mtree out of it
// used by _m_new_from_t
H __mnft(H parent,T *t) {
    int i, c = _t_children(t);

    // clear the allocated flag, because that will get recalculated in __m_new
    uint32_t flags = t->context.flags & ~TFLAG_ALLOCATED;
    // if the ttree points to a type that has an allocated c structure as its surface
    // it must be copied into the mtree as reference, otherwise it would get freed twice
    // when the mtree is freed

    if (flags & (TFLAG_SURFACE_IS_RECEPTOR+TFLAG_SURFACE_IS_SCAPE+TFLAG_SURFACE_IS_STREAM)) flags |= TFLAG_REFERENCE;
    void *surface = _t_surface(t);
    void *sp;
    H h;

    if (flags & TFLAG_SURFACE_IS_TREE && !(flags & TFLAG_SURFACE_IS_RECEPTOR)) {
        H sh = _m_new_from_t((T *)surface);
        h = _m_newt(parent,_t_symbol(t),sh);
    }
    else {
        if (flags & (TFLAG_SURFACE_IS_RECEPTOR+TFLAG_SURFACE_IS_SCAPE+TFLAG_SURFACE_IS_STREAM)) {
            sp = surface;
            surface = &sp;
        }
        h = __m_new(parent,_t_symbol(t),surface,_t_size(t),flags);
    }
    if (flags&TFLAG_RUN_NODE) {
        // @todo, make this more efficient, ie we shouldn't have to
        // do an _m_get, instead there should be a way for mtrees to create run_nodes
        N *n = __m_get(h);
        n->cur_child = ((rT *)t)->cur_child;
    }
    for(i=1;i<=c;i++) {
        __mnft(h,_t_child(t,i));
    }
    return h;
}
Esempio n. 25
0
T *__sem_get_def(SemTable *sem,SemanticType semtype,Context c,SemanticAddr i) {
    T *defs = __sem_get_defs(sem,semtype,c);
    return _t_child(defs,i);
}
Esempio n. 26
0
/**
 * add a name to a definition
 *
 * @param[in] sem is the semantic table where symbols and structures are defined
 * @param[in] s the semantic id of the definition to add a label to
 * @param[in] label_type is a symbol of the label type to add
 * @param[in] label text of the label
 *
 * <b>Examples (from test suite):</b>
 * @snippet spec/semtable_spec.h testSemGetByLabel
 */
void _sem_add_label(SemTable *sem,SemanticID s,Symbol label_type,char *label) {
    T *def = _sem_get_def(sem,s);
    T *labels  = _t_child(def,DefLabelIdx);
    _t_new_str(labels,label_type,label);
}
Esempio n. 27
0
Receptor *_r_new(Symbol s) {
    T *defs = _t_new_root(DEFINITIONS);
    _t_newr(defs,STRUCTURES);
    _t_newr(defs,SYMBOLS);
    _t_newr(defs,PROCESSES);
    _t_newr(defs,PROTOCOLS);
    _t_newr(defs,SCAPES);
    T *aspects = _t_new_root(ASPECTS);
    return __r_new(s,defs,aspects);
}

// set the labels in the label table for the given def
void __r_set_labels(Receptor *r,T *defs,int sem_type) {
    DO_KIDS(
            defs,
            T *def = _t_child(defs,i);
            T *sl = _t_child(def,1);
            __set_label_for_def(r,_t_surface(sl),def,sem_type);
            );
}

/**
 * @brief Creates a new receptor from a receptor package
 *
 * allocates all the memory needed in the heap, cloning the various parts from the package
 * and binding the new receptor to the provided bindings
 *
 * @param[in] s symbol for this receptor
 * @returns pointer to a newly allocated Receptor
 * @todo implement bindings
 */
Esempio n. 28
0
// this is used to set the structure definition of a declared but undefined strcture
void __d_set_structure_def(T *structures,Structure s,T *def) {
    T *d = _t_child(structures,s.id);
    if (_t_children(d) > 1) raise_error("Structure already defined");
    _t_add(d,def);
}
Esempio n. 29
0
// internal check to see if a structure is valid
void __d_validate_structure(SemTable *sem,Structure s,char *n) {
    if (!is_structure(s)) raise_error("Bad structure in %s def: semantic type not SEM_TYPE_STRUCTURE",n);
    if (is_sys_structure(s) && (s.id == 0)) return; // NULL_STRUCTURE ok
    T *structures = _sem_get_defs(sem,s);
    if(s.id && !_t_child(structures,s.id)) {raise_error("Unknown structure <%d.%d.%d> in declaration of %s",s.context,s.semtype,s.id,n);}
}
Esempio n. 30
0
// internal check to see if a symbol is valid
void __d_validate_symbol(SemTable *sem,Symbol s,char *n) {
    if (!is_symbol(s)) raise_error("Bad symbol in %s def: semantic type not SEM_TYPE_SYMBOL",n);
    if (is_sys_symbol(s) && (s.id == 0)) return; // NULL_SYMBOL ok
    T *symbols = _sem_get_defs(sem,s);
    if (!_t_child(symbols,s.id)) raise_error("Bad symbol in %s def: definition not found in context",n);
}