|
| 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 | +thread_local!( |
| 10 | + pub static p_mut: Value<Ptr<i32>> = Rc::new(RefCell::new(Ptr::<i32>::null())); |
| 11 | +); |
| 12 | +thread_local!( |
| 13 | + pub static p_const: Value<Ptr<i32>> = Rc::new(RefCell::new(Ptr::<i32>::null())); |
| 14 | +); |
| 15 | +thread_local!( |
| 16 | + pub static cp: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::<u8>::null())); |
| 17 | +); |
| 18 | +thread_local!( |
| 19 | + pub static arr_of_ptr: Value<Box<[Ptr<i32>]>> = Rc::new(RefCell::new( |
| 20 | + (0..4) |
| 21 | + .map(|_| Ptr::<i32>::null()) |
| 22 | + .collect::<Box<[Ptr<i32>]>>(), |
| 23 | + )); |
| 24 | +); |
| 25 | +thread_local!( |
| 26 | + pub static pp: Value<Ptr<Ptr<i32>>> = Rc::new(RefCell::new(Ptr::<Ptr<i32>>::null())); |
| 27 | +); |
| 28 | +thread_local!( |
| 29 | + pub static const_arr_of_ptr: Value<Box<[Ptr<i32>]>> = Rc::new(RefCell::new( |
| 30 | + (0..3) |
| 31 | + .map(|_| Ptr::<i32>::null()) |
| 32 | + .collect::<Box<[Ptr<i32>]>>(), |
| 33 | + )); |
| 34 | +); |
| 35 | +thread_local!( |
| 36 | + pub static cp_explicit_null: Value<Ptr<u8>> = Rc::new(RefCell::new(Default::default())); |
| 37 | +); |
| 38 | +thread_local!( |
| 39 | + pub static p_zero: Value<Ptr<i32>> = Rc::new(RefCell::new(Default::default())); |
| 40 | +); |
| 41 | +pub fn main() { |
| 42 | + std::process::exit(main_0()); |
| 43 | +} |
| 44 | +fn main_0() -> i32 { |
| 45 | + assert!((*p_mut.with(Value::clone).borrow()).is_null()); |
| 46 | + assert!((*p_const.with(Value::clone).borrow()).is_null()); |
| 47 | + assert!((*cp.with(Value::clone).borrow()).is_null()); |
| 48 | + let i: Value<i32> = Rc::new(RefCell::new(0)); |
| 49 | + 'loop_: while ((*i.borrow()) < 4) { |
| 50 | + assert!(((*arr_of_ptr.with(Value::clone).borrow())[(*i.borrow()) as usize]).is_null()); |
| 51 | + (*i.borrow_mut()).prefix_inc(); |
| 52 | + } |
| 53 | + assert!((*pp.with(Value::clone).borrow()).is_null()); |
| 54 | + let i: Value<i32> = Rc::new(RefCell::new(0)); |
| 55 | + 'loop_: while ((*i.borrow()) < 3) { |
| 56 | + assert!( |
| 57 | + ((*const_arr_of_ptr.with(Value::clone).borrow())[(*i.borrow()) as usize]).is_null() |
| 58 | + ); |
| 59 | + (*i.borrow_mut()).prefix_inc(); |
| 60 | + } |
| 61 | + assert!((*cp_explicit_null.with(Value::clone).borrow()).is_null()); |
| 62 | + assert!((*p_zero.with(Value::clone).borrow()).is_null()); |
| 63 | + return 0; |
| 64 | +} |
0 commit comments