Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:48

0001 #ifndef Py_INTERNAL_INSTRUCTION_SEQUENCE_H
0002 #define Py_INTERNAL_INSTRUCTION_SEQUENCE_H
0003 
0004 #ifndef Py_BUILD_CORE
0005 #  error "this header requires Py_BUILD_CORE define"
0006 #endif
0007 
0008 #include "pycore_symtable.h"
0009 
0010 #ifdef __cplusplus
0011 extern "C" {
0012 #endif
0013 
0014 
0015 typedef struct {
0016     int h_label;
0017     int h_startdepth;
0018     int h_preserve_lasti;
0019 } _PyExceptHandlerInfo;
0020 
0021 typedef struct {
0022     int i_opcode;
0023     int i_oparg;
0024     _Py_SourceLocation i_loc;
0025     _PyExceptHandlerInfo i_except_handler_info;
0026 
0027     /* Temporary fields, used by the assembler and in instr_sequence_to_cfg */
0028     int i_target;
0029     int i_offset;
0030 } _PyInstruction;
0031 
0032 typedef struct instruction_sequence {
0033     PyObject_HEAD
0034     _PyInstruction *s_instrs;
0035     int s_allocated;
0036     int s_used;
0037 
0038     int s_next_free_label; /* next free label id */
0039 
0040     /* Map of a label id to instruction offset (index into s_instrs).
0041      * If s_labelmap is NULL, then each label id is the offset itself.
0042      */
0043     int *s_labelmap;
0044     int s_labelmap_size;
0045 
0046     /* PyList of instruction sequences of nested functions */
0047     PyObject *s_nested;
0048 } _PyInstructionSequence;
0049 
0050 typedef struct {
0051     int id;
0052 } _PyJumpTargetLabel;
0053 
0054 PyAPI_FUNC(PyObject*)_PyInstructionSequence_New(void);
0055 
0056 int _PyInstructionSequence_UseLabel(_PyInstructionSequence *seq, int lbl);
0057 int _PyInstructionSequence_Addop(_PyInstructionSequence *seq,
0058                                  int opcode, int oparg,
0059                                  _Py_SourceLocation loc);
0060 _PyJumpTargetLabel _PyInstructionSequence_NewLabel(_PyInstructionSequence *seq);
0061 int _PyInstructionSequence_ApplyLabelMap(_PyInstructionSequence *seq);
0062 int _PyInstructionSequence_InsertInstruction(_PyInstructionSequence *seq, int pos,
0063                                              int opcode, int oparg, _Py_SourceLocation loc);
0064 int _PyInstructionSequence_AddNested(_PyInstructionSequence *seq, _PyInstructionSequence *nested);
0065 void PyInstructionSequence_Fini(_PyInstructionSequence *seq);
0066 
0067 extern PyTypeObject _PyInstructionSequence_Type;
0068 #define _PyInstructionSequence_Check(v) Py_IS_TYPE((v), &_PyInstructionSequence_Type)
0069 
0070 #ifdef __cplusplus
0071 }
0072 #endif
0073 #endif /* !Py_INTERNAL_INSTRUCTION_SEQUENCE_H */