aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2004-08-22 03:10:23 +0000
committerLev Walkin <vlm@lionet.info>2004-08-22 03:10:23 +0000
commit6fec44d9b2421ac4e556f8b9d21c53c4ad78f629 (patch)
tree3a72a8c8240fc64de40d5ac180cd9d594cd4ea22
parent4ec3b4c088904c50ffc8c8ad06e11214d964e8c4 (diff)
refactoring
-rw-r--r--libasn1compiler/asn1c_out.h2
-rw-r--r--libasn1compiler/asn1compiler.c8
-rw-r--r--libasn1fix/asn1fix_bitstring.c2
-rw-r--r--libasn1fix/asn1fix_class.c6
-rw-r--r--libasn1fix/asn1fix_class.h5
-rw-r--r--libasn1fix/asn1fix_constraint.c22
-rw-r--r--libasn1fix/asn1fix_constraint.h3
-rw-r--r--libasn1fix/asn1fix_dereft.c31
-rw-r--r--libasn1fix/asn1fix_export.c16
-rw-r--r--libasn1fix/asn1fix_export.h6
-rw-r--r--libasn1fix/asn1fix_integer.c6
-rw-r--r--libasn1fix/asn1fix_param.c6
-rw-r--r--libasn1fix/asn1fix_retrieve.c48
-rw-r--r--libasn1fix/asn1fix_retrieve.h13
-rw-r--r--libasn1fix/asn1fix_tags.c4
-rw-r--r--libasn1fix/asn1fix_value.c9
16 files changed, 73 insertions, 114 deletions
diff --git a/libasn1compiler/asn1c_out.h b/libasn1compiler/asn1c_out.h
index f604687b..7e2abfd8 100644
--- a/libasn1compiler/asn1c_out.h
+++ b/libasn1compiler/asn1c_out.h
@@ -69,6 +69,8 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
_tmp.default_cb(&_tmp); \
); \
arg->embed--; \
+ if(ev->expr_type != A1TC_EXTENSIBLE) \
+ OUT(";\n"); \
assert(arg->target->target == OT_TYPE_DECLS); \
REDIR(saved_target); \
} while(0)
diff --git a/libasn1compiler/asn1compiler.c b/libasn1compiler/asn1compiler.c
index dd51156f..0159da15 100644
--- a/libasn1compiler/asn1compiler.c
+++ b/libasn1compiler/asn1compiler.c
@@ -84,6 +84,9 @@ asn1c_compile_expr(arg_t *arg) {
expr->_lineno);
ret = type_cb(arg);
+
+ if(arg->target->destination[OT_TYPE_DECLS].indent_level == 0)
+ OUT(";\n");
} else {
ret = -1;
/*
@@ -112,6 +115,11 @@ asn1c_compile_expr(arg_t *arg) {
}
if(ret == -1) {
+ FATAL("Cannot compile \"%s\" (%x:%x) at line %d",
+ arg->expr->Identifier,
+ arg->expr->expr_type,
+ arg->expr->meta_type,
+ arg->expr->_lineno);
OUT("#error Cannot compile \"%s\" (%x/%x) at line %d\n",
arg->expr->Identifier,
arg->expr->meta_type,
diff --git a/libasn1fix/asn1fix_bitstring.c b/libasn1fix/asn1fix_bitstring.c
index 0d3961d4..c9a09761 100644
--- a/libasn1fix/asn1fix_bitstring.c
+++ b/libasn1fix/asn1fix_bitstring.c
@@ -16,7 +16,7 @@ asn1f_fix_bit_string(arg_t *arg) {
DEBUG("%s(%s) for line %d", __func__,
expr->Identifier, expr->_lineno);
- ttype = asn1f_find_terminal_type(arg, expr, 0);
+ ttype = asn1f_find_terminal_type(arg, expr);
if(ttype && ttype->expr_type == ASN_BASIC_BIT_STRING) {
ret = asn1f_fix_bit_string_value(arg, ttype);
RET2RVAL(ret, r_value);
diff --git a/libasn1fix/asn1fix_class.c b/libasn1fix/asn1fix_class.c
index f617c318..98d47f44 100644
--- a/libasn1fix/asn1fix_class.c
+++ b/libasn1fix/asn1fix_class.c
@@ -23,15 +23,13 @@ static asn1p_expr_t *
asn1f_class_dot_lookup(arg_t *arg, asn1p_expr_t *obj, asn1p_ref_t *ref);
asn1p_expr_t *
-asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) {
+asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
asn1p_expr_t *obj; /* Information Object or Object Set */
object_category_e obj_cat; /* Object category */
//field_category_e field_cat; /* Field category */
asn1p_expr_t *result;
asn1p_ref_t tmpref;
- (void)mod_r; /* Unused argument */
-
assert(ref->comp_count > 1);
DEBUG("%s(%s) for line %d", __func__,
@@ -47,7 +45,7 @@ asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) {
tmpref = *ref;
tmpref.comp_count = 1;
- obj = asn1f_lookup_symbol(arg, &tmpref, 0);
+ obj = asn1f_lookup_symbol(arg, mod, &tmpref);
if(obj == NULL) {
errno = ESRCH;
return NULL;
diff --git a/libasn1fix/asn1fix_class.h b/libasn1fix/asn1fix_class.h
index c849b2b3..763e48cf 100644
--- a/libasn1fix/asn1fix_class.h
+++ b/libasn1fix/asn1fix_class.h
@@ -4,13 +4,12 @@
/*
* Fetch the element from the class-related stuff (thing) by its reference.
*/
-asn1p_expr_t *
-asn1f_class_access(arg_t *, asn1p_ref_t *, asn1p_module_t **mod_r);
+asn1p_expr_t *asn1f_class_access(arg_t *, asn1p_module_t *mod, asn1p_ref_t *);
/*
* Externally accessible version of above function.
*/
asn1p_expr_t *asn1f_class_access2(asn1p_t *asn, asn1p_module_t *mod,
- asn1p_expr_t *expr, asn1p_ref_t *, asn1p_module_t **mod_r);
+ asn1p_expr_t *expr, asn1p_ref_t *);
#endif /* _ASN1FIX_CLASS_H_ */
diff --git a/libasn1fix/asn1fix_constraint.c b/libasn1fix/asn1fix_constraint.c
index 4620ec52..4a25faee 100644
--- a/libasn1fix/asn1fix_constraint.c
+++ b/libasn1fix/asn1fix_constraint.c
@@ -3,7 +3,7 @@
#include <asn1fix_crange.h>
static void _remove_exceptions(arg_t *arg, asn1p_constraint_t *ct);
-static int _constraint_value_resolve(arg_t *arg, asn1p_value_t **value);
+static int _constraint_value_resolve(arg_t *arg, asn1p_module_t *mod, asn1p_value_t **value);
int
asn1constraint_pullup(arg_t *arg) {
@@ -25,11 +25,10 @@ asn1constraint_pullup(arg_t *arg) {
if(expr->expr_type == A1TC_REFERENCE) {
asn1p_ref_t *ref = expr->reference;
- asn1p_module_t *mod_rw = arg->mod;
asn1p_expr_t *parent_expr;
assert(ref);
- parent_expr = asn1f_lookup_symbol(arg, ref, &mod_rw);
+ parent_expr = asn1f_lookup_symbol(arg, expr->module, ref);
if(!parent_expr) {
if(errno != EEXIST) {
DEBUG("\tWhile fetching parent constraints: "
@@ -120,7 +119,7 @@ asn1constraint_pullup(arg_t *arg) {
}
int
-asn1constraint_resolve(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_type_e etype, enum asn1p_constraint_type_e effective_type) {
+asn1constraint_resolve(arg_t *arg, asn1p_module_t *mod, asn1p_constraint_t *ct, asn1p_expr_type_e etype, enum asn1p_constraint_type_e effective_type) {
int rvalue = 0;
int ret;
int el;
@@ -183,15 +182,15 @@ asn1constraint_resolve(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_type_e ety
* Resolve all possible references, wherever they occur.
*/
if(ct->value && ct->value->type == ATV_REFERENCED) {
- ret = _constraint_value_resolve(arg, &ct->value);
+ ret = _constraint_value_resolve(arg, mod, &ct->value);
RET2RVAL(ret, rvalue);
}
if(ct->range_start && ct->range_start->type == ATV_REFERENCED) {
- ret = _constraint_value_resolve(arg, &ct->range_start);
+ ret = _constraint_value_resolve(arg, mod, &ct->range_start);
RET2RVAL(ret, rvalue);
}
if(ct->range_stop && ct->range_stop->type == ATV_REFERENCED) {
- ret = _constraint_value_resolve(arg, &ct->range_stop);
+ ret = _constraint_value_resolve(arg, mod, &ct->range_stop);
RET2RVAL(ret, rvalue);
}
@@ -199,7 +198,7 @@ asn1constraint_resolve(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_type_e ety
* Proceed recursively.
*/
for(el = 0; el < ct->el_count; el++) {
- ret = asn1constraint_resolve(arg, ct->elements[el],
+ ret = asn1constraint_resolve(arg, mod, ct->elements[el],
etype, effective_type);
RET2RVAL(ret, rvalue);
}
@@ -230,15 +229,14 @@ _remove_exceptions(arg_t *arg, asn1p_constraint_t *ct) {
static int
-_constraint_value_resolve(arg_t *arg, asn1p_value_t **value) {
+_constraint_value_resolve(arg_t *arg, asn1p_module_t *mod, asn1p_value_t **value) {
asn1p_expr_t static_expr;
asn1p_expr_t *tmp_expr;
- asn1p_module_t *mod_rw = arg->mod;
arg_t tmp_arg;
int rvalue = 0;
int ret;
- tmp_expr = asn1f_lookup_symbol(arg, (*value)->value.reference, &mod_rw);
+ tmp_expr = asn1f_lookup_symbol(arg, mod, (*value)->value.reference);
if(tmp_expr == NULL) {
FATAL("Cannot find symbol %s "
"used in %s subtype constraint at line %d",
@@ -251,7 +249,7 @@ _constraint_value_resolve(arg_t *arg, asn1p_value_t **value) {
static_expr = *tmp_expr;
static_expr.value = *value;
tmp_arg = *arg;
- tmp_arg.mod = mod_rw;
+ tmp_arg.mod = tmp_expr->module;
tmp_arg.expr = &static_expr;
ret = asn1f_fix_dereference_values(&tmp_arg);
RET2RVAL(ret, rvalue);
diff --git a/libasn1fix/asn1fix_constraint.h b/libasn1fix/asn1fix_constraint.h
index 9e692efa..cc6621f9 100644
--- a/libasn1fix/asn1fix_constraint.h
+++ b/libasn1fix/asn1fix_constraint.h
@@ -4,7 +4,8 @@
/*
* Resolve referenced values inside constraints.
*/
-int asn1constraint_resolve(arg_t *arg, asn1p_constraint_t *ct,
+int asn1constraint_resolve(arg_t *arg, asn1p_module_t *module,
+ asn1p_constraint_t *ct,
asn1p_expr_type_e topmost_parent_expression_type,
enum asn1p_constraint_type_e effective_constraint_type);
diff --git a/libasn1fix/asn1fix_dereft.c b/libasn1fix/asn1fix_dereft.c
index 1f9b5bf4..352df7b0 100644
--- a/libasn1fix/asn1fix_dereft.c
+++ b/libasn1fix/asn1fix_dereft.c
@@ -26,7 +26,7 @@ asn1f_fix_dereference_types(arg_t *arg) {
/*
* Follow the reference.
*/
- type_expr = asn1f_find_terminal_type(arg, expr, 0);
+ type_expr = asn1f_find_terminal_type(arg, expr);
if(type_expr == NULL) {
const char *type_name;
@@ -44,35 +44,6 @@ asn1f_fix_dereference_types(arg_t *arg) {
return -1;
}
- /*
- * Copying members of the source expression
- * into the current expression.
- */
- if(0) {
- asn1p_expr_t *tmp_clone;
-
- tmp_clone = asn1p_expr_clone(type_expr);
- if(tmp_clone == NULL) {
- FATAL("Could not clone \"%s\" at line %d",
- type_expr->Identifier, type_expr->_lineno);
- return -1;
- }
-
- /*
- * Replace the referenced type with its definition.
- */
- DEBUG("\tChanging type of \"%s\":%x to %x for line %d",
- expr->Identifier,
- expr->expr_type,
- type_expr->expr_type,
- expr->_lineno
- );
- expr->expr_type = type_expr->expr_type;
- expr->members = tmp_clone->members;
- memset(&tmp_clone->members, 0, sizeof(tmp_clone->members));
- asn1p_expr_free(tmp_clone);
- }
-
return r_value;
}
diff --git a/libasn1fix/asn1fix_export.c b/libasn1fix/asn1fix_export.c
index cdae6505..3a18ece0 100644
--- a/libasn1fix/asn1fix_export.c
+++ b/libasn1fix/asn1fix_export.c
@@ -7,7 +7,7 @@ extern arg_t a1f_replace_me_with_proper_interface_arg;
asn1p_expr_t *
asn1f_lookup_symbol_ex(
asn1p_t *asn,
- asn1p_module_t **module_rw,
+ asn1p_module_t *mod,
asn1p_expr_t *expr,
asn1p_ref_t *ref) {
arg_t arg;
@@ -15,21 +15,20 @@ asn1f_lookup_symbol_ex(
memset(&arg, 0, sizeof(arg));
arg.asn = asn;
- arg.mod = *module_rw;
+ arg.mod = mod;
arg.expr = expr;
arg.eh = a1f_replace_me_with_proper_interface_arg.eh;
arg.debug = a1f_replace_me_with_proper_interface_arg.debug;
- return asn1f_lookup_symbol(&arg, ref, module_rw);
+ return asn1f_lookup_symbol(&arg, mod, ref);
}
asn1p_expr_t *
asn1f_class_access_ex(asn1p_t *asn,
asn1p_module_t *mod,
asn1p_expr_t *expr,
- asn1p_ref_t *ref,
- asn1p_module_t **mod_r) {
+ asn1p_ref_t *ref) {
arg_t arg;
memset(&arg, 0, sizeof(arg));
@@ -40,14 +39,13 @@ asn1f_class_access_ex(asn1p_t *asn,
arg.eh = a1f_replace_me_with_proper_interface_arg.eh;
arg.debug = a1f_replace_me_with_proper_interface_arg.debug;
- return asn1f_class_access(&arg, ref, mod_r);
+ return asn1f_class_access(&arg, mod, ref);
}
asn1p_expr_t *
asn1f_find_terminal_type_ex(asn1p_t *asn,
asn1p_module_t *mod,
- asn1p_expr_t *expr,
- asn1p_module_t **mod_r) {
+ asn1p_expr_t *expr) {
arg_t arg;
memset(&arg, 0, sizeof(arg));
@@ -58,7 +56,7 @@ asn1f_find_terminal_type_ex(asn1p_t *asn,
arg.eh = a1f_replace_me_with_proper_interface_arg.eh;
arg.debug = a1f_replace_me_with_proper_interface_arg.debug;
- return asn1f_find_terminal_type(&arg, expr, mod_r);
+ return asn1f_find_terminal_type(&arg, expr);
}
int
diff --git a/libasn1fix/asn1fix_export.h b/libasn1fix/asn1fix_export.h
index 7fd9ce11..8ebe4487 100644
--- a/libasn1fix/asn1fix_export.h
+++ b/libasn1fix/asn1fix_export.h
@@ -18,7 +18,7 @@ char const *asn1f_printable_value(asn1p_value_t *value);
*/
asn1p_expr_t *asn1f_lookup_symbol_ex(
asn1p_t *asn,
- asn1p_module_t **module_rw,
+ asn1p_module_t *mod,
asn1p_expr_t *expr,
asn1p_ref_t *ref);
@@ -26,13 +26,13 @@ asn1p_expr_t *asn1f_lookup_symbol_ex(
* Exportable version of an asn1f_class_access().
*/
asn1p_expr_t *asn1f_class_access_ex(asn1p_t *asn, asn1p_module_t *mod,
- asn1p_expr_t *expr, asn1p_ref_t *, asn1p_module_t **mod_r);
+ asn1p_expr_t *expr, asn1p_ref_t *);
/*
* Exportable version of asn1f_find_terminal_type().
*/
asn1p_expr_t *asn1f_find_terminal_type_ex(asn1p_t *asn, asn1p_module_t *mod,
- asn1p_expr_t *tc, asn1p_module_t **opt_module_r);
+ asn1p_expr_t *tc);
/*
* Exportable version of asn1f_fix_dereference_values();
diff --git a/libasn1fix/asn1fix_integer.c b/libasn1fix/asn1fix_integer.c
index c3a2a7b0..729d1e39 100644
--- a/libasn1fix/asn1fix_integer.c
+++ b/libasn1fix/asn1fix_integer.c
@@ -112,7 +112,6 @@ asn1f_fix_integer(arg_t *arg) {
static int
_asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type) {
- asn1p_module_t *mod = NULL;
asn1p_expr_t *next_expr;
asn1p_expr_type_e expr_type;
int ret;
@@ -144,7 +143,7 @@ _asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type)
* Then, it is a reference. For a reference, try to resolve type
* and try again.
*/
- next_expr = asn1f_lookup_symbol(arg, expr->reference, &mod);
+ next_expr = asn1f_lookup_symbol(arg, expr->module, expr->reference);
if(next_expr == NULL) {
errno = ESRCH;
return -1;
@@ -153,7 +152,8 @@ _asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type)
/*
* If symbol is here, recursively check that it conforms to the type.
*/
- WITH_MODULE(mod, ret = _asn1f_make_sure_type_is(arg, next_expr, type));
+ WITH_MODULE(next_expr->module,
+ ret = _asn1f_make_sure_type_is(arg, next_expr, type));
return ret;
}
diff --git a/libasn1fix/asn1fix_param.c b/libasn1fix/asn1fix_param.c
index 0c838cc5..c399ae42 100644
--- a/libasn1fix/asn1fix_param.c
+++ b/libasn1fix/asn1fix_param.c
@@ -23,7 +23,7 @@ asn1f_fix_parametrized_assignment(arg_t *arg) {
*/
DEBUG("Looking for parametrized type definition \"%s\"",
asn1f_printable_reference(expr->reference));
- ptype = asn1f_lookup_symbol(arg, expr->reference, 0);
+ ptype = asn1f_lookup_symbol(arg, expr->module, expr->reference);
if(ptype == NULL) {
DEBUG("%s: missing parametrized type declaration",
asn1f_printable_reference(expr->reference));
@@ -81,7 +81,7 @@ asn1f_parametrize(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype) {
* with the actual values.
*/
- nex = asn1p_expr_clone(ptype);
+ nex = asn1p_expr_clone(ptype, 0);
if(nex == NULL) return -1;
/*
@@ -131,7 +131,7 @@ asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptyp
assert(child->meta_type == AMT_TYPEREF);
assert(child->expr_type == A1TC_REFERENCE);
- ne = asn1p_expr_clone(ra);
+ ne = asn1p_expr_clone(ra, 0);
if(ne == NULL) return -1;
assert(ne->Identifier == 0);
ne->Identifier = strdup(child->Identifier);
diff --git a/libasn1fix/asn1fix_retrieve.c b/libasn1fix/asn1fix_retrieve.c
index f2f91d5c..97e77fed 100644
--- a/libasn1fix/asn1fix_retrieve.c
+++ b/libasn1fix/asn1fix_retrieve.c
@@ -1,6 +1,6 @@
#include "asn1fix_internal.h"
-static asn1p_expr_t *asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, asn1p_module_t **optm, int type_or_value);
+static asn1p_expr_t *asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, int type_or_value);
static int asn1f_compatible_with_exports(arg_t *arg, asn1p_module_t *mod, const char *name);
@@ -135,7 +135,7 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) {
asn1p_expr_t *
-asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
+asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
asn1p_expr_t *ref_tc; /* Referenced tc */
asn1p_module_t *src_mod;
char *modulename;
@@ -155,7 +155,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
DEBUG("%s(%s) in %s for line %d", __func__,
asn1f_printable_reference(ref),
- arg->mod->Identifier,
+ mod->Identifier,
ref->_lineno);
if(ref->comp_count == 1) {
@@ -173,7 +173,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
* This is a reference to a CLASS-related stuff.
* Employ a separate function for that.
*/
- extract = asn1f_class_access(arg, ref, module_r);
+ extract = asn1f_class_access(arg, mod, ref);
return extract;
} else {
@@ -216,7 +216,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
}
}
- if(src_mod == 0) src_mod = arg->mod;
+ if(src_mod == 0) src_mod = mod;
/*
* Now we know where to search for a value.
@@ -242,29 +242,22 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
return NULL;
}
- if(module_r)
- *module_r = src_mod;
-
return ref_tc;
}
asn1p_expr_t *
-asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *expr,
- asn1p_module_t **optm) {
- return asn1f_find_terminal_thing(arg, expr, optm, 0);
+asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *expr) {
+ return asn1f_find_terminal_thing(arg, expr, 0);
}
asn1p_expr_t *
-asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *expr,
- asn1p_module_t **optm) {
- return asn1f_find_terminal_thing(arg, expr, optm, 1);
+asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *expr) {
+ return asn1f_find_terminal_thing(arg, expr, 1);
}
static asn1p_expr_t *
-asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
- asn1p_module_t **optm, int type_or_value) {
- asn1p_module_t *mod;
+asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, int type_or_value) {
asn1p_ref_t *ref;
asn1p_expr_t *tc;
@@ -272,19 +265,15 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
/* VALUE */
assert(expr->meta_type == AMT_VALUE);
assert(expr->value);
- if(expr->value->type != ATV_REFERENCED) {
- /* Expression is a terminal value itself */
- if(optm) *optm = arg->mod;
+ /* Expression may be a terminal type itself */
+ if(expr->value->type != ATV_REFERENCED)
return expr;
- }
ref = expr->value->value.reference;
} else {
/* TYPE */
- if(expr->expr_type != A1TC_REFERENCE) {
- /* Expression is a terminal type itself */
- if(optm) *optm = arg->mod;
+ /* Expression may be a terminal type itself */
+ if(expr->expr_type != A1TC_REFERENCE)
return expr;
- }
ref = expr->reference;
}
@@ -300,12 +289,11 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
*/
if(type_or_value) {
asn1p_expr_t *val_type_tc;
- val_type_tc = asn1f_find_terminal_type(arg, expr, 0);
+ val_type_tc = asn1f_find_terminal_type(arg, expr);
if(val_type_tc
&& asn1f_look_value_in_type(arg, val_type_tc, expr))
return NULL;
if(expr->value->type != ATV_REFERENCED) {
- if(optm) *optm = arg->mod;
return expr;
}
assert(ref == expr->value->value.reference);
@@ -315,7 +303,7 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
/*
* Lookup inside the default module.
*/
- tc = asn1f_lookup_symbol(arg, ref, &mod);
+ tc = asn1f_lookup_symbol(arg, expr->module, ref);
if(tc == NULL) {
DEBUG("\tSymbol \"%s\" not found: %s",
asn1f_printable_reference(ref),
@@ -334,8 +322,8 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
}
tc->_mark |= TM_RECURSION;
- WITH_MODULE(mod,
- expr = asn1f_find_terminal_thing(arg, tc, optm, type_or_value));
+ WITH_MODULE(tc->module,
+ expr = asn1f_find_terminal_thing(arg, tc, type_or_value));
tc->_mark &= ~TM_RECURSION;
return expr;
diff --git a/libasn1fix/asn1fix_retrieve.h b/libasn1fix/asn1fix_retrieve.h
index 47aa0a5b..7088b493 100644
--- a/libasn1fix/asn1fix_retrieve.h
+++ b/libasn1fix/asn1fix_retrieve.h
@@ -36,11 +36,10 @@ asn1p_module_t *asn1f_lookup_module(arg_t *arg,
/*
* Return the reference to a destination of the given reference,
* symbol lookup. Not a recursive function.
- * Optional module reference may be assigned a module in which the
- * particular expr was found.
*/
-asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref,
- asn1p_module_t **opt_module_r);
+asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg,
+ asn1p_module_t *mod,
+ asn1p_ref_t *ref);
/*
* Recursively find the original type for the given expression.
@@ -54,8 +53,7 @@ asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref,
* would return an expression for Type4.
* WARNING: No attempts are made to honor constraints at this moment.
*/
-asn1p_expr_t *asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *tc,
- asn1p_module_t **opt_module_r);
+asn1p_expr_t *asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *tc);
/*
* Recursively find the original value for the given expression.
@@ -67,7 +65,6 @@ asn1p_expr_t *asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *tc,
* Then this function will return the expression for value2 if given
* the v as an argment.
*/
-asn1p_expr_t *asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *tc,
- asn1p_module_t **opt_module_r);
+asn1p_expr_t *asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *tc);
#endif /* _ASN1FIX_RETRIEVE_H_ */
diff --git a/libasn1fix/asn1fix_tags.c b/libasn1fix/asn1fix_tags.c
index ed8c19f2..de80fad5 100644
--- a/libasn1fix/asn1fix_tags.c
+++ b/libasn1fix/asn1fix_tags.c
@@ -30,14 +30,14 @@ asn1f_fetch_tag(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct as
arg.mod = mod;
arg.expr = expr;
- expr = asn1f_lookup_symbol(&arg, expr->reference, &mod);
+ expr = asn1f_lookup_symbol(&arg, expr->module, expr->reference);
if(expr == NULL) return -1;
if(expr->_mark & TM_RECURSION)
return -1;
expr->_mark |= TM_RECURSION;
- ret = asn1f_fetch_tag(asn, mod, expr, tag);
+ ret = asn1f_fetch_tag(asn, expr->module, expr, tag);
expr->_mark &= ~TM_RECURSION;
return ret;
}
diff --git a/libasn1fix/asn1fix_value.c b/libasn1fix/asn1fix_value.c
index a0560edb..33da3661 100644
--- a/libasn1fix/asn1fix_value.c
+++ b/libasn1fix/asn1fix_value.c
@@ -4,7 +4,6 @@ static int _asn1f_copy_value(arg_t *arg, asn1p_expr_t *to,asn1p_expr_t *from);
int
asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
- asn1p_module_t *val_mod;
asn1p_expr_t *val_type_expr;
asn1p_expr_t *value_expr;
asn1p_expr_t *type_expr;
@@ -20,7 +19,7 @@ asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
/*
* 1. Find the terminal type for this assignment.
*/
- type_expr = asn1f_find_terminal_type(arg, expr, 0);
+ type_expr = asn1f_find_terminal_type(arg, expr);
DEBUG("%s(): terminal type %p", __func__, type_expr);
if(type_expr == 0) {
DEBUG("\tTerminal type for %s not found", expr->Identifier);
@@ -33,7 +32,7 @@ asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
/*
* 2. Find the terminal value also.
*/
- value_expr = asn1f_find_terminal_value(arg, expr, &val_mod);
+ value_expr = asn1f_find_terminal_value(arg, expr);
if(value_expr) {
DEBUG("\tTerminal value for %s->%s is %s at line %d",
expr->Identifier, asn1f_printable_value(expr->value),
@@ -47,8 +46,8 @@ asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
/*
* 3. Find the _type_ of a _terminal value_.
*/
- WITH_MODULE(val_mod,
- val_type_expr = asn1f_find_terminal_type(arg, value_expr, 0));
+ WITH_MODULE(value_expr->module,
+ val_type_expr = asn1f_find_terminal_type(arg, value_expr));
if(val_type_expr) {
DEBUG("\tTerminal type of value %s->%s is %s at line %d",
expr->Identifier, asn1f_printable_value(expr->value),