first stange of asn1 table driven compiler

This commit is contained in:
Love Hornquist Astrand
2009-11-21 10:24:56 -08:00
parent ae56d6eede
commit b939943b07
35 changed files with 3572 additions and 240 deletions

View File

@@ -3,6 +3,8 @@
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Portions Copyright (c) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -70,7 +72,8 @@ generate_int2 (const Type *t, const char *gen_name)
fprintf (codefile,
"%s int2%s(unsigned n)\n"
"{\n"
"\t%s flags;\n\n",
"\t%s flags;\n\n"
"\tmemset(&flags, 0, sizeof(flags));\n\n",
gen_name, gen_name, gen_name);
if(t->members) {
@@ -92,9 +95,17 @@ generate_units (const Type *t, const char *gen_name)
{
Member *m;
fprintf (headerfile,
"const struct units * asn1_%s_units(void);",
gen_name);
if (template_flag) {
fprintf (headerfile,
"extern const struct units *asn1_%s_table_units;\n",
gen_name);
fprintf (headerfile, "#define asn1_%s_units() (asn1_%s_table_units)\n",
gen_name, gen_name);
} else {
fprintf (headerfile,
"const struct units * asn1_%s_units(void);",
gen_name);
}
fprintf (codefile,
"static struct units %s_units[] = {\n",
@@ -111,11 +122,16 @@ generate_units (const Type *t, const char *gen_name)
"\t{NULL,\t0}\n"
"};\n\n");
fprintf (codefile,
"const struct units * asn1_%s_units(void){\n"
"return %s_units;\n"
"}\n\n",
gen_name, gen_name);
if (template_flag)
fprintf (codefile,
"const struct units * asn1_%s_table_units = %s_units;\n",
gen_name, gen_name);
else
fprintf (codefile,
"const struct units * asn1_%s_units(void){\n"
"return %s_units;\n"
"}\n\n",
gen_name, gen_name);
}