<commit_before>#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <netinet/in.h>

#include "opcodes.h"
#include "value.h"
#include "types.h"
#include "stack.h"
#include "literals.h"
#include "scope.h"
#include "gc.h"
#include "func.h"
#include "hashmap.h"
#include "header.h"
#include "lib.h"

int signed_opcode(int opcode)
{
	switch (opcode)
	{
		case OP_PUSH_INTEGER:
		case OP_JMP:
		case OP_JMPZ:
			return true;
		default:
			return false;
	}
}

void decode(int instruction, int *opcode, int *argument)
{
	*opcode = instruction >> 24;
	if (signed_opcode(*opcode))
	{
		*argument = instruction & 8388607;
		if (instruction & (1 << 23))
		{
			*argument = -(~*argument & 8388607) - 1;
		}
	}
	else
	{
		*argument = instruction & 16777215;
	}
}

Error do_instruction(Header* h, Stack* S, Stack* scope_arr)
{
	V container;
	V v;
	V key;
	V scope = get_head(scope_arr);
	Scope *sc = toScope(scope);
	Func* f;
	V file;
	uint32_t *pc;
	int opcode, argument;
	decode(ntohl(*sc->pc), &opcode, &argument);
	switch (opcode)
	{
		case OP_PUSH_LITERAL:
			push(S, add_ref(get_literal(h, argument)));
			break;
		case OP_PUSH_INTEGER:
			push(S, int_to_value(argument));
			break;
		case OP_PUSH_WORD:
			key = get_literal(h, argument);<commit_msg>Removes signed_opcode() and decode() just because<commit_after>#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <netinet/in.h>

#include "opcodes.h"
#include "value.h"
#include "types.h"
#include "stack.h"
#include "literals.h"
#include "scope.h"
#include "gc.h"
#include "func.h"
#include "hashmap.h"
#include "header.h"
#include "lib.h"

Error do_instruction(Header* h, Stack* S, Stack* scope_arr)
{
	V container;
	V v;
	V key;
	V scope = get_head(scope_arr);
	Scope *sc = toScope(scope);
	Func* f;
	V file;
	uint32_t *pc;
	int argument;
	int instruction = ntohl(*sc->pc);
	int opcode = instruction >> 24;
	switch (opcode)
	{
		case OP_PUSH_INTEGER:
		case OP_JMP:
		case OP_JMPZ:
			argument = instruction & 8388607;
			if (instruction & (1 << 23))
			{
				argument = -(~argument & 8388607) - 1;
			}
			break;
		default:
			argument = instruction & 16777215;
	}
	switch (opcode)
	{
		case OP_PUSH_LITERAL:
			push(S, add_ref(get_literal(h, argument)));
			break;
		case OP_PUSH_INTEGER:
			push(S, int_to_value(argument));
			break;
		case OP_PUSH_WORD:
			key = get_literal(h, argument);
{'fraction_non_alphanumeric': 0.15134907251264756, 'fraction_numerical': 0.025295109612141653, 'mean_word_length': 4.136363636363637, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '1591404', 'n_tokens_mistral': 1081, 'n_tokens_neox': 981, 'n_words': 232}