You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make sure you create new Issue for it and explain your Idea before you start
Make a file in src/builtin_function/<module_name>/<function_name>.rs
This is equal function and I want to explain how it works:
// imports you needusecrate::builtin_function::utils::{param_to_datatype, returns};usecrate::common::data_type::DataType;usecrate::common::errors::Result;usecrate::{common::executable::ExecutableLine, runtime::Runtime};// do not change function signature, Just change the namepubfnequal(runtime:&mutRuntime,executable:&ExecutableLine) -> Result<()>{// this is how you can get paramslet p1 = param_to_datatype(runtime, executable.params.first(), executable.line_number)?;let p2 = param_to_datatype(runtime, executable.params.get(1), executable.line_number)?;// for example in `5, 6 -> equal -> $output`// p1 is 5 and p2 is 6// `returns` function puts third param in $output variable returns(runtime, executable,DataType::Bool(p1 == p2))}
go to here and add your function to functions match case
Send PR to dev branch and tag me for review and If you need help just let me know
Make an error:
returnErr(ChapError::runtime_with_msg(
executable.line_number,"random_bool not supported in wasm".to_string(),));
Builtin function
It's really easy to add a new builtin function to Chap.
Ideas
You can add what ever you think is cool but here is some ideas:
xor,shift_right,shift_leftchar_atso we can loop over chars,to_listlist is also cool (which converts string to list of chars) Add some string functions in built-in functions #16)length,joinandclearBuiltin functions (list) #15)How to add
Make sure you create new Issue for it and explain your Idea before you start
Make a file in
src/builtin_function/<module_name>/<function_name>.rsThis is equal function and I want to explain how it works:
go to here and add your function to functions match case
Send PR to
devbranch and tag me for review and If you need help just let me knowMake an error: