<commit_before>#include "KAI/ExecutorPCH.h"

KAI_BEGIN

void Continuation::Create()
{
	entered = New(false);
	scopeBreak = New(false);
	args = New<Array>();
	index = New(0);
}

bool Continuation::Destroy()
{
	return true;
}

void Continuation::SetCode(Code C)
{
	code = C;
	*entered = false;
}

void Continuation::Enter(Executor *exec)
{
	if (*entered)
		return;

	if (code.Exists() && !code->Empty())
	{
		if (!scope.Exists())
			scope = exec->New<void>();

		Stack &data = *exec->GetDataStack();
		if (data.Size() < args->Size())
		{
			KAI_TRACE_ERROR_2(data.Size(), args->Size()) << "Failed to enter continuation: not enough args";
			KAI_THROW_0(EmptyStack);
		}

		for (auto arg : *args)
		{
			Object a = data.Pop();
			scope.Set(ConstDeref<Label>(arg), a);
		}
	}

	*index = 0;
	*entered = true;
}

bool Continuation::Next() const
{
	Object unused;
	return Next(unused);
}

bool Continuation::Next(Object &next) const
{ 
	if (!code)
		return false;

	if (!*entered)
		KAI_THROW_1(LogicError, "Continuation not Entered");

	int &n = Deref<int>(index);
	if (n == code->Size())
		return n != 0;

	next = code->At(n++);
<commit_msg>Everything is completely bork<commit_after>#include "KAI/ExecutorPCH.h"

KAI_BEGIN

void Continuation::Create()
{
	entered = New(false);
	scopeBreak = New(false);
	args = New<Array>();
	index = New(0);
}

bool Continuation::Destroy()
{
	return true;
}

void Continuation::SetCode(Code C)
{
	code = C;
	*entered = false;
}

void Continuation::Enter(Executor *exec)
{
	if (*entered)
		return;

	if (code.Exists() && !code->Empty())
	{
		if (!scope.Exists())
			scope = exec->New<void>();

		Stack &data = *exec->GetDataStack();
		if (data.Size() < args->Size())
		{
			KAI_TRACE_ERROR_2(data.Size(), args->Size()) << "Failed to enter continuation: not enough args";
			KAI_THROW_0(EmptyStack);
		}

		for (auto arg : *args)
		{
			Object a = data.Pop();
			scope.Set(ConstDeref<Label>(arg), a);
		}
	}

	*index = 0;
	*entered = true;
}

bool Continuation::Next() const
{
	Object unused;
	return Next(unused);
}

bool Continuation::Next(Object &next) const
{ 
	if (!code)
		return false;

	if (!*entered)
		KAI_THROW_1(LogicError, "Continuation not Entered");

	int &n = Deref<int>(index);
	if (n == code->Size())
		return false;

	next = code->At(n++);

{'fraction_non_alphanumeric': 0.18277219064276345, 'fraction_numerical': 0.004809794490599038, 'mean_word_length': 4.107142857142857, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5757132', 'n_tokens_mistral': 949, 'n_tokens_neox': 868, 'n_words': 198}