Commit 3d43cd2b authored by dcw's avatar dcw
Browse files

replaced all the constants with enumerated types;

renamed GetKind{Type} -> {Type}Kind;
called the enumated type KindOf{Type};
had to use various nasty VAL/ORD gubbins to make it all work
parent 159c90f0
......@@ -150,7 +150,7 @@ static void defn_declns( exports, modulename, decs ) char *exports, *modulename;
{
if( d->Struct )
{
line( "%s;\t(* Opaque *)", d->name );
line( "%s;", d->name );
} else
{
line( "%s\t= INTEGER;", d->name );
......@@ -172,7 +172,7 @@ static void defn_declns( exports, modulename, decs ) char *exports, *modulename;
static void defn_onetype( d ) decln d;
{
shapelist s;
int n;
BOOL first;
line( "(* ----------- Type %s ----------- *)", d->name );
nl();
......@@ -186,16 +186,17 @@ static void defn_onetype( d ) decln d;
if( d->Defines )
{
line( "(* Deconstructed tags for %s *)", d->name );
line( "CONST" );
indent();
n = 0;
line( "(* Kind of %s *)", d->name );
line( "TYPE" );
fprintf( outfile, "\tKindOf%s = ( ", d->name );
first = TRUE;
for( s = d->shapes; s; s=s->next )
{
line( "%sIs%s = %d;",
d->name, s->name, n++ );
if( !first ) fputs( ", ", outfile );
fprintf( outfile, "%sIs%s", d->name, s->name );
first = FALSE;
}
outdent();
fprintf( outfile, " );\n" );
nl();
line( "(* Deconstructor kind function for %s *)",
d->name );
......@@ -304,7 +305,7 @@ static void impln_onetype( d ) decln d;
variantfields( d );
} else if( d->TagField )
{
line( "tag\t: INTEGER;" );
line( "tag\t: KindOf%s;", d->name );
normalfields( d );
} else
{
......@@ -351,7 +352,7 @@ static void variantfields( d ) decln d;
shapelist s;
paramlist p;
line( "CASE tag : INTEGER OF" );
line( "CASE tag : KindOf%s OF", d->name );
for( s = d->shapes; s != NULL; s=s->next )
{
......@@ -424,7 +425,7 @@ static void consproc_body( d, s ) decln d; shape s;
line( "RETURN NIL;" );
} else if( ! d->Struct )
{
line( "RETURN %sIs%s;", d->name, s->name );
line( "RETURN %s( ORD(%sIs%s) );", d->name, d->name, s->name );
} else
{
line( "NEW( new );", d->name );
......@@ -451,7 +452,7 @@ static void consproc_body( d, s ) decln d; shape s;
static void deconskind_header( name ) char *name;
{
line( "PROCEDURE GetKind%s( this : %s ) : INTEGER;", name, name );
line( "PROCEDURE %sKind( this : %s ) : KindOf%s;", name, name, name );
}
......@@ -463,7 +464,7 @@ static void deconskind_body( d ) decln d;
indent();
deconskind_inner( d );
outdent();
line( "END GetKind%s;", d->name );
line( "END %sKind;", d->name );
nl();
nl();
}
......@@ -475,7 +476,7 @@ static void deconskind_inner( d ) decln d;
if( ! d->Struct ) /* enumerated type */
{
line( "RETURN this;" );
line( "RETURN VAL(KindOf%s, this);", d->name );
return;
}
if( d->UseNull )
......@@ -576,7 +577,10 @@ static void printproc_body( d ) decln d;
print_all_params( d->name, shapes );
} else /* enumerated type */
{
print_using_case( "this", d->name, shapes );
char tag[256];
sprintf( tag, "VAL(KindOf%s, this)", d->name );
print_using_case( tag, d->name, shapes );
}
outdent();
line( "END Print%s;", d->name );
......
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