Commit 0bb89078 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Fix item 2 of issue 254

1. Record the de-referenced expression to newly added field ref_expr
   of strcut asn1p_ref_t.
2. In function asn1c_make_identifier(), not only check whehter there
   is name clash occurred for this asn1p_expr_t but also the referenced
   expression to determine whether an additional module name to be added.
3. Change signature of some functions and variables to eliminate warning
   messages when const type pointer, i.e. const asn1p_ref_t *, variables
   versus, non-const * type pointer, i.e. asn1p_ref_t *, varibles are
   used. E.g.:
   warning: assignment discards ‘const’ qualifier from pointer target type
parent 27eaf82a
......@@ -5,6 +5,7 @@
#define ASN1_REFERENCE_H
struct asn1p_module_s;
struct asn1p_expr_s;
typedef struct asn1p_ref_s {
......@@ -39,6 +40,7 @@ typedef struct asn1p_ref_s {
size_t comp_count; /* Number of the components in the reference name. */
size_t comp_size; /* Number of allocated structures */
struct asn1p_expr_s *ref_expr; /* De-referenced expression */
struct asn1p_module_s *module; /* Defined in module */
int _lineno; /* Number of line in the file */
} asn1p_ref_t;
......
......@@ -11,7 +11,7 @@
* Given the table constraint or component relation constraint
* ({ObjectSetName}{...}) returns "ObjectSetName" as a reference.
*/
const asn1p_ref_t *
asn1p_ref_t *
asn1c_get_information_object_set_reference_from_constraint(arg_t *arg,
const asn1p_constraint_t *ct) {
......@@ -68,14 +68,14 @@ asn1c_get_ioc_table(arg_t *arg) {
asn1p_expr_t *expr = arg->expr;
asn1p_expr_t *memb;
asn1p_expr_t *objset = 0;
const asn1p_ref_t *objset_ref = NULL;
asn1p_ref_t *objset_ref = NULL;
asn1c_ioc_table_and_objset_t safe_ioc_tao = {0, 0, 0};
asn1c_ioc_table_and_objset_t failed_ioc_tao = { 0, 0, 1 };
TQ_FOR(memb, &(expr->members), next) {
const asn1p_constraint_t *cr_ct =
asn1p_get_component_relation_constraint(memb->constraints);
const asn1p_ref_t *tmpref =
asn1p_ref_t *tmpref =
asn1c_get_information_object_set_reference_from_constraint(arg,
cr_ct);
if(tmpref) {
......
......@@ -15,7 +15,7 @@ asn1c_ioc_table_and_objset_t asn1c_get_ioc_table(arg_t *arg);
int emit_ioc_table(arg_t *arg, asn1p_expr_t *context,
asn1c_ioc_table_and_objset_t);
const asn1p_ref_t *asn1c_get_information_object_set_reference_from_constraint(
asn1p_ref_t *asn1c_get_information_object_set_reference_from_constraint(
arg_t *arg, const asn1p_constraint_t *ct);
......
......@@ -82,7 +82,13 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
if(expr->_mark & TM_NAMECLASH) {
size += strlen(expr->module->ModuleName) + 2;
sptr[sptr_cnt++] = expr->module->ModuleName;
} else if (expr->reference && expr->reference->ref_expr &&
(expr->reference->ref_expr->_mark & TM_NAMECLASH) &&
(strcmp(expr->Identifier, expr->reference->ref_expr->Identifier) == 0)) {
size += strlen(expr->reference->ref_expr->module->ModuleName) + 2;
sptr[sptr_cnt++] = expr->reference->ref_expr->module->ModuleName;
}
sptr[sptr_cnt++] = expr->Identifier;
size += strlen(expr->Identifier);
......
......@@ -47,7 +47,7 @@ asn1f_lookup_module_ex(asn1p_t *asn, const char *module_name,
asn1p_expr_t *
asn1f_lookup_symbol_ex(asn1p_t *asn, asn1_namespace_t *ns, asn1p_expr_t *expr,
const asn1p_ref_t *ref) {
asn1p_ref_t *ref) {
arg_t arg;
memset(&arg, 0, sizeof(arg));
......
......@@ -30,7 +30,7 @@ asn1p_expr_t *asn1f_lookup_symbol_ex(
asn1p_t *asn,
struct asn1_namespace_s *ns,
asn1p_expr_t *expr,
const asn1p_ref_t *ref);
asn1p_ref_t *ref);
/*
* Exportable version of an asn1f_class_access().
......
......@@ -441,8 +441,10 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_expr_t *rhs_pspecs, const asn1p_ref_t
asn1p_expr_t *
asn1f_lookup_symbol(arg_t *arg, asn1p_expr_t *rhs_pspecs,
const asn1p_ref_t *ref) {
return asn1f_lookup_symbol_impl(arg, rhs_pspecs, ref, 0);
asn1p_ref_t *ref) {
asn1p_expr_t *expr = asn1f_lookup_symbol_impl(arg, rhs_pspecs, ref, 0);
if (ref) ref->ref_expr = expr;
return expr;
}
asn1p_expr_t *
......
......@@ -38,7 +38,7 @@ asn1p_module_t *asn1f_lookup_module(arg_t *arg,
* symbol lookup. Not a recursive function.
*/
asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_expr_t *rhs_pspecs,
const asn1p_ref_t *ref);
asn1p_ref_t *ref);
/*
* Recursively find the original type for the given expression.
......
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