No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

table_symboles.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* TABLE DES SYMBOLE DU COMPILATEUR (PILE)
  2. -----------------------------------------------------
  3. | symbole | adresse | type | initialisé |
  4. -----------------------------------------------------
  5. | | | | |
  6. | | | | |
  7. | | | | |
  8. | i | 0x777756b8 | int | false |
  9. | size | 0x777756b8 | int | true |
  10. -----------------------------------------------------
  11. Types pour l'implémentation :
  12. - enum type_t : [int]
  13. - struct symbole : {
  14. char nom[30];
  15. uintptr_t adresse;
  16. enum type_t type;
  17. char initialized;
  18. }
  19. Opérations possible :
  20. - init -> pile * -> void
  21. - push -> symbole -> pile * -> void
  22. - pop -> pile * -> symbole
  23. - status -> nom -> pile -> char */
  24. #include <stdint.h>
  25. enum type_t {UNKNOWN, INT};
  26. extern int taille_types[];
  27. extern int profondeur;
  28. struct symbole_t {
  29. char nom[30];
  30. uintptr_t adresse;
  31. enum type_t type;
  32. char initialized;
  33. int profondeur;
  34. };
  35. void print_symbole(struct symbole_t symbole);
  36. void init(void);
  37. int push(char * nom, int isInit, enum type_t type);
  38. struct symbole_t pop();
  39. // renvoi 0 si nom n'existe pas, 2 si nom existe sans etre initialisée, 1 sinon
  40. char status(char * nom);
  41. void print();
  42. int get_last_addr();
  43. struct symbole_t * get_variable(char * nom);
  44. int allocate_mem_temp_var(enum type_t type);
  45. void reset_temp_vars();