MCPcopy Create free account
hub / github.com/chc4/lineiform / function_add_codegen

Function function_add_codegen

tangle/src/ir.rs:300–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

298
299 #[test]
300 pub fn function_add_codegen() {
301 let mut ir = IR::new();
302 let mut f = Node::function::<2, 1>(&mut ir);
303 let port_0 = f.add_argument(&mut ir);
304 let port_1 = f.add_argument(&mut ir);
305 let ret_port = f.add_return(&mut ir);
306 let mut add = Node::simple(Operation::Add);
307 f.add_body(add, &mut ir, |add, r| {
308 add.connect_input(0, port_0, r);
309 add.connect_input(1, port_1, r);
310 add.connect_output(0, ret_port, r);
311 });
312 ir.set_body(f);
313 let hello_fn: extern "C" fn((usize, usize)) -> usize = ir.compile_fn().unwrap().0;
314 assert_eq!(hello_fn((1, 2)), 3);
315 }
316
317 #[test]
318 pub fn function_inc_disjoint() {

Callers

nothing calls this directly

Calls 7

add_argumentMethod · 0.80
add_returnMethod · 0.80
add_bodyMethod · 0.80
connect_inputMethod · 0.80
connect_outputMethod · 0.80
set_bodyMethod · 0.80
compile_fnMethod · 0.80

Tested by

no test coverage detected