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
(readLinesFile);
56
ARK_BUILTIN
(fileExists);
57
ARK_BUILTIN
(listFiles);
58
ARK_BUILTIN
(isDirectory);
59
ARK_BUILTIN
(makeDir);
60
ARK_BUILTIN
(removeFile);
61
}
62
63
namespace
Time
64
{
65
ARK_BUILTIN
(timeSinceEpoch);
66
}
67
68
namespace
System
69
{
70
ARK_BUILTIN
(system_);
71
ARK_BUILTIN
(sleep);
72
ARK_BUILTIN
(exit_);
73
}
74
75
namespace
String
76
{
77
ARK_BUILTIN
(format);
78
ARK_BUILTIN
(findSubStr);
79
ARK_BUILTIN
(removeAtStr);
80
ARK_BUILTIN
(ord);
81
ARK_BUILTIN
(chr);
82
ARK_BUILTIN
(setStringAt);
83
}
84
85
namespace
Mathematics
86
{
87
ARK_BUILTIN
(exponential);
88
ARK_BUILTIN
(logarithm);
89
ARK_BUILTIN
(ceil_);
90
ARK_BUILTIN
(floor_);
91
ARK_BUILTIN
(round_);
92
ARK_BUILTIN
(isnan_);
93
ARK_BUILTIN
(isinf_);
94
95
extern
const
Value
pi_
;
96
extern
const
Value
e_
;
97
extern
const
Value
tau_
;
98
extern
const
Value
inf_
;
99
extern
const
Value
nan_
;
100
101
ARK_BUILTIN
(cos_);
102
ARK_BUILTIN
(sin_);
103
ARK_BUILTIN
(tan_);
104
ARK_BUILTIN
(acos_);
105
ARK_BUILTIN
(asin_);
106
ARK_BUILTIN
(atan_);
107
ARK_BUILTIN
(cosh_);
108
ARK_BUILTIN
(sinh_);
109
ARK_BUILTIN
(tanh_);
110
ARK_BUILTIN
(acosh_);
111
ARK_BUILTIN
(asinh_);
112
ARK_BUILTIN
(atanh_);
113
114
ARK_BUILTIN
(random);
115
}
116
117
namespace
Async
118
{
119
ARK_BUILTIN
(async);
120
ARK_BUILTIN
(await);
121
}
122
123
namespace
Dict
124
{
125
ARK_BUILTIN
(dict);
126
ARK_BUILTIN
(get);
127
ARK_BUILTIN
(add);
128
ARK_BUILTIN
(contains);
129
ARK_BUILTIN
(remove);
130
ARK_BUILTIN
(keys);
131
ARK_BUILTIN
(size);
132
}
133
134
namespace
Bytecode
135
{
136
ARK_BUILTIN
(disassemble);
137
}
138
}
139
140
#undef ARK_BUILTIN
141
142
#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:47
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 Sat Jan 3 2026 17:22:02 for ArkScript by
1.12.0