|
| 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 | +pub fn main() { |
| 10 | + __cpp2rust_init_globals(); |
| 11 | + std::process::exit(main_0()); |
| 12 | +} |
| 13 | +fn main_0() -> i32 { |
| 14 | + let twice: Value<lambda_0> = Rc::new(RefCell::new((lambda_0 {}))); |
| 15 | + assert!((({ lambda_0::operator_call_i32__int_const(4,) }) == 8)); |
| 16 | + assert!((({ lambda_0::operator_call_f64__double_const(1.5E+0,) }) == 3.0E+0)); |
| 17 | + let base: Value<i32> = Rc::new(RefCell::new(10)); |
| 18 | + let add_base: Value<lambda_1> = Rc::new(RefCell::new( |
| 19 | + (lambda_1 { |
| 20 | + base: Rc::new(RefCell::new((*base.borrow()))), |
| 21 | + }), |
| 22 | + )); |
| 23 | + assert!((({ lambda_1::operator_call_i32__int_const(&(*add_base.borrow_mut()), 5,) }) == 15)); |
| 24 | + assert!( |
| 25 | + (({ lambda_1::operator_call_f64__double_const(&(*add_base.borrow_mut()), 2.5E+0,) }) |
| 26 | + == 1.25E+1) |
| 27 | + ); |
| 28 | + let total: Value<i32> = Rc::new(RefCell::new(0)); |
| 29 | + let accumulate: Value<lambda_2> = Rc::new(RefCell::new( |
| 30 | + (lambda_2 { |
| 31 | + total: total.as_pointer(), |
| 32 | + }), |
| 33 | + )); |
| 34 | + ({ lambda_2::operator_call_i32_i32__int_int_const(&(*accumulate.borrow_mut()), 2, 3) }); |
| 35 | + ({ |
| 36 | + lambda_2::operator_call_u32_u32__unsigned_int_unsigned_int_const( |
| 37 | + &(*accumulate.borrow_mut()), |
| 38 | + 4_u32, |
| 39 | + 5_u32, |
| 40 | + ) |
| 41 | + }); |
| 42 | + assert!(((*total.borrow()) == 26)); |
| 43 | + let sub: Value<lambda_3> = Rc::new(RefCell::new((lambda_3 {}))); |
| 44 | + assert!((({ lambda_3::operator_call_i32_i32__int_const(9, 4,) }) == 5)); |
| 45 | + assert!((({ lambda_3::operator_call_f64_f64__double_const(2.5E+0, 1.0E+0,) }) == 1.5E+0)); |
| 46 | + let mixed: Value<lambda_4> = Rc::new(RefCell::new( |
| 47 | + (lambda_4 { |
| 48 | + base: Rc::new(RefCell::new((*base.borrow()))), |
| 49 | + }), |
| 50 | + )); |
| 51 | + assert!( |
| 52 | + (({ lambda_4::operator_call_i32_i32__int_int_const(&(*mixed.borrow_mut()), 2, 3,) }) == 16) |
| 53 | + ); |
| 54 | + assert!( |
| 55 | + (({ |
| 56 | + lambda_4::operator_call_i32_f64__int_double_const(&(*mixed.borrow_mut()), 2, 5.0E-1) |
| 57 | + }) == 1.1E+1) |
| 58 | + ); |
| 59 | + let cast_to: Value<lambda_5> = Rc::new(RefCell::new((lambda_5 {}))); |
| 60 | + assert!((({ lambda_5::operator_call_i32__int_const(5,) }) == 2)); |
| 61 | + assert!((({ lambda_5::operator_call_i32__double_const(5,) }) == 2.5E+0)); |
| 62 | + return 0; |
| 63 | +} |
| 64 | +#[derive(Clone, ByteRepr, Default)] |
| 65 | +pub struct lambda_0 {} |
| 66 | +impl lambda_0 { |
| 67 | + pub fn operator_call_i32__int_const(x: i32) -> i32 { |
| 68 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 69 | + return ((*x.borrow()) + (*x.borrow())); |
| 70 | + } |
| 71 | + pub fn operator_call_f64__double_const(x: f64) -> f64 { |
| 72 | + let x: Value<f64> = Rc::new(RefCell::new(x)); |
| 73 | + return ((*x.borrow()) + (*x.borrow())); |
| 74 | + } |
| 75 | +} |
| 76 | +impl Callable1<i32, i32> for lambda_0 { |
| 77 | + fn call(&self, a1: i32) -> i32 { |
| 78 | + { lambda_0::operator_call_i32__int_const(a1) } |
| 79 | + } |
| 80 | +} |
| 81 | +impl Callable1<f64, f64> for lambda_0 { |
| 82 | + fn call(&self, a1: f64) -> f64 { |
| 83 | + { lambda_0::operator_call_f64__double_const(a1) } |
| 84 | + } |
| 85 | +} |
| 86 | +#[derive(Default)] |
| 87 | +pub struct lambda_1 { |
| 88 | + base: Value<i32>, |
| 89 | +} |
| 90 | +impl lambda_1 { |
| 91 | + pub fn operator_call_i32__int_const(&self, x: i32) -> i32 { |
| 92 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 93 | + return ((*x.borrow()) + (*self.base.borrow())); |
| 94 | + } |
| 95 | + pub fn operator_call_f64__double_const(&self, x: f64) -> f64 { |
| 96 | + let x: Value<f64> = Rc::new(RefCell::new(x)); |
| 97 | + return ((*x.borrow()) + ((*self.base.borrow()) as f64)); |
| 98 | + } |
| 99 | +} |
| 100 | +impl Clone for lambda_1 { |
| 101 | + fn clone(&self) -> Self { |
| 102 | + Self { |
| 103 | + base: Rc::new(RefCell::new((*self.base.borrow()).clone())), |
| 104 | + } |
| 105 | + } |
| 106 | +} |
| 107 | +impl ByteRepr for lambda_1 { |
| 108 | + fn byte_size() -> usize { |
| 109 | + 4 |
| 110 | + } |
| 111 | + fn to_bytes(&self, buf: &mut [u8]) { |
| 112 | + (*self.base.borrow()).to_bytes(&mut buf[0..4]); |
| 113 | + } |
| 114 | + fn from_bytes(buf: &[u8]) -> Self { |
| 115 | + Self { |
| 116 | + base: Rc::new(RefCell::new(<i32>::from_bytes(&buf[0..4]))), |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | +impl Callable1<i32, i32> for lambda_1 { |
| 121 | + fn call(&self, a1: i32) -> i32 { |
| 122 | + { lambda_1::operator_call_i32__int_const(self, a1) } |
| 123 | + } |
| 124 | +} |
| 125 | +impl Callable1<f64, f64> for lambda_1 { |
| 126 | + fn call(&self, a1: f64) -> f64 { |
| 127 | + { lambda_1::operator_call_f64__double_const(self, a1) } |
| 128 | + } |
| 129 | +} |
| 130 | +#[derive(Clone, Default)] |
| 131 | +pub struct lambda_2 { |
| 132 | + total: Ptr<i32>, |
| 133 | +} |
| 134 | +impl lambda_2 { |
| 135 | + pub fn operator_call_i32_i32__int_int_const(&self, x: i32, y: i32) { |
| 136 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 137 | + let y: Value<i32> = Rc::new(RefCell::new(y)); |
| 138 | + { |
| 139 | + let _ptr = self.total.clone(); |
| 140 | + _ptr.write(_ptr.read() + ((*x.borrow()) * (*y.borrow()))) |
| 141 | + }; |
| 142 | + } |
| 143 | + pub fn operator_call_u32_u32__unsigned_int_unsigned_int_const(&self, x: u32, y: u32) { |
| 144 | + let x: Value<u32> = Rc::new(RefCell::new(x)); |
| 145 | + let y: Value<u32> = Rc::new(RefCell::new(y)); |
| 146 | + { |
| 147 | + let rhs_0 = (((self.total.read()) as u32) |
| 148 | + .wrapping_add((*x.borrow()).wrapping_mul((*y.borrow())))) |
| 149 | + as i32; |
| 150 | + self.total.write(rhs_0) |
| 151 | + }; |
| 152 | + } |
| 153 | +} |
| 154 | +impl ByteRepr for lambda_2 {} |
| 155 | +impl Callable2<i32, i32, ()> for lambda_2 { |
| 156 | + fn call(&self, a1: i32, a2: i32) -> () { |
| 157 | + { lambda_2::operator_call_i32_i32__int_int_const(self, a1, a2) } |
| 158 | + } |
| 159 | +} |
| 160 | +impl Callable2<u32, u32, ()> for lambda_2 { |
| 161 | + fn call(&self, a1: u32, a2: u32) -> () { |
| 162 | + { lambda_2::operator_call_u32_u32__unsigned_int_unsigned_int_const(self, a1, a2) } |
| 163 | + } |
| 164 | +} |
| 165 | +#[derive(Clone, ByteRepr, Default)] |
| 166 | +pub struct lambda_3 {} |
| 167 | +impl lambda_3 { |
| 168 | + pub fn operator_call_i32_i32__int_const(x: i32, y: i32) -> i32 { |
| 169 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 170 | + let y: Value<i32> = Rc::new(RefCell::new(y)); |
| 171 | + return ((*x.borrow()) - (*y.borrow())); |
| 172 | + } |
| 173 | + pub fn operator_call_f64_f64__double_const(x: f64, y: f64) -> f64 { |
| 174 | + let x: Value<f64> = Rc::new(RefCell::new(x)); |
| 175 | + let y: Value<f64> = Rc::new(RefCell::new(y)); |
| 176 | + return ((*x.borrow()) - (*y.borrow())); |
| 177 | + } |
| 178 | +} |
| 179 | +impl Callable2<i32, i32, i32> for lambda_3 { |
| 180 | + fn call(&self, a1: i32, a2: i32) -> i32 { |
| 181 | + { lambda_3::operator_call_i32_i32__int_const(a1, a2) } |
| 182 | + } |
| 183 | +} |
| 184 | +impl Callable2<f64, f64, f64> for lambda_3 { |
| 185 | + fn call(&self, a1: f64, a2: f64) -> f64 { |
| 186 | + { lambda_3::operator_call_f64_f64__double_const(a1, a2) } |
| 187 | + } |
| 188 | +} |
| 189 | +#[derive(Default)] |
| 190 | +pub struct lambda_4 { |
| 191 | + base: Value<i32>, |
| 192 | +} |
| 193 | +impl lambda_4 { |
| 194 | + pub fn operator_call_i32_i32__int_int_const(&self, x: i32, y: i32) -> i32 { |
| 195 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 196 | + let y: Value<i32> = Rc::new(RefCell::new(y)); |
| 197 | + return (((*x.borrow()) * (*y.borrow())) + (*self.base.borrow())); |
| 198 | + } |
| 199 | + pub fn operator_call_i32_f64__int_double_const(&self, x: i32, y: f64) -> f64 { |
| 200 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 201 | + let y: Value<f64> = Rc::new(RefCell::new(y)); |
| 202 | + return ((((*x.borrow()) as f64) * (*y.borrow())) + ((*self.base.borrow()) as f64)); |
| 203 | + } |
| 204 | +} |
| 205 | +impl Clone for lambda_4 { |
| 206 | + fn clone(&self) -> Self { |
| 207 | + Self { |
| 208 | + base: Rc::new(RefCell::new((*self.base.borrow()).clone())), |
| 209 | + } |
| 210 | + } |
| 211 | +} |
| 212 | +impl ByteRepr for lambda_4 { |
| 213 | + fn byte_size() -> usize { |
| 214 | + 4 |
| 215 | + } |
| 216 | + fn to_bytes(&self, buf: &mut [u8]) { |
| 217 | + (*self.base.borrow()).to_bytes(&mut buf[0..4]); |
| 218 | + } |
| 219 | + fn from_bytes(buf: &[u8]) -> Self { |
| 220 | + Self { |
| 221 | + base: Rc::new(RefCell::new(<i32>::from_bytes(&buf[0..4]))), |
| 222 | + } |
| 223 | + } |
| 224 | +} |
| 225 | +impl Callable2<i32, i32, i32> for lambda_4 { |
| 226 | + fn call(&self, a1: i32, a2: i32) -> i32 { |
| 227 | + { lambda_4::operator_call_i32_i32__int_int_const(self, a1, a2) } |
| 228 | + } |
| 229 | +} |
| 230 | +impl Callable2<i32, f64, f64> for lambda_4 { |
| 231 | + fn call(&self, a1: i32, a2: f64) -> f64 { |
| 232 | + { lambda_4::operator_call_i32_f64__int_double_const(self, a1, a2) } |
| 233 | + } |
| 234 | +} |
| 235 | +#[derive(Clone, ByteRepr, Default)] |
| 236 | +pub struct lambda_5 {} |
| 237 | +impl lambda_5 { |
| 238 | + pub fn operator_call_i32__int_const(x: i32) -> i32 { |
| 239 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 240 | + return (((*x.borrow()) as i32) / 2); |
| 241 | + } |
| 242 | + pub fn operator_call_i32__double_const(x: i32) -> f64 { |
| 243 | + let x: Value<i32> = Rc::new(RefCell::new(x)); |
| 244 | + return (((*x.borrow()) as f64) / 2_f64); |
| 245 | + } |
| 246 | +} |
| 247 | +pub fn __cpp2rust_init_globals() {} |
0 commit comments