|
|
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 d
Length: 20185 (0x4ed9)
Types: TextFile
Names: »dtabs.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦041b9c0f8⟧ »EurOpenD22/isode/pepsy.system-6.0.Z«
└─⟦d49939f05⟧
└─⟦6a28ec38e⟧ »pepsy.tar«
└─⟦this⟧ »pepy/dtabs.c«
/* Copyright 1989 CSIRO Division of Information Technology
* May be given away but not sold for profit - See Copyright file for details
*/
#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 tdec_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 encode a type. generate tables for the encoding of a type
*/
tdec_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, "tdec_typ: bad code %d\n", yp->yp_code);
#ifdef DEB
Printf(1, ("tdec_typ code = %s\n", str_yp_code[yp->yp_code]));
#endif
#if 0
Printf(2, ("\n**** %s ****\n",yp->yp_param_type));
Printf(2, ("**** %s ****\n",yp->yp_intexp));
Printf(2, ("**** %s ****\n",yp->yp_strexp));
if (yp->yp_prfexp != NULL)
Printf(2, ("**** %c ****\n",yp->yp_prfexp));
#endif
if (yp->yp_id != NULL)
Printf(2, ("**** %s ****\n",yp->yp_id));
if (yp == NULL) {
ferr(0, "tdec_typ:NULL arguement\n");
return;
}
#if 0
if (yp->yp_param_type) {
add_list(strip_last(yp->yp_param_type), "parm");
head->defined++;
ptr = head;
}
if (yp->yp_action0) {
s = new_string(yp->yp_action0);
parse_decl(&s, &s1, &s2);
while (*s != '\0') {
add_list(s1, s2);
parse_decl(&s, &s1, &s2);
}
}
#endif
explicit = 0;
if (yp->yp_flags & YP_TAG && !(yp->yp_flags & YP_IMPLICIT)) {
fprintf(fptab, "\t{ ETAG, ");
fprintf(fptab, "%d, ", c_type(yp));
fprintf(fptab, "%s, %s },\n", ec_tag(yp), ec_class(yp));
explicit++;
}
if (type)
t = type;
else {
t = my_strcat("struct ", modsym(mymodule, id, "type"));
switch (yp->yp_code) {
/*
* These generate MALLOC entries inside *_START .. PE_END fields
* for historical reasons. One day we might fix this to be all
* done the same way.
*/
case YP_SEQLIST:
case YP_SEQTYPE:
case YP_SETLIST:
case YP_SETTYPE:
case YP_CHOICE:
break;
default:
if (yp->yp_varexp == NULL)
break; /* S* type entry - doesn't need a malloc */
fprintf(fptab,"\t{ MALLOC, 0, sizeof (%s), 0 },\n", t);
break;
}
}
f = yp->yp_varexp;
switch (yp->yp_code) {
case YP_UNDF:
ferr(1, "tdec_typ:Undefined type\n");
case YP_BOOL:
p1 = "BOOLEAN";
if (yp->yp_action05)
proc_act(yp->yp_action05);
if (yp->yp_varexp) {
#if 0
s = new_string(yp->yp_varexp);
get_val(&s); /* Skip */
f = get_val(&s);
t = concat("struct ", modsym(mymodule, id, "type"));
ptr1 = lookup_list(s1);
if (ptr != ptr1)
ferr(0, "tdec_typ: Offset is incorrect (Boolean)\n");
t = ptr1->type;
#endif
}
else
t = NULL;
break;
/* This needs to be fixed up in the action generating area */
case YP_INTLIST:
case YP_INT:
#if 0
if (yp->yp_action05)
proc_act(yp->yp_action05);
#endif
if (yp->yp_varexp) {
p1 = "INTEGER";
break;
#if 0
s = new_string(yp->yp_varexp);
get_val(&s);
f = get_val(&s);
t = concat("struct ", modsym(mymodule, id, "type"));
ptr1 = lookup_list(s1);
if (ptr != ptr1)
ferr(0, "tdec_typ: Offsets are incorrect (Integer)\n");
t = ptr1->type;
#endif
}
t = NULL;
p1 = NULL;
fprintf(fptab,"\t{ SINTEGER, 0, %s, %s },\n",
c_tag(yp), c_class(yp));
break;
case YP_BIT:
case YP_BITLIST:
if (yp->yp_varexp) {
p1 = "BITSTRING";
break;
#if 0
s = new_string(yp->yp_varexp);
get_val(&s);
f = get_val(&s);
t = concat("struct ", modsym(mymodule, id, "type"));
if (strcmp(s1, "if"))
ferrs(1,"tdec_typ: What to do, action2 = %s\n",yp->yp_action2);
else {
s1 = get_val(&s);
if (strcmp(f = get_val(&s), "prim2bit")) {
ptr1 = lookup_list(s1);
t = ptr1->type;
}
else
t = NULL;
}
#endif
}
t = NULL;
p1 = NULL;
fprintf(fptab,"\t{ SBITSTRING, 0, %s, %s },\n",
c_tag(yp), c_class(yp));
break;
case YP_OCT:
if (yp->yp_varexp) {
p1 = "OCTETSTRING";
break;
#if 0
s = new_string(yp->yp_varexp);
get_val(&s);
f = get_val(&s);
t = concat("struct ", modsym(mymodule, id, "type"));
ptr1 = lookup_list(s1);
if (ptr != ptr1)
ferr(0, "tdec_typ: Offset is incorrect (Octet String)\n");
t = ptr1->type;
#endif
}
t = NULL;
p1 = NULL;
fprintf(fptab,"\t{ SOCTETSTRING, 0, %s, %s },\n",
c_tag(yp), c_class(yp));
break;
case YP_OID:
if (yp->yp_varexp) {
p1 = "OBJID";
break;
#if 0
s = new_string(yp->yp_strexp);
s1 = get_val(&s);
if ((f = get_val(&s)) == NULL) {
if (ptr != head)
ferr(0, "tdec_typ: Offset is incorrect (Object Identifier)\n");
t = NULL;
break;
}
ptr1 = lookup_list(s1);
if (ptr != ptr1)
ferr(0, "tdec_typ: Offset is incorrect (Object Identifier)\n");
t = ptr1->type;
#endif
}
t = NULL;
p1 = NULL;
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
if (yp->yp_action05)
proc_act(yp->yp_action05);
if (yp->yp_strexp) {
s = new_string(yp->yp_strexp);
s1 = get_val(&s);
if ((f = get_val(&s)) == NULL) {
if (ptr != head)
ferr(0, "tdec_typ: Offset is incorrect (Seq/Set/Any)\n");
if (cons_type)
ferr(1, "tdec_type: variable cons_type incorrectly used\n");
t = NULL;
break;
}
ptr1 = lookup_list(s1);
if (ptr != ptr1)
ferr(0, "tdec_typ: Offset is incorrect (Seq/Set/Any)\n");
t = ptr1->type;
#endif
}
t = NULL;
p1 = NULL;
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, %s },\n",
p->univ_tab,
yp->yp_tag->yt_value->yv_number,
c_flags(yp, yp->yp_tag->yt_class));
else
fprintf(fptab,"\t{ S%s, 0, %d, %s },\n",
p->univ_tab, p->univ_id,
c_flags(yp, p->univ_class));
break;
}
if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
fprintf(fptab,"\t{ %s, OFFSET(%s, %s), %d, %s },\n",
p->univ_tab, t, f,
yp->yp_tag->yt_value->yv_number,
c_flags(yp, yp->yp_tag->yt_class));
else
fprintf(fptab,"\t{ %s, OFFSET(%s, %s), %d, %s },\n",
p->univ_tab, t, f, p->univ_id,
c_flags(yp, p->univ_class));
break;
}
}
do_obj:
if (yp->yp_flags & YP_TAG && yp->yp_flags & YP_IMPLICIT)
fprintf(fptab, "\t{ IMP_OBJ, 0, %s, %s },\n", c_tag(yp), c_class(yp));
if (yp->yp_parm) {
ferr(1, "tenc_typ:YP_IDEFINED:yp_parm found\n");
#if 0
Printf(2, ("yp parm is %s \n",yp->yp_parm));
Printf(2, ("yp identifier is %s \n",yp->yp_identifier));
s = new_string(yp->yp_parm);
s1 = get_val(&s);
if ((f = get_val(&s)) == NULL) {
if (ptr != head)
ferr(0, "tdec_typ: Offset is incorrect (Idefined)\n");
fprintf(fptab, "\t{ OBJECT, 0, _Z%s, 0 },\n", proc_name(yp->yp_identifier, 0));
break;
}
ptr1 = lookup_list(s1);
if (ptr != ptr1) {
ferr(0, "tdec_typ: Offset is incorrect (Idefined)\n");
fprintf(fptab, "\t{ OBJECT, 0, _Z%s, 0 },\n", proc_name(yp->yp_identifier, 0));
}
else
fprintf(fptab, "\t{ OBJECT, OFFSET(%s, %s), _Z%s, 0 },\n", ptr1->type, f, proc_name(yp->yp_identifier, 0));
#endif
}
if (yp->yp_module == NULL
|| strcmp(yp->yp_module, mymodule) == 0) {
if (f == NULL)
fprintf(fptab,"\t{ SOBJECT, 0, _Z%s, %s },\n",
proc_name(yp->yp_identifier, 0), c_class(yp));
else
fprintf(fptab,"\t{ OBJECT, OFFSET(%s, %s), _Z%s, %s },\n",
t, f, proc_name(yp->yp_identifier, 0), c_class(yp));
} else {
if (f == NULL)
fprintf(fptab,"\t{ SEXTOBJ, 0, _Z%s, %s },\n",
strp2name(yp->yp_identifier, yp->yp_module),
c_class(yp));
else
fprintf(fptab,"\t{ EXTOBJ, OFFSET(%s, %s), _Z%s, %s },\n",
t, f, strp2name(yp->yp_identifier, yp->yp_module),
c_class(yp));
fprintf(fptab,"\t{ EXTMOD, (int )&%s%s%s, 0, 0 },\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, "tdec_typ:YP_SEQLIST:NULL varexp pointer\n");
#if 0
s = new_string(yp->yp_varexp);
get_val(&s);
f = get_val(&s);
t = concat("struct ", modsym(mymodule, id, "type"));
#endif
if (type != NULL)
fprintf(fptab,"\t{ SEQ_START, OFFSET(%s, %s), %s, %s },\n",
t, f, c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SEQ_START, 0, %s, %s },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
if ((ptr = get_offset(yp, 0)) != NULL)
if (strcmp(ptr->name, "parm")) {
Printf(3, ("arg1 = %s, arg2 = %s\n",ptr->parent->type, ptr->field));
fprintf(fptab,"\t{ SEQ_START, OFFSET(%s, %s), %s, %s },\n", ptr->parent->type, ptr->field, c_tag(yp),c_class(yp));
}
else
fprintf(fptab,"\t{ SEQ_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SEQ_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
if (yp->yp_action1)
proc_act(yp->yp_action1);
if (yp->yp_action05)
proc_act(yp->yp_action05);
#endif
if (y = yp->yp_type) {
genmalloc(yp);
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tdec_typ:YP_SEQLIST:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
if (optfield(y)) {
fprintf(fptab,
"\t{ OPTL, OFFSET(%s, optionals), 0, 0 },\n",
yp->yp_structname);
}
tdec_loop(y, id, yp->yp_structname);
}
fprintf(fptab, "\t{ PE_END, 0, 0, 0 },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_SETLIST:
p1 = NULL;
cons_type++;
if (yp->yp_varexp == NULL && type != NULL)
ferr(1, "tdec_typ:YP_SETLIST:NULL varexp pointer\n");
#if 0
s = new_string(yp->yp_varexp);
get_val(&s);
f = get_val(&s);
t = concat("struct ", modsym(mymodule, id, "type"));
#endif
if (type != NULL)
fprintf(fptab,"\t{ SET_START, OFFSET(%s, %s), %s, %s },\n",
t, f, c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SET_START, 0, %s, %s },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
save_ptr = ptr;
if ((ptr = get_offset(yp, 0)) != NULL)
if (strcmp(ptr->name, "parm")) {
Printf(3, ("arg1 = %s, arg2 = %s\n",ptr->parent->type, ptr->field));
fprintf(fptab,"\t{ SET_START, OFFSET(%s, %s), %s, %s },\n", ptr->parent->type, ptr->field, c_tag(yp),c_class(yp));
}
else
fprintf(fptab,"\t{ SET_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SET_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
if (yp->yp_action1)
proc_act(yp->yp_action1);
if (yp->yp_action05)
proc_act(yp->yp_action05);
#endif
if (y = yp->yp_type) {
genmalloc(yp);
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tdec_typ:YP_SETLIST:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
if (optfield(y)) {
fprintf(fptab,
"\t{ OPTL, OFFSET(%s, optionals), 0, 0 },\n",
yp->yp_structname);
}
tdec_loop(y, id, yp->yp_structname);
}
fprintf(fptab, "\t{ PE_END, 0, 0, 0 },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_SEQTYPE: /* What is the difference ?? */
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (type != NULL)
fprintf(fptab,"\t{ SEQOF_START, OFFSET(%s, %s), %s, %s },\n",
t, f, c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SEQOF_START, 0, %s, %s },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
if ((ptr = get_offset(yp, 0)) != NULL)
if (strcmp(ptr->name, "parm")) {
Printf(3, ("arg1 = %s, arg2 = %s\n",ptr->parent->type, ptr->field));
fprintf(fptab,"\t{ SEQOF_START, OFFSET(%s, %s), %s, %s },\n", ptr->parent->type, ptr->field, c_tag(yp),c_class(yp));
}
else
fprintf(fptab,"\t{ SEQOF_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SEQOF_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
#endif
if (y = yp->yp_type) {
genmalloc(yp);
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tdec_typ:YP_SEQTYPE:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
tdec_loop(y, id, yp->yp_structname);
}
if (yp->yp_structname != NULL)
fprintf(fptab, "\t{ PE_END, OFFSET(%s, next), 0, 0 },\n",
yp->yp_structname);
else
fprintf(fptab,"\t{ PE_END, 0, 0, 0 },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_SETTYPE:
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (type != NULL)
fprintf(fptab,"\t{ SETOF_START, OFFSET(%s, %s), %s, %s },\n",
t, f, c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SETOF_START, 0, %s, %s },\n",
c_tag(yp),c_class(yp));
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
if ((ptr = get_offset(yp, 0)) != NULL)
if (strcmp(ptr->name, "parm")) {
Printf(3, ("arg1 = %s, arg2 = %s\n",ptr->parent->type, ptr->field));
fprintf(fptab,"\t{ SETOF_START, OFFSET(%s, %s), %s, %s },\n", ptr->parent->type, ptr->field, c_tag(yp),c_class(yp));
}
else
fprintf(fptab,"\t{ SETOF_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
else
fprintf(fptab,"\t{ SETOF_START, 0, %s, %s },\n", c_tag(yp),c_class(yp));
yp -> yp_structname =
my_strcat("struct ", yp->yp_declexp);
tdec_loop(yp->yp_type, id, yp->yp_declexp);
/*
fprintf(fptab, "\t{ PE_END, 0, 0, 0 },\n");
*/
#endif
if (y = yp->yp_type) {
genmalloc(yp);
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tdec_typ:YP_SETTYPE:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
tdec_loop(y, id, yp->yp_structname);
}
if (yp->yp_structname != NULL)
fprintf(fptab, "\t{ PE_END, OFFSET(%s, next), 0, 0 },\n",
yp->yp_structname);
else
fprintf(fptab,"\t{ PE_END, 0, 0, 0 },\n");
ptr = save_ptr;
cons_type--;
break;
case YP_CHOICE:
p1 = NULL;
cons_type++;
save_ptr = ptr;
if (type != NULL)
fprintf(fptab,"\t{ CHOICE_START, OFFSET(%s, %s), 0, %s },\n",
t, f, c_class(yp));
else
fprintf(fptab,"\t{ CHOICE_START, 0, 0, 0 },\n");
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
#if 0
if ((ptr = get_offset(yp, 0)) != NULL)
if (strcmp(ptr->name, "parm")) {
Printf(3, ("arg1 = %s, arg2 = %s\n",ptr->parent->type, ptr->field));
fprintf(fptab,"\t{ CHOICE_START, OFFSET(%s, %s), 0, 0 },\n", ptr->parent->type, ptr->field);
}
else
fprintf(fptab,"\t{ CHOICE_START, 0, 0, 0 },\n");
else
fprintf(fptab,"\t{ CHOICE_START, 0, 0, 0 },\n");
if (yp->yp_action1)
proc_act(yp->yp_action1);
if (yp->yp_action05)
proc_act(yp->yp_action05);
yp -> yp_structname =
my_strcat("struct ", yp->yp_declexp);
tdec_loop(yp->yp_type, id, yp->yp_declexp);
fprintf(fptab, "\t{ PE_END, 0, 0, 0 },\n");
#endif
if (y = yp->yp_type) {
genmalloc(yp);
fprintf(fptab, "\t{ SCTRL, OFFSET(%s, offset), 0, 0 },\n",
yp->yp_structname);
if (type) {
if (yp->yp_declexp == NULL)
ferr(1, "tdec_typ:YP_CHOICE:no declexp\n");
yp -> yp_structname = my_strcat("struct ", yp->yp_declexp);
} else
yp->yp_structname = t;
tdec_loop(y, id, yp->yp_structname);
}
fprintf(fptab,"\t{ PE_END, 0, 0, 0 },\n");
ptr = save_ptr;
cons_type--;
break;
default:
ferrd(1, "tdec_typ: yp_code = %d not implemented\n", yp->yp_code);
}
if (p1 != NULL) {
if (t != NULL) {
fprintf(fptab, "\t{ %s, OFFSET(%s, %s), %s, %s },\n", p1, t, f,
c_tag(yp), c_class(yp));
} else {
fprintf(fptab, "\t{ %s, 0, %s, %s },\n", p1, c_tag(yp),
c_class(yp));
}
if (yp->yp_flags & YP_DEFAULT)
gdflt(yp, G_DEC);
}
#if 0
if (yp->yp_action2 && yp->yp_code != YP_BIT && yp->yp_code != YP_BITLIST)
proc_act2(yp->yp_action2);
#endif
}
static int fflags[] = {
0, 1, 2, 2, 3, 3, 4, 5, 16, 16, 16, 17, 17, 17,
0, -1, 7, };
/*
* generate tables for encoding a contructed type
*/
YP tdec_loop(yp, id, type)
YP yp;
char *id;
char *type;
{
for (; yp != NULL; yp = yp->yp_next) {
tdec_typ(yp, id, type);
}
}
/*
* Generate a malloc of for the given object
*/
genmalloc(yp)
YP yp;
{
fprintf(fptab,"\t{ MALLOC, 0, sizeof (%s), 0 },\n", yp->yp_structname);
}
/*
parse the action code which allocates space and create a table
entry where the first field is MALLOC, the second field specifies
in what variable the memory is to be allocated to and the third
field specifies the size of the memory to be allocated.
*/
s_table *proc_act(s)
char *s;
{
#if 0
char *s1;
char *t, *r;
s_table *ptr1;
r = new_string(s);
s1 = get_val(&r);
if (! strcmp(s1, "if")) {
ptr1 = lookup_list(get_val(&r));
if (ptr != ptr1) {
ferr(0, "proc_act: Offset is incorrect\n");
Printf(3, ("arg1 = %s, arg2 = %s\n",ptr1->parent->type, ptr1->field));
fprintf(fptab,"\t{ MALLOC, OFFSET(%s, %s), sizeof(%s), 0 },\n", ptr1->parent->type, ptr1->field, strip_last(ptr1->type));
}
else
fprintf(fptab,"\t{ MALLOC, 0, sizeof(%s), 0 },\n", strip_last(ptr1->type));
}
#endif
}
/*
parse the action code relevant to the types SEQUENCE OF, SET OF and
CHOICE and generate an appropriate table entry. For SEQUENCE OF
and SET OF this entry will contain the offset of the field "next"
and for CHOICE it will contain the offset of the field "offset"
*/
proc_act2(s)
char *s;
{
int choice_flag;
char *t;
char *s1, *s2, *s3, *s4;
s_table *ptr1;
choice_flag = 0;
t = new_string(s);
while ((s1 = get_comp(&t)) != NULL) {
if ((s2 = get_val(&s1)) != NULL) {
s3 = get_val(&s1);
if (! strcmp(s3, "offset")) { /* concerns choice */
s4 = get_val(&s1);
ptr1 = lookup_list(s2);
fprintf(fptab, "\t{ CH_ACT, OFFSET(%s, %s), %s, 0 },\n", ptr1->type, "offset", s4);
choice_flag++;
}
else {
s4 = get_val(&s1);
if (! strcmp(s4, "next")) { /*concerns SET OF or SEQUENCE OF */
if (choice_flag)
ferrs(1, "proc_act2: next following choice in the code %s\n", s);
ptr1 = lookup_list(s2);
fprintf(fptab, "\t{ SCTRL, OFFSET(%s, %s), 0, 0 },\n", ptr1->type, "next");
fprintf(fptab, "\t{ PE_END, 0, 0, 0 },\n");
}
else
ferrs(1, "proc_act2: Unknown action2 = %s\n", s);
}
}
}
}
#if 0
/*
* generate the default entry for decoding fields. This should contain the
* default value which the decoder will know what to value to set if default
* encoding is found
*/
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);
}
}
#endif