|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 16051 (0x3eb3)
Types: TextFile
Names: »ptabs.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦041b9c0f8⟧ »EurOpenD22/isode/pepsy.system-6.0.Z«
└─⟦d49939f05⟧
└─⟦6a28ec38e⟧ »pepsy.tar«
└─⟦this⟧ »pepy/ptabs.c«
#include <stdio.h>
#include "pepy.h"
#include "pass2.h"
#include "mine.h"
extern FILE *fptab;
extern char *c_tag(), *c_class();
extern char *ec_tag(), *ec_class();
extern char *strip_last();
extern char *str_yp_code[];
extern char *get_val(), *get_comp(), *strp2name();
extern s_table *lookup_list(), *proc_act(), *get_offset();
extern YP tprnt_loop();
extern char *concat();
extern char *my_strcat();
extern int explicit;
static int cons_type = 0;
s_table *ptr;
s_table *save_ptr;
#define WORDSIZE 20
/*
* table printe a type. generate tables for the printing of a type
*/
tprnt_typ(yp, id, type)
YP yp;
char *id;
char *type;
{
char *t, *f;
char *p1;
char *s1, *s2, *s3;
char *s;
s_table *ptr1, *ptr2;
YP y;
if (yp->yp_code < 0 || yp->yp_code > YP_IDEFINED)
ferrd(1, "tprnt_typ: bad code %d\n", yp->yp_code);
#ifdef DEB
Printf(1, ("tprnt_typ code = %s\n", str_yp_code[yp->yp_code]));
#endif
#if 0
#endif
if (yp->yp_id)
Printf(2, ("**** %s ****\n",yp->yp_id));
if (yp == NULL) {
ferr(0, "tprnt_typ:NULL arguement\n");
return;
}
#if 0
#endif
explicit = 0;
if (yp->yp_flags & YP_TAG && !(yp->yp_flags & YP_IMPLICIT)) {
if ((yp->yp_flags & YP_ID) && yp->yp_id) {
fprintf(fptab, "\t{ ETAG, ");
fprintf(fptab, "%d, ", c_type(yp));
fprintf(fptab, "%s, %s, \"%s\" },\n", ec_tag(yp), ec_class(yp), yp->yp_id);
explicit++;
} else
if (id && *id) {
fprintf(fptab, "\t{ ETAG, ");
fprintf(fptab, "%d, ", c_type(yp));
fprintf(fptab, "%s, %s, \"%s\" },\n", ec_tag(yp), ec_class(yp), id);
explicit++;
} else {
fprintf(fptab, "\t{ ETAG, ");
fprintf(fptab, "%d, ", c_type(yp));
fprintf(fptab, "%s, %s, NULL },\n", ec_tag(yp), ec_class(yp));
explicit++;
}
}
if (type)
t = type;
else
t = my_strcat("struct ", modsym(mymodule, id, "type"));
f = yp->yp_varexp;
switch (yp->yp_code) {
case YP_UNDF:
ferr(1, "tprnt_typ:Undefined type\n");
case YP_BOOL:
p1 = "BOOLEAN";
if (yp->yp_action05)
proc_act(yp->yp_action05);
if (yp->yp_varexp) {
#if 0
#endif
}
else
t = NULL;
break;
/* This needs to be fixed up in the action generating area */
case YP_INTLIST:
case YP_INT:
p1 = "INTEGER";
if (yp->yp_action05)
proc_act(yp->yp_action05);
if (yp->yp_varexp) {
#if 0
#endif
}
else
t = NULL;
break;
case YP_BIT:
case YP_BITLIST:
if (yp->yp_varexp) {
p1 = "BITSTRING";
break;
#if 0
#endif
}
t = NULL;
p1 = NULL;
fprintf(fptab,"\t{ SBITSTRING, 0, %s, %s, NULL },\n",
c_tag(yp), c_class(yp));
break;
case YP_OCT:
if (yp->yp_varexp) {
p1 = "OCTETSTRING";
break;
#if 0
#endif
}
t = NULL;
p1 = NULL;
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SOCTETSTRING, 0, %s, %s, \"%s\" },\n", c_tag(yp), c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ SOCTETSTRING, 0, %s, %s, NULL },\n",
c_tag(yp), c_class(yp));
break;
case YP_OID:
if (yp->yp_varexp) {
p1 = "OBJID";
break;
#if 0
#endif
}
t = NULL;
p1 = NULL;
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SOBJID, 0, %s, %s, \"%s\" },\n", c_tag(yp), c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ SOBJID, 0, %s, %s },\n",
c_tag(yp), c_class(yp));
break;
case YP_SEQ:
case YP_SET:
case YP_ANY:
/*
if (cons_type)
p1 = "CONS_ANY";
else
*/
if (yp->yp_varexp) {
p1 = "ANY";
break;
#if 0
#endif
}
t = NULL;
p1 = NULL;
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SANY, 0, %s, %s, \"%s\" },\n", c_tag(yp), c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ SANY, 0, %s, %s },\n",
c_tag(yp), c_class(yp));
break;
case YP_NULL:
p1 = "T_NULL";
t = NULL;
break;
case YP_IDEFINED:
p1 = NULL;
{
/* Predefined Universal Type */
struct univ_typ *p, *univtyp();
if ((p = univtyp(yp->yp_identifier))) {
if (p->univ_flags & UNF_EXTMOD) {
yp->yp_module = p->univ_mod;
goto do_obj;
}
if (f == NULL) { /* No offset type */
if (yp->yp_flags & YP_TAG
&& yp->yp_flags & YP_IMPLICIT)
fprintf(fptab,"\t{ S%s, 0, %d, %d, NULL},\n",
p->univ_tab,
yp->yp_tag->yt_value->yv_number,
yp->yp_tag->yt_class);
else
fprintf(fptab,"\t{ S%s, 0, %d, %d, NULL},\n",
p->univ_tab, p->univ_id, p->univ_class);
break;
}
if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ %s, OFFSET(%s, %s), %d, %d, \"%s\" },\n",
p->univ_tab, t, f,
yp->yp_tag->yt_value->yv_number,
yp->yp_tag->yt_class,
yp->yp_id);
else
fprintf(fptab,"\t{ %s, OFFSET(%s, %s), %d, %d, NULL },\n",
p->univ_tab, t, f,
yp->yp_tag->yt_value->yv_number,
yp->yp_tag->yt_class);
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ %s, OFFSET(%s, %s), %d, %d, \"%s\" },\n",
p->univ_tab, t, f, p->univ_id, p->univ_class, yp->yp_id);
else
fprintf(fptab,"\t{ %s, OFFSET(%s, %s), %d, %d, NULL },\n",
p->univ_tab, t, f, p->univ_id, p->univ_class);
break;
}
}
do_obj:
if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab, "\t{ IMP_OBJ, 0, %s, %s, \"%s\" },\n", c_tag(yp), c_class(yp), yp->yp_id);
else
fprintf(fptab, "\t{ IMP_OBJ, 0, %s, %s, NULL },\n", c_tag(yp), c_class(yp));
if (yp->yp_parm) {
ferr(1, "tenc_typ:YP_IDEFINED:yp_parm found\n");
#if 0
#endif
}
if (yp->yp_module == NULL
|| strcmp(yp->yp_module, mymodule) == 0) {
if (f == NULL)
fprintf(fptab,"\t{ SOBJECT, 0, _Z%s, %s , NULL},\n",
proc_name(yp->yp_identifier, 0), c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ OBJECT, OFFSET(%s, %s), _Z%s, %s, \"%s\" },\n", t, f, proc_name(yp->yp_identifier, 0), c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ OBJECT, OFFSET(%s, %s), _Z%s, %s, NULL },\n", t, f, proc_name(yp->yp_identifier, 0), c_class(yp));
} else {
if (f == NULL)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SEXTOBJ, 0, _Z%s, %s, \"%s\" },\n",
strp2name(yp->yp_identifier, yp->yp_module),
c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ SEXTOBJ, 0, _Z%s, %s, NULL },\n",
strp2name(yp->yp_identifier, yp->yp_module),
c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ EXTOBJ, OFFSET(%s, %s), _Z%s, %s, \"%s\" },\n", t, f, strp2name(yp->yp_identifier, yp->yp_module), c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ EXTOBJ, OFFSET(%s, %s), _Z%s, %s, NULL },\n", t, f, strp2name(yp->yp_identifier, yp->yp_module), c_class(yp));
fprintf(fptab,"\t{ EXTMOD, (int )&%s%s%s, 0, 0, NULL },\n",
PREFIX, yp->yp_module, MODTYP_SUFFIX);
}
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
break;
case YP_SEQLIST:
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (yp->yp_varexp == NULL && type != NULL)
ferr(1, "tprnt_typ:YP_SEQLIST:NULL varexp pointer\n");
#if 0
#endif
if (type != NULL)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SEQ_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SEQ_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SEQ_START, OFFSET(%s, %s), %s, %s, NULL },\n", t, f, c_tag(yp),c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SEQ_START, 0, %s, %s, \"%s\" },\n",
c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SEQ_START, 0, %s, %s, \"%s\" },\n",
c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SEQ_START, 0, %s, %s, NULL },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
#endif
if (y = yp->yp_type) {
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tprnt_typ:YP_SEQLIST:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
if (optfield(y)) {
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab, "\t{ OPTL, OFFSET(%s, optionals), 0, 0, \"%s\" },\n", yp->yp_structname, yp->yp_id);
else
fprintf(fptab, "\t{ OPTL, OFFSET(%s, optionals), 0, 0, NULL },\n", yp->yp_structname);
}
tprnt_loop(y, id, yp->yp_structname);
}
fprintf(fptab, "\t{ PE_END, 0, 0, 0, NULL },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_SETLIST:
p1 = NULL;
cons_type++;
if (yp->yp_varexp == NULL && type != NULL)
ferr(1, "tprnt_typ:YP_SETLIST:NULL varexp pointer\n");
#if 0
#endif
if (type != NULL)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SET_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SET_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SET_START, OFFSET(%s, %s), %s, %s, NULL },\n", t, f, c_tag(yp),c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SET_START, 0, %s, %s, \"%s\" },\n",
c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SET_START, 0, %s, %s, \"%s\" },\n",
c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SET_START, 0, %s, %s, NULL },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
ddflt(yp);
#if 0
#endif
if (y = yp->yp_type) {
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tprnt_typ:YP_SETLIST:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
if (optfield(y)) {
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab, "\t{ OPTL, OFFSET(%s, optionals), 0, 0, \"%s\" },\n", yp->yp_structname, yp->yp_id);
else
fprintf(fptab, "\t{ OPTL, OFFSET(%s, optionals), 0, 0, NULL },\n", yp->yp_structname);
}
tprnt_loop(y, id, yp->yp_structname);
}
fprintf(fptab, "\t{ PE_END, 0, 0, 0, NULL },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_SEQTYPE: /* What is the difference ?? */
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (type != NULL)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SEQOF_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SEQOF_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SEQOF_START, OFFSET(%s, %s), %s, %s, NULL },\n", t, f, c_tag(yp),c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SEQOF_START, 0, %s, %s, \"%s\" },\n", c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SEQOF_START, 0, %s, %s, \"%s\" },\n", c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SEQOF_START, 0, %s, %s, NULL },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
#endif
if (y = yp->yp_type) {
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tprnt_typ:YP_SEQTYPE:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
tprnt_loop(y, id, yp->yp_structname);
}
if (yp->yp_structname != NULL)
fprintf(fptab, "\t{ PE_END, OFFSET(%s, next), 0, 0, NULL },\n",
yp->yp_structname);
else
fprintf(fptab,"\t{ PE_END, 0, 0, 0, NULL },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_SETTYPE:
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (type != NULL)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SETOF_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SETOF_START, OFFSET(%s, %s), %s, %s, \"%s\" },\n", t, f, c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SETOF_START, OFFSET(%s, %s), %s, %s, NULL },\n", t, f, c_tag(yp),c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ SETOF_START, 0, %s, %s, \"%s\" },\n", c_tag(yp),c_class(yp), yp->yp_id);
else
if (id && *id)
fprintf(fptab,"\t{ SETOF_START, 0, %s, %s, \"%s\" },\n", c_tag(yp),c_class(yp), id);
else
fprintf(fptab,"\t{ SETOF_START, 0, %s, %s, NULL },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
#endif
if (y = yp->yp_type) {
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tprnt_typ:YP_SETTYPE:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
tprnt_loop(y, id, yp->yp_structname);
}
if (yp->yp_structname != NULL)
fprintf(fptab, "\t{ PE_END, OFFSET(%s, next), 0, 0, NULL },\n",
yp->yp_structname);
else
fprintf(fptab,"\t{ PE_END, 0, 0, 0, NULL },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_CHOICE:
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (type != NULL)
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ CHOICE_START, OFFSET(%s, %s), 0, %s, \"%s\" },\n", t, f, c_class(yp), yp->yp_id);
else
fprintf(fptab,"\t{ CHOICE_START, OFFSET(%s, %s), 0, %s, NULL },\n", t, f, c_class(yp));
else
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab,"\t{ CHOICE_START, 0, 0, 0, \"%s\" },\n", yp->yp_id);
else
fprintf(fptab,"\t{ CHOICE_START, 0, 0, 0, NULL },\n");
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
#endif
if (y = yp->yp_type) {
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab, "\t{ SCTRL, OFFSET(%s, offset), 0, 0, \"%s\" },\n", yp->yp_structname, yp->yp_id);
else
fprintf(fptab, "\t{ SCTRL, OFFSET(%s, offset), 0, 0, NULL },\n", yp->yp_structname);
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tprnt_typ:YP_CHOICE:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
tprnt_loop(y, id, yp->yp_structname);
}
fprintf(fptab,"\t{ PE_END, 0, 0, 0, NULL },\n");
ptr = save_ptr;
cons_type--;
break;
default:
ferrd(1, "tprnt_typ: yp_code = %d not implemented\n", yp->yp_code);
}
if (p1 != NULL) {
if (t != NULL) {
if ((yp->yp_flags & YP_ID) && yp->yp_id)
fprintf(fptab, "\t{ %s, OFFSET(%s, %s), %s, %s, \"%s\" },\n", p1, t, f, c_tag(yp), c_class(yp), yp->yp_id);
else
fprintf(fptab, "\t{ %s, OFFSET(%s, %s), %s, %s, NULL },\n", p1, t, f, c_tag(yp), c_class(yp));
} else {
fprintf(fptab, "\t{ %s, 0, %s, %s, NULL },\n", p1, c_tag(yp),
c_class(yp));
}
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
}
#if 0
#endif
}
static int fflags[] = {
0, 1, 2, 2, 3, 3, 4, 5, 16, 16, 16, 17, 17, 17,
0, -1, 7, };
/*
* generate tables for printing a contructed type
*/
YP tprnt_loop(yp, id, type)
YP yp;
char *id;
char *type;
{
for (; yp != NULL; yp = yp->yp_next) {
tprnt_typ(yp, id, type);
}
}
ddflt(yp)
YP yp;
{
switch (yp->yp_code) {
case YP_BOOL:
case YP_INT:
case YP_INTLIST:
fprintf(fptab, "\t{DFLT_B, %d, 0, 0 },\n",
yp->yp_default->yv_number);
break;
case YP_BIT:
case YP_BITLIST:
case YP_OCT:
case YP_NULL:
case YP_SEQ:
case YP_SEQTYPE:
case YP_SEQLIST:
case YP_SET:
case YP_SETTYPE:
case YP_SETLIST:
case YP_CHOICE:
case YP_ANY:
case YP_OID:
case YP_IDEFINED:
case YP_ENUMLIST:
case YP_REAL:
fprintf(fptab, "\t{DFLT_B, 0, 0, 0 },\n");
break;
default:
ferr(1, "ddflt:unknown type %d\n", yp->yp_code);
}
}