/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: temp.c 1.3 89/10/10 $@(#)efl:temp.c	1.3"
#include "defs"

ptr gentemp(t)
ptr t;
{
register ptr oldp;
register ptr p;
register ptr q;
int ttype;
ptr ttypep, tdim;

/* search the temporary list for a matching type */

ttype = t->vtype;
ttypep = t->vtypep;
tdim = t->vdim;

for(oldp = &tempvarlist ; p = oldp->nextp ; oldp = p)
	if( (q = p->datap) && (q->vtype == ttype) &&
	  (q->vtypep == ttypep) && eqdim(q->vdim,tdim) )
		{
		oldp->nextp = p->nextp;
		break;
		}

if(p == PNULL)
	{
	q = allexpblock();
	q->tag = TTEMP;
	q->subtype = t->subtype;
	q->vtype = ttype;
	q->vclass = t->vclass;
	q->vtypep = ( ttypep ? cpexpr(ttypep) : PNULL);
	q->vdim = tdim;
	mkftnp(q);	/* assign fortran types */

	p = mkchain(q, CHNULL);
	p->datap = q;
	}

p->nextp = thisexec->temps;
thisexec->temps = p;

return( cpexpr(q) );
/* need a copy of the block for the temporary list and another for use */
}


ptr gent(t,tp)  /* make a temporary of type t, typepointer tp */
int t;
ptr tp;
{
static struct varblock model;

model.vtype = t;
model.vtypep = tp;

return( gentemp(&model) );
}
