1
0

var.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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) == 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. read_var,
  33. del_var,
  34. };
  35. typedef struct Var Var;
  36. typedef struct HashTable HashTable;
  37. typedef struct DefaultVar DefaultVar;
  38. typedef struct VarList VarList;
  39. typedef enum VarOperation VarOperation;
  40. Var *makeVar(wchar_t *name, LinkValue *value, LinkValue *name_, Inter *inter);
  41. void freeVar(Var **var);
  42. HashTable *makeHashTable(Inter *inter);
  43. void freeHashTable(HashTable **value);
  44. VarList *makeVarList(Inter *inter, bool make_hash, HashTable *hs);
  45. VarList *freeVarList(VarList *vl);
  46. vhashn time33(wchar_t *key);
  47. LinkValue *findVar(wchar_t *name, VarOperation operating, Var **re, HashTable *ht);
  48. LinkValue *findFromVarList(wchar_t *name, vint times, Var **re, VarOperation operating, struct Inter *inter,
  49. struct VarList *var_list);
  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 *makeObjectVarList(Inherit *value, Inter *inter, VarList *base);
  56. vint findDefault(DefaultVar *base, wchar_t *name);
  57. DefaultVar *connectDefaultVar(DefaultVar *base, wchar_t *name, vint times);
  58. DefaultVar *freeDefaultVar(DefaultVar *dv);
  59. DefaultVar *makeDefaultVar(wchar_t *name, vint times);
  60. #endif //VIRTUALMATH_VAR_H