aboutsummaryrefslogtreecommitdiff
path: root/src/symbol_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/symbol_table.c')
-rw-r--r--src/symbol_table.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/symbol_table.c b/src/symbol_table.c
index 6f84ce4..8e6db97 100644
--- a/src/symbol_table.c
+++ b/src/symbol_table.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include "symbol_table.h" 6#include "symbol_table.h"
7#include "generator.h"
7 8
8extern int lineno; /* from lexical analyser */ 9extern int lineno; /* from lexical analyser */
9 10
@@ -61,15 +62,15 @@ void glo_display_table() {
61 int count; 62 int count;
62 for (count = 0; count < glo_symbol_table.size; count++) { 63 for (count = 0; count < glo_symbol_table.size; count++) {
63 if (glo_symbol_table.entries[count].type == INT) 64 if (glo_symbol_table.entries[count].type == INT)
64 printf(";entier: %s, pos: %d \n", 65 fprintf(output, ";entier: %s, pos: %d \n",
65 glo_symbol_table.entries[count].name, 66 glo_symbol_table.entries[count].name,
66 glo_symbol_table.entries[count].addr); 67 glo_symbol_table.entries[count].addr);
67 else 68 else
68 printf(";caractere: %s, pos: %d \n", 69 fprintf(output, ";caractere: %s, pos: %d \n",
69 glo_symbol_table.entries[count].name, 70 glo_symbol_table.entries[count].name,
70 glo_symbol_table.entries[count].addr); 71 glo_symbol_table.entries[count].addr);
71 } 72 }
72 printf("\n"); 73 fprintf(output, "\n");
73} 74}
74 75
75void loc_addVar(const char name[], int type) { 76void loc_addVar(const char name[], int type) {
@@ -127,21 +128,21 @@ void loc_display_table() {
127 int count; 128 int count;
128 for (count = 0; count < loc_symbol_table.size; count++) { 129 for (count = 0; count < loc_symbol_table.size; count++) {
129 if (loc_symbol_table.entries[count].type == INT) 130 if (loc_symbol_table.entries[count].type == INT)
130 printf(";entier: %s, pos: %d \n", 131 fprintf(output, ";entier: %s, pos: %d \n",
131 loc_symbol_table.entries[count].name, 132 loc_symbol_table.entries[count].name,
132 loc_symbol_table.entries[count].addr); 133 loc_symbol_table.entries[count].addr);
133 else 134 else
134 printf(";caractere: %s, pos: %d \n", 135 fprintf(output, ";caractere: %s, pos: %d \n",
135 loc_symbol_table.entries[count].name, 136 loc_symbol_table.entries[count].name,
136 loc_symbol_table.entries[count].addr); 137 loc_symbol_table.entries[count].addr);
137 } 138 }
138 printf("\n"); 139 fprintf(output, "\n");
139} 140}
140 141
141void loc_clean_table() { 142void loc_clean_table() {
142 int i; 143 int i;
143 for (i = 0; i < loc_symbol_table.size; i++) { 144 for (i = 0; i < loc_symbol_table.size; i++) {
144 printf("pop eax\n"); 145 fprintf(output, "pop eax\n");
145 } 146 }
146 loc_symbol_table.size = 0; 147 loc_symbol_table.size = 0;
147} 148}