/*
 * LateContext.h
 *
 *  Created on: Jan 8, 2016
 *      Author: pgess
 */

#ifndef SRC_COMPILATION_LATECONTEXTCOMPILER_H_
#define SRC_COMPILATION_LATECONTEXTCOMPILER_H_

#include "ast.h"

namespace llvm {
	class Value;
	class Function;
}

namespace xreate {
typedef unsigned int ScopePacked;

class CompilePass;

//SECTIONTAG late-context compilation logic wrt late context

class LateContextCompiler{

public:
	LateContextCompiler(const std::string& function, CompilePass* compilePass);
	~LateContextCompiler();

	llvm::Value* compileCheckContext(const Expression& e);
	llvm::Value* compileArgument(const std::string& callee, ScopePacked scopeOuter);
	llvm::Value* findFunction(const std::string name, ScopePacked scopeOuter, llvm::Function* functionOuter);
	size_t getFunctionDomainSize() const;

	llvm::Value* raw = nullptr;

private:
	std::string functionName;
	CompilePass* pass;
};

} /* namespace xreate */

#endif /* SRC_COMPILATION_LATECONTEXTCOMPILER_H_ */
