Page cover

🕹️Vm Built-ins functions

This a non-exhaustive list of the available builtin functions.

  • Maths operators (add, sub, div, mod, mul) those take 2 numbers as parameters, returns number.

    • equivalent to

      • add = +

      • sub = -

      • div = /

      • mod = %

      • mul = *

      • pow = **

  • Comparison operators (less, greater) those take 2 numbers as parameters, returns bool.

    • equivalent to

      • less = <

      • greater = >

  • Equality operators (eq, neq) those take 2 Values of any type as parameters, returns bool.

    • equivalent to

      • equal = ==

      • not equal = !=

  • Boolean operators (and, or, not) those take 2 booleans (or 1 for not) as parameters, returns bool.

  • Binary operators (band, bor, xor, shiftR, shifR) that takes two integers as parameter, returns integer.

    • equivalent to:

      • binary and = &

      • binary or = |

      • xor = ^

      • right shift = >>

      • left shift = <<

  • set is an operator that takes a list, an index and a value, and sets the value at that index if it is inside of the list size. (Also works on strings)

  • get is an operator that takes a list, an index and returns the value at that index. (Also works on strings)

  • push pushes the var passed as second parameter into the list passed as first parameter. (Will extend the list length)

  • pop removes the element at the index passed as the second parameter into the list passed as first parameter. (Will shrink the list length)

  • print - Takes one argument that is not constrained to any built-in types.

  • open - Takes a filepath as an argument, represented by a string and returns its corresponding file descriptor as an int. Will return -1 on failure.

  • close - Takes a file descriptor as an argument, represented by an int 0 if it successfully was able to close it.

  • read - Takes a file descriptor (int) -1 on failure.

  • append - Take file descriptor (int). Writes data at the end of the file, or returns -1 on failure.

  • write - Takes a file descriptor (int). -1 on failure.

  • getLine - Takes a file descriptor (int). -1 on failure

  • readFile - Takes a filepath (string).

  • writeFile - Takes a filepath (string).

  • appendFile - Takes a filepath (string).

  • listPop - Takes a list and an integer index (int).

  • listPush - Takes a list, an integer index (int) and a value.

  • error - error - Takes a string. Logs or displays an error message

  • strcat - Takes two strings.

  • strlen - Takes a string.

  • substr - Takes a string and two numbers.

  • strcmp - Takes two strings.

  • setField - setField - Takes a struct, a string and a value.

  • getField - Takes a struct and a string (as param).

Last updated