Skip to content

Commit bf1537c

Browse files
committed
Add unary and binary ops for doubles
1 parent 286b87f commit bf1537c

File tree

3 files changed

+301
-45
lines changed

3 files changed

+301
-45
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,8 @@ PInt pos(PInt arg) {
13431343
@GenerateNodeFactory
13441344
@TypeSystemReference(PythonArithmeticTypes.class)
13451345
public abstract static class NegNode extends PythonUnaryBuiltinNode {
1346+
public abstract Object execute(int value);
1347+
13461348
@Specialization(rewriteOn = ArithmeticException.class)
13471349
static int neg(int arg) {
13481350
return Math.negateExact(arg);
@@ -1373,6 +1375,10 @@ PInt doPInt(PInt operand) {
13731375
static BigInteger negate(BigInteger value) {
13741376
return value.negate();
13751377
}
1378+
1379+
public static NegNode create() {
1380+
return IntBuiltinsFactory.NegNodeFactory.create();
1381+
}
13761382
}
13771383

13781384
@Builtin(name = J___INVERT__, minNumOfPositionalArgs = 1)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/OpCodes.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,17 @@ public enum OpCodes {
699699
UNARY_OP_O_O(UNARY_OP, QuickeningTypes.OBJECT, QuickeningTypes.OBJECT),
700700
UNARY_OP_I_O(UNARY_OP, QuickeningTypes.INT, QuickeningTypes.OBJECT),
701701
UNARY_OP_I_I(UNARY_OP, QuickeningTypes.INT, QuickeningTypes.INT, UNARY_OP_I_O),
702+
UNARY_OP_D_O(UNARY_OP, QuickeningTypes.DOUBLE, QuickeningTypes.OBJECT),
703+
UNARY_OP_D_D(UNARY_OP, QuickeningTypes.DOUBLE, QuickeningTypes.DOUBLE, UNARY_OP_D_O),
702704
UNARY_OP_B_O(UNARY_OP, QuickeningTypes.BOOLEAN, QuickeningTypes.OBJECT),
703705
UNARY_OP_B_B(UNARY_OP, QuickeningTypes.BOOLEAN, QuickeningTypes.BOOLEAN, UNARY_OP_I_O),
704706
BINARY_OP_OO_O(BINARY_OP, QuickeningTypes.OBJECT, QuickeningTypes.OBJECT),
705707
BINARY_OP_II_O(BINARY_OP, QuickeningTypes.INT, QuickeningTypes.OBJECT),
706708
BINARY_OP_II_I(BINARY_OP, QuickeningTypes.INT, QuickeningTypes.INT, BINARY_OP_II_O),
707709
BINARY_OP_II_B(BINARY_OP, QuickeningTypes.INT, QuickeningTypes.BOOLEAN, BINARY_OP_II_O),
710+
BINARY_OP_DD_O(BINARY_OP, QuickeningTypes.DOUBLE, QuickeningTypes.OBJECT),
711+
BINARY_OP_DD_D(BINARY_OP, QuickeningTypes.DOUBLE, QuickeningTypes.DOUBLE, BINARY_OP_DD_O),
712+
BINARY_OP_DD_B(BINARY_OP, QuickeningTypes.DOUBLE, QuickeningTypes.BOOLEAN, BINARY_OP_DD_O),
708713
FOR_ITER_O(FOR_ITER, 0, QuickeningTypes.OBJECT),
709714
FOR_ITER_I(FOR_ITER, 0, QuickeningTypes.INT, FOR_ITER_O),
710715
POP_AND_JUMP_IF_FALSE_O(POP_AND_JUMP_IF_FALSE, QuickeningTypes.OBJECT, 0),

0 commit comments

Comments
 (0)