isbpl/docs/std.md

751 lines
13 KiB
Markdown
Raw Normal View History

2022-05-23 20:16:57 +02:00
# Documentation: std.isbpl
The standard library. Everything here is (supposed to be) loaded before ANY other code is executed. It is responsible for things ranging from array literals and comments,
over type definitions, to string processing.
2022-05-24 16:40:26 +02:00
## >Functions
2022-05-23 20:16:57 +02:00
### `ftos ::: float -> string`
[Unfinished]
Converts float to string
2022-05-23 22:10:19 +02:00
### `dtos ::: double -> string`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
[Unfinished]
Converts double to string
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `stof ::: string -> float`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
[Unfinished]
Converts string to float
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `stod ::: string -> double`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
[Unfinished]
Converts string to double
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `strsplit ::: string separator -> array`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Splits string by separator, if the separator is not found anywhere, the entire string
will end up being wrapped in an array. REGEX **not** supported
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `inc ::: integer -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Uses _last_words to find the variable of the integer variable mentioned previously,
takes its value, and increments it, then stores the value back.
The integer argument is discarded as it is not useful.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `dec ::: integer -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Uses _last_words to find the variable of the integer variable mentioned previously,
takes its value, and decrements it, then stores the value back.
The integer argument is discarded as it is not useful.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `gettype ::: object -> object.type.id`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns the type ID of the object's type as integer
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `isfloat ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is a float, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `islong ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is a long, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `isstring ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is a string, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `ischar ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is a char, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `isarray ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is an array, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `isint ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is an int, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `isbyte ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is a byte, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `isdouble ::: object -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if the object is a double, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `strconcat ::: string1 string2 -> string`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Concatenates string1 and string2, and returns the result.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `strjoin ::: array joiner -> string`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Joins all elements of the array with the joiner string.
Example: `"foo" "bar" -> "foobar"`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `fcall ::: callable -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Calls the provided callable
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `asub ::: array begin end -> subarray`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns a portion of array starting at index begin, and ending with index end.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `strsub ::: string begin end -> substring`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns a portion of string starting at index begin, and ending with index end.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `putchar ::: char -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Puts the character into stdout
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `typeid ::: name -> id`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns the name of the type with the id
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_int ::: number -> int`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Casts a number to int
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_char ::: number -> char`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Casts a number to char
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_long ::: number -> long`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Casts a number to long
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_string ::: any -> string`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Tries to cast an object to a string.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_byte ::: number -> byte`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Casts a number to byte
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_double ::: number -> double`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Casts a number to double
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_float ::: number -> float`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Casts a number to float
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_array ::: any -> array`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Tries to cast an object to an array
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `! ::: a -> a a`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Duplicates the topmost value. This is synonymous with dup, and should be used when
multiple actions are done on one object.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `# ::: comment -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Comment indicator. Synonymous with pop.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `aput ::: array idx value -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Puts value into array at index idx.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `% ::: a b -> math(a % b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Calculates the modulo. This **does** work with floats.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `( ::: -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Does nothing, purely for visuals.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `) ::: -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Does nothing, purely for visuals.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `* ::: a b -> math(a * b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Multiplies a and b
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `subprocess ::: commandline -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Starts a subprocess with commandline
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `+ ::: a b -> math(a + b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Adds a and b
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `- ::: a b -> math(a - b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Subtracts a with b
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `/ ::: a b -> math(a / b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Divides a by b
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `exit ::: value -> (throw)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Exits the program. Can be catched.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `defmethod ::: name callable type -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Defines a method in type executing callable named name
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `defsuper ::: type1 type2 -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Makes type2 extend type1.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `alen ::: array -> length`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns the length of array, the last possible idx + 1.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `** ::: a b -> math(pow(a, b))`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Calculates a to the power of b
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `astartswith ::: array1 array2 -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if array1 starts with array2, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `pop ::: object -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Drops an object from the stack.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `[ ::: -> shadow`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Pushes an array shadow to the stack.
This indicates the start of an array literal.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `] ::: shadow [DYN] -> array`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Pops from stack until array shadow is reached, and puts the popped elements into an
array.
This indicates the end of an array literal.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `^ ::: a b -> math(xor(a, b))`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Calculates XOR of a and b
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `deffunc ::: name callable -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Defines a function by a callable.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `++ ::: a -> math(a + 1)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns input + 1
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `include ::: file -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Loads and executes ISBPL code from file.
The argument is parsed differently if:
- it starts with a hash: this loads a global library
- it starts with a /: this indicates that the file path is absolute
Otherwise, it is relative to the directory that the included file is in.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `reload ::: file -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Acts like include, but is able to load a file multiple times.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `getos ::: -> osname`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns OS name. This is identical to System.getProperty("os.name") in Java.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `call ::: name -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
[Deprecated]
Calls function by name. Deprecated in favor of &<name> callable getters.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `puts ::: string-> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Prints a string. No newline is appended.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `throw ::: id description -> (throw)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Throws an error.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `aget ::: array idx -> value`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns value in array at idx
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `char ::: string -> char`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns first character of a string
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `typename ::: id -> name`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns name of the type identified by id
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `itos ::: int -> string`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Converts an integer to a string
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `ltos ::: long -> string`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Converts a long to a string
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `stol ::: string -> long`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Converts string to long, assumes base 10 string, anything else will not throw an error,
and bug out to wrong results instead.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `stoi ::: string -> int`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Converts string to int, assumes base 10 string, anything else will not throw an error,
and bug out to wrong results instead.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `getfile ::: -> file`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Gets the filename of the calling file.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `areverse ::: array1 -> array2`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Reverses the order of array1. array1 is not changed.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `callmethod ::: name object -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Calls method identified by name on the object.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `gt ::: a b -> cond(a > b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if a is greater than b, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `lt ::: a b -> cond(a < b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if a is less than b, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `main ::: args -> 0`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Placeholder main function. Does nothing.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `aadd ::: array1 array2 -> array3`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Adds array1 and array2 together:
Makes array3 with the length of array1 and array2 combined;
Adds values from array1;
Adds values from array2, offset by the length of array1.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `reference ::: object -> reference`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Makes a reference to object
2022-05-23 20:16:57 +02:00
2022-05-26 20:21:16 +02:00
### `->? ::: object -> reference`
Makes a reference to object
2022-05-23 22:10:19 +02:00
### `neg ::: a -> math(-a)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns the negative of a
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `acontains ::: array1 array2 -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if array1 contains all elements from array2, in the same order, and without
any mismatches inbetween. Example: `12345 23 -> 1`, `12345 24 -> 0`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `strcontains ::: string1 string2 -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if string1 contains all elements from string2, in the same order, and without
any mismatches inbetween. Example: `"12345" "23" -> 1`, `"12345" "24" -> 0`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `-- ::: a -> math(a - 1)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns input - 1
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `swap ::: a b -> b a`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Swaps two values on the stack
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `anewput ::: [DYN] amount -> array[amount]<-DYN`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns array with length amount and contents DYN. Exmaple: `a b c 3 -> [ a b c ]`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `eq ::: a b -> equal(a, b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if a and b are equal, otherwise 0
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `anew ::: length -> array[length]`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Creates array.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `deffield ::: name type -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Defines field called name on type
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `extends ::: a b -> result`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns 1 if a extends b, meaning a declared b as supertype, otherwise 0.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `null ::: -> null`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns null object
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `struppercase ::: string -> UPPERCASESTRING`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Flips [a-z] to their uppercase variants.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `strlowercase ::: string -> lowercasestring`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Flips [A-Z] to their lowercase variants.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `mktype ::: name -> id`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Makes a type named name, and returns its id. Generally replaced by construct keyword.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `settype ::: object1 typeid -> object2`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Copies object, and sets the copy's type to typeid
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `mkinstance ::: typeid -> instance`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Makes an instance of typeid, calling constructor if necessary.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `delete ::: object -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Makes the object and all of its copies lose their identity, resetting them and freeing
the occupied storage.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `not ::: a -> cond(!a)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
If a is truthy, return 0, otherwise, return 1.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `acopy ::: a b idxa idxb amount -> b`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Copies array a into b, and returns b. The first element of a that is copied is idxa,
and it is copied from idxb. The amount of copied elements is amount. There is a
faster native version of this, but it is not used here.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_layer_call ::: name idx -> `
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Calls a function called name on the idx'th frame from the top of the framestack.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `and ::: a b -> cond(a && b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns if both a and b are truthy.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `or ::: a b -> cond(a || b)`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns if either a or b are truthy.
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `_last_word ::: idx -> word`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Returns the idx'th last word in the code.
Example `"foobar" 2 _last_word -> "\"foobar"`. Keep in mind that string words
internally do not end with a quote!
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
### `dup ::: a -> a a`
2022-05-23 20:16:57 +02:00
2022-05-23 22:10:19 +02:00
Duplicates the topmost value on the stack.
2022-05-23 20:16:57 +02:00
2022-05-24 16:40:26 +02:00
## >Variables
2022-05-23 20:16:57 +02:00
### TYPE_JIO
2022-05-23 22:10:19 +02:00
The typeid of the JIO type
2022-05-23 20:16:57 +02:00
### String
2022-05-23 22:10:19 +02:00
The typeid of a string
2022-05-23 20:16:57 +02:00
### TYPE_SHADOW
2022-05-23 22:10:19 +02:00
The typeid of a shadow, used for array literals.
2022-05-23 20:16:57 +02:00
### TYPE_INT
2022-05-23 22:10:19 +02:00
The typeid of an integer
2022-05-23 20:16:57 +02:00
### TYPE_BYTE
2022-05-23 22:10:19 +02:00
The typeid of a byte
2022-05-23 20:16:57 +02:00
### TYPE_FUNCTION
2022-05-23 22:10:19 +02:00
[Deprecated]
The typeid of a callable
2022-05-23 20:16:57 +02:00
### TYPE_FLOAT
2022-05-23 22:10:19 +02:00
The typeid of a float
2022-05-23 20:16:57 +02:00
### TYPE_NULL
2022-05-23 22:10:19 +02:00
The typeid of null
2022-05-23 20:16:57 +02:00
### TYPE_LONG
2022-05-23 22:10:19 +02:00
The typeid of a long
2022-05-23 20:16:57 +02:00
### TYPE_STRING
2022-05-23 22:10:19 +02:00
[Deprecated]
The typeid of string
2022-05-23 20:16:57 +02:00
### TYPE_REFERENCE
2022-05-23 22:10:19 +02:00
The typeid of a reference
2022-05-23 20:16:57 +02:00
### Function
2022-05-23 22:10:19 +02:00
The typeid of a callable
2022-05-23 20:16:57 +02:00
### TYPE_ARRAY
2022-05-23 22:10:19 +02:00
[Deprecated]
The typeid of an array
2022-05-23 20:16:57 +02:00
### TYPE_DOUBLE
2022-05-23 22:10:19 +02:00
The typeid of a double
2022-05-23 20:16:57 +02:00
### Array
2022-05-23 22:10:19 +02:00
The typeid of an array
2022-05-23 20:16:57 +02:00
### JIO
2022-05-23 22:10:19 +02:00
The JIO instance.
2022-05-23 20:16:57 +02:00
### TYPE_CHAR
2022-05-23 22:10:19 +02:00
The typeid of chars
2022-05-23 20:16:57 +02:00
2022-05-24 16:38:19 +02:00
---
# Types
2022-05-24 16:40:26 +02:00
## >JIO
2022-05-24 16:38:19 +02:00
Type representing the JIO functions
### Methods
#### `stack ::: -> stack`
Returns the stack being used currently.
#### `getclass ::: name -> classInstance`
Returns the java.lang.Class of the class represented by name
#### `context ::: -> context`
Returns the java Context (do not depend on this unless you know it'll be run in the official interpreter)
#### `class ::: name -> class`
Returns the ISBPL representation of a java class (statics and constructors are usable here)
#### `mirrorInterpreterData ::: -> `
If using a native interpreter, mirror the data of it to the Java one for JIO access.
2022-05-24 16:40:26 +02:00
## >String
2022-05-24 16:38:19 +02:00
Any string in ISBPL
### Methods
#### `_array ::: -> array`
Converts the string to an array of chars
2022-05-24 16:40:26 +02:00
## >int
2022-05-24 16:38:19 +02:00
Integer. Due to its use as a representation for types, it has a new method, which creates an object of the
type this int represents.
### Methods
#### `new ::: [DYN] -> instance`
Constructs another object using its construct method OR the default constructor
#### `construct ::: -> 0`
Returns an int representing 0
2022-05-24 16:40:26 +02:00
## >Reference
2022-05-24 16:38:19 +02:00
A reference to something, useful for passing objects to functions that change the value and reading them back later
### Variables
#### ?
The value (=? to set, like any other)
2022-05-24 16:40:26 +02:00
## >Array
2022-05-24 16:38:19 +02:00
An array of objects, the length is set at creation and can NOT be changed.
Counting starts at 0, length is the last possible index + 1.
### Methods
#### `foreach ::: callable(obj) -> `
Iterates through this array and calls the callable with the object (NOT the index).
2022-07-26 23:34:31 +02:00
#### `aput ::: item idx -> `
Puts an item into the array
2022-05-26 19:28:57 +02:00
#### `stackTraceToString ::: -> string`
Converts this array to a stack trace string. Only use on compatible arrays!
2022-07-26 23:34:31 +02:00
#### `aget ::: idx -> item`
Gets an item from the array
2022-05-24 16:38:19 +02:00
#### `construct ::: length -> array`
Constructs an array with a length
2022-05-26 19:28:57 +02:00
## >Error
An error in ISBPL
### Methods
#### `stacktrace ::: -> array`
Returns the stack trace of this error
#### `construct ::: id msg -> error`
Returns a new error with the id and msg