Variables.h 1.2 KB

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