GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

muctx.rs 11.7 KB
Newer Older
1 2
use super::common::*;

3
pub struct MuCtx {
4
    /// ref to MuVM
5
    mvm: *const MuVM,
6 7 8 9 10

    /// Point to the C-visible CMuCtx so that `close_context` can deallocate itself.
    pub c_struct: *mut CMuCtx,
}

11 12
impl MuCtx {
    pub fn new(mvm: *const MuVM) -> Box<MuCtx> {
13 14 15 16 17 18 19 20
        Box::new(MuCtx {
            mvm: mvm,
            c_struct: ptr::null_mut(),
        })
    }

    #[inline(always)]
    fn get_mvm(&mut self) -> &MuVM {
21 22
        //self.mvm
        unsafe { & *self.mvm }
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    }

    pub fn id_of(&mut self, name: MuName) -> MuID {
        self.get_mvm().id_of(name)
    }

    pub fn name_of(&mut self, id: MuID) -> CMuCString {
        self.get_mvm().name_of(id)
    }

    fn deallocate(&mut self) {
        let c_struct = self.c_struct;
        let ctx_ptr = self as *mut MuCtx;
        debug!("Deallocating MuCtx {:?} and CMuCtx {:?}...", ctx_ptr, c_struct);
        unsafe {
            Box::from_raw(c_struct);
            Box::from_raw(ctx_ptr);
        }
    }

    pub fn close_context(&mut self) {
        info!("Closing MuCtx...");
        self.deallocate();
    }

    pub fn load_bundle(&mut self, buf: &[c_char]) {
        panic!("The fast implementation does not support the text form.")
    }

