Index: trunk/src/libcschem/abstract.c =================================================================== --- trunk/src/libcschem/abstract.c (revision 10092) +++ trunk/src/libcschem/abstract.c (revision 10093) @@ -30,9 +30,11 @@ #include #include -#include "abstract.h" #include +#include +#include "abstract.h" + static const char *atype_names[] = { "", "net", @@ -184,14 +186,51 @@ } -csch_anet_t *csch_anet_get(csch_abstract_t *abs, const char *netname) +csch_anet_t *csch_anet_get_at(csch_abstract_t *abs, csch_hlevel_t *hlev, csch_ascope_t scope, const char *netname) { csch_anet_t *net; + csch_ascope_t prefix_scope; + const char *orig_name = netname; - net = htsp_get(&abs->nets, netname); - return net; + prefix_scope = csch_split_name_scope(&netname); + if (scope != CSCH_ASCOPE_unknown) { + if ((prefix_scope != CSCH_ASCOPE_AUTO) && (prefix_scope != scope)) { + rnd_message(RND_MSG_ERROR, "Failed to resolve net '%s': conflicting scopes\n", orig_name); + return NULL; + } + } + else + scope = prefix_scope; + + + switch(scope) { + case CSCH_ASCOPE_AUTO: +TODO("hierarchy: implement me; at the moment we fall back to global for compatibility"); + case CSCH_ASCOPE_GLOBAL: return htsp_get(&abs->nets, netname); + case CSCH_ASCOPE_SHEET_LOCAL: return htsp_get(&hlev->nets, netname); + case CSCH_ASCOPE_SUBTREE_LOCAL: + case CSCH_ASCOPE_SUBTREE_AUTO: + if (hlev == NULL) { + rnd_message(RND_MSG_ERROR, "Failed to resolve net '%s': scope requires hierarchy which is not available\n", orig_name); + return NULL; + } + + rnd_message(RND_MSG_ERROR, "TODO: scope resolver not yet implemented for '%s'\n", orig_name); + return NULL; + + case CSCH_ASCOPE_unknown: + rnd_message(RND_MSG_ERROR, "Failed to resolve net '%s': unknown scope\n", orig_name); + return NULL; + } + return NULL; } +csch_anet_t *csch_anet_get(csch_abstract_t *abs, const char *netname) +{ + return csch_anet_get_at(abs, NULL, CSCH_ASCOPE_unknown, netname); +} + + csch_anet_t *csch_anet_new(csch_abstract_t *abs, const char *netname, int set_no_uname) { csch_anet_t *net = calloc(sizeof(csch_anet_t), 1); Index: trunk/src/libcschem/abstract.h =================================================================== --- trunk/src/libcschem/abstract.h (revision 10092) +++ trunk/src/libcschem/abstract.h (revision 10093) @@ -91,7 +91,8 @@ const char *csch_atype_name(csch_atype_t type); typedef enum csch_ascope_e { /* implements {des6:8} */ - CSCH_ASCOPE_GLOBAL, /* syntax: /name */ + CSCH_ASCOPE_unknown = -1, + CSCH_ASCOPE_GLOBAL=1, /* syntax: /name */ CSCH_ASCOPE_SUBTREE_LOCAL, /* syntax: v/name */ CSCH_ASCOPE_SHEET_LOCAL, /* syntax: ./name */ CSCH_ASCOPE_AUTO, /* syntax: name */ @@ -206,6 +207,7 @@ /*** net ***/ csch_anet_t *csch_anet_get(csch_abstract_t *abs, const char *netname); +csch_anet_t *csch_anet_get_at(csch_abstract_t *abs, csch_hlevel_t *hlev, csch_ascope_t scope, const char *netname); csch_anet_t *csch_anet_new(csch_abstract_t *abs, const char *netname, int set_no_uname); /*** component and port ***/