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

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


AddressExpr::AddressExpr( Expression *arg, Expression *_aname )
    : Expression( _aname ), arg( arg )
{
    for( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i ) {
	get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) );
    }
}

AddressExpr::AddressExpr( const AddressExpr &other )
    : Expression( other ), arg( maybeClone( other.arg ) )
{
}

AddressExpr::~AddressExpr()
{
    delete arg;
}

void 
AddressExpr::print( std::ostream &os, int indent ) const
{
    os << std::string( indent, ' ' ) << "Address of:" << std::endl;
    if( arg ) {
	arg->print( os, indent+2 );
    }
}


