@@ -1418,6 +1418,8 @@ public final FieldDesc fieldDescriptor() {
1418
1418
public static final class FieldLoadOp extends FieldAccessOp implements Op .Pure {
1419
1419
public static final String NAME = "field.load" ;
1420
1420
1421
+ final TypeElement resultType ;
1422
+
1421
1423
public static FieldLoadOp create (OpDefinition def ) {
1422
1424
if (def .operands ().size () > 1 ) {
1423
1425
throw new IllegalArgumentException ("Operation must accept zero or one operand" );
@@ -1434,10 +1436,14 @@ public static FieldLoadOp create(OpDefinition def) {
1434
1436
1435
1437
FieldLoadOp (OpDefinition opdef , FieldDesc fieldDescriptor ) {
1436
1438
super (opdef , fieldDescriptor );
1439
+
1440
+ resultType = opdef .resultType ();
1437
1441
}
1438
1442
1439
1443
FieldLoadOp (FieldLoadOp that , CopyContext cc ) {
1440
1444
super (that , cc );
1445
+
1446
+ resultType = that .resultType ();
1441
1447
}
1442
1448
1443
1449
@ Override
@@ -1446,20 +1452,22 @@ public FieldLoadOp transform(CopyContext cc, OpTransformer ot) {
1446
1452
}
1447
1453
1448
1454
// instance
1449
- FieldLoadOp (FieldDesc descriptor , Value receiver ) {
1450
- super (NAME ,
1451
- List .of (receiver ), descriptor );
1455
+ FieldLoadOp (TypeElement resultType , FieldDesc descriptor , Value receiver ) {
1456
+ super (NAME , List .of (receiver ), descriptor );
1457
+
1458
+ this .resultType = resultType ;
1452
1459
}
1453
1460
1454
1461
// static
1455
- FieldLoadOp (FieldDesc descriptor ) {
1456
- super (NAME ,
1457
- List .of (), descriptor );
1462
+ FieldLoadOp (TypeElement resultType , FieldDesc descriptor ) {
1463
+ super (NAME , List .of (), descriptor );
1464
+
1465
+ this .resultType = resultType ;
1458
1466
}
1459
1467
1460
1468
@ Override
1461
1469
public TypeElement resultType () {
1462
- return fieldDescriptor (). type () ;
1470
+ return resultType ;
1463
1471
}
1464
1472
}
1465
1473
@@ -3219,16 +3227,40 @@ public static NewOp newArray(TypeElement arrayType, Value length) {
3219
3227
* @return the field load operation
3220
3228
*/
3221
3229
public static FieldAccessOp .FieldLoadOp fieldLoad (FieldDesc descriptor , Value receiver ) {
3222
- return new FieldAccessOp .FieldLoadOp (descriptor , receiver );
3230
+ return new FieldAccessOp .FieldLoadOp (descriptor .type (), descriptor , receiver );
3231
+ }
3232
+
3233
+ /**
3234
+ * Creates a field load operation to a non-static field.
3235
+ *
3236
+ * @param resultType the result type of the operation
3237
+ * @param descriptor the field descriptor
3238
+ * @param receiver the receiver value
3239
+ * @return the field load operation
3240
+ */
3241
+ public static FieldAccessOp .FieldLoadOp fieldLoad (TypeElement resultType , FieldDesc descriptor , Value receiver ) {
3242
+ return new FieldAccessOp .FieldLoadOp (resultType , descriptor , receiver );
3223
3243
}
3224
3244
3225
3245
/**
3226
3246
* Creates a field load operation to a static field.
3227
3247
*
3248
+ * @param descriptor the field descriptor
3228
3249
* @return the field load operation
3229
3250
*/
3230
3251
public static FieldAccessOp .FieldLoadOp fieldLoad (FieldDesc descriptor ) {
3231
- return new FieldAccessOp .FieldLoadOp (descriptor );
3252
+ return new FieldAccessOp .FieldLoadOp (descriptor .type (), descriptor );
3253
+ }
3254
+
3255
+ /**
3256
+ * Creates a field load operation to a static field.
3257
+ *
3258
+ * @param resultType the result type of the operation
3259
+ * @param descriptor the field descriptor
3260
+ * @return the field load operation
3261
+ */
3262
+ public static FieldAccessOp .FieldLoadOp fieldLoad (TypeElement resultType , FieldDesc descriptor ) {
3263
+ return new FieldAccessOp .FieldLoadOp (resultType , descriptor );
3232
3264
}
3233
3265
3234
3266
/**
0 commit comments