ArkScript
A small, lisp-inspired, functional scripting language
Constants.hpp
Go to the documentation of this file.
1/**
2 * @file Constants.hpp
3 * @author Lexy Plateau (lexplt.dev@gmail.com)
4 * @brief Constants used by ArkScript
5 * @date 2020-10-27
6 *
7 * @copyright Copyright (c) 2020-2026
8 *
9 */
10
11#ifndef INCLUDE_ARK_CONSTANTS_HPP_IN
12#define INCLUDE_ARK_CONSTANTS_HPP_IN
13
14#include <string_view>
15#include <limits>
16
17// clang-format off
18constexpr int ARK_VERSION_MAJOR = 4;
19constexpr int ARK_VERSION_MINOR = 7;
20constexpr int ARK_VERSION_PATCH = 2;
21// clang-format on
22
23#if 0==1
24constexpr std::string_view ARK_VERSION { "4.7.2-pre" };
25constexpr std::string_view ARK_FULL_VERSION { "4.7.2-pre-b97ba4e1" };
26#else
27constexpr std::string_view ARK_VERSION { "4.7.2" };
28constexpr std::string_view ARK_FULL_VERSION { "4.7.2-b97ba4e1" };
29#endif // ARK_VERSION_PRERELEASE
30
31#define ARK_COMPILER "AppleClang"
32#define ARK_BUILD_DATE "2026-08-29T16:41:44Z"
33#define ARK_CACHE_DIRNAME "__arkscript__"
34#define ARK_NO_NAME_FILE "FILE"
35
36#if defined(_WIN32) || defined(_WIN64)
37# define ARK_PLATFORM_NAME "Windows"
38#elif defined(__APPLE__) || defined(__MACH__)
39# define ARK_PLATFORM_NAME "Mac OSX"
40#elif defined(__linux__)
41# define ARK_PLATFORM_NAME "Linux"
42#elif defined(__FreeBSD__)
43# define ARK_PLATFORM_NAME "FreeBSD"
44#elif defined(__unix) || defined(__unix__)
45# define ARK_PLATFORM_NAME "Unix"
46#else
47# define ARK_PLATFORM_NAME "Other"
48#endif
49
50#include <cinttypes>
51#include <cstddef>
52
53#ifdef max
54# undef max
55#endif
56
57namespace Ark
58{
59 // Compiler options
60 constexpr uint16_t FeatureImportSolver = 1 << 0;
61 constexpr uint16_t FeatureMacroProcessor = 1 << 1;
62 constexpr uint16_t FeatureASTOptimiser = 1 << 2; ///< Disabled by default because embedding ArkScript should not prune nodes from the AST ; it is active in the `arkscript` executable
63 constexpr uint16_t FeatureIROptimiser = 1 << 3;
64 constexpr uint16_t FeatureIRInliner = 1 << 4;
65 constexpr uint16_t FeatureNameResolver = 1 << 5;
66 constexpr uint16_t FeatureVMDebugger = 1 << 6; ///< Disabled by default because embedding ArkScript should not launch the debugger on every error when running code
67 constexpr uint16_t DisableCache = 1 << 7;
68
69 constexpr uint16_t FeatureDumpIR = 1 << 14;
70 /// This feature should only be used in tests, to disable diagnostics generation and enable exceptions to be thrown
71 constexpr uint16_t FeatureTestFailOnException = 1 << 15;
72
73 // Default features for the VM x Compiler x Parser
74 constexpr uint16_t DefaultFeatures =
80
81 constexpr uint16_t MaxValue16Bits = std::numeric_limits<uint16_t>::max();
82
83 constexpr std::size_t MaxNestedNodes = 1024; ///< Maximum number of nodes that can be nested while parsing code
84 constexpr std::size_t MaxMacroProcessingDepth = 256; ///< Controls the number of recursive calls to MacroProcessor::processNode
85 constexpr std::size_t MaxMacroUnificationDepth = 256; ///< Controls the number of recursive calls to MacroProcessor::unify
86 constexpr std::size_t VMStackSize = 4096;
87 constexpr std::size_t VMOverflowBufferSize = 256; ///< Additional number of elements the stack can tolerate
88 constexpr std::size_t VMStackSizeWithOverflowBuffer = VMStackSize + VMOverflowBufferSize; ///< Exceeding VMStackSize, even if we are below VMStackSizeWithOverflowBuffer, means we stack overflowed
89 constexpr std::size_t ScopeStackSize = 8192;
90
91#if defined(_WIN32) || defined(_WIN64)
92 constexpr std::string_view DefaultLibFolder { "" };
93#else
94 constexpr std::string_view DefaultLibFolder { "/usr/local/lib/Ark" };
95#endif
96}
97
98#endif
constexpr std::string_view ARK_VERSION
Definition Constants.hpp:27
constexpr int ARK_VERSION_MAJOR
Definition Constants.hpp:18
constexpr int ARK_VERSION_PATCH
Definition Constants.hpp:20
constexpr std::string_view ARK_FULL_VERSION
Definition Constants.hpp:28
constexpr int ARK_VERSION_MINOR
Definition Constants.hpp:19
constexpr uint16_t DefaultFeatures
Definition Constants.hpp:74
constexpr uint16_t FeatureImportSolver
Definition Constants.hpp:60
constexpr std::size_t VMStackSize
Definition Constants.hpp:86
constexpr uint16_t MaxValue16Bits
Definition Constants.hpp:81
constexpr std::size_t MaxNestedNodes
Maximum number of nodes that can be nested while parsing code.
Definition Constants.hpp:83
constexpr uint16_t FeatureASTOptimiser
Disabled by default because embedding ArkScript should not prune nodes from the AST ; it is active in...
Definition Constants.hpp:62
constexpr uint16_t DisableCache
Definition Constants.hpp:67
constexpr uint16_t FeatureIROptimiser
Definition Constants.hpp:63
constexpr uint16_t FeatureMacroProcessor
Definition Constants.hpp:61
constexpr std::size_t MaxMacroProcessingDepth
Controls the number of recursive calls to MacroProcessor::processNode.
Definition Constants.hpp:84
constexpr std::size_t ScopeStackSize
Definition Constants.hpp:89
constexpr uint16_t FeatureTestFailOnException
This feature should only be used in tests, to disable diagnostics generation and enable exceptions to...
Definition Constants.hpp:71
constexpr std::size_t MaxMacroUnificationDepth
Controls the number of recursive calls to MacroProcessor::unify.
Definition Constants.hpp:85
constexpr uint16_t FeatureIRInliner
Definition Constants.hpp:64
constexpr std::size_t VMOverflowBufferSize
Additional number of elements the stack can tolerate.
Definition Constants.hpp:87
constexpr std::size_t VMStackSizeWithOverflowBuffer
Exceeding VMStackSize, even if we are below VMStackSizeWithOverflowBuffer, means we stack overflowed.
Definition Constants.hpp:88
constexpr uint16_t FeatureDumpIR
Definition Constants.hpp:69
constexpr std::string_view DefaultLibFolder
Definition Constants.hpp:94
constexpr uint16_t FeatureVMDebugger
Disabled by default because embedding ArkScript should not launch the debugger on every error when ru...
Definition Constants.hpp:66
constexpr uint16_t FeatureNameResolver
Definition Constants.hpp:65