    pub fn load_hail(&mut self, buf: &[c_char]) {
        panic!("The fast implementation does not support the text form.")
    }

56
    pub fn handle_from_sint8(&mut self, num: i8, len: c_int) -> *const APIHandle {
57 58 59
        panic!("Not implemented")
    }

60
    pub fn handle_from_uint8(&mut self, num: u8, len: c_int) -> *const APIHandle {
61 62 63
        panic!("Not implemented")
    }

64
    pub fn handle_from_sint16(&mut self, num: i16, len: c_int) -> *const APIHandle {
65 66 67
        panic!("Not implemented")
    }

68
    pub fn handle_from_uint16(&mut self, num: u16, len: c_int) -> *const APIHandle {
69 70 71
        panic!("Not implemented")
    }

72
    pub fn handle_from_sint32(&mut self, num: i32, len: c_int) -> *const APIHandle {
73 74 75
        panic!("Not implemented")
    }

76
    pub fn handle_from_uint32(&mut self, num: u32, len: c_int) -> *const APIHandle {
77 78 79
        panic!("Not implemented")
    }

80
    pub fn handle_from_sint64(&mut self, num: i64, len: c_int) -> *const APIHandle {
81 82 83
        panic!("Not implemented")
    }

84
    pub fn handle_from_uint64(&mut self, num: u64, len: c_int) -> *const APIHandle {
85 86 87
        panic!("Not implemented")
    }

88
    pub fn handle_from_uint64s(&mut self, nums: &[u64], len: c_int) -> *const APIHandle {
89 90 91
        panic!("Not implemented")
    }

92
    pub fn handle_from_float(&mut self, num: f32) -> *const APIHandle {
93 94 95
        panic!("Not implemented")
    }

96
    pub fn handle_from_double(&mut self, num: f64) -> *const APIHandle {
97 98 99
        panic!("Not implemented")
    }

100
    pub fn handle_from_ptr(&mut self, mu_type: MuID, ptr: CMuCPtr) -> *const APIHandle {
101 102 103
        panic!("Not implemented")
    }

104
    pub fn handle_from_fp(&mut self, mu_type: MuID, fp: CMuCFP) -> *const APIHandle {
105 106 107
        panic!("Not implemented")
    }

108
    pub fn handle_to_sint8(&mut self, opnd: &APIHandle) -> i8 {
109 110 111
        panic!("Not implemented")
    }

112
    pub fn handle_to_uint8(&mut self, opnd: &APIHandle) -> u8 {
113 114 115
        panic!("Not implemented")
    }

116
    pub fn handle_to_sint16(&mut self, opnd: &APIHandle) -> i16 {
117 118 119
        panic!("Not implemented")
    }

120
    pub fn handle_to_uint16(&mut self, opnd: &APIHandle) -> u16 {
121 122 123
        panic!("Not implemented")
    }

124
    pub fn handle_to_sint32(&mut self, opnd: &APIHandle) -> i32 {
125 126 127
        panic!("Not implemented")
    }

128
    pub fn handle_to_uint32(&mut self, opnd: &APIHandle) -> u32 {
129 130 131
        panic!("Not implemented")
    }

132
    pub fn handle_to_sint64(&mut self, opnd: &APIHandle) -> i64 {
133 134 135
        panic!("Not implemented")
    }

136
    pub fn handle_to_uint64(&mut self, opnd: &APIHandle) -> u64 {
137 138 139
        panic!("Not implemented")
    }

140
    pub fn handle_to_float(&mut self, opnd: &APIHandle) -> f32 {
141 142 143
        panic!("Not implemented")
    }

144
    pub fn handle_to_double(&mut self, opnd: &APIHandle) -> f64 {
145 146 147
        panic!("Not implemented")
    }

148
    pub fn handle_to_ptr(&mut self, opnd: &APIHandle) -> CMuCPtr {
149 150 151
        panic!("Not implemented")
    }

152
    pub fn handle_to_fp(&mut self, opnd: &APIHandle) -> CMuCFP {
153 154 155
        panic!("Not implemented")
    }

156
    pub fn handle_from_const(&mut self, id: MuID) -> *const APIHandle {
157 158 159
        panic!("Not implemented")
    }

160
    pub fn handle_from_global(&mut self, id: MuID) -> *const APIHandle {
161 162 163
        panic!("Not implemented")
    }

164
    pub fn handle_from_func(&mut self, id: MuID) -> *const APIHandle {
165 166 167
        panic!("Not implemented")
    }

168
    pub fn handle_from_expose(&mut self, id: MuID) -> *const APIHandle {
169 170 171
        panic!("Not implemented")
    }

172
    pub fn delete_value(&mut self, opnd: &APIHandle) {
173 174 175
        panic!("Not implemented")
    }

176
    pub fn ref_eq(&mut self, lhs: &APIHandle, rhs: &APIHandle) -> bool {
177 178 179
        panic!("Not implemented")
    }

180
    pub fn ref_ult(&mut self, lhs: &APIHandle, rhs: &APIHandle) -> bool {
181 182 183
        panic!("Not implemented")
    }

184
    pub fn extract_value(&mut self, str: &APIHandle, index: c_int) -> *const APIHandle {
185 186 187
        panic!("Not implemented")
    }

188
    pub fn insert_value(&mut self, str: &APIHandle, index: c_int, newval: &APIHandle) -> *const APIHandle {
189 190 191
        panic!("Not implemented")
    }

192
    pub fn extract_element(&mut self, str: &APIHandle, index: &APIHandle) -> *const APIHandle {
193 194 195
        panic!("Not implemented")
    }

196
    pub fn insert_element(&mut self, str: &APIHandle, index: &APIHandle, newval: &APIHandle) -> *const APIHandle {
197 198 199
        panic!("Not implemented")
    }

200
    pub fn new_fixed(&mut self, mu_type: MuID) -> *const APIHandle {
201 202 203
        panic!("Not implemented")
    }

204
    pub fn new_hybrid(&mut self, mu_type: MuID, length: &APIHandle) -> *const APIHandle {
205 206 207
        panic!("Not implemented")
    }

208
    pub fn refcast(&mut self, opnd: &APIHandle, new_type: MuID) -> *const APIHandle {
209 210 211
        panic!("Not implemented")
    }

212
    pub fn get_iref(&mut self, opnd: &APIHandle) -> *const APIHandle {
213 214 215
        panic!("Not implemented")
    }

216
    pub fn get_field_iref(&mut self, opnd: &APIHandle, field: c_int) -> *const APIHandle {
217 218 219
        panic!("Not implemented")
    }

220
    pub fn get_elem_iref(&mut self, opnd: &APIHandle, index: &APIHandle) -> *const APIHandle {
221 222 223
        panic!("Not implemented")
    }

224
    pub fn shift_iref(&mut self, opnd: &APIHandle, offset: &APIHandle) -> *const APIHandle {
225 226 227
        panic!("Not implemented")
    }

228
    pub fn get_var_part_iref(&mut self, opnd: &APIHandle) -> *const APIHandle {
229 230 231
        panic!("Not implemented")
    }

232
    pub fn load(&mut self, ord: CMuMemOrd, loc: &APIHandle) -> *const APIHandle {
233 234 235
        panic!("Not implemented")
    }

236
    pub fn store(&mut self, ord: CMuMemOrd, loc: &APIHandle, newval: &APIHandle) {
237 238 239
        panic!("Not implemented")
    }

240
    pub fn cmpxchg(&mut self, ord_succ: CMuMemOrd, ord_fail: CMuMemOrd, weak: bool, loc: &APIHandle, expected: &APIHandle, desired: &APIHandle, is_succ: *mut CMuBool) -> *const APIHandle {
241 242 243
        panic!("Not implemented")
    }

244
    pub fn atomicrmw(&mut self, ord: CMuMemOrd, op: CMuAtomicRMWOptr, loc: &APIHandle, opnd: &APIHandle) -> *const APIHandle {
245 246 247 248 249 250 251
        panic!("Not implemented")
    }

