/*
 * This file is part of the Cforall project
 *
 * $Id: AttrType.cc,v 1.3 2005/08/29 20:59:25 rcbilson Exp $
 *
 */

#include "Type.h"
#include "Expression.h"
#include "utility.h"


AttrType::AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr )
    : Type( tq ), name( name ), expr( expr ), type( 0 ), isType( false )
{
}

AttrType::AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type )
    : Type( tq ), name( name ), expr( 0 ), type( type ), isType( true )
{
}

AttrType::AttrType( const AttrType &other )
    : Type( other ), name( other.name ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType )
{
}

AttrType::~AttrType()
{
    delete expr;
    delete type;
}

void 
AttrType::print( std::ostream &os, int indent ) const
{
    Type::print( os, indent );
    os << "attribute " << name << " applied to ";
    if( expr ) {
	os << "expression ";
	expr->print( os, indent );
    }
    if( type ) {
	os << "type ";
	type->print( os, indent );
    }
}

