|
| 1 | +extern crate libcc2rs; |
| 2 | +use libcc2rs::*; |
| 3 | +use std::cell::RefCell; |
| 4 | +use std::collections::BTreeMap; |
| 5 | +use std::io::prelude::*; |
| 6 | +use std::io::{Read, Seek, Write}; |
| 7 | +use std::os::fd::AsFd; |
| 8 | +use std::rc::{Rc, Weak}; |
| 9 | +#[derive(Default)] |
| 10 | +pub struct Outer_RunInfo { |
| 11 | + pub block_idx: Value<i32>, |
| 12 | + pub num_extra_zero_runs: Value<i32>, |
| 13 | +} |
| 14 | +impl Clone for Outer_RunInfo { |
| 15 | + fn clone(&self) -> Self { |
| 16 | + let mut this = Self { |
| 17 | + block_idx: Rc::new(RefCell::new((*self.block_idx.borrow()))), |
| 18 | + num_extra_zero_runs: Rc::new(RefCell::new((*self.num_extra_zero_runs.borrow()))), |
| 19 | + }; |
| 20 | + this |
| 21 | + } |
| 22 | +} |
| 23 | +impl ByteRepr for Outer_RunInfo {} |
| 24 | +#[derive(Default)] |
| 25 | +pub struct Outer { |
| 26 | + pub runs: Value<Vec<Outer_RunInfo>>, |
| 27 | +} |
| 28 | +impl Clone for Outer { |
| 29 | + fn clone(&self) -> Self { |
| 30 | + let mut this = Self { |
| 31 | + runs: Rc::new(RefCell::new((*self.runs.borrow()).clone())), |
| 32 | + }; |
| 33 | + this |
| 34 | + } |
| 35 | +} |
| 36 | +impl ByteRepr for Outer {} |
| 37 | +pub fn main() { |
| 38 | + std::process::exit(main_0()); |
| 39 | +} |
| 40 | +fn main_0() -> i32 { |
| 41 | + let o: Value<Outer> = Rc::new(RefCell::new(<Outer>::default())); |
| 42 | + let info: Value<Outer_RunInfo> = Rc::new(RefCell::new(<Outer_RunInfo>::default())); |
| 43 | + (*(*info.borrow()).block_idx.borrow_mut()) = 1; |
| 44 | + (*(*info.borrow()).num_extra_zero_runs.borrow_mut()) = 2; |
| 45 | + { |
| 46 | + let a0_clone = (*info.borrow()).clone(); |
| 47 | + (*(*o.borrow()).runs.borrow_mut()).push(a0_clone) |
| 48 | + }; |
| 49 | + assert!(((*(*o.borrow()).runs.borrow()).len() as u64 == 1_u64)); |
| 50 | + assert!( |
| 51 | + ((*(*((*o.borrow()).runs.as_pointer() as Ptr<Outer_RunInfo>) |
| 52 | + .offset(0_u64 as isize) |
| 53 | + .upgrade() |
| 54 | + .deref()) |
| 55 | + .block_idx |
| 56 | + .borrow()) |
| 57 | + == 1) |
| 58 | + ); |
| 59 | + assert!( |
| 60 | + ((*(*((*o.borrow()).runs.as_pointer() as Ptr<Outer_RunInfo>) |
| 61 | + .offset(0_u64 as isize) |
| 62 | + .upgrade() |
| 63 | + .deref()) |
| 64 | + .num_extra_zero_runs |
| 65 | + .borrow()) |
| 66 | + == 2) |
| 67 | + ); |
| 68 | + return 0; |
| 69 | +} |
0 commit comments