Compiler support for tagged parametrized members.

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@894 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2005-06-02 05:21:53 +00:00
parent fbd6d9e9d4
commit 5b1030361c
6 changed files with 61 additions and 22 deletions

View File

@ -1,8 +1,9 @@
0.9.15: 2005-May-17
0.9.15: 2005-June-01
* Compiler now checks 64-bit overflows in constraints range handling
code. No effect on the code produced by the compiler.
* Compiler support for tagged parametrized members.
* Empty tags to element map avoided.
0.9.14: 2005-Apr-29

View File

@ -419,6 +419,7 @@ _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) {
|| ta.tag_value == -1 /* Spread IMAGINARY ANY tag... */
|| tb.tag_value == -1 /* ...it is an evil virus, fear it! */
) {
char tagbuf[2][TAG2STRING_BUFFER_SIZE];
char *p = (a->expr_type == A1TC_EXTENSIBLE)
?"potentially ":"";
FATAL("Processing %s at line %d: component \"%s\" at line %d %shas the same tag "
@ -431,6 +432,12 @@ _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) {
b->Identifier,
b->_lineno
);
DEBUG("Tags: %s %s vs. %s %s",
asn1p_tag2string(&ta, tagbuf[0]),
a->Identifier,
asn1p_tag2string(&tb, tagbuf[1]),
b->Identifier
);
if((arg->mod->module_flags & MSF_EXTENSIBILITY_IMPLIED)
&& (a->expr_type == A1TC_EXTENSIBLE)
&& (b->expr_type == A1TC_EXTENSIBLE)) {

View File

@ -60,12 +60,22 @@ asn1f_fix_parametrized_assignment(arg_t *arg) {
#define SUBSTITUTE(to, from) do { \
asn1p_expr_t tmp, *__v; \
if((to)->tag.tag_class \
&& (from)->tag.tag_class) { \
FATAL("Layered tagging " \
"in parametrization " \
"is not yet supported, " \
"contact asn1c author for"); \
return -1; \
} \
tmp = *(to); \
*(to) = *(from); \
TQ_MOVE(&(to)->members, &(from)->members); \
*(from) = tmp; \
(to)->next = tmp.next; \
(to)->parent_expr = tmp.parent_expr; \
if(tmp.tag.tag_class) \
(to)->tag = tmp.tag; \
memset(&((from)->next), 0, \
sizeof((from)->next)); \
memset(&((from)->members), 0, \

View File

@ -142,3 +142,41 @@ asn1p_expr_free(asn1p_expr_t *expr) {
}
}
char *asn1p_tag2string(struct asn1p_type_tag_s *tag, char *buf) {
static buf_stat[TAG2STRING_BUFFER_SIZE];
char *start;
char *end;
if(!buf) buf = buf_stat;
start = buf;
end = buf + TAG2STRING_BUFFER_SIZE;
if(tag->tag_class == TC_NOCLASS) {
*buf = 0;
return buf;
}
strcpy(buf, "[");
switch(tag->tag_class) {
case TC_NOCLASS:
assert(tag->tag_class != TC_NOCLASS);
break;
case TC_UNIVERSAL: strcat(buf, "UNIVERSAL "); break;
case TC_PRIVATE: strcat(buf, "PRIVATE "); break;
case TC_APPLICATION: strcat(buf, "APPLICATION "); break;
case TC_CONTEXT_SPECIFIC:
break;
}
buf += snprintf(buf + strlen(buf), end - buf,
"%" PRIdASN "]", tag->tag_value);
assert((buf - end) > sizeof(" IMPLICIT "));
switch(tag->tag_mode) {
case TM_DEFAULT: break;
case TM_IMPLICIT: strcat(buf, " IMPLICIT"); break;
case TM_EXPLICIT: strcat(buf, " EXPLICIT"); break;
}
return start;
}

View File

@ -242,4 +242,7 @@ asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *, int skip_extensions);
void asn1p_expr_add(asn1p_expr_t *to, asn1p_expr_t *what);
void asn1p_expr_free(asn1p_expr_t *expr);
#define TAG2STRING_BUFFER_SIZE 64 /* buf should be at least this big */
char *asn1p_tag2string(struct asn1p_type_tag_s *tag, char *opt_buf);
#endif /* ASN1_PARSER_EXPR_H */

View File

@ -168,27 +168,7 @@ asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags flags) {
(void)flags; /* Unused argument */
if(tag->tag_class == TC_NOCLASS)
return 0;
printf("[");
switch(tag->tag_class) {
case TC_NOCLASS:
assert(tag->tag_class != TC_NOCLASS);
break;
case TC_UNIVERSAL: printf("UNIVERSAL "); break;
case TC_PRIVATE: printf("PRIVATE "); break;
case TC_APPLICATION: printf("APPLICATION "); break;
case TC_CONTEXT_SPECIFIC:
break;
}
printf("%" PRIdASN "]", tag->tag_value);
switch(tag->tag_mode) {
case TM_DEFAULT: break;
case TM_IMPLICIT: printf(" IMPLICIT"); break;
case TM_EXPLICIT: printf(" EXPLICIT"); break;
}
printf("%s", asn1p_tag2string(tag, 0));
return 0;
}