<commit_before>#pragma once
#include "program.h"
#include "details/ir/sequence.h"
#include <array>


namespace ny {
namespace vm {


struct Mountpoint final {
	Yuni::ShortString256 path;
	nyio_adapter_t adapter;
};


class Context final {
public:
	//! Default constructor
	explicit Context(Program& program, const AnyString& name);
	//! Clone a thread context
	explicit Context(Context&);
	//! Destructor
	~Context();

	//! Get the equivalent C type
	nytctx_t* self();
	//! Get the equivalent C type (const)
	const nytctx_t* self() const;

	/*!
	** \brief Print a message on the console
	*/
	void cerr(const AnyString& msg);
	//! Set the text color on the error output
	void cerrColor(nycolor_t);

	void cerrException(const AnyString& msg);
	void cerrUnknownPointer(void*, uint32_t offset);


	bool invoke(uint64_t& exitstatus, const ir::Sequence& callee, uint32_t atomid, uint32_t instanceid);

	bool initializeFirstTContext();


public:
	//! Attached program
	Program& program;

	//! Temporary structure for complex return values by intrinsics
	struct {
		uint64_t size;
		uint64_t capacity;
		void* data;
	}
	returnValue;

	struct IO {
		/*!
		** \brief Find the adapter and the relative adapter path from a virtual path
		**
		** \param[out] relativepath Get a non-empty absolute path (but may contain segments like '.' amd '..')
		** \param path Am aboslute virtual path
		** \return An adapter, fallbackAdapter if not found
		*/
		nyio_adapter_t& resolve(AnyString& relativepath, const AnyString& path);

		/*!
		** \brief Add a new virtual mountpoint
		**
		** \param path A Virtual path (may not exist)
		** \param adapter The adapter to handle this mountpoint
		** \return True if the operation succeeded
		*/
		bool addMountpoint(const AnyString& path, nyio_adapter_t& adapter);

	public:
		// Current Working directory
		Yuni::String cwd;
		//! The total number of mountpoints
		uint32_t mountpointSize = 0;
		//! All mountpoints, from the last added to the first one (stored in the reverse order)
		std::array<Mountpoint, 32> mountpoints;
		//! Current working directory
		Mountpoint fallback;
	}
	io;

	nyprogram_cf_t& cf;
	//! Thread name
	Yuni::ShortString64 name;

private:
	void initFallbackAdapter(nyio_adapter_t& adapter);

}; // class Context


} // namespace vm
} // namespace ny
<commit_msg>vm: Context: struct instead of class<commit_after>#pragma once
#include "program.h"
#include "details/ir/sequence.h"
#include <array>


namespace ny {
namespace vm {


struct Mountpoint final {
	Yuni::ShortString256 path;
	nyio_adapter_t adapter;
};


struct Context final {
	//! Default constructor
	explicit Context(Program& program, const AnyString& name);
	//! Clone a thread context
	explicit Context(Context&);
	//! Destructor
	~Context();

	//! Get the equivalent C type
	nytctx_t* self();
	//! Get the equivalent C type (const)
	const nytctx_t* self() const;

	/*!
	** \brief Print a message on the console
	*/
	void cerr(const AnyString& msg);
	//! Set the text color on the error output
	void cerrColor(nycolor_t);

	void cerrException(const AnyString& msg);
	void cerrUnknownPointer(void*, uint32_t offset);


	bool invoke(uint64_t& exitstatus, const ir::Sequence& callee, uint32_t atomid, uint32_t instanceid);

	bool initializeFirstTContext();


public:
	//! Attached program
	Program& program;

	//! Temporary structure for complex return values by intrinsics
	struct {
		uint64_t size;
		uint64_t capacity;
		void* data;
	}
	returnValue;

	struct IO {
		/*!
		** \brief Find the adapter and the relative adapter path from a virtual path
		**
		** \param[out] relativepath Get a non-empty absolute path (but may contain segments like '.' amd '..')
		** \param path Am aboslute virtual path
		** \return An adapter, fallbackAdapter if not found
		*/
		nyio_adapter_t& resolve(AnyString& relativepath, const AnyString& path);

		/*!
		** \brief Add a new virtual mountpoint
		**
		** \param path A Virtual path (may not exist)
		** \param adapter The adapter to handle this mountpoint
		** \return True if the operation succeeded
		*/
		bool addMountpoint(const AnyString& path, nyio_adapter_t& adapter);

	public:
		// Current Working directory
		Yuni::String cwd;
		//! The total number of mountpoints
		uint32_t mountpointSize = 0;
		//! All mountpoints, from the last added to the first one (stored in the reverse order)
		std::array<Mountpoint, 32> mountpoints;
		//! Current working directory
		Mountpoint fallback;
	}
	io;

	nyprogram_cf_t& cf;
	//! Thread name
	Yuni::ShortString64 name;

private:
	void initFallbackAdapter(nyio_adapter_t& adapter);

}; // struct Context


} // namespace vm
} // namespace ny

{'fraction_non_alphanumeric': 0.10445832435925048, 'fraction_numerical': 0.009476631488261899, 'mean_word_length': 3.9247083775185576, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5511800', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1432, 'n_words': 510}