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
18
namespace
Ark
19
{
20
class
VM
;
21
}
22
23
#define ARK_BUILTIN(name) Value name(std::vector<Value>& n, VM* vm)
24
25
namespace
Ark::internal::Builtins
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);
42
ARK_BUILTIN
(sort_);
43
ARK_BUILTIN
(fill);
44
ARK_BUILTIN
(setListAt);
45
}
46
47
namespace
IO
48
{
49
ARK_BUILTIN
(print);
50
ARK_BUILTIN
(puts_);
51
ARK_BUILTIN
(input);
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_);
70
ARK_BUILTIN
(sleep);
71
ARK_BUILTIN
(exit_);
72
}
73
74
namespace
String
75
{
76
ARK_BUILTIN
(format);
77
ARK_BUILTIN
(findSubStr);
78
ARK_BUILTIN
(removeAtStr);
79
ARK_BUILTIN
(ord);
80
ARK_BUILTIN
(chr);
81
ARK_BUILTIN
(setStringAt);
82
}
83
84
namespace
Mathematics
85
{
86
ARK_BUILTIN
(exponential);
87
ARK_BUILTIN
(logarithm);
88
ARK_BUILTIN
(ceil_);
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
100
ARK_BUILTIN
(cos_);
101
ARK_BUILTIN
(sin_);
102
ARK_BUILTIN
(tan_);
103
ARK_BUILTIN
(acos_);
104
ARK_BUILTIN
(asin_);
105
ARK_BUILTIN
(atan_);
106
ARK_BUILTIN
(cosh_);
107
ARK_BUILTIN
(sinh_);
108
ARK_BUILTIN
(tanh_);
109
ARK_BUILTIN
(acosh_);
110
ARK_BUILTIN
(asinh_);
111
ARK_BUILTIN
(atanh_);
112
113
ARK_BUILTIN
(random);
114
}
115
116
namespace
Async
117
{
118
ARK_BUILTIN
(async);
119
ARK_BUILTIN
(await);
120
}
121
122
namespace
Dict
123
{
124
ARK_BUILTIN
(dict);
125
ARK_BUILTIN
(get);
126
ARK_BUILTIN
(add);
127
ARK_BUILTIN
(contains);
128
ARK_BUILTIN
(remove);
129
ARK_BUILTIN
(keys);
130
ARK_BUILTIN
(size);
131
}
132
}
133
134
#undef ARK_BUILTIN
135
136
#endif
ARK_BUILTIN
#define ARK_BUILTIN(name)
Definition
Builtins.hpp:23
ARK_API
#define ARK_API
Definition
Module.hpp:22
Value.hpp
Default value type handled by the virtual machine.
Ark::VM
The ArkScript virtual machine, executing ArkScript bytecode.
Definition
VM.hpp:46
Ark::Value
Definition
Value.hpp:91
Ark::internal::Dict
Definition
Dict.hpp:29
Ark::internal::Builtins::Mathematics::inf_
const Value inf_
Ark::internal::Builtins::Mathematics::nan_
const Value nan_
Ark::internal::Builtins::Mathematics::tau_
const Value tau_
Ark::internal::Builtins::Mathematics::e_
const Value e_
Ark::internal::Builtins::Mathematics::pi_
const Value pi_
Ark::internal::Builtins
Definition
Builtins.hpp:26
Ark::internal::Builtins::platform
const Value platform
Ark::internal::Builtins::nil
const Value nil
Ark::internal::Builtins::falseSym
const Value falseSym
Ark::internal::Builtins::trueSym
const Value trueSym
Ark::internal::Builtins::builtins
ARK_API const std::vector< std::pair< std::string, Value > > builtins
Ark::internal::NodeType::String
@ String
Ark::internal::NodeType::List
@ List
Ark
Definition
Builtins.hpp:19
include
Ark
Builtins
Builtins.hpp
Generated on Sun Sep 28 2025 15:55:36 for ArkScript by
1.12.0