@@ -4,7 +4,6 @@ use self::inkwell::{AddressSpace, OptimizationLevel};
4
4
use self :: inkwell:: context:: Context ;
5
5
use self :: inkwell:: builder:: Builder ;
6
6
use self :: inkwell:: targets:: { InitializationConfig , Target } ;
7
- use self :: inkwell:: execution_engine:: Symbol ;
8
7
9
8
use std:: ffi:: CString ;
10
9
use std:: ptr:: null;
@@ -137,17 +136,17 @@ fn test_null_checked_ptr_ops() {
137
136
let execution_engine = module. create_jit_execution_engine ( OptimizationLevel :: None ) . unwrap ( ) ;
138
137
139
138
unsafe {
140
- let check_null_index1: Symbol < unsafe extern "C" fn ( * const i8 ) -> i8 > = execution_engine . get_function ( "check_null_index1" ) . unwrap ( ) ;
139
+ let check_null_index1 = execution_engine . get_function :: < unsafe extern "C" fn ( * const i8 ) -> i8 > ( "check_null_index1" ) . unwrap ( ) ;
141
140
142
141
let array = & [ 100i8 , 42i8 ] ;
143
142
144
- assert_eq ! ( check_null_index1( null( ) ) , -1i8 ) ;
145
- assert_eq ! ( check_null_index1( array. as_ptr( ) ) , 42i8 ) ;
143
+ assert_eq ! ( check_null_index1. call ( null( ) ) , -1i8 ) ;
144
+ assert_eq ! ( check_null_index1. call ( array. as_ptr( ) ) , 42i8 ) ;
146
145
147
- let check_null_index2: Symbol < unsafe extern "C" fn ( * const i8 ) -> i8 > = execution_engine . get_function ( "check_null_index2" ) . unwrap ( ) ;
146
+ let check_null_index2 = execution_engine . get_function :: < unsafe extern "C" fn ( * const i8 ) -> i8 > ( "check_null_index2" ) . unwrap ( ) ;
148
147
149
- assert_eq ! ( check_null_index2( null( ) ) , -1i8 ) ;
150
- assert_eq ! ( check_null_index2( array. as_ptr( ) ) , 42i8 ) ;
148
+ assert_eq ! ( check_null_index2. call ( null( ) ) , -1i8 ) ;
149
+ assert_eq ! ( check_null_index2. call ( array. as_ptr( ) ) , 42i8 ) ;
151
150
}
152
151
}
153
152
@@ -216,24 +215,24 @@ fn test_binary_ops() {
216
215
unsafe {
217
216
type BoolFunc = unsafe extern "C" fn ( bool , bool ) -> bool ;
218
217
219
- let and: Symbol < BoolFunc > = execution_engine. get_function ( "and" ) . unwrap ( ) ;
220
- let or: Symbol < BoolFunc > = execution_engine. get_function ( "or" ) . unwrap ( ) ;
221
- let xor: Symbol < BoolFunc > = execution_engine. get_function ( "xor" ) . unwrap ( ) ;
218
+ let and = execution_engine. get_function :: < BoolFunc > ( "and" ) . unwrap ( ) ;
219
+ let or = execution_engine. get_function :: < BoolFunc > ( "or" ) . unwrap ( ) ;
220
+ let xor = execution_engine. get_function :: < BoolFunc > ( "xor" ) . unwrap ( ) ;
222
221
223
- assert ! ( !and( false , false ) ) ;
224
- assert ! ( !and( true , false ) ) ;
225
- assert ! ( !and( false , true ) ) ;
226
- assert ! ( and( true , true ) ) ;
222
+ assert ! ( !and. call ( false , false ) ) ;
223
+ assert ! ( !and. call ( true , false ) ) ;
224
+ assert ! ( !and. call ( false , true ) ) ;
225
+ assert ! ( and. call ( true , true ) ) ;
227
226
228
- assert ! ( !or( false , false ) ) ;
229
- assert ! ( or( true , false ) ) ;
230
- assert ! ( or( false , true ) ) ;
231
- assert ! ( or( true , true ) ) ;
227
+ assert ! ( !or. call ( false , false ) ) ;
228
+ assert ! ( or. call ( true , false ) ) ;
229
+ assert ! ( or. call ( false , true ) ) ;
230
+ assert ! ( or. call ( true , true ) ) ;
232
231
233
- assert ! ( !xor( false , false ) ) ;
234
- assert ! ( xor( true , false ) ) ;
235
- assert ! ( xor( false , true ) ) ;
236
- assert ! ( !xor( true , true ) ) ;
232
+ assert ! ( !xor. call ( false , false ) ) ;
233
+ assert ! ( xor. call ( true , false ) ) ;
234
+ assert ! ( xor. call ( false , true ) ) ;
235
+ assert ! ( !xor. call ( true , true ) ) ;
237
236
}
238
237
}
239
238
@@ -287,13 +286,13 @@ fn test_switch() {
287
286
builder. build_return ( Some ( & double) ) ;
288
287
289
288
unsafe {
290
- let switch: Symbol < unsafe extern "C" fn ( u8 ) -> u8 > = execution_engine . get_function ( "switch" ) . unwrap ( ) ;
289
+ let switch = execution_engine . get_function :: < unsafe extern "C" fn ( u8 ) -> u8 > ( "switch" ) . unwrap ( ) ;
291
290
292
- assert_eq ! ( switch( 0 ) , 1 ) ;
293
- assert_eq ! ( switch( 1 ) , 2 ) ;
294
- assert_eq ! ( switch( 3 ) , 6 ) ;
295
- assert_eq ! ( switch( 10 ) , 20 ) ;
296
- assert_eq ! ( switch( 42 ) , 255 ) ;
291
+ assert_eq ! ( switch. call ( 0 ) , 1 ) ;
292
+ assert_eq ! ( switch. call ( 1 ) , 2 ) ;
293
+ assert_eq ! ( switch. call ( 3 ) , 6 ) ;
294
+ assert_eq ! ( switch. call ( 10 ) , 20 ) ;
295
+ assert_eq ! ( switch. call ( 42 ) , 255 ) ;
297
296
}
298
297
}
299
298
@@ -357,37 +356,37 @@ fn test_bit_shifts() {
357
356
builder. build_return ( Some ( & shift) ) ;
358
357
359
358
unsafe {
360
- let left_shift: Symbol < unsafe extern "C" fn ( u8 , u8 ) -> u8 > = execution_engine . get_function ( "left_shift" ) . unwrap ( ) ;
361
- let right_shift: Symbol < unsafe extern "C" fn ( u8 , u8 ) -> u8 > = execution_engine . get_function ( "right_shift" ) . unwrap ( ) ;
362
- let right_shift_sign_extend: Symbol < unsafe extern "C" fn ( i8 , u8 ) -> i8 > = execution_engine . get_function ( "right_shift_sign_extend" ) . unwrap ( ) ;
363
-
364
- assert_eq ! ( left_shift( 0 , 0 ) , 0 ) ;
365
- assert_eq ! ( left_shift( 0 , 4 ) , 0 ) ;
366
- assert_eq ! ( left_shift( 1 , 0 ) , 1 ) ;
367
- assert_eq ! ( left_shift( 1 , 1 ) , 2 ) ;
368
- assert_eq ! ( left_shift( 1 , 2 ) , 4 ) ;
369
- assert_eq ! ( left_shift( 1 , 3 ) , 8 ) ;
370
- assert_eq ! ( left_shift( 64 , 1 ) , 128 ) ;
371
-
372
- assert_eq ! ( right_shift( 128 , 1 ) , 64 ) ;
373
- assert_eq ! ( right_shift( 8 , 3 ) , 1 ) ;
374
- assert_eq ! ( right_shift( 4 , 2 ) , 1 ) ;
375
- assert_eq ! ( right_shift( 2 , 1 ) , 1 ) ;
376
- assert_eq ! ( right_shift( 1 , 0 ) , 1 ) ;
377
- assert_eq ! ( right_shift( 0 , 4 ) , 0 ) ;
378
- assert_eq ! ( right_shift( 0 , 0 ) , 0 ) ;
379
-
380
- assert_eq ! ( right_shift_sign_extend( 8 , 3 ) , 1 ) ;
381
- assert_eq ! ( right_shift_sign_extend( 4 , 2 ) , 1 ) ;
382
- assert_eq ! ( right_shift_sign_extend( 2 , 1 ) , 1 ) ;
383
- assert_eq ! ( right_shift_sign_extend( 1 , 0 ) , 1 ) ;
384
- assert_eq ! ( right_shift_sign_extend( 0 , 4 ) , 0 ) ;
385
- assert_eq ! ( right_shift_sign_extend( 0 , 0 ) , 0 ) ;
386
- assert_eq ! ( right_shift_sign_extend( -127 , 1 ) , -64 ) ;
387
- assert_eq ! ( right_shift_sign_extend( -127 , 8 ) , -1 ) ;
388
- assert_eq ! ( right_shift_sign_extend( -65 , 3 ) , -9 ) ;
389
- assert_eq ! ( right_shift_sign_extend( -64 , 3 ) , -8 ) ;
390
- assert_eq ! ( right_shift_sign_extend( -63 , 3 ) , -8 ) ;
359
+ let left_shift = execution_engine . get_function :: < unsafe extern "C" fn ( u8 , u8 ) -> u8 > ( "left_shift" ) . unwrap ( ) ;
360
+ let right_shift = execution_engine . get_function :: < unsafe extern "C" fn ( u8 , u8 ) -> u8 > ( "right_shift" ) . unwrap ( ) ;
361
+ let right_shift_sign_extend = execution_engine . get_function :: < unsafe extern "C" fn ( i8 , u8 ) -> i8 > ( "right_shift_sign_extend" ) . unwrap ( ) ;
362
+
363
+ assert_eq ! ( left_shift. call ( 0 , 0 ) , 0 ) ;
364
+ assert_eq ! ( left_shift. call ( 0 , 4 ) , 0 ) ;
365
+ assert_eq ! ( left_shift. call ( 1 , 0 ) , 1 ) ;
366
+ assert_eq ! ( left_shift. call ( 1 , 1 ) , 2 ) ;
367
+ assert_eq ! ( left_shift. call ( 1 , 2 ) , 4 ) ;
368
+ assert_eq ! ( left_shift. call ( 1 , 3 ) , 8 ) ;
369
+ assert_eq ! ( left_shift. call ( 64 , 1 ) , 128 ) ;
370
+
371
+ assert_eq ! ( right_shift. call ( 128 , 1 ) , 64 ) ;
372
+ assert_eq ! ( right_shift. call ( 8 , 3 ) , 1 ) ;
373
+ assert_eq ! ( right_shift. call ( 4 , 2 ) , 1 ) ;
374
+ assert_eq ! ( right_shift. call ( 2 , 1 ) , 1 ) ;
375
+ assert_eq ! ( right_shift. call ( 1 , 0 ) , 1 ) ;
376
+ assert_eq ! ( right_shift. call ( 0 , 4 ) , 0 ) ;
377
+ assert_eq ! ( right_shift. call ( 0 , 0 ) , 0 ) ;
378
+
379
+ assert_eq ! ( right_shift_sign_extend. call ( 8 , 3 ) , 1 ) ;
380
+ assert_eq ! ( right_shift_sign_extend. call ( 4 , 2 ) , 1 ) ;
381
+ assert_eq ! ( right_shift_sign_extend. call ( 2 , 1 ) , 1 ) ;
382
+ assert_eq ! ( right_shift_sign_extend. call ( 1 , 0 ) , 1 ) ;
383
+ assert_eq ! ( right_shift_sign_extend. call ( 0 , 4 ) , 0 ) ;
384
+ assert_eq ! ( right_shift_sign_extend. call ( 0 , 0 ) , 0 ) ;
385
+ assert_eq ! ( right_shift_sign_extend. call ( -127 , 1 ) , -64 ) ;
386
+ assert_eq ! ( right_shift_sign_extend. call ( -127 , 8 ) , -1 ) ;
387
+ assert_eq ! ( right_shift_sign_extend. call ( -65 , 3 ) , -9 ) ;
388
+ assert_eq ! ( right_shift_sign_extend. call ( -64 , 3 ) , -8 ) ;
389
+ assert_eq ! ( right_shift_sign_extend. call ( -63 , 3 ) , -8 ) ;
391
390
}
392
391
}
393
392
0 commit comments