asn1: Circular types and Topo. sort declarations
Many external ASN.1 modules that we have imported over time define types like this: Foo ::= SEQUENCE { bar Bar } Bar ::= SEQUENCE { aMember INTEGER } and before this change one had to re-order the definitions so that the one for `Bar` came first. No more. We can now have out of order definitions in ASN.1 modules and the compiler will topologically sort output C type declarations so that one no longer has to manually sort types in ASN.1 modules when importing them. Besides that, it is now possible to create circular data types using OPTIONAL since we generate such fields as pointers (which can then be pointers to incomplete struct declarations): Circular ::= SEQUENCE { name UTF8String, next Circular OPTIONAL } Circular types aren't necessarily useful, but they have been used in the past. E.g., the rpc.mountd protocol uses a circular type as a linked list -- it should just have used an array, of course, as that's semantically equivalent but more space efficient in its encoding, but the point is that such types exist out there.
This commit is contained in:
@@ -156,12 +156,27 @@ struct symbol {
|
||||
enum { SUndefined, SValue, Stype } stype;
|
||||
struct value *value;
|
||||
Type *type;
|
||||
HEIM_TAILQ_ENTRY(symbol) symlist;
|
||||
unsigned int emitted_declaration:1;
|
||||
unsigned int emitted_definition:1;
|
||||
};
|
||||
|
||||
typedef struct symbol Symbol;
|
||||
|
||||
//HEIM_TAILQ_HEAD(symhead, symbol);
|
||||
struct symhead {
|
||||
struct symbol *tqh_first;
|
||||
struct symbol **tqh_last;
|
||||
};
|
||||
|
||||
extern struct symhead symbols;
|
||||
|
||||
void initsym (void);
|
||||
Symbol *addsym (char *);
|
||||
Symbol *getsym(char *name);
|
||||
void output_name (char *);
|
||||
int checkundefined(void);
|
||||
void generate_types(void);
|
||||
void emitted_declaration(const Symbol *);
|
||||
void emitted_definition(const Symbol *);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user