-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd.msh
77 lines (61 loc) · 2.14 KB
/
std.msh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use reef::std::math
use reef::std::memory
use reef::std::assert
use reef::std::convert
use reef::std::process
/// Causes the runtime to panic, with the specified message.
/// This also prints the current callstack trace.
/// Once executed the process will exit with code 1.
/// @param message the cause of the panic
fun panic(message: String) -> Nothing;
/// Exits the current process with the given exitcode.
/// @param code program's exitcode
fun exit(code: Exitcode) -> Nothing;
/// @returns string value of given environment variable
fun env(name: String) -> Option[String];
/// Set or override a given environment variable with given string value.
/// @param name the targeted environment variable name.
/// @param value the new value of targeted variable.
fun set_env(name: String, value: String);
/// Reads a single line from the standard input.
///
/// If the input is closed, an empty string is returned.
fun read_line() -> String;
/// Aborts runtime.
/// Prints given message to stderr and then exit with exitcode 1.
/// Unlike [[reef::std::panic]], this function does not print the callstack trace.
fun abort(message: String) -> Nothing = {
echo $message >&2
exit(1.to_exitcode())
}
/// Instantiate a new empty vector of A
fun new_vec[A]() -> Vec[A];
/// Instantiate an option with some value
fun some[A](v: A) -> Option[A];
/// Instantiate a None option
// TODO make Option's generic parameter (`A`) covariant to return an Option[Nothing]
fun none[A]() -> Option[A];
/// Changes the current working directory to a relative or an absolute path.
///
/// @panics if the path is not accessible or is not a directory.
fun cd(path: String);
/// Gets the current working directory.
///
/// @panics if the current working directory does not exist.
fun working_dir() -> String;
/// Gets the home directory of the user.
fun home_dir(username: String) -> Option[String];
/// Gets the home directory of the current user.
///
/// @panics if the current user does not have a home directory specified.
fun current_home_dir() -> String;
struct Range {
start: Int,
end: Int,
step: Int,
}
struct InclusiveRange {
start: Int,
end: Int,
step: Int,
}