|
40 | 40 | */
|
41 | 41 | package com.oracle.graal.python.builtins.modules.cext;
|
42 | 42 |
|
43 |
| -<<<<<<< HEAD |
44 |
| -======= |
45 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextAbstractBuiltins.PYTHON_CEXT_ABSTRACT; |
46 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextBytesBuiltins.PYTHON_CEXT_BYTES; |
47 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextCEvalBuiltins.PYTHON_CEXT_CEVAL; |
48 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextCodeBuiltins.PYTHON_CEXT_CODE; |
49 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextComplexBuiltins.PYTHON_CEXT_COMPLEX; |
50 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextDictBuiltins.PYTHON_CEXT_DICT; |
51 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextFileBuiltins.PYTHON_CEXT_FILE; |
52 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextFloatBuiltins.PYTHON_CEXT_FLOAT; |
53 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextImportBuiltins.PYTHON_CEXT_IMPORT; |
54 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextListBuiltins.PYTHON_CEXT_LIST; |
55 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextLongBuiltins.PYTHON_CEXT_LONG; |
56 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextMemoryViewBuiltins.PYTHON_CEXT_MEMORYVIEW; |
57 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextNamespaceBuiltins.PYTHON_CEXT_NAMESPACE; |
58 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextPythonRunBuiltins.PYTHON_CEXT_PYTHON_RUN; |
59 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextSetBuiltins.PYTHON_CEXT_SET; |
60 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextSliceBuiltins.PYTHON_CEXT_SLICE; |
61 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextSysBuiltins.PYTHON_CEXT_SYS; |
62 |
| -import static com.oracle.graal.python.builtins.modules.cext.PythonCextUnicodeBuiltins.PYTHON_CEXT_UNICODE; |
63 |
| ->>>>>>> intrinsified PySys_XXX |
64 | 43 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.IndexError;
|
65 | 44 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError;
|
66 | 45 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
|
|
101 | 80 | import com.oracle.graal.python.builtins.modules.BuiltinConstructors.MappingproxyNode;
|
102 | 81 | import com.oracle.graal.python.builtins.modules.SysModuleBuiltins;
|
103 | 82 | import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltinsFactory.CreateFunctionNodeGen;
|
| 83 | +import static com.oracle.graal.python.builtins.modules.cext.PythonCextTupleBuiltins.PYTHON_CEXT_TUPLE; |
104 | 84 | import com.oracle.graal.python.builtins.objects.PNone;
|
105 | 85 | import com.oracle.graal.python.builtins.objects.PNotImplemented;
|
106 | 86 | import com.oracle.graal.python.builtins.objects.bytes.BytesBuiltins;
|
|
118 | 98 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes;
|
119 | 99 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.AsCharPointerNode;
|
120 | 100 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.AsPythonObjectNode;
|
121 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.AsPythonObjectStealingNode; |
122 | 101 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CastToJavaDoubleNode;
|
123 | 102 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CastToNativeLongNode;
|
124 | 103 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CextUpcallNode;
|
|
189 | 168 | import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes;
|
190 | 169 | import com.oracle.graal.python.builtins.objects.common.HashingStorage;
|
191 | 170 | import com.oracle.graal.python.builtins.objects.common.HashingStorageLibrary;
|
| 171 | +<<<<<<< HEAD |
192 | 172 | import com.oracle.graal.python.builtins.objects.common.IndexNodes.NormalizeIndexNode;
|
| 173 | +======= |
| 174 | +import com.oracle.graal.python.builtins.objects.common.HashingStorageLibrary.HashingStorageIterable; |
| 175 | +import com.oracle.graal.python.builtins.objects.common.HashingStorageLibrary.HashingStorageIterator; |
| 176 | +>>>>>>> moved PythonCextBuiltins.PyTupleXXX to PythonCextTupleBuiltins |
193 | 177 | import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
|
194 | 178 | import com.oracle.graal.python.builtins.objects.common.SequenceNodes;
|
195 | 179 | import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetObjectArrayNode;
|
|
233 | 217 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroStorageNode;
|
234 | 218 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode;
|
235 | 219 | import com.oracle.graal.python.lib.PyMemoryViewFromObject;
|
236 |
| -import com.oracle.graal.python.lib.PyNumberAsSizeNode; |
237 | 220 | import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
|
238 | 221 | import com.oracle.graal.python.lib.PyObjectLookupAttr;
|
239 | 222 | import com.oracle.graal.python.nodes.BuiltinNames;
|
@@ -362,47 +345,6 @@ public void initialize(Python3Core core) {
|
362 | 345 | builtinConstants.put("PyGILState_Release", new PyGILStateRelease());
|
363 | 346 | }
|
364 | 347 |
|
365 |
| -<<<<<<< HEAD |
366 |
| -======= |
367 |
| - @Override |
368 |
| - public void postInitialize(Python3Core core) { |
369 |
| - PythonModule cext = core.lookupBuiltinModule(PYTHON_CEXT); |
370 |
| - addModuleDict(cext, PYTHON_CEXT_ABSTRACT, core); |
371 |
| - addModuleDict(cext, PYTHON_CEXT_BYTES, core); |
372 |
| - addModuleDict(cext, PYTHON_CEXT_CEVAL, core); |
373 |
| - addModuleDict(cext, PYTHON_CEXT_CODE, core); |
374 |
| - addModuleDict(cext, PYTHON_CEXT_COMPLEX, core); |
375 |
| - addModuleDict(cext, PYTHON_CEXT_DICT, core); |
376 |
| - addModuleDict(cext, PYTHON_CEXT_FILE, core); |
377 |
| - addModuleDict(cext, PYTHON_CEXT_FLOAT, core); |
378 |
| - addModuleDict(cext, PYTHON_CEXT_IMPORT, core); |
379 |
| - addModuleDict(cext, PYTHON_CEXT_LONG, core); |
380 |
| - addModuleDict(cext, PYTHON_CEXT_LIST, core); |
381 |
| - addModuleDict(cext, PYTHON_CEXT_MEMORYVIEW, core); |
382 |
| - addModuleDict(cext, PYTHON_CEXT_NAMESPACE, core); |
383 |
| - addModuleDict(cext, PYTHON_CEXT_PYTHON_RUN, core); |
384 |
| - addModuleDict(cext, PYTHON_CEXT_SET, core); |
385 |
| - addModuleDict(cext, PYTHON_CEXT_SLICE, core); |
386 |
| - addModuleDict(cext, PYTHON_CEXT_SYS, core); |
387 |
| - addModuleDict(cext, PYTHON_CEXT_UNICODE, core); |
388 |
| - } |
389 |
| - |
390 |
| - private static void addModuleDict(PythonModule cext, String module, Python3Core core) { |
391 |
| - PythonModule cext_module = core.lookupBuiltinModule(module); |
392 |
| - PDict dict = GetDictIfExistsNodeGen.getUncached().execute(cext_module); |
393 |
| - HashingStorageIterable<Object> keys = dict.keys(); |
394 |
| - HashingStorageIterator<Object> it = keys.iterator(); |
395 |
| - while (it.hasNext()) { |
396 |
| - Object key = it.next(); |
397 |
| - Object value = dict.getItem(key); |
398 |
| - if (value instanceof PythonBuiltinObject) { |
399 |
| - assert cext.getAttribute(key) == PNone.NO_VALUE || cext.getAttribute(key) == null : "python_cext dict already contains value " + cext.getAttribute(key) + " for key " + key; |
400 |
| - cext.setAttribute(key, value); |
401 |
| - } |
402 |
| - } |
403 |
| - } |
404 |
| - |
405 |
| ->>>>>>> intrinsified PySys_XXX |
406 | 348 | @FunctionalInterface
|
407 | 349 | public interface TernaryFunction<T1, T2, T3, R> {
|
408 | 350 | R apply(T1 arg0, T2 arg1, T3 arg2);
|
@@ -659,56 +601,6 @@ Object doI(Object typeNameObject) {
|
659 | 601 | }
|
660 | 602 | }
|
661 | 603 |
|
662 |
| - @Builtin(name = "PyTuple_New", minNumOfPositionalArgs = 1) |
663 |
| - @GenerateNodeFactory |
664 |
| - abstract static class PyTuple_New extends PythonUnaryBuiltinNode { |
665 |
| - @Specialization |
666 |
| - PTuple doGeneric(VirtualFrame frame, Object size, |
667 |
| - @Cached PyNumberAsSizeNode asSizeNode) { |
668 |
| - return factory().createTuple(new Object[asSizeNode.executeExact(frame, size)]); |
669 |
| - } |
670 |
| - } |
671 |
| - |
672 |
| - @Builtin(name = "PyTuple_SetItem", minNumOfPositionalArgs = 3) |
673 |
| - @GenerateNodeFactory |
674 |
| - @ImportStatic(CApiGuards.class) |
675 |
| - abstract static class PyTuple_SetItem extends PythonTernaryBuiltinNode { |
676 |
| - @Specialization |
677 |
| - static int doManaged(VirtualFrame frame, PythonNativeWrapper selfWrapper, Object position, Object elementWrapper, |
678 |
| - @Cached AsPythonObjectNode selfAsPythonObjectNode, |
679 |
| - @Cached AsPythonObjectStealingNode elementAsPythonObjectNode, |
680 |
| - @Cached("createSetItem()") SequenceStorageNodes.SetItemNode setItemNode, |
681 |
| - @Cached PRaiseNode raiseNode, |
682 |
| - @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) { |
683 |
| - try { |
684 |
| - Object self = selfAsPythonObjectNode.execute(selfWrapper); |
685 |
| - if (!PGuards.isPTuple(self) || selfWrapper.getRefCount() != 1) { |
686 |
| - throw raiseNode.raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_P, "PTuple_SetItem"); |
687 |
| - } |
688 |
| - PTuple tuple = (PTuple) self; |
689 |
| - Object element = elementAsPythonObjectNode.execute(elementWrapper); |
690 |
| - setItemNode.execute(frame, tuple.getSequenceStorage(), position, element); |
691 |
| - return 0; |
692 |
| - } catch (PException e) { |
693 |
| - transformExceptionToNativeNode.execute(frame, e); |
694 |
| - return -1; |
695 |
| - } |
696 |
| - } |
697 |
| - |
698 |
| - @Specialization(guards = "!isNativeWrapper(tuple)") |
699 |
| - static int doNative(Object tuple, long position, Object element, |
700 |
| - @Cached PCallCapiFunction callSetItem) { |
701 |
| - // TODO(fa): This path should be avoided since this is called from native code to do a |
702 |
| - // native operation. |
703 |
| - callSetItem.call(NativeCAPISymbol.FUN_PY_TRUFFLE_TUPLE_SET_ITEM, tuple, position, element); |
704 |
| - return 0; |
705 |
| - } |
706 |
| - |
707 |
| - protected static SequenceStorageNodes.SetItemNode createSetItem() { |
708 |
| - return SequenceStorageNodes.SetItemNode.create(NormalizeIndexNode.forTupleAssign(), "invalid item for assignment"); |
709 |
| - } |
710 |
| - } |
711 |
| - |
712 | 604 | @Builtin(name = "CreateBuiltinMethod", minNumOfPositionalArgs = 2)
|
713 | 605 | @GenerateNodeFactory
|
714 | 606 | abstract static class CreateBuiltinMethodNode extends PythonBuiltinNode {
|
@@ -2059,29 +1951,6 @@ int doSlow(VirtualFrame frame, Object derived, Object cls) {
|
2059 | 1951 | }
|
2060 | 1952 | }
|
2061 | 1953 |
|
2062 |
| - @Builtin(name = "PyTuple_GetItem", minNumOfPositionalArgs = 2) |
2063 |
| - @GenerateNodeFactory |
2064 |
| - abstract static class PyTuple_GetItem extends PythonBinaryBuiltinNode { |
2065 |
| - |
2066 |
| - @Specialization |
2067 |
| - Object doPTuple(VirtualFrame frame, PTuple tuple, long key, |
2068 |
| - @Cached SequenceStorageNodes.LenNode lenNode, |
2069 |
| - @Cached("createNotNormalized()") SequenceStorageNodes.GetItemNode getItemNode) { |
2070 |
| - SequenceStorage sequenceStorage = tuple.getSequenceStorage(); |
2071 |
| - // we must do a bounds-check but we must not normalize the index |
2072 |
| - if (key < 0 || key >= lenNode.execute(sequenceStorage)) { |
2073 |
| - throw raise(IndexError, ErrorMessages.TUPLE_OUT_OF_BOUNDS); |
2074 |
| - } |
2075 |
| - return getItemNode.execute(frame, sequenceStorage, key); |
2076 |
| - } |
2077 |
| - |
2078 |
| - @Fallback |
2079 |
| - Object doPTuple(Object tuple, @SuppressWarnings("unused") Object key) { |
2080 |
| - // TODO(fa) To be absolutely correct, we need to do a 'isinstance' check on the object. |
2081 |
| - throw raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, tuple, tuple); |
2082 |
| - } |
2083 |
| - } |
2084 |
| - |
2085 | 1954 | @Builtin(name = "PyTruffle_Compute_Mro", minNumOfPositionalArgs = 2)
|
2086 | 1955 | @GenerateNodeFactory
|
2087 | 1956 | @TypeSystemReference(PythonTypes.class)
|
|
0 commit comments