    pub fn fence(&mut self, ord: CMuMemOrd) {
        panic!("Not implemented")
    }

252
    pub fn new_stack(&mut self, func: &APIHandle) -> *const APIHandle {
253 254 255
        panic!("Not implemented")
    }

256
    pub fn new_thread_nor(&mut self, stack: &APIHandle, threadlocal: Option<&APIHandle>, vals: Vec<&APIHandle>) -> *const APIHandle {
257 258 259
        panic!("Not implemented")
    }

260
    pub fn new_thread_exc(&mut self, stack: &APIHandle, threadlocal: Option<&APIHandle>, exc: &APIHandle) -> *const APIHandle {
261 262 263
        panic!("Not implemented")
    }

264
    pub fn kill_stack(&mut self, stack: &APIHandle) {
265 266 267
        panic!("Not implemented")
    }

268
    pub fn set_threadlocal(&mut self, thread: &APIHandle, threadlocal: &APIHandle) {
269 270 271
        panic!("Not implemented")
    }

272
    pub fn get_threadlocal(&mut self, thread: &APIHandle) -> *const APIHandle {
273 274 275
        panic!("Not implemented")
    }

276
    pub fn new_cursor(&mut self, stack: &APIHandle) -> *const APIHandle {
277 278 279
        panic!("Not implemented")
    }

280
    pub fn next_frame(&mut self, cursor: &APIHandle) {
281 282 283
        panic!("Not implemented")
    }

284
    pub fn copy_cursor(&mut self, cursor: &APIHandle) -> *const APIHandle {
285 286 287
        panic!("Not implemented")
    }

288
    pub fn close_cursor(&mut self, cursor: &APIHandle) {
289 290 291
        panic!("Not implemented")
    }

292
    pub fn cur_func(&mut self, cursor: &APIHandle) -> MuID {
293 294 295
        panic!("Not implemented")
    }

296
    pub fn cur_func_ver(&mut self, cursor: &APIHandle) -> MuID {
297 298 299
        panic!("Not implemented")
    }

300
    pub fn cur_inst(&mut self, cursor: &APIHandle) -> MuID {
301 302 303
        panic!("Not implemented")
    }

304
    pub fn dump_keepalives(&mut self, cursor: &APIHandle, results: *mut CMuValue) {
305 306 307
        panic!("Not implemented")
    }

308
    pub fn pop_frames_to(&mut self, cursor: &APIHandle) {
309 310 311
        panic!("Not implemented")
    }

312
    pub fn push_frame(&mut self, stack: &APIHandle, func: &APIHandle) {
313 314 315
        panic!("Not implemented")
    }

316
    pub fn tr64_is_fp(&mut self, value: &APIHandle) -> bool {
317 318 319
        panic!("Not implemented")
    }

320
    pub fn tr64_is_int(&mut self, value: &APIHandle) -> bool {
321 322 323
        panic!("Not implemented")
    }

324
    pub fn tr64_is_ref(&mut self, value: &APIHandle) -> bool {
325 326 327
        panic!("Not implemented")
    }

328
    pub fn tr64_to_fp(&mut self, value: &APIHandle) -> *const APIHandle {
329 330 331
        panic!("Not implemented")
    }

332
    pub fn tr64_to_int(&mut self, value: &APIHandle) -> *const APIHandle {
333 334 335
        panic!("Not implemented")
    }

336
    pub fn tr64_to_ref(&mut self, value: &APIHandle) -> *const APIHandle {
337 338 339
        panic!("Not implemented")
    }

340
    pub fn tr64_to_tag(&mut self, value: &APIHandle) -> *const APIHandle {
341 342 343
        panic!("Not implemented")
    }

344
    pub fn tr64_from_fp(&mut self, value: &APIHandle) -> *const APIHandle {
345 346 347
        panic!("Not implemented")
    }

348
    pub fn tr64_from_int(&mut self, value: &APIHandle) -> *const APIHandle {
349 350 351
        panic!("Not implemented")
    }

352
    pub fn tr64_from_ref(&mut self, reff: &APIHandle, tag: &APIHandle) -> *const APIHandle {
353 354 355 356 357 358 359 360 361 362 363
        panic!("Not implemented")
    }

