Skip to content
Snippets Groups Projects
Commit c3e29404 authored by Lev Walkin's avatar Lev Walkin
Browse files

new tags api

parent 8945e0ea
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ static int asn1c_lang_C_type_SEQUENCE_def(arg_t *arg); ...@@ -24,7 +24,7 @@ static int asn1c_lang_C_type_SEQUENCE_def(arg_t *arg);
static int asn1c_lang_C_type_SET_def(arg_t *arg); static int asn1c_lang_C_type_SET_def(arg_t *arg);
static int asn1c_lang_C_type_CHOICE_def(arg_t *arg); static int asn1c_lang_C_type_CHOICE_def(arg_t *arg);
static int asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of); static int asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of);
static int _print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p); static int _print_tag(arg_t *arg, struct asn1p_type_tag_s *tag_p);
static int check_if_extensible(asn1p_expr_t *expr); static int check_if_extensible(asn1p_expr_t *expr);
static int expr_elements_count(arg_t *arg, asn1p_expr_t *expr); static int expr_elements_count(arg_t *arg, asn1p_expr_t *expr);
static int emit_member_table(arg_t *arg, asn1p_expr_t *expr); static int emit_member_table(arg_t *arg, asn1p_expr_t *expr);
...@@ -903,20 +903,10 @@ static int check_if_extensible(asn1p_expr_t *expr) { ...@@ -903,20 +903,10 @@ static int check_if_extensible(asn1p_expr_t *expr) {
} }
static int static int
_print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p) { _print_tag(arg_t *arg, struct asn1p_type_tag_s *tag) {
struct asn1p_type_tag_s tag;
if(tag_p) {
tag = *tag_p;
} else {
if(asn1f_fetch_tag(arg->asn, arg->mod, expr, &tag, 0)) {
OUT("-1 /* Ambiguous tag (CHOICE|ANY?) */");
return 0;
}
}
OUT("("); OUT("(");
switch(tag.tag_class) { switch(tag->tag_class) {
case TC_UNIVERSAL: OUT("ASN_TAG_CLASS_UNIVERSAL"); break; case TC_UNIVERSAL: OUT("ASN_TAG_CLASS_UNIVERSAL"); break;
case TC_APPLICATION: OUT("ASN_TAG_CLASS_APPLICATION"); break; case TC_APPLICATION: OUT("ASN_TAG_CLASS_APPLICATION"); break;
case TC_CONTEXT_SPECIFIC: OUT("ASN_TAG_CLASS_CONTEXT"); break; case TC_CONTEXT_SPECIFIC: OUT("ASN_TAG_CLASS_CONTEXT"); break;
...@@ -924,7 +914,7 @@ _print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p) { ...@@ -924,7 +914,7 @@ _print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p) {
case TC_NOCLASS: case TC_NOCLASS:
break; break;
} }
OUT(" | (%lld << 2))", tag.tag_value); OUT(" | (%lld << 2))", tag->tag_value);
return 0; return 0;
} }
...@@ -1030,7 +1020,7 @@ _add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) { ...@@ -1030,7 +1020,7 @@ _add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) {
assert(el_no >= 0); assert(el_no >= 0);
ret = asn1f_fetch_tag(arg->asn, arg->mod, arg->expr, &tag, 1); ret = asn1f_fetch_outmost_tag(arg->asn, arg->mod, arg->expr, &tag, 1);
if(ret == 0) { if(ret == 0) {
tag2el_t *te; tag2el_t *te;
int new_count = (*count) + 1; int new_count = (*count) + 1;
...@@ -1106,7 +1096,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count) { ...@@ -1106,7 +1096,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count) {
int i; int i;
for(i = 0; i < tag2el_count; i++) { for(i = 0; i < tag2el_count; i++) {
OUT(" { "); OUT(" { ");
_print_tag(arg, expr, &tag2el[i].el_tag); _print_tag(arg, &tag2el[i].el_tag);
OUT(", "); OUT(", ");
OUT("%d, ", tag2el[i].el_no); OUT("%d, ", tag2el[i].el_no);
OUT("%d, ", tag2el[i].toff_first); OUT("%d, ", tag2el[i].toff_first);
...@@ -1148,7 +1138,7 @@ emit_tags_vector(arg_t *arg, asn1p_expr_t *expr, int *tags_impl_skip, int choice ...@@ -1148,7 +1138,7 @@ emit_tags_vector(arg_t *arg, asn1p_expr_t *expr, int *tags_impl_skip, int choice
INDENT(+1); INDENT(+1);
if(expr->tag.tag_class) { if(expr->tag.tag_class) {
tags_count++; tags_count++;
_print_tag(arg, expr, &expr->tag); _print_tag(arg, &expr->tag);
if(expr->tag.tag_mode != TM_EXPLICIT) if(expr->tag.tag_mode != TM_EXPLICIT)
(*tags_impl_skip)++; (*tags_impl_skip)++;
} else { } else {
...@@ -1165,7 +1155,7 @@ emit_tags_vector(arg_t *arg, asn1p_expr_t *expr, int *tags_impl_skip, int choice ...@@ -1165,7 +1155,7 @@ emit_tags_vector(arg_t *arg, asn1p_expr_t *expr, int *tags_impl_skip, int choice
tag.tag_class = TC_UNIVERSAL; tag.tag_class = TC_UNIVERSAL;
tag.tag_mode = TM_IMPLICIT; tag.tag_mode = TM_IMPLICIT;
tag.tag_value = expr_type2uclass_value[expr->expr_type]; tag.tag_value = expr_type2uclass_value[expr->expr_type];
_print_tag(arg, expr, &tag); _print_tag(arg, &tag);
tags_count++; tags_count++;
} }
} }
...@@ -1201,6 +1191,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) { ...@@ -1201,6 +1191,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
static int global_memb_unique; static int global_memb_unique;
int save_target; int save_target;
arg_t tmp_arg; arg_t tmp_arg;
struct asn1p_type_tag_s outmost_tag;
char *p; char *p;
OUT("{ "); OUT("{ ");
...@@ -1228,7 +1219,12 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) { ...@@ -1228,7 +1219,12 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
} }
INDENT(+1); INDENT(+1);
if(C99_MODE) OUT(".tag = "); if(C99_MODE) OUT(".tag = ");
_print_tag(arg, expr , NULL); if(asn1f_fetch_outmost_tag(arg->asn,
expr->module, expr, &outmost_tag, 0)) {
OUT("-1 /* Ambiguous tag (CHOICE|ANY?) */");
} else {
_print_tag(arg, &outmost_tag);
}
OUT(",\n"); OUT(",\n");
if(C99_MODE) OUT(".tag_mode = "); if(C99_MODE) OUT(".tag_mode = ");
if(expr->tag.tag_class) { if(expr->tag.tag_class) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment