ArkScript
A small, fast, functional and scripting language for video games
ValTableElem.hpp
Go to the documentation of this file.
1/**
2 * @file ValTableElem.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief The basic value type handled by the compiler
5 * @version 0.2
6 * @date 2020-10-27
7 *
8 * @copyright Copyright (c) 2020-2024
9 *
10 */
11
12#ifndef ARK_COMPILER_VALTABLEELEM_HPP
13#define ARK_COMPILER_VALTABLEELEM_HPP
14
15#include <variant>
16#include <string>
17
19
20namespace Ark::internal
21{
22 /**
23 * @brief Enumeration to keep track of the type of a Compiler Value
24 *
25 */
27 {
28 Number,
29 String,
30 PageAddr // for function definitions
31 };
32
33 /**
34 * @brief A Compiler Value class helper to handle multiple types
35 *
36 */
38 {
39 std::variant<double, std::string, std::size_t> value;
41
42 // Numbers
43 explicit ValTableElem(double value) noexcept;
44 explicit ValTableElem(long value) noexcept;
45 // Strings
46 explicit ValTableElem(const std::string& value) noexcept;
47 // automatic handling (Number/String/Function)
48 explicit ValTableElem(const Node& v) noexcept;
49 // Functions
50 explicit ValTableElem(std::size_t value) noexcept;
51
52 bool operator==(const ValTableElem& A) const noexcept;
53 };
54}
55
56#endif
AST node used by the parser, optimizer and compiler.
A node of an Abstract Syntax Tree for ArkScript.
Definition: Node.hpp:30
ValTableElemType
Enumeration to keep track of the type of a Compiler Value.
A Compiler Value class helper to handle multiple types.
std::variant< double, std::string, std::size_t > value
bool operator==(const ValTableElem &A) const noexcept