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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 base_type_t {UNKNOWN, INT};
  26. extern int taille_types[];
  27. extern int profondeur;
  28. struct type_t {
  29. enum base_type_t base;
  30. int pointeur_level;
  31. };
  32. struct symbole_t {
  33. char nom[30];
  34. uintptr_t adresse;
  35. struct type_t type;
  36. int initialized;
  37. int profondeur;
  38. };
  39. void print_symbole(struct symbole_t symbole);
  40. void init(void);
  41. int push(char * nom, int isInit, struct type_t type);
  42. struct symbole_t pop();
  43. // renvoi 0 si nom n'existe pas, 2 si nom existe sans etre initialisée, 1 sinon
  44. char status(char * nom);
  45. void print();
  46. int get_last_addr();
  47. struct symbole_t * get_variable(char * nom);
  48. int allocate_mem_temp_var(enum base_type_t type);
  49. void reset_temp_vars();
  50. void reset_pronf();
  51. void decrement_temp_var();