//
// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// FunctionFixer.h -- 
//
// Author           : Rodolfo G. Esteves
// Created On       : Mon May 18 07:44:20 2015
// Last Modified By : Peter A. Buhr
// Last Modified On : Mon May 18 14:58:45 2015
// Update Count     : 3
//

#ifndef _FUNCTIONFIXER_H_
#define _FUNCTIONFIXER_H_

#include "SynTree/Mutator.h"

#include "SynTree/Declaration.h"
#include "SynTree/Expression.h"
#include "SynTree/Statement.h"
#include "SynTree/Type.h"

#include "SymTab/Indexer.h"
#include "ResolvExpr/Resolver.h"
#include "ResolvExpr/AlternativeFinder.h"

namespace Tuples {
	class FunctionFixer : public Mutator {
		typedef Mutator Parent;
	  public:
		FunctionFixer() {}
		virtual ~FunctionFixer() {}
		virtual Type       *mutate( FunctionType *functionType );
		virtual Statement  *mutate( ReturnStmt   *retStmt  );
		virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
		virtual Expression *mutate( VariableExpr *variableExpr);

		// indexer runs
		virtual ObjectDecl     *mutate( ObjectDecl *objectDecl )
			{ index.visit( objectDecl ); return objectDecl; }
		virtual TypeDecl       *mutate( TypeDecl *typeDecl )
			{ index.visit( typeDecl ); return typeDecl; }
		virtual TypedefDecl    *mutate( TypedefDecl *typeDecl )
			{ index.visit( typeDecl ); return typeDecl; }
		virtual StructDecl     *mutate( StructDecl *aggregateDecl )
			{ index.visit( aggregateDecl ); return aggregateDecl; }
		virtual UnionDecl      *mutate( UnionDecl *aggregateDecl )
			{ index.visit( aggregateDecl ); return aggregateDecl; }
		virtual EnumDecl       *mutate( EnumDecl *aggregateDecl )
			{ index.visit( aggregateDecl ); return aggregateDecl; }

		virtual Type           *mutate( StructInstType *aggrInst )
			{ index.visit( aggrInst ); return aggrInst; }
		virtual Type           *mutate( UnionInstType *aggrInst )
			{ index.visit( aggrInst ); return aggrInst; }
	  private:
		std::list< DeclarationWithType * > rets;
		SymTab::Indexer index;
	};
} // namespace Tuples

#endif // _FUNCTIONFIXER_H_

// Local Variables: //
// tab-width: 4 //
// mode: c++ //
// compile-command: "make install" //
// End: //
