datastack.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef _COVERAGE_DATASTACK_H
  4. #define _COVERAGE_DATASTACK_H
  5. #include "util.h"
  6. #include "stats.h"
  7. /* An entry on the data stack. For each call frame, we need to record all
  8. * the information needed for CTracer_handle_line to operate as quickly as
  9. * possible. All PyObject* here are borrowed references.
  10. */
  11. typedef struct DataStackEntry {
  12. /* The current file_data dictionary. Borrowed, owned by self->data. */
  13. PyObject * file_data;
  14. /* The disposition object for this frame. If collector.py and control.py
  15. * are working properly, this will be an instance of CFileDisposition.
  16. */
  17. PyObject * disposition;
  18. /* The FileTracer handling this frame, or None if it's Python. */
  19. PyObject * file_tracer;
  20. /* The line number of the last line recorded, for tracing arcs.
  21. -1 means there was no previous line, as when entering a code object.
  22. */
  23. int last_line;
  24. BOOL started_context;
  25. } DataStackEntry;
  26. /* A data stack is a dynamically allocated vector of DataStackEntry's. */
  27. typedef struct DataStack {
  28. int depth; /* The index of the last-used entry in stack. */
  29. int alloc; /* number of entries allocated at stack. */
  30. /* The file data at each level, or NULL if not recording. */
  31. DataStackEntry * stack;
  32. } DataStack;
  33. int DataStack_init(Stats * pstats, DataStack *pdata_stack);
  34. void DataStack_dealloc(Stats * pstats, DataStack *pdata_stack);
  35. int DataStack_grow(Stats * pstats, DataStack *pdata_stack);
  36. #endif /* _COVERAGE_DATASTACK_H */