5 #include "asn1parser.h"
8 * Construct a new empty module.
14 mod = calloc(1, sizeof *mod);
16 TQ_INIT(&(mod->exports));
17 TQ_INIT(&(mod->imports));
18 TQ_INIT(&(mod->members));
20 mod->members_hash = genhash_new(cmpf_string, hashf_string, NULL, NULL);
21 assert(mod->members_hash);
30 asn1p_module_free(asn1p_module_t *mod) {
33 asn1p_xports_t *xports;
35 free(mod->ModuleName);
36 free(mod->source_file_name);
38 asn1p_oid_free(mod->module_oid);
40 while((xports = TQ_REMOVE(&(mod->exports), xp_next)))
41 asn1p_xports_free(xports);
43 while((xports = TQ_REMOVE(&(mod->imports), xp_next)))
44 asn1p_xports_free(xports);
46 while((expr = TQ_REMOVE(&(mod->members), next)))
47 asn1p_expr_free(expr);
49 genhash_destroy(mod->members_hash);
50 mod->members_hash = NULL;
59 asn = calloc(1, sizeof(*asn));
61 TQ_INIT(&(asn->modules));
68 asn1p_delete(asn1p_t *asn) {
71 while((mod = TQ_REMOVE(&(asn->modules), mod_next)))
72 asn1p_module_free(mod);
79 asn1p_module_move_members(asn1p_module_t *to, asn1p_module_t *from) {
81 while(TQ_FIRST(&(from->members))) {
82 asn1p_expr_t *expr = TQ_REMOVE(&from->members, next);
83 TQ_ADD(&to->members, expr, next);
84 genhash_add(to->members_hash, expr->Identifier, expr);
86 assert(TQ_FIRST(&from->members) == 0);
88 genhash_empty(from->members_hash, 0, 0);
93 asn1p_module_member_add(asn1p_module_t *mod, asn1p_expr_t *expr) {
95 TQ_ADD(&mod->members, expr, next);
96 genhash_add(mod->members_hash, expr->Identifier, expr);