Skip to content

Commit 9fb519b

Browse files
committed
Small refactoring.
1 parent 4eea65f commit 9fb519b

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
import com.oracle.graal.python.nodes.object.GetClassNode;
122122
import com.oracle.graal.python.nodes.subscript.GetItemNode;
123123
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
124-
import com.oracle.graal.python.nodes.util.ConvertToIntNode;
124+
import com.oracle.graal.python.nodes.util.CastToIntNode;
125125
import com.oracle.graal.python.runtime.PythonContext;
126126
import com.oracle.graal.python.runtime.PythonCore;
127127
import com.oracle.graal.python.runtime.PythonOptions;
@@ -237,7 +237,7 @@ public String doPI(PInt x) {
237237

238238
@Specialization
239239
public String doO(Object x,
240-
@Cached("create()") ConvertToIntNode toIntNode,
240+
@Cached("create()") CastToIntNode toIntNode,
241241
@Cached("create()") BinNode recursiveNode) {
242242
Object value = toIntNode.execute(x);
243243
return recursiveNode.executeObject(value);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public double doPI(PInt value) {
127127

128128
@Specialization(guards = "!isNumber(value)")
129129
public double doGeneral(Object value,
130-
@Cached("create()") ConvertToDoubleNode convertToFloat) {
130+
@Cached("create()") CastToDoubleNode convertToFloat) {
131131
return count(convertToFloat.execute(value));
132132
}
133133
}
@@ -261,7 +261,7 @@ public Object ceil(PInt value,
261261

262262
@Specialization(guards = {"!isNumber(value)"})
263263
public Object ceil(Object value,
264-
@Cached("create()") ConvertToDoubleNode convertToFloat,
264+
@Cached("create()") CastToDoubleNode convertToFloat,
265265
@Cached("create(__CEIL__)") LookupAndCallUnaryNode dispatchCeil) {
266266
Object result = dispatchCeil.executeObject(value);
267267
if (result == PNone.NO_VALUE) {
@@ -742,7 +742,7 @@ public PTuple frexpPI(PInt value) {
742742

743743
@Specialization(guards = "!isNumber(value)")
744744
public PTuple frexpO(Object value,
745-
@Cached("create()") ConvertToDoubleNode convertToFloat) {
745+
@Cached("create()") CastToDoubleNode convertToFloat) {
746746
return frexpD(convertToFloat.execute(value));
747747
}
748748
}
@@ -769,7 +769,7 @@ public boolean isNan(double value) {
769769

770770
@Specialization(guards = "!isNumber(value)")
771771
public boolean isinf(Object value,
772-
@Cached("create()") ConvertToDoubleNode convertToFloat) {
772+
@Cached("create()") CastToDoubleNode convertToFloat) {
773773
return isNan(convertToFloat.execute(value));
774774
}
775775
}
@@ -958,7 +958,7 @@ public PTuple frexpPI(PInt value) {
958958

959959
@Specialization(guards = "!isNumber(value)")
960960
public PTuple frexpO(Object value,
961-
@Cached("create()") ConvertToDoubleNode convertToFloatNode) {
961+
@Cached("create()") CastToDoubleNode convertToFloatNode) {
962962
return modfD(convertToFloatNode.execute(value));
963963
}
964964
}
@@ -983,7 +983,7 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
983983
public double doIt(Object iterable,
984984
@Cached("create()") GetIteratorNode getIterator,
985985
@Cached("create(__NEXT__)") LookupAndCallUnaryNode next,
986-
@Cached("create()") ConvertToDoubleNode toFloat,
986+
@Cached("create()") CastToDoubleNode toFloat,
987987
@Cached("createBinaryProfile()") ConditionProfile stopProfile) {
988988
Object iterator = getIterator.executeWith(iterable);
989989
double x, y, t, hi, lo = 0, yr, inf_sum = 0, special_sum = 0, sum;
@@ -1144,11 +1144,11 @@ int gcd(@SuppressWarnings("unused") PInt x, @SuppressWarnings("unused") double y
11441144

11451145
@Specialization(guards = "!isNumber(x) || !isNumber(y)")
11461146
Object gcd(Object x, Object y,
1147-
@Cached("create()") ConvertToIntNode xConvert,
1148-
@Cached("create()") ConvertToIntNode yConvert,
1147+
@Cached("create()") CastToIntNode xCast,
1148+
@Cached("create()") CastToIntNode yCast,
11491149
@Cached("create()") GcdNode recursiveNode) {
1150-
Object xValue = xConvert.execute(x);
1151-
Object yValue = yConvert.execute(y);
1150+
Object xValue = xCast.execute(x);
1151+
Object yValue = yCast.execute(y);
11521152
return recursiveNode.execute(xValue, yValue);
11531153
}
11541154

@@ -1340,7 +1340,7 @@ public boolean isfinite(double value) {
13401340

13411341
@Specialization(guards = "!isNumber(value)")
13421342
public boolean isinf(Object value,
1343-
@Cached("create()") ConvertToDoubleNode convertToFloat) {
1343+
@Cached("create()") CastToDoubleNode convertToFloat) {
13441344
return isfinite(convertToFloat.execute(value));
13451345
}
13461346
}
@@ -1368,7 +1368,7 @@ public boolean isinf(double value) {
13681368

13691369
@Specialization(guards = "!isNumber(value)")
13701370
public boolean isinf(Object value,
1371-
@Cached("create()") ConvertToDoubleNode convertToFloat) {
1371+
@Cached("create()") CastToDoubleNode convertToFloat) {
13721372
return isinf(convertToFloat.execute(value));
13731373
}
13741374
}
@@ -1379,24 +1379,24 @@ public boolean isinf(Object value,
13791379
@GenerateNodeFactory
13801380
public abstract static class LogNode extends PythonBinaryBuiltinNode {
13811381

1382-
@Child private ConvertToDoubleNode valueConvertNode;
1383-
@Child private ConvertToDoubleNode baseConvertNode;
1382+
@Child private CastToDoubleNode valueCastNode;
1383+
@Child private CastToDoubleNode baseCastNode;
13841384
@Child private LogNode recLogNode;
13851385

1386-
private ConvertToDoubleNode getValueConvertNode() {
1387-
if (valueConvertNode == null) {
1386+
private CastToDoubleNode getValueCastNode() {
1387+
if (valueCastNode == null) {
13881388
CompilerDirectives.transferToInterpreterAndInvalidate();
1389-
valueConvertNode = insert(ConvertToDoubleNode.create());
1389+
valueCastNode = insert(CastToDoubleNode.create());
13901390
}
1391-
return valueConvertNode;
1391+
return valueCastNode;
13921392
}
13931393

1394-
private ConvertToDoubleNode getBaseConvertNode() {
1395-
if (baseConvertNode == null) {
1394+
private CastToDoubleNode getBaseCastNode() {
1395+
if (baseCastNode == null) {
13961396
CompilerDirectives.transferToInterpreterAndInvalidate();
1397-
baseConvertNode = insert(ConvertToDoubleNode.create());
1397+
baseCastNode = insert(CastToDoubleNode.create());
13981398
}
1399-
return baseConvertNode;
1399+
return baseCastNode;
14001400
}
14011401

14021402
private double executeRecursiveLogNode(Object value, Object base) {
@@ -1540,27 +1540,27 @@ public double logPIPI(PInt value, PInt base,
15401540

15411541
@Specialization(guards = "!isNumber(value)")
15421542
public double logO(Object value, PNone novalue) {
1543-
return executeRecursiveLogNode(getValueConvertNode().execute(value), novalue);
1543+
return executeRecursiveLogNode(getValueCastNode().execute(value), novalue);
15441544
}
15451545

15461546
@Specialization(guards = {"!isNumber(value)", "!isNoValue(base)"})
15471547
public double logOO(Object value, Object base) {
1548-
return executeRecursiveLogNode(getValueConvertNode().execute(value), getBaseConvertNode().execute(base));
1548+
return executeRecursiveLogNode(getValueCastNode().execute(value), getBaseCastNode().execute(base));
15491549
}
15501550

15511551
@Specialization(guards = {"!isNumber(base)"})
15521552
public double logLO(long value, Object base) {
1553-
return executeRecursiveLogNode(value, getBaseConvertNode().execute(base));
1553+
return executeRecursiveLogNode(value, getBaseCastNode().execute(base));
15541554
}
15551555

15561556
@Specialization(guards = {"!isNumber(base)"})
15571557
public double logDO(double value, Object base) {
1558-
return executeRecursiveLogNode(value, getBaseConvertNode().execute(base));
1558+
return executeRecursiveLogNode(value, getBaseCastNode().execute(base));
15591559
}
15601560

15611561
@Specialization(guards = {"!isNumber(base)"})
15621562
public double logPIO(PInt value, Object base) {
1563-
return executeRecursiveLogNode(value, getBaseConvertNode().execute(base));
1563+
return executeRecursiveLogNode(value, getBaseCastNode().execute(base));
15641564
}
15651565

15661566
private void raiseMathError(ConditionProfile doNotFit, boolean con) {
@@ -1801,8 +1801,8 @@ public abstract static class PowNode extends PythonBinaryBuiltinNode {
18011801

18021802
@Specialization(guards = {"!isNumber(left)||!isNumber(right)"})
18031803
double pow(Object left, Object right,
1804-
@Cached("create()") ConvertToDoubleNode convertLeftFloat,
1805-
@Cached("create()") ConvertToDoubleNode convertRightFloat) {
1804+
@Cached("create()") CastToDoubleNode convertLeftFloat,
1805+
@Cached("create()") CastToDoubleNode convertRightFloat) {
18061806
return pow(convertLeftFloat.execute(left), convertRightFloat.execute(right));
18071807
}
18081808
}
@@ -1875,8 +1875,8 @@ public abstract static class Atan2Node extends PythonBinaryBuiltinNode {
18751875

18761876
@Specialization(guards = "!isNumber(left) || !isNumber(right)")
18771877
double atan2(Object left, Object right,
1878-
@Cached("create()") ConvertToDoubleNode convertLeftFloat,
1879-
@Cached("create()") ConvertToDoubleNode convertRightFloat) {
1878+
@Cached("create()") CastToDoubleNode convertLeftFloat,
1879+
@Cached("create()") CastToDoubleNode convertRightFloat) {
18801880
return atan2DD(convertLeftFloat.execute(left), convertRightFloat.execute(right));
18811881
}
18821882
}
@@ -1963,9 +1963,9 @@ public double hypotPIL(PInt x, long y) {
19631963

19641964
@Specialization(guards = "!isNumber(objectX) || !isNumber(objectY)")
19651965
public double hypotOO(Object objectX, Object objectY,
1966-
@Cached("create()") ConvertToDoubleNode xConvertNode,
1967-
@Cached("create()") ConvertToDoubleNode yConvertNode) {
1968-
return hypotDD(xConvertNode.execute(objectX), yConvertNode.execute(objectY));
1966+
@Cached("create()") CastToDoubleNode xCastNode,
1967+
@Cached("create()") CastToDoubleNode yCastNode) {
1968+
return hypotDD(xCastNode.execute(objectX), yCastNode.execute(objectY));
19691969
}
19701970
}
19711971

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555

5656
@TypeSystemReference(PythonArithmeticTypes.class)
5757
@ImportStatic(MathGuards.class)
58-
public abstract class ConvertToDoubleNode extends PBaseNode {
58+
public abstract class CastToDoubleNode extends PBaseNode {
5959

6060
@Node.Child private LookupAndCallUnaryNode callFloatNode;
6161

6262
abstract public double execute(Object x);
6363

64-
public static ConvertToDoubleNode create() {
65-
return ConvertToDoubleNodeGen.create();
64+
public static CastToDoubleNode create() {
65+
return CastToDoubleNodeGen.create();
6666
}
6767

6868
@Specialization

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/ConvertToIntNode.java renamed to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToIntNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555

5656
@TypeSystemReference(PythonArithmeticTypes.class)
5757
@ImportStatic(MathGuards.class)
58-
public abstract class ConvertToIntNode extends PBaseNode {
58+
public abstract class CastToIntNode extends PBaseNode {
5959

6060
@Node.Child private LookupAndCallUnaryNode callIndexNode;
6161

6262
public abstract Object execute(Object x);
6363

64-
public static ConvertToIntNode create() {
65-
return ConvertToIntNodeGen.create();
64+
public static CastToIntNode create() {
65+
return CastToIntNodeGen.create();
6666
}
6767

6868
@Specialization

0 commit comments

Comments
 (0)