Commit 20879ba2 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Set expr_type to SEQUENCE type

Mimic what OAI's asnfix.c of generate_asn1 script does.
parent 18971e7c
...@@ -329,6 +329,7 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) { ...@@ -329,6 +329,7 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
int comp_mode = 0; /* {root,ext=1,root,root,...} */ int comp_mode = 0; /* {root,ext=1,root,root,...} */
int saved_target = arg->target->target; int saved_target = arg->target->target;
asn1c_ioc_table_and_objset_t ioc_tao; asn1c_ioc_table_and_objset_t ioc_tao;
int ext_num = 1;
DEPENDENCIES; DEPENDENCIES;
...@@ -373,6 +374,15 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) { ...@@ -373,6 +374,15 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
INDENT(-1); INDENT(-1);
tmp_arg.embed--; tmp_arg.embed--;
} else { } else {
char ext_name[20];
if((v->expr_type == ASN_CONSTR_SEQUENCE) &&
(v->marker.flags & EM_OPTIONAL) &&
(v->Identifier == NULL)) {
sprintf(ext_name, "ext%d", ext_num++);
v->Identifier = strdup(ext_name);
}
EMBED_WITH_IOCT(v, ioc_tao); EMBED_WITH_IOCT(v, ioc_tao);
} }
} }
...@@ -568,6 +578,7 @@ asn1c_lang_C_type_SET(arg_t *arg) { ...@@ -568,6 +578,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
const char *id; const char *id;
int comp_mode = 0; /* {root,ext=1,root,root,...} */ int comp_mode = 0; /* {root,ext=1,root,root,...} */
int saved_target = arg->target->target; int saved_target = arg->target->target;
int ext_num = 1;
DEPENDENCIES; DEPENDENCIES;
...@@ -603,11 +614,20 @@ asn1c_lang_C_type_SET(arg_t *arg) { ...@@ -603,11 +614,20 @@ asn1c_lang_C_type_SET(arg_t *arg) {
} }
TQ_FOR(v, &(expr->members), next) { TQ_FOR(v, &(expr->members), next) {
char ext_name[20];
if(v->expr_type == A1TC_EXTENSIBLE) if(v->expr_type == A1TC_EXTENSIBLE)
if(comp_mode < 3) comp_mode++; if(comp_mode < 3) comp_mode++;
if(comp_mode == 1) if(comp_mode == 1)
v->marker.flags |= EM_OMITABLE | EM_INDIRECT; v->marker.flags |= EM_OMITABLE | EM_INDIRECT;
try_inline_default(arg, v, 1); try_inline_default(arg, v, 1);
if((v->expr_type == ASN_CONSTR_SEQUENCE) &&
(v->marker.flags & EM_OPTIONAL) &&
(v->Identifier == NULL)) {
sprintf(ext_name, "ext%d", ext_num++);
v->Identifier = strdup(ext_name);
}
EMBED(v); EMBED(v);
} }
......
...@@ -349,6 +349,7 @@ void asn1p_lexer_hack_push_encoding_control(void); ...@@ -349,6 +349,7 @@ void asn1p_lexer_hack_push_encoding_control(void);
extern int asn1p_lineno; extern int asn1p_lineno;
const char *asn1p_parse_debug_filename; const char *asn1p_parse_debug_filename;
#define ASN_FILENAME asn1p_parse_debug_filename #define ASN_FILENAME asn1p_parse_debug_filename
int ext_num = 1;
/* /*
* Process directives as <ASN1C:RepresentAsPointer> * Process directives as <ASN1C:RepresentAsPointer>
...@@ -3086,8 +3087,10 @@ yyreduce: ...@@ -3086,8 +3087,10 @@ yyreduce:
#line 1034 "asn1p_y.y" #line 1034 "asn1p_y.y"
{ {
(yyval.a_expr) = (yyvsp[(1) - (5)].a_expr); (yyval.a_expr) = (yyvsp[(1) - (5)].a_expr);
asn1p_expr_add_many((yyval.a_expr), (yyvsp[(4) - (5)].a_expr)); (yyvsp[(4) - (5)].a_expr)->meta_type = AMT_TYPE;
asn1p_expr_free((yyvsp[(4) - (5)].a_expr)); (yyvsp[(4) - (5)].a_expr)->expr_type = ASN_CONSTR_SEQUENCE;
(yyvsp[(4) - (5)].a_expr)->marker.flags |= EM_OPTIONAL;
asn1p_expr_add((yyval.a_expr), (yyvsp[(4) - (5)].a_expr));
} }
break; break;
......
...@@ -1033,8 +1033,10 @@ ComponentTypeLists: ...@@ -1033,8 +1033,10 @@ ComponentTypeLists:
} }
| ComponentTypeLists ',' TOK_VBracketLeft ComponentTypeLists TOK_VBracketRight { | ComponentTypeLists ',' TOK_VBracketLeft ComponentTypeLists TOK_VBracketRight {
$$ = $1; $$ = $1;
asn1p_expr_add_many($$, $4); $4->meta_type = AMT_TYPE;
asn1p_expr_free($4); $4->expr_type = ASN_CONSTR_SEQUENCE;
$4->marker.flags |= EM_OPTIONAL;
asn1p_expr_add($$, $4);
} }
; ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment