Commit b85a8135 authored by Lev Walkin's avatar Lev Walkin

automatic dependency tracking

parent e44ea0bd
0.9.19: 2005-Aug-16
0.9.19: 2005-Aug-18
* asn1c's -findirect-choice flag generates less dependent code.
* A proper solution to circular references. No kludge flags
should be necessary anymore to produce reference-free code:
recursive dependencies are resolved automatically.
* Test cases 73 & 92 keep track of various circular references.
0.9.18: 2005-Aug-14
......
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include <Everything.h>
int
main(int ac, char **av) {
Everything_t t;
(void)ac; /* Unused argument */
(void)av; /* Unused argument */
memset(&t, 0, sizeof(t));
/*
* No plans to fill it up: just checking whether it compiles or not.
*/
return 0;
}
This diff is collapsed.
......@@ -609,13 +609,13 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang
default:
WARNING("%s:%d: Value cannot be determined "
"for constraint check for %s",
arg->mod->source_file_name,
arg->expr->module->source_file_name,
arg->expr->_lineno,
arg->expr->Identifier
);
OUT_NOINDENT(
"#error %s:%d: Value of %s cannot be determined\n",
arg->mod->source_file_name,
arg->expr->module->source_file_name,
arg->expr->_lineno,
arg->expr->Identifier
);
......
......@@ -51,7 +51,7 @@ typedef struct arg_s {
struct compiler_streams *target;
asn1p_t *asn;
asn1p_module_t *mod;
//asn1p_module_t *mod;
asn1p_expr_t *expr;
int embed;
......
......@@ -142,11 +142,10 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
* This is a reference to a type defined in a class.
* Resolve it and use instead.
*/
tmp.expr = asn1f_class_access_ex(arg->asn, arg->mod,
arg->expr, expr->reference);
tmp.expr = asn1f_class_access_ex(arg->asn,
arg->expr->module, arg->expr, expr->reference);
if(tmp.expr) return NULL;
tmp.mod = tmp.expr->module;
return asn1c_type_name(&tmp, tmp.expr, _format);
}
......
......@@ -17,6 +17,7 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
int argc, char **argv) {
asn1c_fdeps_t *deps = 0;
asn1c_fdeps_t *dlist;
asn1p_module_t *mod;
FILE *mkf;
int i;
......@@ -26,8 +27,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
"from %s\n", datadir);
}
TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(arg->mod->members), next) {
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) {
if(asn1c_dump_streams(arg, deps))
......@@ -51,8 +52,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
}
fprintf(mkf, "ASN_MODULE_SOURCES=");
TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(arg->mod->members), next) {
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) {
fprintf(mkf, "\t\\\n\t%s.c",
......@@ -61,8 +62,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
}
}
fprintf(mkf, "\n\nASN_MODULE_HEADERS=");
TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(arg->mod->members), next) {
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
if(asn1_lang_map[arg->expr->meta_type]
[arg->expr->expr_type].type_cb) {
fprintf(mkf, "\t\\\n\t%s.h",
......@@ -208,8 +209,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
" * From ASN.1 module \"%s\"\n"
" * \tfound in \"%s\"\n"
" */\n\n",
arg->mod->ModuleName,
arg->mod->source_file_name
expr->module->ModuleName,
expr->module->source_file_name
);
fprintf(fp_h,
"/*\n"
......@@ -217,8 +218,8 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
" * From ASN.1 module \"%s\"\n"
" * \tfound in \"%s\"\n"
" */\n\n",
arg->mod->ModuleName,
arg->mod->source_file_name
expr->module->ModuleName,
expr->module->source_file_name
);
header_id = asn1c_make_identifier(0, expr->Identifier, NULL);
......
......@@ -12,6 +12,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
int argc, char **argv) {
arg_t arg_s;
arg_t *arg = &arg_s;
asn1p_module_t *mod;
int ret;
/*
......@@ -29,8 +30,8 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
/*
* Compile each individual top level structure.
*/
TQ_FOR(arg->mod, &(asn->modules), mod_next) {
TQ_FOR(arg->expr, &(arg->mod->members), next) {
TQ_FOR(mod, &(asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
compiler_streams_t *cs = NULL;
if(asn1c_attach_streams(arg->expr))
......
......@@ -7,7 +7,6 @@ extern arg_t a1f_replace_me_with_proper_interface_arg;
asn1p_expr_t *
asn1f_lookup_symbol_ex(
asn1p_t *asn,
asn1p_module_t *mod,
asn1p_expr_t *expr,
asn1p_ref_t *ref) {
arg_t arg;
......@@ -15,13 +14,13 @@ asn1f_lookup_symbol_ex(
memset(&arg, 0, sizeof(arg));
arg.asn = asn;
arg.mod = mod;
arg.mod = expr->module;
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, mod, ref);
return asn1f_lookup_symbol(&arg, expr->module, ref);
}
asn1p_expr_t *
......
......@@ -18,7 +18,6 @@ char const *asn1f_printable_value(asn1p_value_t *value);
*/
asn1p_expr_t *asn1f_lookup_symbol_ex(
asn1p_t *asn,
asn1p_module_t *mod,
asn1p_expr_t *expr,
asn1p_ref_t *ref);
......
......@@ -174,11 +174,12 @@ typedef struct asn1p_expr_s {
struct asn1p_expr_marker_s {
enum asn1p_expr_marker_e {
EM_NOMARK,
EM_INDIRECT = 0x01, /* 0001: Represent as pointer */
EM_OPTIONAL = 0x03, /* 0011: Optional member */
EM_DEFAULT = 0x07, /* 0111: default_value */
EM_UNRECURSE = 0x08, /* 1000: Use safe naming */
EM_NOMARK,
EM_INDIRECT = 0x01, /* 00001 Represent as pointer */
EM_OMITABLE = 0x03, /* 00011 May be absent in encoding */
EM_OPTIONAL = 0x07, /* 00111 Optional member */
EM_DEFAULT = 0x0F, /* 01111 default_value */
EM_UNRECURSE = 0x10, /* 10000 Use safe naming */
} flags;
asn1p_value_t *default_value; /* For EM_DEFAULT case */
} marker;
......
......@@ -58,7 +58,7 @@ static asn_TYPE_member_t asn_MBR_T_1[] = {
.memb_constraints = 0, /* Defer constraints checking to the member type */
.name = "s"
},
{ ATF_POINTER, 0, offsetof(struct T, b),
{ ATF_POINTER, 1, offsetof(struct T, b),
.tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn_DEF_BOOLEAN,
......
......@@ -423,7 +423,7 @@ static asn_TYPE_member_t asn_MBR_Stuff_1[] = {
.memb_constraints = 0, /* Defer constraints checking to the member type */
.name = "anything"
},
{ ATF_POINTER, 0, offsetof(struct Stuff, other),
{ ATF_POINTER, 1, offsetof(struct Stuff, other),
.tag = -1 /* Ambiguous tag (CHOICE?) */,
.tag_mode = 0,
.type = (void *)&asn_DEF_other_9,
......
......@@ -542,7 +542,7 @@ static asn_TYPE_member_t asn_MBR_ExtensibleSet_1[] = {
.memb_constraints = 0, /* Defer constraints checking to the member type */
.name = "string"
},
{ ATF_POINTER, 0, offsetof(struct ExtensibleSet, Enum),
{ ATF_POINTER, 1, offsetof(struct ExtensibleSet, Enum),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn_DEF_enum_4,
......@@ -637,7 +637,7 @@ static asn_TYPE_member_t asn_MBR_ExtensibleSequence_1[] = {
.memb_constraints = 0, /* Defer constraints checking to the member type */
.name = "integer"
},
{ ATF_POINTER, 0, offsetof(struct ExtensibleSequence, gtime),
{ ATF_POINTER, 1, offsetof(struct ExtensibleSequence, gtime),
.tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn_DEF_GeneralizedTime,
......
......@@ -379,7 +379,6 @@ asn_TYPE_descriptor_t asn_DEF_Epyt = {
/*** <<< INCLUDES [Ypet] >>> ***/
#include <Epyt.h>
#include <INTEGER.h>
#include <IA5String.h>
#include <EnumType.h>
......@@ -401,10 +400,14 @@ typedef enum Ypet_PR {
Ypet_PR_patest2, /* Member patest2 is present */
} Ypet_PR;
/*** <<< FWD-DECLS [Ypet] >>> ***/
struct Epyt;
/*** <<< TYPE-DECLS [Ypet] >>> ***/
typedef struct Ypet {
Epyt_t epyt;
struct Epyt *epyt;
INTEGER_t *plain /* DEFAULT 7 */;
struct senums {
A_SET_OF(EnumType_t) list;
......@@ -427,6 +430,10 @@ typedef struct Ypet {
extern asn_TYPE_descriptor_t asn_DEF_Ypet;
/*** <<< POST-INCLUDE [Ypet] >>> ***/
#include <Epyt.h>
/*** <<< CTABLES [Ypet] >>> ***/
static int check_permitted_alphabet_6(const void *sptr) {
......@@ -550,7 +557,7 @@ asn_TYPE_descriptor_t asn_DEF_senums_4 = {
};
static asn_TYPE_member_t asn_MBR_Ypet_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Ypet, epyt),
{ ATF_POINTER, 0, offsetof(struct Ypet, epyt),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = (void *)&asn_DEF_Epyt,
......
......@@ -14,7 +14,14 @@ BEGIN
Everything ::= SEQUENCE {
ch1 Choice1,
ch2 Choice2,
set Set
ch3 Choice3,
set Set,
a Alpha,
b Beta,
g Gamma,
ot OneTwo,
tt TwoThree,
to ThreeOne
}
-- This type refers to the type directly containing itself.
......@@ -25,10 +32,19 @@ BEGIN
}
Choice2 ::= CHOICE {
typeref TypeRef,
...,
some3 Everything
}
Choice3 ::= CHOICE {
a SEQUENCE {
aa Everything
},
b Everything,
c SEQUENCE OF Choice3
}
Set ::= SET OF SEQUENCE {
int INTEGER,
set Set,
......@@ -46,4 +62,29 @@ BEGIN
set Set OPTIONAL
}
TypeRef ::= Sequence
Alpha ::= SEQUENCE {
a Beta,
b SEQUENCE {
b Beta OPTIONAL
}
}
Beta ::= SEQUENCE {
b Alpha OPTIONAL,
g Gamma OPTIONAL
}
Gamma ::= SEQUENCE {
o TwoThree,
a Alpha, -- expected inline
b Beta -- expected inline
}
-- This is a true superdependency.
OneTwo ::= SET { m12 TwoThree }
TwoThree ::= SET { m23 ThreeOne }
ThreeOne ::= SET { m31 OneTwo, g Gamma }
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