var.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef VIRTUALMATH_VAR_H
  2. #define VIRTUALMATH_VAR_H
  3. #define MAX_SIZE (8)
  4. #define copyVarListCore(base, inter) makeVarList((inter), false, (base)->hashtable)
  5. #define popVarList(base) (((base)->next == NULL) ? (base) : freeVarList(base))
  6. struct Var{
  7. GCStatus gc_status;
  8. wchar_t *name;
  9. struct LinkValue *value;
  10. struct LinkValue *name_;
  11. struct Var *next;
  12. struct Var *gc_next;
  13. struct Var *gc_last;
  14. };
  15. struct HashTable{
  16. GCStatus gc_status;
  17. struct Var **hashtable;
  18. struct HashTable *gc_next;
  19. struct HashTable *gc_last;
  20. };
  21. struct DefaultVar{
  22. wchar_t *name;
  23. vint times;
  24. struct DefaultVar *next;
  25. };
  26. struct VarList{
  27. struct HashTable *hashtable;
  28. struct DefaultVar *default_var;
  29. struct VarList *next;
  30. };
  31. enum VarOperation {
  32. get_var,
  33. read_var,
  34. del_var,
  35. };
  36. typedef struct Var Var;
  37. typedef struct HashTable HashTable;
  38. typedef struct DefaultVar DefaultVar;
  39. typedef struct VarList VarList;
  40. typedef enum VarOperation VarOperation;
  41. Var *makeVar(wchar_t *name, LinkValue *value, LinkValue *name_, Inter *inter);
  42. void freeVar(Var **var);
  43. HashTable *makeHashTable(Inter *inter);
  44. void freeHashTable(HashTable **value);
  45. VarList *makeVarList(Inter *inter, bool make_hash, HashTable *hs);
  46. VarList *freeVarList(VarList *vl);
  47. vhashn time33(wchar_t *key);
  48. LinkValue *findVar(wchar_t *name, VarOperation operating, Inter *inter, HashTable *ht);
  49. LinkValue *findFromVarList(wchar_t *name, vint times, VarOperation operating, FUNC_CORE);
  50. void addVar(wchar_t *name, LinkValue *value, LinkValue *name_, Inter *inter, HashTable *ht);
  51. void updateHashTable(HashTable *update, HashTable *new, Inter *inter);
  52. void addFromVarList(wchar_t *name, LinkValue *name_, vint times, LinkValue *value, FUNC_CORE);
  53. VarList *pushVarList(VarList *base, Inter *inter);
  54. VarList *copyVarList(VarList *base, bool n_new, Inter *inter);
  55. VarList *connectVarListBack(VarList *base, VarList *back);
  56. VarList *makeObjectVarList(Inherit *value, Inter *inter, VarList *base);
  57. vint findDefault(DefaultVar *base, wchar_t *name);
  58. DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vint times);
  59. DefaultVar *freeDefaultVar(DefaultVar *dv);
  60. DefaultVar *makeDefaultVar(wchar_t *name, vint times);
  61. #endif //VIRTUALMATH_VAR_H