ArkScript
A small, lisp-inspired, functional scripting language
Builtins.hpp
Go to the documentation of this file.
1/**
2 * @file Builtins.hpp
3 * @author Lex Plateau (lexplt.dev@gmail.com)
4 * @brief Host the declaration of all the ArkScript builtins
5 * @date 2020-10-27
6 *
7 * @copyright Copyright (c) 2020-2025
8 *
9 */
10
11#ifndef ARK_BUILTINS_BUILTINS_HPP
12#define ARK_BUILTINS_BUILTINS_HPP
13
14#include <vector>
15
16#include <Ark/VM/Value.hpp>
17
18namespace Ark
19{
20 class VM;
21}
22
23#define ARK_BUILTIN(name) Value name(std::vector<Value>& n, VM* vm)
24
26{
27 extern const Value falseSym;
28 extern const Value trueSym;
29 extern const Value nil;
30 extern const Value platform;
31
32 ARK_API extern const std::vector<std::pair<std::string, Value>> builtins;
33
34 // ------------------------------
35 // builtins functions: we must use the instruction `BUILTIN index`
36 // ------------------------------
37 namespace List
38 {
39 ARK_BUILTIN(reverseList);
40 ARK_BUILTIN(findInList);
41 ARK_BUILTIN(sliceList);
44 ARK_BUILTIN(setListAt);
45 }
46
47 namespace IO
48 {
52 ARK_BUILTIN(writeFile);
53 ARK_BUILTIN(appendToFile);
54 ARK_BUILTIN(readFile);
55 ARK_BUILTIN(fileExists);
56 ARK_BUILTIN(listFiles);
57 ARK_BUILTIN(isDirectory);
58 ARK_BUILTIN(makeDir);
59 ARK_BUILTIN(removeFile);
60 }
61
62 namespace Time
63 {
64 ARK_BUILTIN(timeSinceEpoch);
65 }
66
67 namespace System
68 {
69 ARK_BUILTIN(system_);
72 }
73
74 namespace String
75 {
76 ARK_BUILTIN(format);
77 ARK_BUILTIN(findSubStr);
78 ARK_BUILTIN(removeAtStr);
81 ARK_BUILTIN(setStringAt);
82 }
83
84 namespace Mathematics
85 {
86 ARK_BUILTIN(exponential);
87 ARK_BUILTIN(logarithm);
89 ARK_BUILTIN(floor_);
90 ARK_BUILTIN(round_);
91 ARK_BUILTIN(isnan_);
92 ARK_BUILTIN(isinf_);
93
94 extern const Value pi_;
95 extern const Value e_;
96 extern const Value tau_;
97 extern const Value inf_;
98 extern const Value nan_;
99
109 ARK_BUILTIN(acosh_);
110 ARK_BUILTIN(asinh_);
111 ARK_BUILTIN(atanh_);
112
113 ARK_BUILTIN(random);
114 }
115
116 namespace Async
117 {
120 }
121
122 namespace Dict
123 {
127 ARK_BUILTIN(contains);
128 ARK_BUILTIN(remove);
131 }
132}
133
134#undef ARK_BUILTIN
135
136#endif
#define ARK_BUILTIN(name)
Definition Builtins.hpp:23
#define ARK_API
Definition Module.hpp:22
Default value type handled by the virtual machine.
The ArkScript virtual machine, executing ArkScript bytecode.
Definition VM.hpp:46
ARK_API const std::vector< std::pair< std::string, Value > > builtins