58 vm.
log(std::format(
"StdLib::{}(&VM@{:#x})\n", __func__,
reinterpret_cast<std::uintptr_t
>(&vm)));
70 static void checkArgCount(
const std::vector<Value> &args,
size_t minimumArguments,
const std::string &name,
71 bool allowMoreArguments =
false);
106#pragma endregion stdmeta
108#pragma region stdmemory
112#pragma region stdmath
114 static double math_pow(
const std::vector<Value> &args,
VM *vm);
121 static double math_log(
const std::vector<Value> &args,
VM *vm);
122 static double math_exp(
const std::vector<Value> &args,
VM *vm);
123 static double math_sin(
const std::vector<Value> &args,
VM *vm);
124 static double math_cos(
const std::vector<Value> &args,
VM *vm);
125 static double math_tan(
const std::vector<Value> &args,
VM *vm);
128#pragma region stdfile
149 static std::string
file_stem(
const std::vector<Value> &args,
VM *vm);
161 static int64_t
sys_fork(
const std::vector<Value> &args,
VM *vm);
165 static int64_t
sys_pid(
const std::vector<Value> &args,
VM *vm);
166 static std::string
sys_os(
const std::vector<Value> &args,
VM *vm);
171 static int64_t
sys_argc(
const std::vector<Value> &args,
VM *vm);
172 static double sys_time(
const std::vector<Value> &args,
VM *vm);
178#pragma region stdtype
179 static int64_t
to_int(
const std::vector<Value> &args,
VM *vm);
180 static double to_float(
const std::vector<Value> &args,
VM *vm);
181 static std::string
to_string(
const std::vector<Value> &args,
VM *vm);
182 static bool to_bool(
const std::vector<Value> &args,
VM *vm);
185#pragma region stdrand
195 static int64_t
str_find(
const std::vector<Value> &args,
VM *vm);
196 static int64_t
str_len(
const std::vector<Value> &args,
VM *vm);
200 static std::string
str_upper(
const std::vector<Value> &args,
VM *vm);
201 static std::string
str_lower(
const std::vector<Value> &args,
VM *vm);
205 static int64_t
sb_new(
const std::vector<Value> &args,
VM *vm);
209 static std::string
sb_free(
const std::vector<Value> &args,
VM *vm);
217 static std::string
io_prints(
const std::vector<Value> &args,
VM *vm);
218 static std::string
io_printf(
const std::vector<Value> &args,
VM *vm);
219 static std::string
io_puts(
const std::vector<Value> &args,
VM *vm);
220 static std::string
io_putf(
const std::vector<Value> &args,
VM *vm);
static bool file_create_directory(const std::vector< Value > &args, VM *vm)
static int64_t file_get_size(const std::vector< Value > &args, VM *vm)
static void registerIOFunctions(VM *vm)
static double sys_time(const std::vector< Value > &args, VM *vm)
Current time.
static std::string sb_free(const std::vector< Value > &args, VM *vm)
Free string builder.
static Value rand_seed(const std::vector< Value > &args, VM *vm)
Seed the random number generator.
static Value sys_sleep(const std::vector< Value > &args, VM *vm)
Sleep for a specified amount of time.
static void registerStringFunctions(VM *vm)
static Value sys_argv(const std::vector< Value > &args, VM *vm)
Get the current command line arguments.
static Value sys_crash(const std::vector< Value > &args, VM *vm)
Crash the VM / Program.
static Value math_max(const std::vector< Value > &args, VM *vm)
Maximum.
static int64_t str_find(const std::vector< Value > &args, VM *vm)
Find string in string.
static Value sb_append(const std::vector< Value > &args, VM *vm)
Append to string builder.
static Value math_min(const std::vector< Value > &args, VM *vm)
Minimum.
static char ** argv
Command line arguments.
static double math_exp(const std::vector< Value > &args, VM *vm)
Exponential.
static bool file_is_directory(const std::vector< Value > &args, VM *vm)
Check if path is directory.
static Value io_gets(const std::vector< Value > &args, VM *vm)
Get string.
static std::string file_filename(const std::vector< Value > &args, VM *vm)
Get the filename.
static Value str_starts_with(const std::vector< Value > &args, VM *vm)
Check if string starts with.
static double math_round(const std::vector< Value > &args, VM *vm)
Round.
static double math_ceil(const std::vector< Value > &args, VM *vm)
Ceiling.
static void registerSysFunctions(VM *vm)
static std::string file_read_line(const std::vector< Value > &args, VM *vm)
Read a line from file.
static int64_t sys_get_free_memory(const std::vector< Value > &args, VM *vm)
Get current free memory.
static double math_log(const std::vector< Value > &args, VM *vm)
Natural logarithm.
static double math_sqrt(const std::vector< Value > &args, VM *vm)
Square root.
static int64_t meta_operation(const std::vector< Value > &args, VM *vm)
static Value sys_time_formatted(const std::vector< Value > &args, VM *vm)
Current time formatted.
static bool file_delete(const std::vector< Value > &args, VM *vm)
Delete file.
static std::string to_string(const std::vector< Value > &args, VM *vm)
Convert to string.
static bool file_copy(const std::vector< Value > &args, VM *vm)
Copy file.
static Value sys_wait_for_input(const std::vector< Value > &args, VM *vm)
Wait for input.
static std::string io_prints(const std::vector< Value > &args, VM *vm)
Print string without newline.
static std::string file_absolute(const std::vector< Value > &args, VM *vm)
Get full path to relative path.
static std::string io_c_format(const std::vector< Value > &args, VM *vm)
Format string.
static void registerFunctions(VM &vm)
static double math_sin(const std::vector< Value > &args, VM *vm)
Sine.
static Value sys_reset(const std::vector< Value > &args, VM *vm)
Reset the VM.
static std::string sb_to_string(const std::vector< Value > &args, VM *vm)
Convert string builder to string.
static int64_t sys_pid(const std::vector< Value > &args, VM *vm)
Get the current process ID.
static Value math_abs(const std::vector< Value > &args, VM *vm)
Absolute value.
static Value sys_shutdown(const std::vector< Value > &args, VM *vm)
Shutdown the VM.
static Value io_clear(const std::vector< Value > &args, VM *vm)
Clear the console.
static bool file_write_line(const std::vector< Value > &args, VM *vm)
Write a line to file.
static std::string io_putf(const std::vector< Value > &args, VM *vm)
Print formatted string with newline.
static int argc
Number of command line arguments.
static std::string io_printf(const std::vector< Value > &args, VM *vm)
Print formatted string.
static void checkArgCount(const std::vector< Value > &args, size_t minimumArguments, const std::string &name, bool allowMoreArguments=false)
static Value file_read_directory(const std::vector< Value > &args, VM *vm)
static int64_t str_len(const std::vector< Value > &args, VM *vm)
Get string length.
static Value sb_clear(const std::vector< Value > &args, VM *vm)
Clear string builder.
static dupenv_ret dupenv(std::string &out, const char *name)
static bool file_property_edit(const std::vector< Value > &args, VM *vm)
static std::string file_parent(const std::vector< Value > &args, VM *vm)
Get the parent of a path.
static Value std_assert(const std::vector< Value > &args, VM *vm)
static std::string str_lower(const std::vector< Value > &args, VM *vm)
Convert to lowercase.
static int64_t sys_argc(const std::vector< Value > &args, VM *vm)
Get the current number of command line arguments.
static std::string io_puts(const std::vector< Value > &args, VM *vm)
Print string with newline.
static bool file_create(const std::vector< Value > &args, VM *vm)
static bool file_move(const std::vector< Value > &args, VM *vm)
Move file.
static int64_t rand_next_range(const std::vector< Value > &args, VM *vm)
Get a random number in range.
static double math_pow(const std::vector< Value > &args, VM *vm)
Power.
static int64_t to_int(const std::vector< Value > &args, VM *vm)
Convert to integer.
static bool to_bool(const std::vector< Value > &args, VM *vm)
Convert to boolean.
static int64_t sys_fork_detached(const std::vector< Value > &args, VM *vm)
Run a native program detached.
static bool std_import(const std::vector< Value > &args, VM *vm)
static void registerMetaFunctions(VM *vm)
static void registerFileFunctions(VM *vm)
static void registerTypeConvFunctions(VM *vm)
static bool file_rename(const std::vector< Value > &args, VM *vm)
Rename file.
static std::string sys_os(const std::vector< Value > &args, VM *vm)
Get the current OS.
static Value str_substr(const std::vector< Value > &args, VM *vm)
Get substring.
static int64_t sys_fork(const std::vector< Value > &args, VM *vm)
Run a native program.
static void registerMathFunctions(VM *vm)
static bool file_write(const std::vector< Value > &args, VM *vm)
Write to file.
static std::string io_puts_error(const std::vector< Value > &args, VM *vm)
Print string with newline to error output.
static Value var_free(const std::vector< Value > &args, VM *vm)
Free a variable.
static bool file_append(const std::vector< Value > &args, VM *vm)
Append to file.
static Value file_current_directory(const std::vector< Value > &args, VM *vm)
Get/set working directory.
static std::string io_putf_error(const std::vector< Value > &args, VM *vm)
Print formatted string with newline to error output.
static bool file_remove_directory(const std::vector< Value > &args, VM *vm)
static std::string file_extension(const std::vector< Value > &args, VM *vm)
Get the extension of a path.
static double to_float(const std::vector< Value > &args, VM *vm)
Convert to float.
static Value file_read(const std::vector< Value > &args, VM *vm)
Read file.
static int64_t sb_new(const std::vector< Value > &args, VM *vm)
Create new string builder.
static std::string str_upper(const std::vector< Value > &args, VM *vm)
Convert to uppercase.
static Value std_assert(const std::vector< Value > &args, VM *vm)
static Value meta_stack_run(const std::vector< Value > &args, VM *vm)
static std::string str_concat(const std::vector< Value > &args, VM *vm)
Concatenate strings.
static Value str_ends_with(const std::vector< Value > &args, VM *vm)
Check if string ends with.
static double math_tan(const std::vector< Value > &args, VM *vm)
Tangent.
static void registerMemoryFunctions(VM *vm)
static Value str_char_at(const std::vector< Value > &args, VM *vm)
Get character at index.
static std::string meta_get_version(const std::vector< Value > &args, VM *vm)
static int64_t file_property_get(const std::vector< Value > &args, VM *vm)
static double math_cos(const std::vector< Value > &args, VM *vm)
Cosine.
static void registerRandomFunctions(VM *vm)
static Value sys_shell(const std::vector< Value > &args, VM *vm)
Run a shell command.
static Value sys_env(const std::vector< Value > &args, VM *vm)
Get the current environment variables.
static std::string file_join_path(const std::vector< Value > &args, VM *vm)
static bool file_exists(const std::vector< Value > &args, VM *vm)
Check if file exists.
static Value sys_isatty(const std::vector< Value > &args, VM *vm)
Check if the current output is a terminal.
static double math_floor(const std::vector< Value > &args, VM *vm)
Floor.
static bool std_import(const std::vector< Value > &args, VM *vm)
static double rand_next_float(const std::vector< Value > &args, VM *vm)
Get a random float (technically a double at a low level).
static std::string file_stem(const std::vector< Value > &args, VM *vm)
Get the stem of a path.
void registerNativeFunction(const std::string &name, NativeFunction fn)
Register a native function.
void log(const Value &msg)
Log a Value to stdout.
void flush()
Flush stdout.
A value in the Phasor VM.
The Phasor Programming Language and Runtime.
std::function< Value(const std::vector< Value > &args, VM *vm)> NativeFunction
Native function signature.