/*
 * LateContextCompiler2.h
 *
 *  Created on: 10 февр. 2016
 *      Author: pgess
 */

#ifndef LATECONTEXTCOMPILER2_H_
#define LATECONTEXTCOMPILER2_H_

#include "serialization.h"

namespace llvm {
	class Value;
	class Function;
}

namespace xreate {
	class CompilePass;

namespace compilation {
	class FunctionUnit;
}}

namespace xreate {

typedef unsigned int ScopePacked;
class LateContextCompiler2 {
public:
	llvm::Value* raw = nullptr;

	LateContextCompiler2(compilation::FunctionUnit* f, CompilePass* p);
	llvm::Value* findFunction(const std::string& calleeName, llvm::Function* specializationDefault);
	llvm::Value* compileArgument(const std::string& callee, ScopePacked scopeOuter);
	size_t getFunctionVariantsSize() const;
	size_t getFunctionDemandSize() const;

private:
	typedef ExpressionSerialization<RequirementIntegralCode>::Code Code;
	typedef ExpressionSerialization<RequirementIntegralCode>::Serializer Domain;
	//boost::bimap<size_t, std::string> __decisions;
	//std::vector<Domain> __scheme;

	compilation::FunctionUnit* function;
	CompilePass* pass;
};

} /* namespace xreate */

#endif /* LATECONTEXTCOMPILER2_H_ */
