gc.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef VIRTUALMATH_GC_H
  2. #define VIRTUALMATH_GC_H
  3. #define START_GC true
  4. struct Inter;
  5. struct Value;
  6. struct LinkValue;
  7. struct HashTable;
  8. struct Var;
  9. struct VarList;
  10. struct GCStatus{
  11. long int tmp_link; // tmp link的次数
  12. long int statement_link; // statement link的次数
  13. long int link; // 被直接link的次数
  14. enum {
  15. not_free,
  16. run_del,
  17. need_free,
  18. } c_value; // value的计数 (先call __del__ 后释放)
  19. bool continue_; // 是否迭代过
  20. };
  21. typedef struct GCStatus GCStatus;
  22. void resetGC(GCStatus *gcs);
  23. void setGC(GCStatus *gcs);
  24. void gc_addTmpLink(GCStatus *gcs);
  25. void gc_addLink(GCStatus *gcs);
  26. void gc_addStatementLink(GCStatus *gcs);
  27. void gc_freeStatementLink(GCStatus *gcs);
  28. void gc_freeTmpLink(GCStatus *gcs);
  29. bool gc_IterAlready(GCStatus *gcs);
  30. bool gc_needFree(GCStatus *gcs);
  31. void gc_resetValue(struct Value *value);
  32. bool gc_needFreeValue(struct Value *value);
  33. void gc_freeBase(struct Inter *inter);
  34. void gc_checkDel(struct Inter *inter);
  35. void gc_runDelAll(struct Inter *inter);
  36. void gc_runDel(struct Inter *inter, struct VarList *var_list);
  37. void gc_checkBase(struct Inter *inter);
  38. void gc_resetBase(struct Inter *inter);
  39. void gc_iterValue(struct Value *value);
  40. void gc_iterLinkValue(struct LinkValue *value);
  41. void gc_iterHashTable(struct HashTable *ht);
  42. void gc_iterVar(struct Var *var);
  43. void gc_varList(struct VarList *vl);
  44. void gc_iterFreezeVarList(struct VarList *freeze, struct VarList *base, bool is_lock);
  45. void gc_freeze(struct Inter *inter, struct VarList *freeze, struct VarList *base, bool is_lock);
  46. void gc_run(struct Inter *inter, struct VarList *run_var, int var_list, int link_value, int value, ...);
  47. #endif //VIRTUALMATH_GC_H