ArkScript
A small, lisp-inspired, functional scripting language
Constants.hpp
Go to the documentation of this file.
1/**
2 * @file Constants.hpp
3 * @author Lex Plateau (lexplt.dev@gmail.com)
4 * @brief Constants used by ArkScript
5 * @date 2020-10-27
6 *
7 * @copyright Copyright (c) 2020-2025
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 = 0;
20constexpr int ARK_VERSION_PATCH = 0;
21// clang-format on
22constexpr std::string_view ARK_VERSION { "4.0.0" };
23constexpr std::string_view ARK_FULL_VERSION { "4.0.0-093c1714" };
24
25#define ARK_COMPILER "AppleClang"
26#define ARK_CACHE_DIRNAME "__arkscript__"
27#define ARK_NO_NAME_FILE "FILE"
28
29#if defined(_WIN32) || defined(_WIN64)
30# define ARK_PLATFORM_NAME "Windows"
31#elif defined(__APPLE__) || defined(__MACH__)
32# define ARK_PLATFORM_NAME "Mac OSX"
33#elif defined(__linux__)
34# define ARK_PLATFORM_NAME "Linux"
35#elif defined(__FreeBSD__)
36# define ARK_PLATFORM_NAME "FreeBSD"
37#elif defined(__unix) || defined(__unix__)
38# define ARK_PLATFORM_NAME "Unix"
39#else
40# define ARK_PLATFORM_NAME "Other"
41#endif
42
43#include <cinttypes>
44#include <cstddef>
45
46#ifdef max
47# undef max
48#endif
49
50namespace Ark
51{
52 // Compiler options
53 constexpr uint16_t FeatureImportSolver = 1 << 0;
54 constexpr uint16_t FeatureMacroProcessor = 1 << 1;
55 constexpr uint16_t FeatureASTOptimizer = 1 << 2; ///< This is disabled so that embedding ArkScript does not prune nodes from the AST ; it is active in the `arkscript` executable
56 constexpr uint16_t FeatureIROptimizer = 1 << 3;
57 constexpr uint16_t FeatureNameResolver = 1 << 4;
58
59 constexpr uint16_t FeatureDumpIR = 1 << 14;
60 /// This feature should only be used in tests, to disable diagnostics generation and enable exceptions to be thrown
61 constexpr uint16_t FeatureTestFailOnException = 1 << 15;
62
63 // Default features for the VM x Compiler x Parser
64 constexpr uint16_t DefaultFeatures =
69
70 constexpr uint16_t MaxValue16Bits = std::numeric_limits<uint16_t>::max();
71
72 constexpr std::size_t MaxNestedNodes = 1024; ///< Maximum number of nodes that can be nested while parsing code
73 constexpr std::size_t MaxMacroProcessingDepth = 256; ///< Controls the number of recursive calls to MacroProcessor::processNode
74 constexpr std::size_t MaxMacroUnificationDepth = 256; ///< Controls the number of recursive calls to MacroProcessor::unify
75 constexpr std::size_t VMStackSize = 4096;
76 constexpr std::size_t VMOverflowBufferSize = 256; ///< Additional number of elements the stack can tolerate
77 constexpr std::size_t VMStackSizeWithOverflowBuffer = VMStackSize + VMOverflowBufferSize; ///< Exceeding VMStackSize, even if we are below VMStackSizeWithOverflowBuffer, means we stack overflowed
78 constexpr std::size_t ScopeStackSize = 8192;
79}
80
81#endif
constexpr std::string_view ARK_VERSION
Definition Constants.hpp:22
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:23
constexpr int ARK_VERSION_MINOR
Definition Constants.hpp:19
constexpr uint16_t DefaultFeatures
Definition Constants.hpp:64
constexpr uint16_t FeatureImportSolver
Definition Constants.hpp:53
constexpr std::size_t VMStackSize
Definition Constants.hpp:75
constexpr uint16_t FeatureIROptimizer
Definition Constants.hpp:56
constexpr uint16_t MaxValue16Bits
Definition Constants.hpp:70
constexpr std::size_t MaxNestedNodes
Maximum number of nodes that can be nested while parsing code.
Definition Constants.hpp:72
constexpr uint16_t FeatureMacroProcessor
Definition Constants.hpp:54
constexpr std::size_t MaxMacroProcessingDepth
Controls the number of recursive calls to MacroProcessor::processNode.
Definition Constants.hpp:73
constexpr std::size_t ScopeStackSize
Definition Constants.hpp:78
constexpr uint16_t FeatureTestFailOnException
This feature should only be used in tests, to disable diagnostics generation and enable exceptions to...
Definition Constants.hpp:61
constexpr std::size_t MaxMacroUnificationDepth
Controls the number of recursive calls to MacroProcessor::unify.
Definition Constants.hpp:74
constexpr std::size_t VMOverflowBufferSize
Additional number of elements the stack can tolerate.
Definition Constants.hpp:76
constexpr std::size_t VMStackSizeWithOverflowBuffer
Exceeding VMStackSize, even if we are below VMStackSizeWithOverflowBuffer, means we stack overflowed.
Definition Constants.hpp:77
constexpr uint16_t FeatureASTOptimizer
This is disabled so that embedding ArkScript does not prune nodes from the AST ; it is active in the ...
Definition Constants.hpp:55
constexpr uint16_t FeatureDumpIR
Definition Constants.hpp:59
constexpr uint16_t FeatureNameResolver
Definition Constants.hpp:57