diff options
Diffstat (limited to 'src/generator.c')
-rw-r--r-- | src/generator.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/generator.c b/src/generator.c index bbb2af5..1b11b67 100644 --- a/src/generator.c +++ b/src/generator.c | |||
@@ -264,7 +264,7 @@ void gen_ifelse_end(int idx) { | |||
264 | 264 | ||
265 | // ----- OPERATORS ----- | 265 | // ----- OPERATORS ----- |
266 | 266 | ||
267 | int gen_assign(const char ident[], Scope scope) { | 267 | static int gen_assign_simple(const char ident[], Scope scope) { |
268 | int l_addr = loc_get_addr(ident); | 268 | int l_addr = loc_get_addr(ident); |
269 | int g_addr = glo_get_addr(ident); | 269 | int g_addr = glo_get_addr(ident); |
270 | 270 | ||
@@ -290,7 +290,7 @@ int gen_assign(const char ident[], Scope scope) { | |||
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | int gen_assign_tab(const char ident[], Scope scope) { | 293 | static int gen_assign_tab(const char ident[], Scope scope) { |
294 | int l_addr = loc_get_addr(ident); | 294 | int l_addr = loc_get_addr(ident); |
295 | int g_addr = glo_get_addr(ident); | 295 | int g_addr = glo_get_addr(ident); |
296 | 296 | ||
@@ -322,6 +322,13 @@ int gen_assign_tab(const char ident[], Scope scope) { | |||
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | int gen_assign(const char ident[], Scope scope) { | ||
326 | switch (loc_lookup(ident)) { | ||
327 | case TAB: return gen_assign_tab(ident, scope); | ||
328 | default: return gen_assign_simple(ident, scope); | ||
329 | } | ||
330 | } | ||
331 | |||
325 | void gen_or(int left, int right, int idx) { | 332 | void gen_or(int left, int right, int idx) { |
326 | check_expected_types(left, INT, TAB); | 333 | check_expected_types(left, INT, TAB); |
327 | check_expected_types(right, INT, TAB); | 334 | check_expected_types(right, INT, TAB); |
@@ -452,7 +459,7 @@ int gen_negate_expr(int type) { | |||
452 | return type; | 459 | return type; |
453 | } | 460 | } |
454 | 461 | ||
455 | int gen_value(const char ident[], Scope scope) { | 462 | static int gen_value_simple(const char ident[], Scope scope) { |
456 | int l_addr = loc_get_addr(ident); | 463 | int l_addr = loc_get_addr(ident); |
457 | 464 | ||
458 | switch (scope) { | 465 | switch (scope) { |
@@ -475,7 +482,8 @@ int gen_value(const char ident[], Scope scope) { | |||
475 | exit(1); | 482 | exit(1); |
476 | } | 483 | } |
477 | } | 484 | } |
478 | int gen_value_tab(const char ident[], Scope scope) { | 485 | |
486 | static int gen_value_tab(const char ident[], Scope scope) { | ||
479 | int l_addr = loc_get_addr(ident); | 487 | int l_addr = loc_get_addr(ident); |
480 | int g_addr = glo_get_addr(ident); | 488 | int g_addr = glo_get_addr(ident); |
481 | switch (scope) { | 489 | switch (scope) { |
@@ -500,6 +508,14 @@ int gen_value_tab(const char ident[], Scope scope) { | |||
500 | exit(1); | 508 | exit(1); |
501 | } | 509 | } |
502 | } | 510 | } |
511 | |||
512 | int gen_value(const char ident[], Scope scope) { | ||
513 | switch (loc_lookup(ident)) { | ||
514 | case TAB: return gen_value_tab(ident, scope); | ||
515 | default: return gen_value_simple(ident, scope); | ||
516 | } | ||
517 | } | ||
518 | |||
503 | int gen_num(int value, Scope scope) { | 519 | int gen_num(int value, Scope scope) { |
504 | fprintf(output, "push %d\n", value); | 520 | fprintf(output, "push %d\n", value); |
505 | return INT; | 521 | return INT; |