|
@@ -65,6 +65,7 @@ import static org.openzen.zenscript.codemodel.type.member.BuiltinID.*;
|
65
|
65
|
import static org.openzen.zencode.shared.CodePosition.BUILTIN;
|
66
|
66
|
import org.openzen.zenscript.codemodel.Module;
|
67
|
67
|
import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
|
|
68
|
+import org.openzen.zenscript.codemodel.expression.CallArguments;
|
68
|
69
|
import org.openzen.zenscript.codemodel.expression.ConstantUSizeExpression;
|
69
|
70
|
import org.openzen.zenscript.codemodel.member.IteratorMember;
|
70
|
71
|
import org.openzen.zenscript.codemodel.type.InvalidTypeID;
|
|
@@ -1158,15 +1159,51 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
|
1158
|
1159
|
inc(builtin, FLOAT_INC, FLOAT);
|
1159
|
1160
|
dec(builtin, FLOAT_DEC, FLOAT);
|
1160
|
1161
|
|
|
1162
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, BYTE, FLOAT, BYTE_TO_FLOAT);
|
|
1163
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, SBYTE, FLOAT, SBYTE_TO_FLOAT);
|
|
1164
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, SHORT, FLOAT, SHORT_TO_FLOAT);
|
|
1165
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, USHORT, FLOAT, USHORT_TO_FLOAT);
|
|
1166
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, INT, FLOAT, INT_TO_FLOAT);
|
|
1167
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, UINT, FLOAT, UINT_TO_FLOAT);
|
|
1168
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, LONG, FLOAT, LONG_TO_FLOAT);
|
|
1169
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, ULONG, FLOAT, ULONG_TO_FLOAT);
|
|
1170
|
+ addWithCastedOperand(builtin, FLOAT_ADD_FLOAT, USIZE, FLOAT, USIZE_TO_FLOAT);
|
1161
|
1171
|
add(builtin, FLOAT_ADD_FLOAT, FLOAT, FLOAT);
|
1162
|
1172
|
add(builtin, DOUBLE_ADD_DOUBLE, DOUBLE, DOUBLE, FLOAT_TO_DOUBLE);
|
1163
|
1173
|
|
|
1174
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, BYTE, FLOAT, BYTE_TO_FLOAT);
|
|
1175
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, SBYTE, FLOAT, SBYTE_TO_FLOAT);
|
|
1176
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, SHORT, FLOAT, SHORT_TO_FLOAT);
|
|
1177
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, USHORT, FLOAT, USHORT_TO_FLOAT);
|
|
1178
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, INT, FLOAT, INT_TO_FLOAT);
|
|
1179
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, UINT, FLOAT, UINT_TO_FLOAT);
|
|
1180
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, LONG, FLOAT, LONG_TO_FLOAT);
|
|
1181
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, ULONG, FLOAT, ULONG_TO_FLOAT);
|
|
1182
|
+ subWithCastedOperand(builtin, FLOAT_SUB_FLOAT, USIZE, FLOAT, USIZE_TO_FLOAT);
|
1164
|
1183
|
sub(builtin, FLOAT_SUB_FLOAT, FLOAT, FLOAT);
|
1165
|
1184
|
sub(builtin, DOUBLE_SUB_DOUBLE, DOUBLE, DOUBLE, LONG_TO_DOUBLE);
|
1166
|
1185
|
|
|
1186
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, BYTE, FLOAT, BYTE_TO_FLOAT);
|
|
1187
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, SBYTE, FLOAT, SBYTE_TO_FLOAT);
|
|
1188
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, SHORT, FLOAT, SHORT_TO_FLOAT);
|
|
1189
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, USHORT, FLOAT, USHORT_TO_FLOAT);
|
|
1190
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, INT, FLOAT, INT_TO_FLOAT);
|
|
1191
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, UINT, FLOAT, UINT_TO_FLOAT);
|
|
1192
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, LONG, FLOAT, LONG_TO_FLOAT);
|
|
1193
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, ULONG, FLOAT, ULONG_TO_FLOAT);
|
|
1194
|
+ mulWithCastedOperand(builtin, FLOAT_MUL_FLOAT, USIZE, FLOAT, USIZE_TO_FLOAT);
|
1167
|
1195
|
mul(builtin, FLOAT_MUL_FLOAT, FLOAT, FLOAT);
|
1168
|
1196
|
mul(builtin, DOUBLE_MUL_DOUBLE, DOUBLE, DOUBLE, LONG_TO_DOUBLE);
|
1169
|
1197
|
|
|
1198
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, BYTE, FLOAT, BYTE_TO_FLOAT);
|
|
1199
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, SBYTE, FLOAT, SBYTE_TO_FLOAT);
|
|
1200
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, SHORT, FLOAT, SHORT_TO_FLOAT);
|
|
1201
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, USHORT, FLOAT, USHORT_TO_FLOAT);
|
|
1202
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, INT, FLOAT, INT_TO_FLOAT);
|
|
1203
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, UINT, FLOAT, UINT_TO_FLOAT);
|
|
1204
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, LONG, FLOAT, LONG_TO_FLOAT);
|
|
1205
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, ULONG, FLOAT, ULONG_TO_FLOAT);
|
|
1206
|
+ divWithCastedOperand(builtin, FLOAT_DIV_FLOAT, USIZE, FLOAT, USIZE_TO_FLOAT);
|
1170
|
1207
|
div(builtin, FLOAT_DIV_FLOAT, FLOAT, FLOAT);
|
1171
|
1208
|
div(builtin, DOUBLE_DIV_DOUBLE, DOUBLE, DOUBLE, LONG_TO_DOUBLE);
|
1172
|
1209
|
|
|
@@ -1267,6 +1304,13 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
|
1267
|
1304
|
members.getOrCreateGroup(member.operator).addMethod(method, TypeMemberPriority.SPECIFIED);
|
1268
|
1305
|
}
|
1269
|
1306
|
|
|
1307
|
+ private void castedOperandCall(OperatorMember member, StoredType toType, BuiltinID casterBuiltin) {
|
|
1308
|
+ CasterMemberRef caster = castImplicitRef(member.definition, casterBuiltin, toType);
|
|
1309
|
+ TranslatedOperatorMemberRef method = new TranslatedOperatorMemberRef(member, members.type, GenericMapper.EMPTY,
|
|
1310
|
+ call -> member.ref(members.type, null).call(call.position, call.target, new CallArguments(caster.cast(call.position, call.arguments.arguments[0], true)), call.scope));
|
|
1311
|
+ members.getOrCreateGroup(member.operator).addMethod(method, TypeMemberPriority.SPECIFIED);
|
|
1312
|
+ }
|
|
1313
|
+
|
1270
|
1314
|
private void register(IDefinitionMember member) {
|
1271
|
1315
|
member.registerTo(members, TypeMemberPriority.SPECIFIED, null);
|
1272
|
1316
|
}
|
|
@@ -1347,6 +1391,10 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
|
1347
|
1391
|
castedTargetCall(addOp(definition, id, operand.stored, result.stored), result.stored, caster);
|
1348
|
1392
|
}
|
1349
|
1393
|
|
|
1394
|
+ private void addWithCastedOperand(HighLevelDefinition definition, BuiltinID id, BasicTypeID operand, BasicTypeID result, BuiltinID caster) {
|
|
1395
|
+ castedOperandCall(addOp(definition, id, operand.stored, result.stored), operand.stored, caster);
|
|
1396
|
+ }
|
|
1397
|
+
|
1350
|
1398
|
private OperatorMember subOp(HighLevelDefinition cls, BuiltinID id, StoredType operand, StoredType result) {
|
1351
|
1399
|
return new OperatorMember(
|
1352
|
1400
|
BUILTIN,
|
|
@@ -1365,6 +1413,10 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
|
1365
|
1413
|
castedTargetCall(subOp(definition, id, operand.stored, result.stored), result.stored, caster);
|
1366
|
1414
|
}
|
1367
|
1415
|
|
|
1416
|
+ private void subWithCastedOperand(HighLevelDefinition definition, BuiltinID id, BasicTypeID operand, BasicTypeID result, BuiltinID caster) {
|
|
1417
|
+ castedOperandCall(subOp(definition, id, operand.stored, result.stored), operand.stored, caster);
|
|
1418
|
+ }
|
|
1419
|
+
|
1368
|
1420
|
private OperatorMember mulOp(HighLevelDefinition cls, BuiltinID id, StoredType operand, StoredType result) {
|
1369
|
1421
|
return new OperatorMember(
|
1370
|
1422
|
BUILTIN,
|
|
@@ -1383,6 +1435,10 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
|
1383
|
1435
|
castedTargetCall(mulOp(definition, id, operand.stored, result.stored), result.stored, caster);
|
1384
|
1436
|
}
|
1385
|
1437
|
|
|
1438
|
+ private void mulWithCastedOperand(HighLevelDefinition definition, BuiltinID id, BasicTypeID operand, BasicTypeID result, BuiltinID caster) {
|
|
1439
|
+ castedOperandCall(mulOp(definition, id, operand.stored, result.stored), operand.stored, caster);
|
|
1440
|
+ }
|
|
1441
|
+
|
1386
|
1442
|
private OperatorMember divOp(HighLevelDefinition cls, BuiltinID id, StoredType operand, StoredType result) {
|
1387
|
1443
|
return new OperatorMember(
|
1388
|
1444
|
BUILTIN,
|
|
@@ -1401,6 +1457,10 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
|
1401
|
1457
|
castedTargetCall(divOp(definition, id, operand.stored, result.stored), result.stored, caster);
|
1402
|
1458
|
}
|
1403
|
1459
|
|
|
1460
|
+ private void divWithCastedOperand(HighLevelDefinition definition, BuiltinID id, BasicTypeID operand, BasicTypeID result, BuiltinID caster) {
|
|
1461
|
+ castedOperandCall(divOp(definition, id, operand.stored, result.stored), operand.stored, caster);
|
|
1462
|
+ }
|
|
1463
|
+
|
1404
|
1464
|
private OperatorMember modOp(HighLevelDefinition cls, BuiltinID id, StoredType operand, StoredType result) {
|
1405
|
1465
|
return new OperatorMember(
|
1406
|
1466
|
BUILTIN,
|