|
136 | 136 | import com.oracle.graal.python.builtins.objects.set.SetNodes;
|
137 | 137 | import com.oracle.graal.python.builtins.objects.str.PString;
|
138 | 138 | import com.oracle.graal.python.builtins.objects.superobject.SuperObject;
|
| 139 | +import com.oracle.graal.python.builtins.objects.traceback.PTraceback; |
139 | 140 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
140 | 141 | import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
|
141 | 142 | import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
|
|
189 | 190 | import com.oracle.graal.python.runtime.PythonContext;
|
190 | 191 | import com.oracle.graal.python.runtime.PythonCore;
|
191 | 192 | import com.oracle.graal.python.runtime.exception.PException;
|
| 193 | +import com.oracle.graal.python.runtime.object.PythonObjectFactory; |
192 | 194 | import com.oracle.graal.python.runtime.sequence.PSequence;
|
193 | 195 | import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage;
|
194 | 196 | import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage;
|
@@ -2827,12 +2829,40 @@ Object call() {
|
2827 | 2829 | }
|
2828 | 2830 | }
|
2829 | 2831 |
|
2830 |
| - @Builtin(name = "traceback", constructsClass = PythonBuiltinClassType.PTraceback, isPublic = false) |
| 2832 | + @Builtin(name = "TracebackType", constructsClass = PythonBuiltinClassType.PTraceback, isPublic = false, minNumOfPositionalArgs = 5, parameterNames = {"$cls", "tb_next", "tb_frame", "tb_lasti", |
| 2833 | + "tb_lineno"}) |
2831 | 2834 | @GenerateNodeFactory
|
2832 | 2835 | public abstract static class TracebackTypeNode extends PythonBuiltinNode {
|
2833 |
| - @Specialization |
2834 |
| - Object call() { |
2835 |
| - throw raise(RuntimeError, ErrorMessages.CANNOT_CALL_CTOR_OF, "traceback type"); |
| 2836 | + @Specialization(limit = "1") |
| 2837 | + Object createTraceback(@SuppressWarnings("unused") LazyPythonClass cls, PTraceback next, PFrame frame, Object lasti, Object lineno, |
| 2838 | + @CachedLibrary("lasti") PythonObjectLibrary lastiLib, |
| 2839 | + @CachedLibrary("lineno") PythonObjectLibrary linenoLib, |
| 2840 | + @Cached PythonObjectFactory factory) { |
| 2841 | + return factory.createTraceback(frame, linenoLib.asSize(lineno), lastiLib.asSize(lasti), next); |
| 2842 | + } |
| 2843 | + |
| 2844 | + @Specialization(limit = "1") |
| 2845 | + Object createTraceback(@SuppressWarnings("unused") LazyPythonClass cls, @SuppressWarnings("unused") PNone next, PFrame frame, Object lasti, Object lineno, |
| 2846 | + @CachedLibrary("lasti") PythonObjectLibrary lastiLib, |
| 2847 | + @CachedLibrary("lineno") PythonObjectLibrary linenoLib, |
| 2848 | + @Cached PythonObjectFactory factory) { |
| 2849 | + return factory.createTraceback(frame, linenoLib.asSize(lineno), lastiLib.asSize(lasti), null); |
| 2850 | + } |
| 2851 | + |
| 2852 | + @Specialization(guards = {"!isPTraceback(next)", "!isNone(next)"}) |
| 2853 | + @SuppressWarnings("unused") |
| 2854 | + Object errorNext(LazyPythonClass cls, Object next, Object frame, Object lasti, Object lineno) { |
| 2855 | + throw raise(TypeError, "expected traceback object or None, got '%p'", next); |
| 2856 | + } |
| 2857 | + |
| 2858 | + @Specialization(guards = "!isPFrame(frame)") |
| 2859 | + @SuppressWarnings("unused") |
| 2860 | + Object errorFrame(LazyPythonClass cls, Object next, Object frame, Object lasti, Object lineno) { |
| 2861 | + throw raise(TypeError, "TracebackType() argument 'tb_frame' must be frame, not %p", frame); |
| 2862 | + } |
| 2863 | + |
| 2864 | + protected static boolean isPFrame(Object obj) { |
| 2865 | + return obj instanceof PFrame; |
2836 | 2866 | }
|
2837 | 2867 | }
|
2838 | 2868 |
|
|
0 commit comments