    pub fn enable_watchpoint(&mut self, wpid: CMuWPID) {
        panic!("Not implemented")
    }

    pub fn disable_watchpoint(&mut self, wpid: CMuWPID) {
        panic!("Not implemented")
    }

364
    pub fn pin(&mut self, loc: &APIHandle) -> *const APIHandle {
365 366 367
        panic!("Not implemented")
    }

368
    pub fn unpin(&mut self, loc: &APIHandle) {
369 370 371
        panic!("Not implemented")
    }

372
    pub fn get_addr(&mut self, loc: &APIHandle) -> *const APIHandle {
373 374 375
        panic!("Not implemented")
    }

376
    pub fn expose(&mut self, func: &APIHandle, call_conv: CMuCallConv, cookie: &APIHandle) -> *const APIHandle {
377 378 379
        panic!("Not implemented")
    }

380
    pub fn unexpose(&mut self, call_conv: CMuCallConv, value: &APIHandle) {
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
        panic!("Not implemented")
    }

    pub fn new_ir_builder(&mut self) -> *mut CMuIRBuilder {
        info!("Creating MuIRBuilder...");

        let b: Box<MuIRBuilder> = MuIRBuilder::new(self.mvm);

        let b_ptr = Box::into_raw(b);

        debug!("The MuIRBuilder address: {:?}", b_ptr);

        let cb = make_new_MuIRBuilder(b_ptr as *mut c_void);

        debug!("The C-visible CMuIRBuilder struct address: {:?}", cb);

        unsafe{ (*b_ptr).c_struct = cb; }

        cb
    }

402
    pub fn make_boot_image(&mut self, whitelist: Vec<MuID>, primordial_func: Option<&APIHandle>, primordial_stack: Option<&APIHandle>, primordial_threadlocal: Option<&APIHandle>, sym_fields: Vec<&APIHandle>, sym_strings: Vec<String>, reloc_fields: Vec<&APIHandle>, reloc_strings: Vec<String>, output_file: String) {
403 404 405 406
        panic!("Not implemented")
    }

}