Skip to content

Commit 51e7708

Browse files
committed
Rename 'Arity' to 'Signature'.
1 parent 8a000c2 commit 51e7708

23 files changed

+216
-218
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
102102
import com.oracle.graal.python.builtins.objects.dict.PDict;
103103
import com.oracle.graal.python.builtins.objects.frame.FrameBuiltins.GetLocalsNode;
104-
import com.oracle.graal.python.builtins.objects.function.Arity;
104+
import com.oracle.graal.python.builtins.objects.function.Signature;
105105
import com.oracle.graal.python.builtins.objects.function.PArguments;
106106
import com.oracle.graal.python.builtins.objects.function.PFunction;
107107
import com.oracle.graal.python.builtins.objects.function.PKeyword;
@@ -1735,9 +1735,9 @@ public synchronized Object doIt(PFunction func) {
17351735
* won't work when they are called from an instance of that class due to the implicit
17361736
* currying with "self".
17371737
*/
1738-
Arity arity = func.getArity();
1738+
Signature signature = func.getSignature();
17391739
PFunction builtinFunc;
1740-
if (arity.getParameterIds().length > 0 && arity.getParameterIds()[0].equals("self")) {
1740+
if (signature.getParameterIds().length > 0 && signature.getParameterIds()[0].equals("self")) {
17411741
/*
17421742
* If the first parameter is called self, we assume the function does explicitly
17431743
* declare the module argument
@@ -1753,14 +1753,14 @@ public boolean visit(Node node) {
17531753
});
17541754
} else {
17551755
/*
1756-
* Otherwise, we create a new function with an arity that requires one extra
1756+
* Otherwise, we create a new function with a signature that requires one extra
17571757
* argument in front. We actually modify the function's AST here, so the original
1758-
* PFunction cannot be used anymore (its Arity won't agree with it's indexed
1758+
* PFunction cannot be used anymore (its signature won't agree with it's indexed
17591759
* parameter reads).
17601760
*/
17611761
FunctionRootNode functionRootNode = (FunctionRootNode) func.getFunctionRootNode();
17621762
assert !functionRootNode.isRewritten() : "a function cannot be annotated as builtin twice";
1763-
functionRootNode = functionRootNode.copyWithNewArity(arity.createWithSelf());
1763+
functionRootNode = functionRootNode.copyWithNewSignature(signature.createWithSelf());
17641764
functionRootNode.setRewritten();
17651765
functionRootNode.accept(new NodeVisitor() {
17661766
public boolean visit(Node node) {

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
import com.oracle.graal.python.builtins.objects.dict.PDict;
102102
import com.oracle.graal.python.builtins.objects.exception.PBaseException;
103103
import com.oracle.graal.python.builtins.objects.frame.PFrame;
104-
import com.oracle.graal.python.builtins.objects.function.Arity;
104+
import com.oracle.graal.python.builtins.objects.function.Signature;
105105
import com.oracle.graal.python.builtins.objects.function.PArguments;
106106
import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
107107
import com.oracle.graal.python.builtins.objects.function.PFunction;
@@ -330,37 +330,37 @@ Object runWithoutCWrapper(PBuiltinFunction descriptor, Object self) {
330330
@GenerateNodeFactory
331331
@TypeSystemReference(PythonArithmeticTypes.class)
332332
abstract static class CreateFunctionNode extends PythonBuiltinNode {
333-
private static final Arity ARITY = Arity.createVarArgsAndKwArgsOnly();
333+
private static final Signature SIGNATURE = Signature.createVarArgsAndKwArgsOnly();
334334

335335
@Specialization(guards = "isNoValue(cwrapper)")
336336
@TruffleBoundary
337337
PBuiltinFunction runWithoutCWrapper(String name, TruffleObject callable, @SuppressWarnings("unused") PNone cwrapper, LazyPythonClass type) {
338338
CompilerDirectives.transferToInterpreter();
339-
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, null, callable, ARITY));
339+
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, null, callable, SIGNATURE));
340340
return factory().createBuiltinFunction(name, type, 0, callTarget);
341341
}
342342

343343
@Specialization(guards = {"isNoValue(cwrapper)", "isNoValue(type)"})
344344
@TruffleBoundary
345345
PBuiltinFunction runWithoutCWrapper(String name, TruffleObject callable, @SuppressWarnings("unused") PNone cwrapper, @SuppressWarnings("unused") PNone type) {
346346
CompilerDirectives.transferToInterpreter();
347-
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, null, callable, ARITY));
347+
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, null, callable, SIGNATURE));
348348
return factory().createBuiltinFunction(name, null, 0, callTarget);
349349
}
350350

