-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bytecodeIssues related to bytecodeIssues related to bytecodecompilerIssues related to compilation & parsingIssues related to compilation & parsingenhancementNew feature or requestNew feature or requesthigh priorityThis issue is required for the next releaseThis issue is required for the next release
Milestone
Description
MScript
call_rust_function: fn(a: int, b: int) -> int = symbol "add_ints" : "path/to/my_lib.dll"
assert call_rust_function(5, 10) == 15
Rust
use bytecode::BytecodePrimitive;
use bytecode::{int, raise_error};
use bytecode::FFIReturnValue;
#[no_mangle]
pub fn adder(args: &[BytecodePrimitive]) -> FFIReturnValue {
let (Some(BytecodePrimitive::Int(x)), Some(BytecodePrimitive::Int(y))) = (args.get(0), args.get(1)) else {
raise_error!("cannot add two non-ints!")
};
let result = x + y;
println!("hello from rust!!! the answer is {result}");
FFIReturnValue::Value(int!(result))
}
Metadata
Metadata
Assignees
Labels
bytecodeIssues related to bytecodeIssues related to bytecodecompilerIssues related to compilation & parsingIssues related to compilation & parsingenhancementNew feature or requestNew feature or requesthigh priorityThis issue is required for the next releaseThis issue is required for the next release