<commit_before>#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/PassRegistry.h"
#include "ExpertSystem/KnowledgeConstructionEngine.h"
#include "pipeline/clips/CLIPSPassGenerator.h"
#include "rampancy/Cortex.h"
#include "rampancy/CompilerManager.h"
#include "rampancy/CompilerRegistry.h"
#include "indirect/Indirector.h"
#include "llvm/Support/raw_ostream.h"

extern "C" {
#include "clips.h"
}

using namespace llvm;
using namespace indirect;
extern "C" void CLIPSOptimizeCode(void* theEnv);
extern "C" void CLIPSRegisterPass(void* theEnv);
extern "C" void CLIPSUnregisterPass(void* theEnv);
extern "C" void* CLIPSPassRegistered(void* theEnv);
#define pass_registered (char*)"pass-registered"
#define optimize (char*)"optimize"
#define unregister_pass (char*)"unregister-pass"
#define register_pass (char*)"register-pass"
#define werror (char*)"werror"
#define msg(x) (char*) x
#define copy(from, to) \
	to = CharBuffer(strlen(from)); \
sprintf(to, "%s", from) 
#define BoolCast(str, tgt) tgt = (strcmp(str, "TRUE") == 0) ? TRUE : FALSE

extern "C" void RegisterCLIPSPipelineFunctions(void* theEnv) {
	EnvDefineFunction(theEnv, optimize, 'v',
			PTIEF CLIPSOptimizeCode, "CLIPSOptimizeCode");
	EnvDefineFunction(theEnv, register_pass, 'v',
			PTIEF CLIPSRegisterPass, "CLIPSRegisterPass");
	EnvDefineFunction(theEnv, unregister_pass, 'v',
			PTIEF CLIPSUnregisterPass, "CLIPSUnregisterPass");
	EnvDefineFunction2(theEnv, pass_registered, 'w', 
			PTIEF CLIPSPassRegistered, "CLIPSPassRegistered", 
			"11k");
}

void CLIPSOptimizeCode(void* theEnv) {

}

void CLIPSRegisterPass(void* theEnv) {
	/* register-pass has the following arguments
	 * 1) name (PassArg)
	 * 2) description (PassName)
	 * 3) type (string)
	 * 4) IsAnalysis (bool)
	 * 5) isCFGPass (bool)
	 * 6) needRegions (bool)
	 * 7) needLoops (bool)
	 * 8) passes (multifield)
	 * 9) required (multifield)
	 * 10) required-transitive (multifield)
	 * 11) Preserved (multifield)
	 * 12) preservesAll (bool)
	 * 13) preservesCFG (bool);
	 */

	void* passes;
	void* required;
	void* requiredTransitive;
	void* preserved;
	DATA_OBJECT arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, 
					arg10, arg11, arg12;
	char *tmp0, *tmp1, *tmp2, *tmp3, *tmp4, *tmp5, *tmp5, *tmp6, *tmp7, *tmp8,
		  *tmp9;
	char* pArg;
	char* pName;
	bool isAnalysis, isCFG, 
		  needRegions, needLoops,
		  preservesAll, preservesCFG;
	char* type;
	long long l0, l1, l2, l3;
	std::string tmp;
	raw_string_ostream stream(tmp);
	pipeline::clips::CLIPSPassHeader* header = new pipeline::clips::CLIPSPassHeader();
	header->setTemplateSet("clips");
	if(EnvArgCountCheck(theEnv, register_pass, EXACTLY, 13) == -1) {
		return;
	}

	if(EnvArgTypeCheck(theEnv, register_pass, 1, STRING_OR_SYMBOL, &arg0) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 2, STRING_OR_SYMBOL, &arg1) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 3, STRING_OR_SYMBOL, &arg2) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 4, SYMBOL, &arg3) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 5, SYMBOL, &arg4) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 6, SYMBOL, &arg5) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 7, SYMBOL, &arg6) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 8, MULTIFIELD, &arg7) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 9, MULTIFIELD, &arg8) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 10, MULTIFIELD, &arg9) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 11, MULTIFIELD, &arg10) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 12, SYMBOL, &arg11) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 13, SYMBOL, &arg12) == FALSE) {
		return;
	}
	tmp0 = DOToString(arg0);
	copy(tmp0, pArg);
	header->setPassName((const char*)pArg, true);
	tmp1 = DOToString(arg1);
	copy(tmp1, pName);
	header->setPassDescription((const char*)pName, true);
	tmp2 = DOToString(arg2);
	copy(tmp2, type);
	header->setPassType(type);
	tmp3 = DOToString(arg3);
	BoolCast(tmp3, isAnalysis);
	header->setIsAnalysis(isAnalysis);
	tmp4 = DOToString(arg4);
	BoolCast(tmp4, isCFG);
	header->setIsCFGOnlyPass(isCFG);
	tmp5 = DOToString(arg5);
	BoolCast(tmp5, needRegions);
	header->setNeedsRegions(needRegions);
	tmp6 = DOToString(arg6);
	BoolCast(tmp6, needLoops);
	header->setNeedsLoops(needLoops);
	l0 = (long long)GetDOLength(arg7);
	l1 = (long long)GetDOLength(arg8);
	aUsage = GetValue(arg7);



   IndirectPassRegistry& indirectRegistry = *IndirectPassRegistry::getIndirectPassRegistry();
	indirectRegistry.registerIndirectPassHeader(header);

}

void CLIPSUnregisterPass(void* theEnv) {

}

void* CLIPSPassRegistered(void* theEnv) {
	DATA_OBJECT arg0;
	char* a;
	char* b;
	if(EnvArgCountCheck(theEnv, pass_registered, EXACTLY, 1) == -1) {
		return FalseSymbol();
	}

	if(EnvArgTypeCheck(theEnv, pass_registered, 1, STRING_OR_SYMBOL, &arg0) == FALSE) {
		return FalseSymbol();
	}
	a = DOToString(arg0);
	copy(a, b);

	llvm::PassRegistry* registry = llvm::PassRegistry::getPassRegistry();
	const llvm::PassInfo* pi = registry->getPassInfo(llvm::StringRef(b));<commit_msg>Fixed errors in CLIPSPipelineFunctions.cpp<commit_after>#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/PassRegistry.h"
#include "ExpertSystem/KnowledgeConstructionEngine.h"
#include "pipeline/clips/CLIPSPassGenerator.h"
#include "pipeline/clips/CLIPSPass.h"
#include "pipeline/clips/CLIPSPassHeader.h"
#include "rampancy/Cortex.h"
#include "rampancy/CompilerManager.h"
#include "rampancy/CompilerRegistry.h"
#include "indirect/Indirector.h"
#include "llvm/Support/raw_ostream.h"

extern "C" {
#include "clips.h"
}

using namespace llvm;
using namespace indirect;
extern "C" void CLIPSOptimizeCode(void* theEnv);
extern "C" void CLIPSRegisterPass(void* theEnv);
extern "C" void CLIPSUnregisterPass(void* theEnv);
extern "C" void* CLIPSPassRegistered(void* theEnv);
#define pass_registered (char*)"pass-registered"
#define optimize (char*)"optimize"
#define unregister_pass (char*)"unregister-pass"
#define register_pass (char*)"register-pass"
#define werror (char*)"werror"
#define msg(x) (char*) x
#define copy(from, to) \
	to = CharBuffer(strlen(from)); \
sprintf(to, "%s", from) 
#define BoolCast(str, tgt) tgt = (strcmp(str, "TRUE") == 0) ? TRUE : FALSE

extern "C" void RegisterCLIPSPipelineFunctions(void* theEnv) {
	EnvDefineFunction(theEnv, optimize, 'v',
			PTIEF CLIPSOptimizeCode, "CLIPSOptimizeCode");
	EnvDefineFunction(theEnv, register_pass, 'v',
			PTIEF CLIPSRegisterPass, "CLIPSRegisterPass");
	EnvDefineFunction(theEnv, unregister_pass, 'v',
			PTIEF CLIPSUnregisterPass, "CLIPSUnregisterPass");
	EnvDefineFunction2(theEnv, pass_registered, 'w', 
			PTIEF CLIPSPassRegistered, "CLIPSPassRegistered", 
			"11k");
}

void CLIPSOptimizeCode(void* theEnv) {

}

void CLIPSRegisterPass(void* theEnv) {
	/* register-pass has the following arguments
	 * 1) name (PassArg)
	 * 2) description (PassName)
	 * 3) type (string)
	 * 4) IsAnalysis (bool)
	 * 5) isCFGPass (bool)
	 * 6) needRegions (bool)
	 * 7) needLoops (bool)
	 * 8) passes (multifield)
	 * 9) required (multifield)
	 * 10) required-transitive (multifield)
	 * 11) Preserved (multifield)
	 * 12) preservesAll (bool)
	 * 13) preservesCFG (bool);
	 */

	void* passes;
	void* required;
	void* requiredTransitive;
	void* preserved;
	DATA_OBJECT arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, 
					arg10, arg11, arg12;
	char *tmp0, *tmp1, *tmp2, *tmp3, *tmp4, *tmp5, *tmp6, *tmp7, *tmp8, *tmp9,
		  *tmp10;
	char* pArg;
	char* pName;
	bool isAnalysis, isCFG, 
		  needRegions, needLoops,
		  preservesAll, preservesCFG;
	char* type;
	long long l0, l1, l2, l3;
	std::string tmp;
	raw_string_ostream stream(tmp);
	pipeline::clips::CLIPSPassHeader* header = new pipeline::clips::CLIPSPassHeader();
	header->setTemplateSet("clips");
	if(EnvArgCountCheck(theEnv, register_pass, EXACTLY, 13) == -1) {
		return;
	}

	if(EnvArgTypeCheck(theEnv, register_pass, 1, SYMBOL_OR_STRING, &arg0) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 2, SYMBOL_OR_STRING, &arg1) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 3, SYMBOL_OR_STRING, &arg2) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 4, SYMBOL, &arg3) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 5, SYMBOL, &arg4) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 6, SYMBOL, &arg5) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 7, SYMBOL, &arg6) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 8, MULTIFIELD, &arg7) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 9, MULTIFIELD, &arg8) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 10, MULTIFIELD, &arg9) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 11, MULTIFIELD, &arg10) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 12, SYMBOL, &arg11) == FALSE) {
		return;
	}
	if(EnvArgTypeCheck(theEnv, register_pass, 13, SYMBOL, &arg12) == FALSE) {
		return;
	}
	tmp0 = DOToString(arg0);
	copy(tmp0, pArg);
	header->setPassName((const char*)pArg);
	tmp1 = DOToString(arg1);
	copy(tmp1, pName);
	header->setPassDescription((const char*)pName);
	tmp2 = DOToString(arg2);
	copy(tmp2, type);
	header->setPassType(type);
	tmp3 = DOToString(arg3);
	BoolCast(tmp3, isAnalysis);
	header->setIsAnalysis(isAnalysis);
	tmp4 = DOToString(arg4);
	BoolCast(tmp4, isCFG);
	header->setIsCFGOnlyPass(isCFG);
	tmp5 = DOToString(arg5);
	BoolCast(tmp5, needRegions);
	header->setNeedsRegions(needRegions);
	tmp6 = DOToString(arg6);
	BoolCast(tmp6, needLoops);
	header->setNeedsLoops(needLoops);
	//l0 = (long long)GetDOLength(arg7);
	//l1 = (long long)GetDOLength(arg8);
	//aUsage = GetValue(arg7);



   IndirectPassRegistry& indirectRegistry = *IndirectPassRegistry::getIndirectPassRegistry();
	indirectRegistry.registerIndirectPassHeader(header);
	free(pArg);
	free(pName);
	free(type);

}

void CLIPSUnregisterPass(void* theEnv) {

}

void* CLIPSPassRegistered(void* theEnv) {
	DATA_OBJECT arg0;
	char* a;
	char* b;
	if(EnvArgCountCheck(theEnv, pass_registered, EXACTLY, 1) == -1) {
		return FalseSymbol();
	}

	if(EnvArgTypeCheck(theEnv, pass_registered, 1, SYMBOL_OR_STRING, &arg0) == FALSE) {
		return FalseSymbol();
	}
	a = DOToString(arg0);
	copy(a, b);

	llvm::PassRegistry* registry = llvm::PassRegistry::getPassRegistry();
	const llvm::PassInfo* pi = registry->getPassInfo(llvm::StringRef(b));
{'fraction_non_alphanumeric': 0.14722430607651912, 'fraction_numerical': 0.022599399849962492, 'mean_word_length': 5.947882736156352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1780228', 'n_tokens_mistral': 4329, 'n_tokens_neox': 4091, 'n_words': 835}