Skip to content

Commit 5bb696c

Browse files
committed
Add parameter names and missing specialization to the 'function' builtin
1 parent 5699d9f commit 5bb696c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,8 @@ PZip zip(VirtualFrame frame, Object cls, Object[] args,
20072007
}
20082008

20092009
// function(code, globals[, name[, argdefs[, closure]]])
2010-
@Builtin(name = "function", minNumOfPositionalArgs = 3, maxNumOfPositionalArgs = 6, constructsClass = PythonBuiltinClassType.PFunction, isPublic = false)
2010+
@Builtin(name = "function", minNumOfPositionalArgs = 3, parameterNames = {"$cls", "code", "globals", "name", "argdefs",
2011+
"closure"}, constructsClass = PythonBuiltinClassType.PFunction, isPublic = false)
20112012
@GenerateNodeFactory
20122013
public abstract static class FunctionNode extends PythonBuiltinNode {
20132014
private static final TruffleString T_LAMBDA = tsLiteral("<lambda>");
@@ -2038,6 +2039,14 @@ public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PD
20382039
return factory().createFunction(name, code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure)));
20392040
}
20402041

2042+
@Specialization
2043+
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, PTuple defaultArgs,
2044+
@SuppressWarnings("unused") PNone closure,
2045+
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
2046+
// TODO split defaults of positional args from kwDefaults
2047+
return factory().createFunction(code.getName(), code, globals, getObjectArrayNode.execute(defaultArgs), null, null);
2048+
}
2049+
20412050
@Specialization
20422051
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, PTuple defaultArgs, @SuppressWarnings("unused") PNone closure,
20432052
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {

0 commit comments

Comments
 (0)