<commit_before>#include "InstructionTreeVmEval.h"

#include <math.h>

#include "ExpressionTree.h"
#include "TypeTree.h"
#include "InstructionTreeVm.h"
#include "InstructionTreeVmCommon.h"

#define FMT_ISTR(x) unsigned(x.end - x.begin), x.begin
#define allocate(T) new (ctx.get<T>()) T

typedef InstructionVMEvalContext Eval;

const unsigned memoryStorageBits = 16u;
const unsigned memoryOffsetMask = (1u << memoryStorageBits) - 1;
const unsigned memoryStorageMask = ~0u & ~memoryOffsetMask;

namespace
{
	unsigned GetFunctionIndex(VmModule *module, VmFunction *function)
	{
		unsigned index = ~0u;

		for(unsigned i = 0, e = module->functions.size(); i < e; i++)
		{
			if(module->functions[i] == function)
			{
				index = i;
				break;
			}
		}

		assert(index != ~0u);

		return index;
	}

	int GetIntPow(int power, int number)
	{
		if(power < 0)
			return number == 1 ? 1 : (number == -1 ? (power & 1 ? -1 : 1) : 0);

		int result = 1;
		while(power)
		{
			if(power & 1)
			{
				result *= number;
				power--;
			}
			number *= number;
			power >>= 1;
		}
		return result;
	}

	long long GetLongPow(long long power, long long number)
	{
		if(power < 0)
			return number == 1 ? 1 : (number == -1 ? (power & 1 ? -1 : 1) : 0);

		long long result = 1;
		while(power)
		{
			if(power & 1)
			{
				result *= number;
				power--;
			}
			number *= number;
			power >>= 1;
		}
		return result;
	}
<commit_msg>Fixed evaluation of integer exponentiation<commit_after>#include "InstructionTreeVmEval.h"

#include <math.h>

#include "ExpressionTree.h"
#include "TypeTree.h"
#include "InstructionTreeVm.h"
#include "InstructionTreeVmCommon.h"

#define FMT_ISTR(x) unsigned(x.end - x.begin), x.begin
#define allocate(T) new (ctx.get<T>()) T

typedef InstructionVMEvalContext Eval;

const unsigned memoryStorageBits = 16u;
const unsigned memoryOffsetMask = (1u << memoryStorageBits) - 1;
const unsigned memoryStorageMask = ~0u & ~memoryOffsetMask;

namespace
{
	unsigned GetFunctionIndex(VmModule *module, VmFunction *function)
	{
		unsigned index = ~0u;

		for(unsigned i = 0, e = module->functions.size(); i < e; i++)
		{
			if(module->functions[i] == function)
			{
				index = i;
				break;
			}
		}

		assert(index != ~0u);

		return index;
	}

	int GetIntPow(int number, int power)
	{
		if(power < 0)
			return number == 1 ? 1 : (number == -1 ? (power & 1 ? -1 : 1) : 0);

		int result = 1;
		while(power)
		{
			if(power & 1)
			{
				result *= number;
				power--;
			}
			number *= number;
			power >>= 1;
		}
		return result;
	}

	long long GetLongPow(long long number, long long power)
	{
		if(power < 0)
			return number == 1 ? 1 : (number == -1 ? (power & 1 ? -1 : 1) : 0);

		long long result = 1;
		while(power)
		{
			if(power & 1)
			{
				result *= number;
				power--;
			}
			number *= number;
			power >>= 1;
		}
		return result;
	}

{'fraction_non_alphanumeric': 0.14892869687390237, 'fraction_numerical': 0.02107481559536354, 'mean_word_length': 3.051209103840683, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '221178', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1043, 'n_words': 276}