@@ -100,7 +100,7 @@ pub fn convert_rvalue_to_operand<'a>(
100
100
for i in 0 ..array_size {
101
101
let index_operand = oomir:: Operand :: Constant ( oomir:: Constant :: I32 ( i as i32 ) ) ;
102
102
instructions. push ( oomir:: Instruction :: ArrayStore {
103
- array_var : temp_array_var. clone ( ) , // Store into temp array
103
+ array : temp_array_var. clone ( ) ,
104
104
index : index_operand,
105
105
value : oomir_elem_op. clone ( ) ,
106
106
} ) ;
@@ -135,7 +135,14 @@ pub fn convert_rvalue_to_operand<'a>(
135
135
let source_name = place_to_string ( source_place, tcx) ;
136
136
instructions. push ( oomir:: Instruction :: Length {
137
137
dest : temp_len_var. clone ( ) ,
138
- array_var : source_name,
138
+ array : oomir:: Operand :: Variable {
139
+ name : source_name,
140
+ ty : ty_to_oomir_type (
141
+ source_place. ty ( & mir. local_decls , tcx) . ty ,
142
+ tcx,
143
+ data_types,
144
+ ) ,
145
+ } ,
139
146
} ) ;
140
147
result_operand = oomir:: Operand :: Variable {
141
148
name : temp_len_var,
@@ -307,7 +314,7 @@ pub fn convert_rvalue_to_operand<'a>(
307
314
} ) ;
308
315
// Set fields on the *temporary* tuple
309
316
instructions. push ( oomir:: Instruction :: SetField {
310
- object_var : temp_tuple_var. clone ( ) ,
317
+ object : temp_tuple_var. clone ( ) ,
311
318
field_name : "field0" . to_string ( ) ,
312
319
value : oomir:: Operand :: Variable {
313
320
name : tmp_result_var,
@@ -317,7 +324,7 @@ pub fn convert_rvalue_to_operand<'a>(
317
324
owner_class : tuple_class_name. clone ( ) ,
318
325
} ) ;
319
326
instructions. push ( oomir:: Instruction :: SetField {
320
- object_var : temp_tuple_var. clone ( ) ,
327
+ object : temp_tuple_var. clone ( ) ,
321
328
field_name : "field1" . to_string ( ) ,
322
329
value : oomir:: Operand :: Variable {
323
330
name : tmp_overflow_var,
@@ -374,7 +381,7 @@ pub fn convert_rvalue_to_operand<'a>(
374
381
match oomir_src_operand {
375
382
oomir:: Operand :: Variable {
376
383
name : source_name,
377
- ty : _ ,
384
+ ty : var_ty ,
378
385
} => {
379
386
// Check if source is actually an array/slice/str type
380
387
let operand_place = match operand {
@@ -400,7 +407,10 @@ pub fn convert_rvalue_to_operand<'a>(
400
407
println ! ( "Info: Detected Length op via PtrMetadata." ) ;
401
408
instructions. push ( oomir:: Instruction :: Length {
402
409
dest : temp_unop_var. clone ( ) ,
403
- array_var : source_name,
410
+ array : oomir:: Operand :: Variable {
411
+ name : source_name,
412
+ ty : var_ty,
413
+ } ,
404
414
} ) ;
405
415
} else {
406
416
println ! (
@@ -481,7 +491,7 @@ pub fn convert_rvalue_to_operand<'a>(
481
491
let value_operand =
482
492
convert_operand ( mir_op, tcx, mir, data_types, & mut instructions) ;
483
493
instructions. push ( oomir:: Instruction :: SetField {
484
- object_var : temp_aggregate_var. clone ( ) ,
494
+ object : temp_aggregate_var. clone ( ) ,
485
495
field_name,
486
496
value : value_operand,
487
497
field_ty : element_oomir_type,
@@ -510,7 +520,7 @@ pub fn convert_rvalue_to_operand<'a>(
510
520
let index_operand =
511
521
oomir:: Operand :: Constant ( oomir:: Constant :: I32 ( i as i32 ) ) ;
512
522
instructions. push ( oomir:: Instruction :: ArrayStore {
513
- array_var : temp_aggregate_var. clone ( ) ,
523
+ array : temp_aggregate_var. clone ( ) ,
514
524
index : index_operand,
515
525
value : value_operand,
516
526
} ) ;
@@ -544,7 +554,7 @@ pub fn convert_rvalue_to_operand<'a>(
544
554
& mut instructions,
545
555
) ;
546
556
instructions. push ( oomir:: Instruction :: SetField {
547
- object_var : temp_aggregate_var. clone ( ) ,
557
+ object : temp_aggregate_var. clone ( ) ,
548
558
field_name,
549
559
value : value_operand,
550
560
field_ty : field_oomir_type,
@@ -686,7 +696,7 @@ pub fn convert_rvalue_to_operand<'a>(
686
696
& mut instructions,
687
697
) ;
688
698
instructions. push ( oomir:: Instruction :: SetField {
689
- object_var : temp_aggregate_var. clone ( ) ,
699
+ object : temp_aggregate_var. clone ( ) ,
690
700
field_name,
691
701
value : value_operand,
692
702
field_ty : field_oomir_type,
@@ -768,34 +778,37 @@ pub fn convert_rvalue_to_operand<'a>(
768
778
// 1. Generate instructions to get the actual value from the place
769
779
let ( actual_value_var_name, get_instructions, actual_value_oomir_type) =
770
780
emit_instructions_to_get_on_own ( place, tcx, mir, data_types) ;
771
-
781
+
772
782
// Add the instructions needed to get the value (e.g., ArrayGet)
773
783
instructions. extend ( get_instructions) ;
774
-
784
+
775
785
// 2. Now operate on the variable holding the actual value
776
786
let temp_discriminant_var = generate_temp_var_name ( & base_temp_name) ;
777
-
787
+
778
788
let place_class_name = match actual_value_oomir_type. clone ( ) {
779
789
oomir:: Type :: Class ( name) => name. clone ( ) ,
780
790
// Handle potential references if get_on_own returns Ref(Class)
781
791
oomir:: Type :: Reference ( inner) => {
782
- if let oomir:: Type :: Class ( name) = inner. as_ref ( ) {
792
+ if let oomir:: Type :: Class ( name) = inner. as_ref ( ) {
783
793
name. clone ( )
784
- } else {
785
- panic ! ( "Discriminant on Ref to non-class type: {:?}" , inner)
786
- }
794
+ } else {
795
+ panic ! ( "Discriminant on Ref to non-class type: {:?}" , inner)
796
+ }
787
797
}
788
- _ => panic ! ( "Discriminant on non-class type: {:?}" , actual_value_oomir_type) ,
798
+ _ => panic ! (
799
+ "Discriminant on non-class type: {:?}" ,
800
+ actual_value_oomir_type
801
+ ) ,
789
802
} ;
790
-
803
+
791
804
let method_name = "getVariantIdx" . to_string ( ) ;
792
805
let method_return_type = oomir:: Type :: I32 ;
793
-
806
+
794
807
let method_ty = oomir:: Signature {
795
808
params : vec ! [ ] ,
796
809
ret : Box :: new ( method_return_type. clone ( ) ) ,
797
810
} ;
798
-
811
+
799
812
// 3. Call InvokeVirtual on the CORRECT variable
800
813
instructions. push ( oomir:: Instruction :: InvokeVirtual {
801
814
class_name : place_class_name. clone ( ) ,
@@ -808,13 +821,13 @@ pub fn convert_rvalue_to_operand<'a>(
808
821
ty : actual_value_oomir_type,
809
822
} ,
810
823
} ) ;
811
-
824
+
812
825
// 4. The result is the temporary variable holding the discriminant value
813
826
result_operand = oomir:: Operand :: Variable {
814
827
name : temp_discriminant_var,
815
828
ty : method_return_type, // Should be I32
816
829
} ;
817
- }
830
+ }
818
831
// Handle other Rvalue variants by generating a placeholder
819
832
_ => {
820
833
println ! (
0 commit comments