feat(defs): builtin definitions
This commit is contained in:
parent
c0785f7004
commit
8ebc50bea8
@ -0,0 +1,251 @@
|
|||||||
|
module static;
|
||||||
|
|
||||||
|
op ==(i64, i64) -> bool;
|
||||||
|
op !=(i64, i64) -> bool;
|
||||||
|
op >(i64, i64) -> bool;
|
||||||
|
op >=(i64, i64) -> bool;
|
||||||
|
op <(i64, i64) -> bool;
|
||||||
|
op <=(i64, i64) -> bool;
|
||||||
|
op &(i64, i64) -> i64;
|
||||||
|
op |(i64, i64) -> i64;
|
||||||
|
op ^(i64, i64) -> i64;
|
||||||
|
op ..(i64, i64) -> Range<i64>;
|
||||||
|
op ..=(i64, i64) -> RangeInclusive<i64>;
|
||||||
|
|
||||||
|
op ==(bool, bool) -> bool;
|
||||||
|
op !=(bool, bool) -> bool;
|
||||||
|
op >(bool, bool) -> bool;
|
||||||
|
op >=(bool, bool) -> bool;
|
||||||
|
op <(bool, bool) -> bool;
|
||||||
|
op <=(bool, bool) -> bool;
|
||||||
|
op &(bool, bool) -> bool;
|
||||||
|
op |(bool, bool) -> bool;
|
||||||
|
op ^(bool, bool) -> bool;
|
||||||
|
|
||||||
|
op ==((), ()) -> bool;
|
||||||
|
op !=((), ()) -> bool;
|
||||||
|
op >((), ()) -> bool;
|
||||||
|
op >=((), ()) -> bool;
|
||||||
|
op <((), ()) -> bool;
|
||||||
|
op <=((), ()) -> bool;
|
||||||
|
|
||||||
|
op +(i64, i64) -> i64;
|
||||||
|
op -(i64, i64) -> i64;
|
||||||
|
op *(i64, i64) -> i64;
|
||||||
|
op /(i64, i64) -> i64;
|
||||||
|
op %(i64, i64) -> i64;
|
||||||
|
op **(i64, i64) -> i64;
|
||||||
|
op >>(i64, i64) -> i64;
|
||||||
|
op <<(i64, i64) -> i64;
|
||||||
|
|
||||||
|
op +(f64, f64) -> f64;
|
||||||
|
op -(f64, f64) -> f64;
|
||||||
|
op *(f64, f64) -> f64;
|
||||||
|
op /(f64, f64) -> f64;
|
||||||
|
op %(f64, f64) -> f64;
|
||||||
|
op **(f64, f64) -> f64;
|
||||||
|
op ==(f64, f64) -> bool;
|
||||||
|
op !=(f64, f64) -> bool;
|
||||||
|
op >(f64, f64) -> bool;
|
||||||
|
op >=(f64, f64) -> bool;
|
||||||
|
op <(f64, f64) -> bool;
|
||||||
|
op <=(f64, f64) -> bool;
|
||||||
|
|
||||||
|
op +(f64, i64) -> f64;
|
||||||
|
op -(f64, i64) -> f64;
|
||||||
|
op *(f64, i64) -> f64;
|
||||||
|
op /(f64, i64) -> f64;
|
||||||
|
op %(f64, i64) -> f64;
|
||||||
|
op **(f64, i64) -> f64;
|
||||||
|
op ==(f64, i64) -> bool;
|
||||||
|
op !=(f64, i64) -> bool;
|
||||||
|
op >(f64, i64) -> bool;
|
||||||
|
op >=(f64, i64) -> bool;
|
||||||
|
op <(f64, i64) -> bool;
|
||||||
|
op <=(f64, i64) -> bool;
|
||||||
|
|
||||||
|
op +(i64, f64) -> f64;
|
||||||
|
op -(i64, f64) -> f64;
|
||||||
|
op *(i64, f64) -> f64;
|
||||||
|
op /(i64, f64) -> f64;
|
||||||
|
op %(i64, f64) -> f64;
|
||||||
|
op **(i64, f64) -> f64;
|
||||||
|
op ==(i64, f64) -> bool;
|
||||||
|
op !=(i64, f64) -> bool;
|
||||||
|
op >(i64, f64) -> bool;
|
||||||
|
op >=(i64, f64) -> bool;
|
||||||
|
op <(i64, f64) -> bool;
|
||||||
|
op <=(i64, f64) -> bool;
|
||||||
|
|
||||||
|
op +(Decimal, Decimal) -> Decimal;
|
||||||
|
op -(Decimal, Decimal) -> Decimal;
|
||||||
|
op *(Decimal, Decimal) -> Decimal;
|
||||||
|
op /(Decimal, Decimal) -> Decimal;
|
||||||
|
op %(Decimal, Decimal) -> Decimal;
|
||||||
|
op **(Decimal, Decimal) -> Decimal;
|
||||||
|
op ==(Decimal, Decimal) -> bool;
|
||||||
|
op !=(Decimal, Decimal) -> bool;
|
||||||
|
op >(Decimal, Decimal) -> bool;
|
||||||
|
op >=(Decimal, Decimal) -> bool;
|
||||||
|
op <(Decimal, Decimal) -> bool;
|
||||||
|
op <=(Decimal, Decimal) -> bool;
|
||||||
|
|
||||||
|
op +(Decimal, i64) -> Decimal;
|
||||||
|
op -(Decimal, i64) -> Decimal;
|
||||||
|
op *(Decimal, i64) -> Decimal;
|
||||||
|
op /(Decimal, i64) -> Decimal;
|
||||||
|
op %(Decimal, i64) -> Decimal;
|
||||||
|
op **(Decimal, i64) -> Decimal;
|
||||||
|
op ==(Decimal, i64) -> bool;
|
||||||
|
op !=(Decimal, i64) -> bool;
|
||||||
|
op >(Decimal, i64) -> bool;
|
||||||
|
op >=(Decimal, i64) -> bool;
|
||||||
|
op <(Decimal, i64) -> bool;
|
||||||
|
op <=(Decimal, i64) -> bool;
|
||||||
|
|
||||||
|
op +(i64, Decimal) -> Decimal;
|
||||||
|
op -(i64, Decimal) -> Decimal;
|
||||||
|
op *(i64, Decimal) -> Decimal;
|
||||||
|
op /(i64, Decimal) -> Decimal;
|
||||||
|
op %(i64, Decimal) -> Decimal;
|
||||||
|
op **(i64, Decimal) -> Decimal;
|
||||||
|
op ==(i64, Decimal) -> bool;
|
||||||
|
op !=(i64, Decimal) -> bool;
|
||||||
|
op >(i64, Decimal) -> bool;
|
||||||
|
op >=(i64, Decimal) -> bool;
|
||||||
|
op <(i64, Decimal) -> bool;
|
||||||
|
op <=(i64, Decimal) -> bool;
|
||||||
|
|
||||||
|
op +(String, String) -> String;
|
||||||
|
op -(String, String) -> String;
|
||||||
|
op ==(String, String) -> bool;
|
||||||
|
op !=(String, String) -> bool;
|
||||||
|
op >(String, String) -> bool;
|
||||||
|
op >=(String, String) -> bool;
|
||||||
|
op <(String, String) -> bool;
|
||||||
|
op <=(String, String) -> bool;
|
||||||
|
|
||||||
|
op +(char, char) -> String;
|
||||||
|
op ==(char, char) -> bool;
|
||||||
|
op !=(char, char) -> bool;
|
||||||
|
op >(char, char) -> bool;
|
||||||
|
op >=(char, char) -> bool;
|
||||||
|
op <(char, char) -> bool;
|
||||||
|
op <=(char, char) -> bool;
|
||||||
|
|
||||||
|
op +(char, String) -> String;
|
||||||
|
op ==(char, String) -> bool;
|
||||||
|
op !=(char, String) -> bool;
|
||||||
|
op >(char, String) -> bool;
|
||||||
|
op >=(char, String) -> bool;
|
||||||
|
op <(char, String) -> bool;
|
||||||
|
op <=(char, String) -> bool;
|
||||||
|
|
||||||
|
op +(String, char) -> String;
|
||||||
|
op -(String, char) -> String;
|
||||||
|
op ==(String, char) -> bool;
|
||||||
|
op !=(String, char) -> bool;
|
||||||
|
op >(String, char) -> bool;
|
||||||
|
op >=(String, char) -> bool;
|
||||||
|
op <(String, char) -> bool;
|
||||||
|
op <=(String, char) -> bool;
|
||||||
|
|
||||||
|
op +((), String) -> String;
|
||||||
|
op ==((), String) -> bool;
|
||||||
|
op !=((), String) -> bool;
|
||||||
|
op >((), String) -> bool;
|
||||||
|
op >=((), String) -> bool;
|
||||||
|
op <((), String) -> bool;
|
||||||
|
op <=((), String) -> bool;
|
||||||
|
|
||||||
|
op +(String, ()) -> String;
|
||||||
|
op ==(String, ()) -> bool;
|
||||||
|
op !=(String, ()) -> bool;
|
||||||
|
op >(String, ()) -> bool;
|
||||||
|
op >=(String, ()) -> bool;
|
||||||
|
op <(String, ()) -> bool;
|
||||||
|
op <=(String, ()) -> bool;
|
||||||
|
|
||||||
|
op +(Blob, Blob) -> Blob;
|
||||||
|
op +(Blob, char) -> Blob;
|
||||||
|
op ==(Blob, Blob) -> bool;
|
||||||
|
op !=(Blob, Blob) -> bool;
|
||||||
|
|
||||||
|
|
||||||
|
op ==(Range<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
op !=(Range<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(RangeInclusive<i64>, Range<i64>) -> bool;
|
||||||
|
op !=(RangeInclusive<i64>, Range<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(Range<i64>, Range<i64>) -> bool;
|
||||||
|
op !=(Range<i64>, Range<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(RangeInclusive<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
op !=(RangeInclusive<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(?, ?) -> bool;
|
||||||
|
op !=(?, ?) -> bool;
|
||||||
|
op >(?, ?) -> bool;
|
||||||
|
op >=(?, ?) -> bool;
|
||||||
|
op <(?, ?) -> bool;
|
||||||
|
op <=(?, ?) -> bool;
|
||||||
|
|
||||||
|
|
||||||
|
op &=(bool, bool);
|
||||||
|
op |=(bool, bool);
|
||||||
|
|
||||||
|
op +=(i64, i64);
|
||||||
|
op -=(i64, i64);
|
||||||
|
op *=(i64, i64);
|
||||||
|
op /=(i64, i64);
|
||||||
|
op %=(i64, i64);
|
||||||
|
op **=(i64, i64);
|
||||||
|
op >>=(i64, i64);
|
||||||
|
op <<=(i64, i64);
|
||||||
|
op &=(i64, i64);
|
||||||
|
op |=(i64, i64);
|
||||||
|
op ^=(i64, i64);
|
||||||
|
|
||||||
|
op +=(f64, f64);
|
||||||
|
op -=(f64, f64);
|
||||||
|
op *=(f64, f64);
|
||||||
|
op /=(f64, f64);
|
||||||
|
op %=(f64, f64);
|
||||||
|
op **=(f64, f64);
|
||||||
|
|
||||||
|
op +=(f64, i64);
|
||||||
|
op -=(f64, i64);
|
||||||
|
op *=(f64, i64);
|
||||||
|
op /=(f64, i64);
|
||||||
|
op %=(f64, i64);
|
||||||
|
op **=(f64, i64);
|
||||||
|
|
||||||
|
op +=(Decimal, Decimal);
|
||||||
|
op -=(Decimal, Decimal);
|
||||||
|
op *=(Decimal, Decimal);
|
||||||
|
op /=(Decimal, Decimal);
|
||||||
|
op %=(Decimal, Decimal);
|
||||||
|
op **=(Decimal, Decimal);
|
||||||
|
|
||||||
|
op +=(Decimal, i64);
|
||||||
|
op -=(Decimal, i64);
|
||||||
|
op *=(Decimal, i64);
|
||||||
|
op /=(Decimal, i64);
|
||||||
|
op %=(Decimal, i64);
|
||||||
|
op **=(Decimal, i64);
|
||||||
|
|
||||||
|
op +=(String, String);
|
||||||
|
op -=(String, String);
|
||||||
|
op +=(String, char);
|
||||||
|
op -=(String, char);
|
||||||
|
op +=(char, String);
|
||||||
|
op +=(char, char);
|
||||||
|
|
||||||
|
op +=(arraArray, item: Array);
|
||||||
|
op +=(arraArray, item: ?);
|
||||||
|
|
||||||
|
op +=(Blob, Blob);
|
||||||
|
op +=(Blob, value: i64);
|
||||||
|
op +=(Blob, char);
|
||||||
|
op +=(Blob, String);
|
170
examples/definitions/.rhai/definitions/__builtin__.d.rhai
Normal file
170
examples/definitions/.rhai/definitions/__builtin__.d.rhai
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
module static;
|
||||||
|
|
||||||
|
/// Display any data to the standard output.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let answer = 42;
|
||||||
|
///
|
||||||
|
/// print(`The Answer is ${answer}`);
|
||||||
|
/// ```
|
||||||
|
fn print(data: ?);
|
||||||
|
|
||||||
|
/// Display any data to the standard output in debug format.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let answer = 42;
|
||||||
|
///
|
||||||
|
/// debug(answer);
|
||||||
|
/// ```
|
||||||
|
fn debug(data: ?);
|
||||||
|
|
||||||
|
/// Get the type of a value.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = "hello, world!";
|
||||||
|
///
|
||||||
|
/// print(x.type_of()); // prints "string"
|
||||||
|
/// ```
|
||||||
|
fn type_of(data: ?) -> String;
|
||||||
|
|
||||||
|
/// Create a function pointer to a named function.
|
||||||
|
///
|
||||||
|
/// If the specified name is not a valid function name, an error is raised.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let f = Fn("foo"); // function pointer to 'foo'
|
||||||
|
///
|
||||||
|
/// f.call(42); // call: foo(42)
|
||||||
|
/// ```
|
||||||
|
fn Fn(fn_name: String) -> FnPtr;
|
||||||
|
|
||||||
|
/// Call a function pointed to by a function pointer,
|
||||||
|
/// passing following arguments to the function call.
|
||||||
|
///
|
||||||
|
/// If an appropriate function is not found, an error is raised.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let f = Fn("foo"); // function pointer to 'foo'
|
||||||
|
///
|
||||||
|
/// f.call(1, 2, 3); // call: foo(1, 2, 3)
|
||||||
|
/// ```
|
||||||
|
fn call(fn_ptr: FnPtr, ...args: ?) -> ?;
|
||||||
|
|
||||||
|
/// Call a function pointed to by a function pointer, binding the `this` pointer
|
||||||
|
/// to the object of the method call, and passing on following arguments to the function call.
|
||||||
|
///
|
||||||
|
/// If an appropriate function is not found, an error is raised.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// fn add(x) {
|
||||||
|
/// this + x
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let f = Fn("add"); // function pointer to 'add'
|
||||||
|
///
|
||||||
|
/// let x = 41;
|
||||||
|
///
|
||||||
|
/// let r = x.call(f, 1); // call: add(1) with 'this' = 'x'
|
||||||
|
///
|
||||||
|
/// print(r); // prints 42
|
||||||
|
/// ```
|
||||||
|
fn call(obj: ?, fn_ptr: FnPtr, ...args: ?) -> ?;
|
||||||
|
|
||||||
|
/// Curry a number of arguments into a function pointer and return it as a new function pointer.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// fn foo(x, y, z) {
|
||||||
|
/// x + y + z
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let f = Fn("foo");
|
||||||
|
///
|
||||||
|
/// let g = f.curry(1, 2); // curried arguments: 1, 2
|
||||||
|
///
|
||||||
|
/// g.call(3); // call: foo(1, 2, 3)
|
||||||
|
/// ```
|
||||||
|
fn curry(fn_ptr: FnPtr, ...args: ?) -> FnPtr;
|
||||||
|
|
||||||
|
/// Return `true` if a script-defined function exists with a specified name and
|
||||||
|
/// number of parameters.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// fn foo(x) { }
|
||||||
|
///
|
||||||
|
/// print(is_def_fn("foo", 1)); // prints true
|
||||||
|
/// print(is_def_fn("foo", 2)); // prints false
|
||||||
|
/// print(is_def_fn("foo", 0)); // prints false
|
||||||
|
/// print(is_def_fn("bar", 1)); // prints false
|
||||||
|
/// ```
|
||||||
|
fn is_def_fn(fn_name: String, num_params: i64) -> bool;
|
||||||
|
|
||||||
|
/// Return `true` if a variable matching a specified name is defined.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = 42;
|
||||||
|
///
|
||||||
|
/// print(is_def_var("x")); // prints true
|
||||||
|
/// print(is_def_var("foo")); // prints false
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let y = 1;
|
||||||
|
/// print(is_def_var("y")); // prints true
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// print(is_def_var("y")); // prints false
|
||||||
|
/// ```
|
||||||
|
fn is_def_var(var_name: String) -> bool;
|
||||||
|
|
||||||
|
/// Return `true` if the variable is shared.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = 42;
|
||||||
|
///
|
||||||
|
/// print(is_shared(x)); // prints false
|
||||||
|
///
|
||||||
|
/// let f = || x; // capture 'x', making it shared
|
||||||
|
///
|
||||||
|
/// print(is_shared(x)); // prints true
|
||||||
|
/// ```
|
||||||
|
fn is_shared(variable: ?) -> bool;
|
||||||
|
|
||||||
|
/// Evaluate a text script within the current scope.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = 42;
|
||||||
|
///
|
||||||
|
/// eval("let y = x; x = 123;");
|
||||||
|
///
|
||||||
|
/// print(x); // prints 123
|
||||||
|
/// print(y); // prints 42
|
||||||
|
/// ```
|
||||||
|
fn eval(script: String) -> ?;
|
||||||
|
|
||||||
|
fn contains(string: String, find: String) -> bool;
|
||||||
|
fn contains(range: Range<i64>, value: i64) -> bool;
|
||||||
|
fn contains(range: RangeInclusive<i64>, value: i64) -> bool;
|
||||||
|
fn contains(map: Map, string: String) -> bool;
|
||||||
|
fn contains(blob: Blob, value: i64) -> bool;
|
||||||
|
fn contains(string: String, ch: char) -> bool;
|
File diff suppressed because it is too large
Load Diff
251
src/definitions/builtin-operators.d.rhai
Normal file
251
src/definitions/builtin-operators.d.rhai
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
module static;
|
||||||
|
|
||||||
|
op ==(i64, i64) -> bool;
|
||||||
|
op !=(i64, i64) -> bool;
|
||||||
|
op >(i64, i64) -> bool;
|
||||||
|
op >=(i64, i64) -> bool;
|
||||||
|
op <(i64, i64) -> bool;
|
||||||
|
op <=(i64, i64) -> bool;
|
||||||
|
op &(i64, i64) -> i64;
|
||||||
|
op |(i64, i64) -> i64;
|
||||||
|
op ^(i64, i64) -> i64;
|
||||||
|
op ..(i64, i64) -> Range<i64>;
|
||||||
|
op ..=(i64, i64) -> RangeInclusive<i64>;
|
||||||
|
|
||||||
|
op ==(bool, bool) -> bool;
|
||||||
|
op !=(bool, bool) -> bool;
|
||||||
|
op >(bool, bool) -> bool;
|
||||||
|
op >=(bool, bool) -> bool;
|
||||||
|
op <(bool, bool) -> bool;
|
||||||
|
op <=(bool, bool) -> bool;
|
||||||
|
op &(bool, bool) -> bool;
|
||||||
|
op |(bool, bool) -> bool;
|
||||||
|
op ^(bool, bool) -> bool;
|
||||||
|
|
||||||
|
op ==((), ()) -> bool;
|
||||||
|
op !=((), ()) -> bool;
|
||||||
|
op >((), ()) -> bool;
|
||||||
|
op >=((), ()) -> bool;
|
||||||
|
op <((), ()) -> bool;
|
||||||
|
op <=((), ()) -> bool;
|
||||||
|
|
||||||
|
op +(i64, i64) -> i64;
|
||||||
|
op -(i64, i64) -> i64;
|
||||||
|
op *(i64, i64) -> i64;
|
||||||
|
op /(i64, i64) -> i64;
|
||||||
|
op %(i64, i64) -> i64;
|
||||||
|
op **(i64, i64) -> i64;
|
||||||
|
op >>(i64, i64) -> i64;
|
||||||
|
op <<(i64, i64) -> i64;
|
||||||
|
|
||||||
|
op +(f64, f64) -> f64;
|
||||||
|
op -(f64, f64) -> f64;
|
||||||
|
op *(f64, f64) -> f64;
|
||||||
|
op /(f64, f64) -> f64;
|
||||||
|
op %(f64, f64) -> f64;
|
||||||
|
op **(f64, f64) -> f64;
|
||||||
|
op ==(f64, f64) -> bool;
|
||||||
|
op !=(f64, f64) -> bool;
|
||||||
|
op >(f64, f64) -> bool;
|
||||||
|
op >=(f64, f64) -> bool;
|
||||||
|
op <(f64, f64) -> bool;
|
||||||
|
op <=(f64, f64) -> bool;
|
||||||
|
|
||||||
|
op +(f64, i64) -> f64;
|
||||||
|
op -(f64, i64) -> f64;
|
||||||
|
op *(f64, i64) -> f64;
|
||||||
|
op /(f64, i64) -> f64;
|
||||||
|
op %(f64, i64) -> f64;
|
||||||
|
op **(f64, i64) -> f64;
|
||||||
|
op ==(f64, i64) -> bool;
|
||||||
|
op !=(f64, i64) -> bool;
|
||||||
|
op >(f64, i64) -> bool;
|
||||||
|
op >=(f64, i64) -> bool;
|
||||||
|
op <(f64, i64) -> bool;
|
||||||
|
op <=(f64, i64) -> bool;
|
||||||
|
|
||||||
|
op +(i64, f64) -> f64;
|
||||||
|
op -(i64, f64) -> f64;
|
||||||
|
op *(i64, f64) -> f64;
|
||||||
|
op /(i64, f64) -> f64;
|
||||||
|
op %(i64, f64) -> f64;
|
||||||
|
op **(i64, f64) -> f64;
|
||||||
|
op ==(i64, f64) -> bool;
|
||||||
|
op !=(i64, f64) -> bool;
|
||||||
|
op >(i64, f64) -> bool;
|
||||||
|
op >=(i64, f64) -> bool;
|
||||||
|
op <(i64, f64) -> bool;
|
||||||
|
op <=(i64, f64) -> bool;
|
||||||
|
|
||||||
|
op +(Decimal, Decimal) -> Decimal;
|
||||||
|
op -(Decimal, Decimal) -> Decimal;
|
||||||
|
op *(Decimal, Decimal) -> Decimal;
|
||||||
|
op /(Decimal, Decimal) -> Decimal;
|
||||||
|
op %(Decimal, Decimal) -> Decimal;
|
||||||
|
op **(Decimal, Decimal) -> Decimal;
|
||||||
|
op ==(Decimal, Decimal) -> bool;
|
||||||
|
op !=(Decimal, Decimal) -> bool;
|
||||||
|
op >(Decimal, Decimal) -> bool;
|
||||||
|
op >=(Decimal, Decimal) -> bool;
|
||||||
|
op <(Decimal, Decimal) -> bool;
|
||||||
|
op <=(Decimal, Decimal) -> bool;
|
||||||
|
|
||||||
|
op +(Decimal, i64) -> Decimal;
|
||||||
|
op -(Decimal, i64) -> Decimal;
|
||||||
|
op *(Decimal, i64) -> Decimal;
|
||||||
|
op /(Decimal, i64) -> Decimal;
|
||||||
|
op %(Decimal, i64) -> Decimal;
|
||||||
|
op **(Decimal, i64) -> Decimal;
|
||||||
|
op ==(Decimal, i64) -> bool;
|
||||||
|
op !=(Decimal, i64) -> bool;
|
||||||
|
op >(Decimal, i64) -> bool;
|
||||||
|
op >=(Decimal, i64) -> bool;
|
||||||
|
op <(Decimal, i64) -> bool;
|
||||||
|
op <=(Decimal, i64) -> bool;
|
||||||
|
|
||||||
|
op +(i64, Decimal) -> Decimal;
|
||||||
|
op -(i64, Decimal) -> Decimal;
|
||||||
|
op *(i64, Decimal) -> Decimal;
|
||||||
|
op /(i64, Decimal) -> Decimal;
|
||||||
|
op %(i64, Decimal) -> Decimal;
|
||||||
|
op **(i64, Decimal) -> Decimal;
|
||||||
|
op ==(i64, Decimal) -> bool;
|
||||||
|
op !=(i64, Decimal) -> bool;
|
||||||
|
op >(i64, Decimal) -> bool;
|
||||||
|
op >=(i64, Decimal) -> bool;
|
||||||
|
op <(i64, Decimal) -> bool;
|
||||||
|
op <=(i64, Decimal) -> bool;
|
||||||
|
|
||||||
|
op +(String, String) -> String;
|
||||||
|
op -(String, String) -> String;
|
||||||
|
op ==(String, String) -> bool;
|
||||||
|
op !=(String, String) -> bool;
|
||||||
|
op >(String, String) -> bool;
|
||||||
|
op >=(String, String) -> bool;
|
||||||
|
op <(String, String) -> bool;
|
||||||
|
op <=(String, String) -> bool;
|
||||||
|
|
||||||
|
op +(char, char) -> String;
|
||||||
|
op ==(char, char) -> bool;
|
||||||
|
op !=(char, char) -> bool;
|
||||||
|
op >(char, char) -> bool;
|
||||||
|
op >=(char, char) -> bool;
|
||||||
|
op <(char, char) -> bool;
|
||||||
|
op <=(char, char) -> bool;
|
||||||
|
|
||||||
|
op +(char, String) -> String;
|
||||||
|
op ==(char, String) -> bool;
|
||||||
|
op !=(char, String) -> bool;
|
||||||
|
op >(char, String) -> bool;
|
||||||
|
op >=(char, String) -> bool;
|
||||||
|
op <(char, String) -> bool;
|
||||||
|
op <=(char, String) -> bool;
|
||||||
|
|
||||||
|
op +(String, char) -> String;
|
||||||
|
op -(String, char) -> String;
|
||||||
|
op ==(String, char) -> bool;
|
||||||
|
op !=(String, char) -> bool;
|
||||||
|
op >(String, char) -> bool;
|
||||||
|
op >=(String, char) -> bool;
|
||||||
|
op <(String, char) -> bool;
|
||||||
|
op <=(String, char) -> bool;
|
||||||
|
|
||||||
|
op +((), String) -> String;
|
||||||
|
op ==((), String) -> bool;
|
||||||
|
op !=((), String) -> bool;
|
||||||
|
op >((), String) -> bool;
|
||||||
|
op >=((), String) -> bool;
|
||||||
|
op <((), String) -> bool;
|
||||||
|
op <=((), String) -> bool;
|
||||||
|
|
||||||
|
op +(String, ()) -> String;
|
||||||
|
op ==(String, ()) -> bool;
|
||||||
|
op !=(String, ()) -> bool;
|
||||||
|
op >(String, ()) -> bool;
|
||||||
|
op >=(String, ()) -> bool;
|
||||||
|
op <(String, ()) -> bool;
|
||||||
|
op <=(String, ()) -> bool;
|
||||||
|
|
||||||
|
op +(Blob, Blob) -> Blob;
|
||||||
|
op +(Blob, char) -> Blob;
|
||||||
|
op ==(Blob, Blob) -> bool;
|
||||||
|
op !=(Blob, Blob) -> bool;
|
||||||
|
|
||||||
|
|
||||||
|
op ==(Range<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
op !=(Range<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(RangeInclusive<i64>, Range<i64>) -> bool;
|
||||||
|
op !=(RangeInclusive<i64>, Range<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(Range<i64>, Range<i64>) -> bool;
|
||||||
|
op !=(Range<i64>, Range<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(RangeInclusive<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
op !=(RangeInclusive<i64>, RangeInclusive<i64>) -> bool;
|
||||||
|
|
||||||
|
op ==(?, ?) -> bool;
|
||||||
|
op !=(?, ?) -> bool;
|
||||||
|
op >(?, ?) -> bool;
|
||||||
|
op >=(?, ?) -> bool;
|
||||||
|
op <(?, ?) -> bool;
|
||||||
|
op <=(?, ?) -> bool;
|
||||||
|
|
||||||
|
|
||||||
|
op &=(bool, bool);
|
||||||
|
op |=(bool, bool);
|
||||||
|
|
||||||
|
op +=(i64, i64);
|
||||||
|
op -=(i64, i64);
|
||||||
|
op *=(i64, i64);
|
||||||
|
op /=(i64, i64);
|
||||||
|
op %=(i64, i64);
|
||||||
|
op **=(i64, i64);
|
||||||
|
op >>=(i64, i64);
|
||||||
|
op <<=(i64, i64);
|
||||||
|
op &=(i64, i64);
|
||||||
|
op |=(i64, i64);
|
||||||
|
op ^=(i64, i64);
|
||||||
|
|
||||||
|
op +=(f64, f64);
|
||||||
|
op -=(f64, f64);
|
||||||
|
op *=(f64, f64);
|
||||||
|
op /=(f64, f64);
|
||||||
|
op %=(f64, f64);
|
||||||
|
op **=(f64, f64);
|
||||||
|
|
||||||
|
op +=(f64, i64);
|
||||||
|
op -=(f64, i64);
|
||||||
|
op *=(f64, i64);
|
||||||
|
op /=(f64, i64);
|
||||||
|
op %=(f64, i64);
|
||||||
|
op **=(f64, i64);
|
||||||
|
|
||||||
|
op +=(Decimal, Decimal);
|
||||||
|
op -=(Decimal, Decimal);
|
||||||
|
op *=(Decimal, Decimal);
|
||||||
|
op /=(Decimal, Decimal);
|
||||||
|
op %=(Decimal, Decimal);
|
||||||
|
op **=(Decimal, Decimal);
|
||||||
|
|
||||||
|
op +=(Decimal, i64);
|
||||||
|
op -=(Decimal, i64);
|
||||||
|
op *=(Decimal, i64);
|
||||||
|
op /=(Decimal, i64);
|
||||||
|
op %=(Decimal, i64);
|
||||||
|
op **=(Decimal, i64);
|
||||||
|
|
||||||
|
op +=(String, String);
|
||||||
|
op -=(String, String);
|
||||||
|
op +=(String, char);
|
||||||
|
op -=(String, char);
|
||||||
|
op +=(char, String);
|
||||||
|
op +=(char, char);
|
||||||
|
|
||||||
|
op +=(arraArray, item: Array);
|
||||||
|
op +=(arraArray, item: ?);
|
||||||
|
|
||||||
|
op +=(Blob, Blob);
|
||||||
|
op +=(Blob, value: i64);
|
||||||
|
op +=(Blob, char);
|
||||||
|
op +=(Blob, String);
|
170
src/definitions/builtin.d.rhai
Normal file
170
src/definitions/builtin.d.rhai
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
module static;
|
||||||
|
|
||||||
|
/// Display any data to the standard output.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let answer = 42;
|
||||||
|
///
|
||||||
|
/// print(`The Answer is ${answer}`);
|
||||||
|
/// ```
|
||||||
|
fn print(data: ?);
|
||||||
|
|
||||||
|
/// Display any data to the standard output in debug format.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let answer = 42;
|
||||||
|
///
|
||||||
|
/// debug(answer);
|
||||||
|
/// ```
|
||||||
|
fn debug(data: ?);
|
||||||
|
|
||||||
|
/// Get the type of a value.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = "hello, world!";
|
||||||
|
///
|
||||||
|
/// print(x.type_of()); // prints "string"
|
||||||
|
/// ```
|
||||||
|
fn type_of(data: ?) -> String;
|
||||||
|
|
||||||
|
/// Create a function pointer to a named function.
|
||||||
|
///
|
||||||
|
/// If the specified name is not a valid function name, an error is raised.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let f = Fn("foo"); // function pointer to 'foo'
|
||||||
|
///
|
||||||
|
/// f.call(42); // call: foo(42)
|
||||||
|
/// ```
|
||||||
|
fn Fn(fn_name: String) -> FnPtr;
|
||||||
|
|
||||||
|
/// Call a function pointed to by a function pointer,
|
||||||
|
/// passing following arguments to the function call.
|
||||||
|
///
|
||||||
|
/// If an appropriate function is not found, an error is raised.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let f = Fn("foo"); // function pointer to 'foo'
|
||||||
|
///
|
||||||
|
/// f.call(1, 2, 3); // call: foo(1, 2, 3)
|
||||||
|
/// ```
|
||||||
|
fn call(fn_ptr: FnPtr, ...args: ?) -> ?;
|
||||||
|
|
||||||
|
/// Call a function pointed to by a function pointer, binding the `this` pointer
|
||||||
|
/// to the object of the method call, and passing on following arguments to the function call.
|
||||||
|
///
|
||||||
|
/// If an appropriate function is not found, an error is raised.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// fn add(x) {
|
||||||
|
/// this + x
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let f = Fn("add"); // function pointer to 'add'
|
||||||
|
///
|
||||||
|
/// let x = 41;
|
||||||
|
///
|
||||||
|
/// let r = x.call(f, 1); // call: add(1) with 'this' = 'x'
|
||||||
|
///
|
||||||
|
/// print(r); // prints 42
|
||||||
|
/// ```
|
||||||
|
fn call(obj: ?, fn_ptr: FnPtr, ...args: ?) -> ?;
|
||||||
|
|
||||||
|
/// Curry a number of arguments into a function pointer and return it as a new function pointer.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// fn foo(x, y, z) {
|
||||||
|
/// x + y + z
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let f = Fn("foo");
|
||||||
|
///
|
||||||
|
/// let g = f.curry(1, 2); // curried arguments: 1, 2
|
||||||
|
///
|
||||||
|
/// g.call(3); // call: foo(1, 2, 3)
|
||||||
|
/// ```
|
||||||
|
fn curry(fn_ptr: FnPtr, ...args: ?) -> FnPtr;
|
||||||
|
|
||||||
|
/// Return `true` if a script-defined function exists with a specified name and
|
||||||
|
/// number of parameters.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// fn foo(x) { }
|
||||||
|
///
|
||||||
|
/// print(is_def_fn("foo", 1)); // prints true
|
||||||
|
/// print(is_def_fn("foo", 2)); // prints false
|
||||||
|
/// print(is_def_fn("foo", 0)); // prints false
|
||||||
|
/// print(is_def_fn("bar", 1)); // prints false
|
||||||
|
/// ```
|
||||||
|
fn is_def_fn(fn_name: String, num_params: i64) -> bool;
|
||||||
|
|
||||||
|
/// Return `true` if a variable matching a specified name is defined.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = 42;
|
||||||
|
///
|
||||||
|
/// print(is_def_var("x")); // prints true
|
||||||
|
/// print(is_def_var("foo")); // prints false
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let y = 1;
|
||||||
|
/// print(is_def_var("y")); // prints true
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// print(is_def_var("y")); // prints false
|
||||||
|
/// ```
|
||||||
|
fn is_def_var(var_name: String) -> bool;
|
||||||
|
|
||||||
|
/// Return `true` if the variable is shared.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = 42;
|
||||||
|
///
|
||||||
|
/// print(is_shared(x)); // prints false
|
||||||
|
///
|
||||||
|
/// let f = || x; // capture 'x', making it shared
|
||||||
|
///
|
||||||
|
/// print(is_shared(x)); // prints true
|
||||||
|
/// ```
|
||||||
|
fn is_shared(variable: ?) -> bool;
|
||||||
|
|
||||||
|
/// Evaluate a text script within the current scope.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```rhai
|
||||||
|
/// let x = 42;
|
||||||
|
///
|
||||||
|
/// eval("let y = x; x = 123;");
|
||||||
|
///
|
||||||
|
/// print(x); // prints 123
|
||||||
|
/// print(y); // prints 42
|
||||||
|
/// ```
|
||||||
|
fn eval(script: String) -> ?;
|
||||||
|
|
||||||
|
fn contains(string: String, find: String) -> bool;
|
||||||
|
fn contains(range: Range<i64>, value: i64) -> bool;
|
||||||
|
fn contains(range: RangeInclusive<i64>, value: i64) -> bool;
|
||||||
|
fn contains(map: Map, string: String) -> bool;
|
||||||
|
fn contains(blob: Blob, value: i64) -> bool;
|
||||||
|
fn contains(string: String, ch: char) -> bool;
|
@ -86,6 +86,9 @@ impl<'e> Definitions<'e> {
|
|||||||
|
|
||||||
fs::create_dir_all(path)?;
|
fs::create_dir_all(path)?;
|
||||||
|
|
||||||
|
fs::write(path.join("__builtin__.d.rhai"), include_bytes!("builtin.d.rhai"))?;
|
||||||
|
fs::write(path.join("__builtin-operators__.d.rhai"), include_bytes!("builtin-operators.d.rhai"))?;
|
||||||
|
|
||||||
fs::write(path.join("__static__.d.rhai"), self.static_module())?;
|
fs::write(path.join("__static__.d.rhai"), self.static_module())?;
|
||||||
|
|
||||||
if self.scope.is_some() {
|
if self.scope.is_some() {
|
Loading…
Reference in New Issue
Block a user