Commit d8e07c5f authored by Lev Walkin's avatar Lev Walkin

parameterized referencing of information object sets

parent a45518f5
...@@ -4,6 +4,7 @@ AM_CFLAGS = @ADD_CFLAGS@ ...@@ -4,6 +4,7 @@ AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-I$(top_srcdir)/libasn1common \ -I$(top_srcdir)/libasn1common \
-I$(top_srcdir)/libasn1parser \ -I$(top_srcdir)/libasn1parser \
-I$(top_srcdir)/libasn1print \
-I$(top_srcdir)/libasn1fix -I$(top_srcdir)/libasn1fix
noinst_LTLIBRARIES = libasn1compiler.la noinst_LTLIBRARIES = libasn1compiler.la
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "asn1c_out.h" #include "asn1c_out.h"
#include "asn1c_misc.h" #include "asn1c_misc.h"
#include "asn1c_ioc.h" #include "asn1c_ioc.h"
#include <asn1print.h>
#include <asn1fix_crange.h> /* constraint groker from libasn1fix */ #include <asn1fix_crange.h> /* constraint groker from libasn1fix */
#include <asn1fix_export.h> /* other exportables from libasn1fix */ #include <asn1fix_export.h> /* other exportables from libasn1fix */
#include <asn1parser.h> #include <asn1parser.h>
...@@ -320,6 +321,7 @@ is_open_type(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *opt_i ...@@ -320,6 +321,7 @@ is_open_type(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *opt_i
&& expr->reference->comp_count == 2 && expr->reference->comp_count == 2
&& expr->reference->components[1].lex_type && expr->reference->components[1].lex_type
== RLT_AmpUppercase) { == RLT_AmpUppercase) {
DEBUG("%s is a true open type", MKID(expr));
return 1; return 1;
} }
...@@ -461,7 +463,8 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg, asn1c_ioc_table_and_objset_t *opt_ioc ...@@ -461,7 +463,8 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg, asn1c_ioc_table_and_objset_t *opt_ioc
} }
if(v->marker.flags & EM_OMITABLE) if(v->marker.flags & EM_OMITABLE)
comp_mode == 1 ? ++aoms_count : ++roms_count; comp_mode == 1 ? ++aoms_count : ++roms_count;
emit_member_table(arg, v, opt_ioc); if(emit_member_table(arg, v, opt_ioc) < 0)
return -1;
elements++; elements++;
}); });
OUT("};\n"); OUT("};\n");
...@@ -2709,16 +2712,16 @@ emit_member_type_selector(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_ob ...@@ -2709,16 +2712,16 @@ emit_member_type_selector(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_ob
return 0; return 0;
} }
if(crc->el_count <= 1 || crc->elements[0]->type != ACT_EL_VALUE const asn1p_ref_t *objset_ref =
|| crc->elements[0]->value->type != ATV_REFERENCED asn1c_get_information_object_set_reference_from_constraint(arg, crc);
|| crc->elements[0]->value->value.reference->comp_count != 1) {
FATAL( if(!objset_ref || objset_ref->comp_count != 1) {
"Reference does not look like an object set"); FATAL("Reference %s does not look like an object set type %s",
asn1p_constraint_string(crc), asn1p_ref_string(objset_ref));
return -1; return -1;
} }
const char *objset_name = const char *objset_name = objset_ref->components[0].name;
crc->elements[0]->value->value.reference->components[0].name;
if(strcmp(objset_name, opt_ioc->objset->Identifier) != 0) { if(strcmp(objset_name, opt_ioc->objset->Identifier) != 0) {
FATAL("Object Set references do not match: %s != %s", objset_name, FATAL("Object Set references do not match: %s != %s", objset_name,
opt_ioc->objset->Identifier); opt_ioc->objset->Identifier);
...@@ -3006,7 +3009,8 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t * ...@@ -3006,7 +3009,8 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *
if(C99_MODE) OUT(".type_selector = "); if(C99_MODE) OUT(".type_selector = ");
if(opt_ioc) { if(opt_ioc) {
emit_member_type_selector(arg, expr, opt_ioc); if(emit_member_type_selector(arg, expr, opt_ioc) < 0)
return -1;
} else { } else {
OUT("0"); OUT("0");
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "asn1c_out.h" #include "asn1c_out.h"
#include "asn1c_misc.h" #include "asn1c_misc.h"
#include <asn1fix_export.h> #include <asn1fix_export.h>
#include <asn1print.h>
#define MKID(expr) asn1c_make_identifier(0, (expr), 0) #define MKID(expr) asn1c_make_identifier(0, (expr), 0)
...@@ -10,18 +11,26 @@ ...@@ -10,18 +11,26 @@
* Given the table constraint or component relation constraint * Given the table constraint or component relation constraint
* ({ObjectSetName}{...}) returns "ObjectSetName" as a reference. * ({ObjectSetName}{...}) returns "ObjectSetName" as a reference.
*/ */
static const asn1p_ref_t * const asn1p_ref_t *
asn1c_get_information_object_set_reference_from_constraint( asn1c_get_information_object_set_reference_from_constraint(arg_t *arg,
const asn1p_constraint_t *ct) { const asn1p_constraint_t *ct) {
if(!ct) return NULL; if(!ct) return NULL;
assert(ct->type == ACT_CA_CRC); assert(ct->type == ACT_CA_CRC);
assert(ct->el_count >= 1); assert(ct->el_count >= 1);
DEBUG("Component Relation Constraint: %s", asn1p_constraint_string(ct));
assert(ct->elements[0]->type == ACT_EL_VALUE); assert(ct->elements[0]->type == ACT_EL_VALUE);
asn1p_value_t *val = ct->elements[0]->value; asn1p_value_t *val = ct->elements[0]->value;
if(val->type == ATV_VALUESET && val->value.constraint->type == ACT_EL_TYPE && val->value.constraint->containedSubtype && val->value.constraint->containedSubtype->type == ATV_REFERENCED) {
return val->value.constraint->containedSubtype->value.reference;
}
if(val->type != ATV_REFERENCED) {
FATAL("Set reference: %s", asn1f_printable_value(val));
assert(val->type == ATV_REFERENCED); assert(val->type == ATV_REFERENCED);
}
return val->value.reference; return val->value.reference;
} }
...@@ -53,17 +62,12 @@ asn1c_get_ioc_table(arg_t *arg) { ...@@ -53,17 +62,12 @@ asn1c_get_ioc_table(arg_t *arg) {
asn1c_ioc_table_and_objset_t safe_ioc_tao = {0, 0, 0}; asn1c_ioc_table_and_objset_t safe_ioc_tao = {0, 0, 0};
asn1c_ioc_table_and_objset_t failed_ioc_tao = { 0, 0, 1 }; asn1c_ioc_table_and_objset_t failed_ioc_tao = { 0, 0, 1 };
if(expr->lhs_params) {
if(0) WARNING(
"Can not process Information Object Set on a parameterized type %s",
MKID(expr));
return safe_ioc_tao;
}
TQ_FOR(memb, &(expr->members), next) { TQ_FOR(memb, &(expr->members), next) {
const asn1p_constraint_t *cr_ct =
asn1p_get_component_relation_constraint(memb->constraints);
const asn1p_ref_t *tmpref = const asn1p_ref_t *tmpref =
asn1c_get_information_object_set_reference_from_constraint( asn1c_get_information_object_set_reference_from_constraint(arg,
asn1p_get_component_relation_constraint(memb->constraints)); cr_ct);
if(tmpref) { if(tmpref) {
if(objset_ref && asn1p_ref_compare(objset_ref, tmpref) != 0) { if(objset_ref && asn1p_ref_compare(objset_ref, tmpref) != 0) {
FATAL( FATAL(
...@@ -74,6 +78,7 @@ asn1c_get_ioc_table(arg_t *arg) { ...@@ -74,6 +78,7 @@ asn1c_get_ioc_table(arg_t *arg) {
} }
objset_ref = tmpref; objset_ref = tmpref;
} }
} }
if(!objset_ref) { if(!objset_ref) {
......
...@@ -15,5 +15,8 @@ asn1c_ioc_table_and_objset_t asn1c_get_ioc_table(arg_t *arg); ...@@ -15,5 +15,8 @@ asn1c_ioc_table_and_objset_t asn1c_get_ioc_table(arg_t *arg);
int emit_ioc_table(arg_t *arg, asn1p_expr_t *context, int emit_ioc_table(arg_t *arg, asn1p_expr_t *context,
asn1c_ioc_table_and_objset_t); asn1c_ioc_table_and_objset_t);
const asn1p_ref_t *asn1c_get_information_object_set_reference_from_constraint(
arg_t *arg, const asn1p_constraint_t *ct);
#endif /* ASN1_IOC_H */ #endif /* ASN1_IOC_H */
...@@ -27,10 +27,6 @@ asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_ps ...@@ -27,10 +27,6 @@ asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_ps
assert(expr->lhs_params); assert(expr->lhs_params);
assert(expr->parent_expr == 0); assert(expr->parent_expr == 0);
DEBUG("Forking parameterization at %d for %s (%d alr)",
rhs_pspecs->_lineno, expr->Identifier,
expr->specializations.pspecs_count);
/* /*
* Find if this exact specialization has been used already. * Find if this exact specialization has been used already.
*/ */
...@@ -45,6 +41,10 @@ asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_ps ...@@ -45,6 +41,10 @@ asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_ps
} }
} }
DEBUG("Forking parameterization at %d for %s (%d alr)",
rhs_pspecs->_lineno, expr->Identifier,
expr->specializations.pspecs_count);
rarg.resolver = resolve_expr; rarg.resolver = resolve_expr;
rarg.arg = arg; rarg.arg = arg;
rarg.original_expr = expr; rarg.original_expr = expr;
......

-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .144
ModuleInformationObjectParameterization
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 144 }
DEFINITIONS ::=
BEGIN
MYID ::= CLASS {
&id INTEGER UNIQUE,
&Type
} WITH SYNTAX {&Type IDENTIFIED BY &id}
RegionalExtension MYID ::= {
{INTEGER IDENTIFIED BY 1} |
{BOOLEAN IDENTIFIED BY 2},
...
}
Message ::= SEQUENCE {
content SpecializedContent {{RegionalExtension}}
}
SpecializedContent {MYID : Set} ::= SEQUENCE {
id MYID.&id({Set}),
value MYID.&Type({Set}{@id})
}
END
This diff is collapsed.
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