Variables.h 956 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef STRINGINTMAP_H
  2. #define STRINGINTMAP_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdbool.h>
  7. #include "DataType.h"
  8. typedef struct {
  9. int address;
  10. int entries;
  11. int scope;
  12. } Scope;
  13. typedef struct {
  14. const char* name;
  15. DataType type;
  16. int address;
  17. } Variable;
  18. typedef struct {
  19. int capacity;
  20. int entries;
  21. int address;
  22. int scope;
  23. Variable* data;
  24. int maxAddress;
  25. char padding[sizeof(Variable*) - sizeof(int)];
  26. } Variables;
  27. void vsInit(Variables* v);
  28. void vsDelete(Variables* v);
  29. bool vsSearch(const Variables* vs, Variable* v, const char* s);
  30. bool vSearchStruct(Variable* v, Structs* sts, Struct* st, const char* s);
  31. bool vsInScope(const Variables* vs, const char* s);
  32. Variable* vsAdd(Variables* v, const char* s, DataType type, Structs* sts);
  33. void vsReset(Variables* v);
  34. void vsEnterScope(Variables* v, Scope* s);
  35. void vsLeaveScope(Variables* v, Scope* s);
  36. #ifdef __cplusplus
  37. }
  38. #endif
  39. #endif