@@ -977,31 +977,6 @@ public boolean getDefinedBoolean() {
977977 }
978978
979979 public RuntimeScalar preAutoIncrement () {
980- // Check if object is eligible for overloading
981- int blessId = blessedId (this );
982- if (blessId != 0 ) {
983- // Prepare overload context and check if object is eligible for overloading
984- OverloadContext ctx = OverloadContext .prepare (blessId );
985- if (ctx != null ) {
986- // Try direct overload method for ++
987- RuntimeScalar result = ctx .tryOverload ("(++" , new RuntimeArray (this ));
988- if (result != null ) {
989- // The ++ operator has already modified this operand
990- // Just return this (which has been modified)
991- return this ;
992- }
993-
994- // Try fallback to + operator with undef as third argument (mutator indicator)
995- result = ctx .tryOverload ("(+" , new RuntimeArray (this , scalarOne , scalarUndef ));
996- if (result != null ) {
997- // For fallback, + should NOT modify operand, so we handle assignment
998- this .type = result .type ;
999- this .value = result .value ;
1000- return this ;
1001- }
1002- }
1003- }
1004-
1005980 // Cases 0-11 are listed in order from RuntimeScalarType, and compile to fast tableswitch
1006981 switch (type ) {
1007982 case INTEGER -> { // 0
@@ -1051,6 +1026,31 @@ public RuntimeScalar preAutoIncrement() {
10511026 this .value = 1 ;
10521027 }
10531028 default -> { // All reference types (CODE, REFERENCE, ARRAYREFERENCE, etc.)
1029+ // Check if object is eligible for overloading
1030+ int blessId = blessedId (this );
1031+ if (blessId != 0 ) {
1032+ // Prepare overload context and check if object is eligible for overloading
1033+ OverloadContext ctx = OverloadContext .prepare (blessId );
1034+ if (ctx != null ) {
1035+ // Try direct overload method for ++
1036+ RuntimeScalar result = ctx .tryOverload ("(++" , new RuntimeArray (this ));
1037+ if (result != null ) {
1038+ // The ++ operator has already modified this operand
1039+ // Just return this (which has been modified)
1040+ return this ;
1041+ }
1042+
1043+ // Try fallback to + operator with undef as third argument (mutator indicator)
1044+ result = ctx .tryOverload ("(+" , new RuntimeArray (this , scalarOne , scalarUndef ));
1045+ if (result != null ) {
1046+ // For fallback, + should NOT modify operand, so we handle assignment
1047+ this .type = result .type ;
1048+ this .value = result .value ;
1049+ return this ;
1050+ }
1051+ }
1052+ }
1053+
10541054 this .type = RuntimeScalarType .INTEGER ;
10551055 this .value = 1 ;
10561056 }
@@ -1076,31 +1076,6 @@ private RuntimeScalar postAutoIncrementLarge() {
10761076 RuntimeScalar old = this .type == RuntimeScalarType .UNDEF ?
10771077 new RuntimeScalar (0 ) : new RuntimeScalar (this );
10781078
1079- // Check if object is eligible for overloading
1080- int blessId = blessedId (this );
1081- if (blessId != 0 ) {
1082- // Prepare overload context and check if object is eligible for overloading
1083- OverloadContext ctx = OverloadContext .prepare (blessId );
1084- if (ctx != null ) {
1085- // Try direct overload method for ++
1086- RuntimeScalar result = ctx .tryOverload ("(++" , new RuntimeArray (this ));
1087- if (result != null ) {
1088- // The ++ operator has already modified this operand
1089- // Return the old value
1090- return old ;
1091- }
1092-
1093- // Try fallback to + operator with undef as third argument (mutator indicator)
1094- result = ctx .tryOverload ("(+" , new RuntimeArray (this , scalarOne , scalarUndef ));
1095- if (result != null ) {
1096- // For fallback, + should NOT modify operand, so we handle assignment
1097- this .type = result .type ;
1098- this .value = result .value ;
1099- return old ;
1100- }
1101- }
1102- }
1103-
11041079 // Cases 0-11 are listed in order from RuntimeScalarType, and compile to fast tableswitch
11051080 switch (type ) {
11061081 case INTEGER -> { // 0
@@ -1149,6 +1124,31 @@ private RuntimeScalar postAutoIncrementLarge() {
11491124 this .value = 1 ;
11501125 }
11511126 default -> { // All reference types
1127+ // Check if object is eligible for overloading
1128+ int blessId = blessedId (this );
1129+ if (blessId != 0 ) {
1130+ // Prepare overload context and check if object is eligible for overloading
1131+ OverloadContext ctx = OverloadContext .prepare (blessId );
1132+ if (ctx != null ) {
1133+ // Try direct overload method for ++
1134+ RuntimeScalar result = ctx .tryOverload ("(++" , new RuntimeArray (this ));
1135+ if (result != null ) {
1136+ // The ++ operator has already modified this operand
1137+ // Return the old value
1138+ return old ;
1139+ }
1140+
1141+ // Try fallback to + operator with undef as third argument (mutator indicator)
1142+ result = ctx .tryOverload ("(+" , new RuntimeArray (this , scalarOne , scalarUndef ));
1143+ if (result != null ) {
1144+ // For fallback, + should NOT modify operand, so we handle assignment
1145+ this .type = result .type ;
1146+ this .value = result .value ;
1147+ return old ;
1148+ }
1149+ }
1150+ }
1151+
11521152 this .type = RuntimeScalarType .INTEGER ;
11531153 this .value = 1 ;
11541154 }
@@ -1157,31 +1157,6 @@ private RuntimeScalar postAutoIncrementLarge() {
11571157 }
11581158
11591159 public RuntimeScalar preAutoDecrement () {
1160- // Check if object is eligible for overloading
1161- int blessId = blessedId (this );
1162- if (blessId != 0 ) {
1163- // Prepare overload context and check if object is eligible for overloading
1164- OverloadContext ctx = OverloadContext .prepare (blessId );
1165- if (ctx != null ) {
1166- // Try direct overload method for --
1167- RuntimeScalar result = ctx .tryOverload ("(--" , new RuntimeArray (this ));
1168- if (result != null ) {
1169- // The -- operator has already modified this operand
1170- // Just return this (which has been modified)
1171- return this ;
1172- }
1173-
1174- // Try fallback to - operator with undef as third argument (mutator indicator)
1175- result = ctx .tryOverload ("(-" , new RuntimeArray (this , scalarOne , scalarUndef ));
1176- if (result != null ) {
1177- // For fallback, - should NOT modify operand, so we handle assignment
1178- this .type = result .type ;
1179- this .value = result .value ;
1180- return this ;
1181- }
1182- }
1183- }
1184-
11851160 // Cases 0-11 are listed in order from RuntimeScalarType, and compile to fast tableswitch
11861161 switch (type ) {
11871162 case INTEGER -> // 0
@@ -1229,6 +1204,31 @@ public RuntimeScalar preAutoDecrement() {
12291204 this .value = -1 ;
12301205 }
12311206 default -> { // All reference types
1207+ // Check if object is eligible for overloading
1208+ int blessId = blessedId (this );
1209+ if (blessId != 0 ) {
1210+ // Prepare overload context and check if object is eligible for overloading
1211+ OverloadContext ctx = OverloadContext .prepare (blessId );
1212+ if (ctx != null ) {
1213+ // Try direct overload method for --
1214+ RuntimeScalar result = ctx .tryOverload ("(--" , new RuntimeArray (this ));
1215+ if (result != null ) {
1216+ // The -- operator has already modified this operand
1217+ // Just return this (which has been modified)
1218+ return this ;
1219+ }
1220+
1221+ // Try fallback to - operator with undef as third argument (mutator indicator)
1222+ result = ctx .tryOverload ("(-" , new RuntimeArray (this , scalarOne , scalarUndef ));
1223+ if (result != null ) {
1224+ // For fallback, - should NOT modify operand, so we handle assignment
1225+ this .type = result .type ;
1226+ this .value = result .value ;
1227+ return this ;
1228+ }
1229+ }
1230+ }
1231+
12321232 this .type = RuntimeScalarType .INTEGER ;
12331233 this .value = -1 ;
12341234 }
@@ -1243,31 +1243,6 @@ public boolean isBlessed() {
12431243 public RuntimeScalar postAutoDecrement () {
12441244 RuntimeScalar old = new RuntimeScalar (this );
12451245
1246- // Check if object is eligible for overloading
1247- int blessId = blessedId (this );
1248- if (blessId != 0 ) {
1249- // Prepare overload context and check if object is eligible for overloading
1250- OverloadContext ctx = OverloadContext .prepare (blessId );
1251- if (ctx != null ) {
1252- // Try direct overload method for --
1253- RuntimeScalar result = ctx .tryOverload ("(--" , new RuntimeArray (this ));
1254- if (result != null ) {
1255- // The -- operator has already modified this operand
1256- // Return the old value
1257- return old ;
1258- }
1259-
1260- // Try fallback to - operator with undef as third argument (mutator indicator)
1261- result = ctx .tryOverload ("(-" , new RuntimeArray (this , scalarOne , scalarUndef ));
1262- if (result != null ) {
1263- // For fallback, - should NOT modify operand, so we handle assignment
1264- this .type = result .type ;
1265- this .value = result .value ;
1266- return old ;
1267- }
1268- }
1269- }
1270-
12711246 // Cases 0-11 are listed in order from RuntimeScalarType, and compile to fast tableswitch
12721247 switch (type ) {
12731248 case INTEGER -> // 0
@@ -1314,6 +1289,31 @@ public RuntimeScalar postAutoDecrement() {
13141289 this .value = -1 ;
13151290 }
13161291 default -> { // All reference types
1292+ // Check if object is eligible for overloading
1293+ int blessId = blessedId (this );
1294+ if (blessId != 0 ) {
1295+ // Prepare overload context and check if object is eligible for overloading
1296+ OverloadContext ctx = OverloadContext .prepare (blessId );
1297+ if (ctx != null ) {
1298+ // Try direct overload method for --
1299+ RuntimeScalar result = ctx .tryOverload ("(--" , new RuntimeArray (this ));
1300+ if (result != null ) {
1301+ // The -- operator has already modified this operand
1302+ // Return the old value
1303+ return old ;
1304+ }
1305+
1306+ // Try fallback to - operator with undef as third argument (mutator indicator)
1307+ result = ctx .tryOverload ("(-" , new RuntimeArray (this , scalarOne , scalarUndef ));
1308+ if (result != null ) {
1309+ // For fallback, - should NOT modify operand, so we handle assignment
1310+ this .type = result .type ;
1311+ this .value = result .value ;
1312+ return old ;
1313+ }
1314+ }
1315+ }
1316+
13171317 this .type = RuntimeScalarType .INTEGER ;
13181318 this .value = -1 ;
13191319 }
0 commit comments