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

Function function_inc_shared

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

Source from the content-addressed store, hash-verified

367
368 #[test]
369 pub fn function_inc_shared() {
370 let mut ir = IR::new();
371 let mut f = Node::function::<2, 2>(&mut ir);
372 let port_0 = f.add_argument(&mut ir);
373 let port_1 = f.add_argument(&mut ir);
374 let ret_port_0 = f.add_return(&mut ir);
375 let ret_port_1 = f.add_return(&mut ir);
376 let mut inc_0 = Node::simple(Operation::Inc);
377 let mut inc_1 = Node::simple(Operation::Inc);
378 f.add_body(inc_0, &mut ir, |inc, r| {
379 inc.connect_input(0, port_0, r);
380 inc.connect_output(0, ret_port_0, r);
381 });
382 f.add_body(inc_1, &mut ir, |inc, r| {
383 inc.connect_input(0, port_1, r);
384 inc.connect_output(0, ret_port_1, r);
385 });
386
387 ir.set_body(f);
388 let hello_fn: extern "C" fn((usize, usize)) -> (usize, usize) = ir.compile_fn().unwrap().0;
389 assert_eq!(hello_fn((1, 2)), (2, 3));
390 }
391
392 #[test]
393 pub fn function_inc_a_lot() {

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