//
// 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 23:31:58 2015
// Update Count     : 3
//

#ifndef _FUNCTION_FIXER_H_
#define _FUNCTION_FIXER_H_

#include "SynTree/Mutator.h"
#include "SymTab/Indexer.h"

#include "SynTree/Expression.h"

namespace ArgTweak {
	class FunctionFixer : public Mutator {
		typedef Mutator Parent;
	  public:
		FunctionFixer(SymTab::Indexer *ind = 0);
		~FunctionFixer();

		virtual DeclarationWithType *mutate( FunctionDecl *functionDecl );
		virtual Expression *mutate( UntypedExpr *untypedExpr ) throw ( SemanticError );
	  private:
		class Matcher {
			typedef std::string key;
			typedef DeclarationWithType * pattern_type;
			typedef Expression * permutation_type;
		  public:
			static key null_key;
			static permutation_type null_value;

			std::string extract_key( DeclarationWithType * );
			std::string extract_key( Expression * );

			bool operator()( DeclarationWithType *, Expression * ) { return true; }
		};

		SymTab::Indexer *index;
	};

	template < class L1, class L2, class Predicate > bool align( L1 &pattern, L2 &possible_permutation, Predicate pred ); 
} // namespace ArgTweak

#endif // _FUNCTION_FIXER_H_

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