|
34 | 34 | import static com.oracle.graal.python.nodes.BuiltinNames.BYTEARRAY;
|
35 | 35 | import static com.oracle.graal.python.nodes.BuiltinNames.BYTES;
|
36 | 36 | import static com.oracle.graal.python.nodes.BuiltinNames.CLASSMETHOD;
|
37 |
| -import static com.oracle.graal.python.nodes.BuiltinNames.INSTANCEMETHOD; |
38 | 37 | import static com.oracle.graal.python.nodes.BuiltinNames.COMPLEX;
|
39 | 38 | import static com.oracle.graal.python.nodes.BuiltinNames.DICT;
|
40 | 39 | import static com.oracle.graal.python.nodes.BuiltinNames.DICT_ITEMITERATOR;
|
|
47 | 46 | import static com.oracle.graal.python.nodes.BuiltinNames.FLOAT;
|
48 | 47 | import static com.oracle.graal.python.nodes.BuiltinNames.FROZENSET;
|
49 | 48 | import static com.oracle.graal.python.nodes.BuiltinNames.GETSET_DESCRIPTOR;
|
| 49 | +import static com.oracle.graal.python.nodes.BuiltinNames.INSTANCEMETHOD; |
50 | 50 | import static com.oracle.graal.python.nodes.BuiltinNames.INT;
|
51 | 51 | import static com.oracle.graal.python.nodes.BuiltinNames.LIST;
|
52 | 52 | import static com.oracle.graal.python.nodes.BuiltinNames.MAP;
|
|
181 | 181 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetItemsizeNode;
|
182 | 182 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroNode;
|
183 | 183 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroStorageNode;
|
184 |
| -import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; |
185 | 184 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsAcceptableBaseNode;
|
186 | 185 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode;
|
187 | 186 | import com.oracle.graal.python.lib.CanBeDoubleNode;
|
@@ -2028,59 +2027,51 @@ PZip zip(VirtualFrame frame, Object cls, Object[] args,
|
2028 | 2027 | @Builtin(name = "function", minNumOfPositionalArgs = 3, maxNumOfPositionalArgs = 6, constructsClass = PythonBuiltinClassType.PFunction, isPublic = false)
|
2029 | 2028 | @GenerateNodeFactory
|
2030 | 2029 | public abstract static class FunctionNode extends PythonBuiltinNode {
|
2031 |
| - @Child private GetNameNode getNameNode; |
2032 |
| - |
2033 | 2030 | @Specialization
|
2034 |
| - public PFunction function(Object cls, PCode code, PDict globals, String name, @SuppressWarnings("unused") PNone defaultArgs, @SuppressWarnings("unused") PNone closure) { |
2035 |
| - return factory().createFunction(name, getTypeName(cls), code, globals, null); |
| 2031 | + public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, String name, @SuppressWarnings("unused") PNone defaultArgs, |
| 2032 | + @SuppressWarnings("unused") PNone closure) { |
| 2033 | + return factory().createFunction(name, code, globals, null); |
2036 | 2034 | }
|
2037 | 2035 |
|
2038 | 2036 | @Specialization
|
2039 |
| - public PFunction function(Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, @SuppressWarnings("unused") PNone defaultArgs, PTuple closure, |
| 2037 | + public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, @SuppressWarnings("unused") PNone defaultArgs, |
| 2038 | + PTuple closure, |
2040 | 2039 | @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
|
2041 |
| - return factory().createFunction("<lambda>", getTypeName(cls), code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure))); |
| 2040 | + return factory().createFunction("<lambda>", code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure))); |
2042 | 2041 | }
|
2043 | 2042 |
|
2044 | 2043 | @Specialization
|
2045 |
| - public PFunction function(Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, @SuppressWarnings("unused") PNone defaultArgs, |
| 2044 | + public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, @SuppressWarnings("unused") PNone defaultArgs, |
2046 | 2045 | @SuppressWarnings("unused") PNone closure,
|
2047 | 2046 | @SuppressWarnings("unused") @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
|
2048 |
| - return factory().createFunction("<lambda>", getTypeName(cls), code, globals, null); |
| 2047 | + return factory().createFunction("<lambda>", code, globals, null); |
2049 | 2048 | }
|
2050 | 2049 |
|
2051 | 2050 | @Specialization
|
2052 |
| - public PFunction function(Object cls, PCode code, PDict globals, String name, @SuppressWarnings("unused") PNone defaultArgs, PTuple closure, |
| 2051 | + public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, String name, @SuppressWarnings("unused") PNone defaultArgs, PTuple closure, |
2053 | 2052 | @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
|
2054 |
| - return factory().createFunction(name, getTypeName(cls), code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure))); |
| 2053 | + return factory().createFunction(name, code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure))); |
2055 | 2054 | }
|
2056 | 2055 |
|
2057 | 2056 | @Specialization
|
2058 |
| - public PFunction function(Object cls, PCode code, PDict globals, String name, PTuple defaultArgs, @SuppressWarnings("unused") PNone closure, |
| 2057 | + public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, String name, PTuple defaultArgs, @SuppressWarnings("unused") PNone closure, |
2059 | 2058 | @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
|
2060 | 2059 | // TODO split defaults of positional args from kwDefaults
|
2061 |
| - return factory().createFunction(name, getTypeName(cls), code, globals, getObjectArrayNode.execute(defaultArgs), null, null); |
| 2060 | + return factory().createFunction(name, code, globals, getObjectArrayNode.execute(defaultArgs), null, null); |
2062 | 2061 | }
|
2063 | 2062 |
|
2064 | 2063 | @Specialization
|
2065 |
| - public PFunction function(Object cls, PCode code, PDict globals, String name, PTuple defaultArgs, PTuple closure, |
| 2064 | + public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, String name, PTuple defaultArgs, PTuple closure, |
2066 | 2065 | @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
|
2067 | 2066 | // TODO split defaults of positional args from kwDefaults
|
2068 |
| - return factory().createFunction(name, getTypeName(cls), code, globals, getObjectArrayNode.execute(defaultArgs), null, PCell.toCellArray(getObjectArrayNode.execute(closure))); |
| 2067 | + return factory().createFunction(name, code, globals, getObjectArrayNode.execute(defaultArgs), null, PCell.toCellArray(getObjectArrayNode.execute(closure))); |
2069 | 2068 | }
|
2070 | 2069 |
|
2071 | 2070 | @Fallback
|
2072 | 2071 | @SuppressWarnings("unused")
|
2073 |
| - public PFunction function(Object cls, Object code, Object globals, Object name, Object defaultArgs, Object closure) { |
| 2072 | + public PFunction function(@SuppressWarnings("unused") Object cls, Object code, Object globals, Object name, Object defaultArgs, Object closure) { |
2074 | 2073 | throw raise(TypeError, ErrorMessages.FUNC_CONSTRUCTION_NOT_SUPPORTED, cls, code, globals, name, defaultArgs, closure);
|
2075 | 2074 | }
|
2076 |
| - |
2077 |
| - private String getTypeName(Object typeObj) { |
2078 |
| - if (getNameNode == null) { |
2079 |
| - CompilerDirectives.transferToInterpreterAndInvalidate(); |
2080 |
| - getNameNode = insert(TypeNodes.GetNameNode.create()); |
2081 |
| - } |
2082 |
| - return getNameNode.execute(typeObj); |
2083 |
| - } |
2084 | 2075 | }
|
2085 | 2076 |
|
2086 | 2077 | // builtin-function(method-def, self, module)
|
|
0 commit comments