/*
 * logging.h
 *
 *  Created on: Jun 23, 2015
 *      Author: pgess
 */

#ifndef SRC_LOGGING_H_
#define SRC_LOGGING_H_

#include "ast.h"
#include <llvm/IR/Value.h>
#include "pass/compilepass.h"
#include "pass/abstractpass.h"
#include "clasplayer.h"

namespace xreate {

class Logging:public AbstractPass<void>, public IQuery {
public:
	void inject(const Symbol& symbol, const CompilePass::Context& context);
	Logging(PassManager* manager);

	virtual void init(ClaspLayer* clasp);
	void initDependencies(CompilePass* pass);
	virtual void process(const Expression& expression, PassContext context, const std::string& varDecl="");

private:
	CompilePass* compiler = nullptr;
	llvm::Function* refPrintf;
	void initOutput();
};

struct IsLogging{};

template<>
struct AttachmentsDict<IsLogging> {
   typedef bool Data;
   static const unsigned int key = 5;
};

} /* namespace xreate */

#endif /* SRC_LOGGING_H_ */