351351
@Specialization(guards = {"!isNoValue(cwrapper)", "isNoValue(type)"})
352352
@TruffleBoundary
353353
PBuiltinFunction runWithoutCWrapper(String name, TruffleObject callable, TruffleObject cwrapper, @SuppressWarnings("unused") PNone type) {
354354
CompilerDirectives.transferToInterpreter();
355-
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, cwrapper, callable, ARITY));
355+
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, cwrapper, callable, SIGNATURE));
356356
return factory().createBuiltinFunction(name, null, 0, callTarget);
357357
}
358358

359359
@Specialization(guards = "!isNoValue(cwrapper)")
360360
@TruffleBoundary
361361
PBuiltinFunction run(String name, TruffleObject callable, TruffleObject cwrapper, LazyPythonClass type) {
362362
CompilerDirectives.transferToInterpreter();
363-
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, cwrapper, callable, ARITY));
363+
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new ExternalFunctionNode(getRootNode().getLanguage(PythonLanguage.class), name, cwrapper, callable, SIGNATURE));
364364
return factory().createBuiltinFunction(name, type, 0, callTarget);
365365
}
366366
}
@@ -669,7 +669,7 @@ public static CheckFunctionResultNode create() {
669669
}
670670

671671
static class ExternalFunctionNode extends PRootNode {
672-
private final Arity arity;
672+
private final Signature signature;
673673
private final TruffleObject cwrapper;
674674
private final TruffleObject callable;
675675
private final String name;
@@ -680,9 +680,9 @@ static class ExternalFunctionNode extends PRootNode {
680680
@Child private CheckFunctionResultNode checkResultNode = CheckFunctionResultNode.create();
681681
@Child private PForeignToPTypeNode fromForeign = PForeignToPTypeNode.create();
682682

683-
ExternalFunctionNode(PythonLanguage lang, String name, TruffleObject cwrapper, TruffleObject callable, Arity arity) {
683+
ExternalFunctionNode(PythonLanguage lang, String name, TruffleObject cwrapper, TruffleObject callable, Signature signature) {
684684
super(lang);
685-
this.arity = arity;
685+
this.signature = signature;
686686
this.name = name;
687687
this.cwrapper = cwrapper;
688688
this.callable = callable;
@@ -758,8 +758,8 @@ public boolean isCloningAllowed() {
758758
}
759759

760760
@Override
761-
public Arity getArity() {
762-
return arity;
761+
public Signature getSignature() {
762+
return signature;
763763
}
764764
}
765765

@@ -1537,7 +1537,7 @@ public String toString() {
15371537
}
15381538

15391539
static class MethKeywordsRoot extends MethodDescriptorRoot {
1540-
private static final Arity ARITY = new Arity(true, 1, false, new String[]{"self"}, new String[0]);
1540+
private static final Signature SIGNATURE = new Signature(true, 1, false, new String[]{"self"}, new String[0]);
15411541

15421542
@Child private ReadVarArgsNode readVarargsNode;
15431543
@Child private ReadVarKeywordsNode readKwargsNode;
@@ -1559,13 +1559,13 @@ public Object execute(VirtualFrame frame) {
15591559
}
15601560

15611561
@Override
1562-
public Arity getArity() {
1563-
return ARITY;
1562+
public Signature getSignature() {
1563+
return SIGNATURE;
15641564
}
15651565
}
15661566

15671567
static class MethVarargsRoot extends MethodDescriptorRoot {
1568-
private static final Arity ARITY = new Arity(false, 1, false, new String[]{"self"}, new String[0]);
1568+
private static final Signature SIGNATURE = new Signature(false, 1, false, new String[]{"self"}, new String[0]);
15691569

15701570
@Child private ReadVarArgsNode readVarargsNode;
15711571

@@ -1584,13 +1584,13 @@ public Object execute(VirtualFrame frame) {
15841584
}
15851585

15861586
@Override
1587-
public Arity getArity() {
1588-
return ARITY;
1587+
public Signature getSignature() {
1588+
return SIGNATURE;
15891589
}
15901590
}
15911591

15921592
static class MethNoargsRoot extends MethodDescriptorRoot {
1593-
private static final Arity ARITY = new Arity(false, -1, false, new String[]{"self"}, new String[0]);
1593+
private static final Signature SIGNATURE = new Signature(false, -1, false, new String[]{"self"}, new String[0]);
15941594

15951595
protected MethNoargsRoot(PythonLanguage language, PythonObjectFactory factory, CallTarget callTarget) {
15961596
super(language, factory, callTarget);
@@ -1605,13 +1605,13 @@ public Object execute(VirtualFrame frame) {
16051605
}
16061606

16071607
@Override
1608-
public Arity getArity() {
1609-
return ARITY;
1608+
public Signature getSignature() {
1609+
return SIGNATURE;
16101610
}
16111611
}
16121612

16131613
static class MethORoot extends MethodDescriptorRoot {
1614-
private static final Arity ARITY = new Arity(false, -1, false, new String[]{"self", "arg"}, new String[0]);
1614+
private static final Signature SIGNATURE = new Signature(false, -1, false, new String[]{"self", "arg"}, new String[0]);
16151615

16161616
@Child private ReadIndexedArgumentNode readArgNode;
16171617

@@ -1630,13 +1630,13 @@ public Object execute(VirtualFrame frame) {
16301630
}
16311631

16321632
@Override
1633-
public Arity getArity() {
1634-
return ARITY;
1633+
public Signature getSignature() {
1634+
return SIGNATURE;
16351635
}
16361636
}
16371637

16381638
static class MethFastcallRoot extends MethodDescriptorRoot {
1639-
private static final Arity ARITY = new Arity(true, 1, false, new String[]{"self"}, new String[0]);
1639+
private static final Signature SIGNATURE = new Signature(true, 1, false, new String[]{"self"}, new String[0]);
16401640

16411641
@Child private ReadVarArgsNode readVarargsNode;
16421642
@Child private ReadVarKeywordsNode readKwargsNode;
@@ -1658,8 +1658,8 @@ public Object execute(VirtualFrame frame) {
16581658
}
16591659

16601660
@Override
1661-
public Arity getArity() {
1662-
return ARITY;
1661+
public Signature getSignature() {
1662+
return SIGNATURE;
16631663
}
16641664
}
16651665

@@ -1943,9 +1943,9 @@ public boolean visit(Node node) {
19431943
});
19441944

19451945
RootNode rootNode = null;
1946-
Arity funcArity = func.getArity();
1947-
if (funcArity.takesPositionalOnly()) {
1948-
switch (funcArity.getMaxNumOfPositionalArgs()) {
1946+
Signature funcSignature = func.getSignature();
1947+
if (funcSignature.takesPositionalOnly()) {
1948+
switch (funcSignature.getMaxNumOfPositionalArgs()) {
19491949
case 1:
19501950
rootNode = new BuiltinFunctionRootNode(getRootNode().getLanguage(PythonLanguage.class), unaryBuiltin,
19511951
new MayRaiseNodeFactory<PythonUnaryBuiltinNode>(MayRaiseUnaryNodeGen.create(func, errorResult)),

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import com.oracle.graal.python.builtins.objects.cell.PCell;
4747
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes;
4848
import com.oracle.graal.python.builtins.objects.dict.PDict;
49-
import com.oracle.graal.python.builtins.objects.function.Arity;
49+
import com.oracle.graal.python.builtins.objects.function.Signature;
5050
import com.oracle.graal.python.builtins.objects.function.PArguments;
5151
import com.oracle.graal.python.builtins.objects.function.PFunction;
5252
import com.oracle.graal.python.builtins.objects.str.PString;
@@ -127,9 +127,9 @@ public Object execute(VirtualFrame frame) {
127127
});
128128
}
129129

130-
Arity arity = createArity(flags, argcount, kwonlyargcount, varnames);
130+
Signature signature = createSignature(flags, argcount, kwonlyargcount, varnames);
131131

132-
return factory().createCode(cls, callTarget, arity, nlocals, stacksize, flags, codestring, constants, names, varnames, freevars, cellvars, filename, name, firstlineno, lnotab);
132+
return factory().createCode(cls, callTarget, signature, nlocals, stacksize, flags, codestring, constants, names, varnames, freevars, cellvars, filename, name, firstlineno, lnotab);
133133
}
134134

135135
private static String createFuncdef(byte[] codestring, Object[] freevars, String name) {
@@ -159,7 +159,7 @@ private static String createFuncdef(byte[] codestring, Object[] freevars, String
159159
}
160160
}
161161

162-
private static Arity createArity(int flags, int argcount, int kwonlyargcount, Object[] varnames) {
162+
private static Signature createSignature(int flags, int argcount, int kwonlyargcount, Object[] varnames) {
163163
CompilerAsserts.neverPartOfCompilation();
164164
char paramNom = 'A';
165165
String[] paramNames = new String[argcount];
@@ -184,7 +184,7 @@ private static Arity createArity(int flags, int argcount, int kwonlyargcount, Ob
184184
}
185185
kwNames[i] = Character.toString(paramNom++);
186186
}
187-
return new Arity(PCode.takesVarKeywordArgs(flags), PCode.takesVarArgs(flags) ? argcount : -1, !PCode.takesVarArgs(flags) && kwonlyargcount > 0, paramNames, kwNames);
187+
return new Signature(PCode.takesVarKeywordArgs(flags), PCode.takesVarArgs(flags) ? argcount : -1, !PCode.takesVarArgs(flags) && kwonlyargcount > 0, paramNames, kwNames);
188188
}
189189

190190
private HashingStorageNodes.GetItemNode ensureGetItemNode() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import java.util.Set;
4848

4949
import com.oracle.graal.python.PythonLanguage;
50-
import com.oracle.graal.python.builtins.objects.function.Arity;
50+
import com.oracle.graal.python.builtins.objects.function.Signature;
5151
import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
5252
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
5353
import com.oracle.graal.python.nodes.ModuleRootNode;
@@ -75,7 +75,7 @@ public final class PCode extends PythonBuiltinObject {
7575
// modules
7676

7777
private final RootCallTarget callTarget;
78-
private final Arity arity;
78+
private final Signature signature;
7979

8080
// number of local variables
8181
private int nlocals = -1;
@@ -112,13 +112,13 @@ public PCode(LazyPythonClass cls, RootCallTarget callTarget) {
112112
super(cls);
113113
this.callTarget = callTarget;
114114
if (callTarget.getRootNode() instanceof PRootNode) {
115-
this.arity = ((PRootNode) callTarget.getRootNode()).getArity();
115+
this.signature = ((PRootNode) callTarget.getRootNode()).getSignature();
116116
} else {
117-
this.arity = Arity.createVarArgsAndKwArgsOnly();
117+
this.signature = Signature.createVarArgsAndKwArgsOnly();
118118
}
119119
}
120120

121-
public PCode(LazyPythonClass cls, RootCallTarget callTarget, Arity arity,
121+
public PCode(LazyPythonClass cls, RootCallTarget callTarget, Signature signature,
122122
int nlocals, int stacksize, int flags,
123123
byte[] codestring, Object[] constants, Object[] names,
124124
Object[] varnames, Object[] freevars, Object[] cellvars,
@@ -139,7 +139,7 @@ public PCode(LazyPythonClass cls, RootCallTarget callTarget, Arity arity,
139139
this.freevars = freevars;
140140
this.cellvars = cellvars;
141141
this.callTarget = callTarget;
142-
this.arity = arity;
142+
this.signature = signature;
143143
}
144144

145145
@TruffleBoundary
@@ -337,11 +337,11 @@ public String getName() {
337337
}
338338

339339
public int getArgcount() {
340-
return arity.getMaxNumOfPositionalArgs();
340+
return signature.getMaxNumOfPositionalArgs();
341341
}
342342

343343
public int getKwonlyargcount() {
344-
return arity.getNumOfRequiredKeywords();
344+
return signature.getNumOfRequiredKeywords();
345345
}
346346

347347
public int getNlocals() {
@@ -367,7 +367,7 @@ public int getFlags() {
367367

368368
public Object[] getVarnames() {
369369
if (varnames == null) {
370-
varnames = extractVarnames(getRootNode(), getArity().getParameterIds(), getArity().getKeywordNames(), getFreeVars(), getCellVars());
370+
varnames = extractVarnames(getRootNode(), getSignature().getParameterIds(), getSignature().getKeywordNames(), getFreeVars(), getCellVars());
371371
}
372372
return varnames;
373373
}
@@ -411,8 +411,8 @@ public boolean takesVarKeywordArgs() {
411411
return PCode.takesVarKeywordArgs(getFlags());
412412
}
413413

414-
public Arity getArity() {
415-
return arity;
414+
public Signature getSignature() {
415+
return signature;
416416
}
417417

418418
public RootCallTarget getRootCallTarget() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,21 @@ Object builtinCode(PBuiltinFunction self) {
252252
public abstract static class TextSignatureNode extends PythonUnaryBuiltinNode {
253253
@Specialization
254254
protected Object doStatic(@SuppressWarnings("unused") PBuiltinFunction self) {
255-
Arity arity = self.getArity();
256-
return getSignature(arity);
255+
return getSignature(self.getSignature());
257256
}
258257

259258
@Specialization
260259
protected Object doStatic(@SuppressWarnings("unused") PFunction self) {
261-
Arity arity = self.getArity();
262-
return getSignature(arity);
260+
return getSignature(self.getSignature());
263261
}
264262

265263
@TruffleBoundary
266-
private static Object getSignature(Arity arity) {
267-
String[] keywordNames = arity.getKeywordNames();
268-
boolean takesVarArgs = arity.takesVarArgs();
269-
boolean takesVarKeywordArgs = arity.takesVarKeywordArgs();
264+
private static Object getSignature(Signature signature) {
265+
String[] keywordNames = signature.getKeywordNames();
266+
boolean takesVarArgs = signature.takesVarArgs();
267+
boolean takesVarKeywordArgs = signature.takesVarKeywordArgs();
270268

271-
String[] parameterNames = arity.getParameterIds();
269+
String[] parameterNames = signature.getParameterIds();
272270
int paramIdx = 0;
273271

274272
StringBuilder sb = new StringBuilder();

0 commit comments

Comments
 (0)