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
To use it with Dyon, it must be registered with a name and type information:
module.add(Arc::new("say_hello".into()), say_hello,PreludeFunction{lts:vec![],// lifetime constraintstys:vec![],// type constraintsret:Type::Void// return type});
If any arguments are mutated, add pattern (mut,_,_,...) to the function name.
For example, if 2 of 2 arguments are mutable to function foo, you register foo(mut,mut).
Mutating a variable on the stack
When mutating a variable on the stack, you need to resolve the reference first. This is because
let ind = rt.stack.pop().expect("There is no value on the stack");let id = ifletVariable::Ref(id) = rt.stack[ind]{
id
}else{
rt.stack[ind]};ifletVariable::Array(refmut arr) = rt.stack[id]{// mutate array here}
The text was updated successfully, but these errors were encountered:
Dyon is designed to be used with Rust only, but not designed to replace Rust. It complements Rust on some areas where Rust has lacking features.
Because Dyon uses a simple object model, the values must be converted when talking with Rust.
See functions example
A more complex example is the dyon_interactive library.
Functions that helps talking with Rust
dyon::embed::obj_field
Runtime::pop
Runtime::push
Runtime::pop_vec4
Runtime::push_vec4
Runtime::var
Runtime::expected
External functions
Example:
To use it with Dyon, it must be registered with a name and type information:
If any arguments are mutated, add pattern
(mut,_,_,...)
to the function name.For example, if 2 of 2 arguments are mutable to function
foo
, you registerfoo(mut,mut)
.Mutating a variable on the stack
When mutating a variable on the stack, you need to resolve the reference first. This is because
The text was updated successfully, but these errors were encountered: