1 /* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
2 /* For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt */
3 
4 #ifndef _COVERAGE_DATASTACK_H
5 #define _COVERAGE_DATASTACK_H
6 
7 #include "util.h"
8 #include "stats.h"
9 
10 /* An entry on the data stack.  For each call frame, we need to record all
11  * the information needed for CTracer_handle_line to operate as quickly as
12  * possible.  All PyObject* here are borrowed references.
13  */
14 typedef struct DataStackEntry {
15     /* The current file_data dictionary.  Borrowed, owned by self->data. */
16     PyObject * file_data;
17 
18     /* The disposition object for this frame. If collector.py and control.py
19      * are working properly, this will be an instance of CFileDisposition.
20      */
21     PyObject * disposition;
22 
23     /* The FileTracer handling this frame, or None if it's Python. */
24     PyObject * file_tracer;
25 
26     /* The line number of the last line recorded, for tracing arcs.
27         -1 means there was no previous line, as when entering a code object.
28     */
29     int last_line;
30 } DataStackEntry;
31 
32 /* A data stack is a dynamically allocated vector of DataStackEntry's. */
33 typedef struct DataStack {
34     int depth;      /* The index of the last-used entry in stack. */
35     int alloc;      /* number of entries allocated at stack. */
36     /* The file data at each level, or NULL if not recording. */
37     DataStackEntry * stack;
38 } DataStack;
39 
40 
41 int DataStack_init(Stats * pstats, DataStack *pdata_stack);
42 void DataStack_dealloc(Stats * pstats, DataStack *pdata_stack);
43 int DataStack_grow(Stats * pstats, DataStack *pdata_stack);
44 
45 #endif /* _COVERAGE_DATASTACK_H */
46