diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-06 21:35:04 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-06 21:35:17 -0400 |
commit | ef25180600e74dfe1453ab4dbd68df43c11688a6 (patch) | |
tree | fa3e3683a1630f4eb82e924ab2aed1fa63499907 | |
parent | 63f1baa5f4583fb1d919a01b7e658c0e305ac96c (diff) |
Add gen_statement base code to code generation
-rw-r--r-- | gen_code.c | 43 |
1 files changed, 38 insertions, 5 deletions
@@ -1,3 +1,4 @@ +#include <stdio.h> #include "gen_code.h" #include "pc.h" @@ -37,13 +38,45 @@ ptree *t; { } -void gen_code(t, name) +void gen_statement(t) ptree *t; { - /*Test gen_label*/ - if (t->type == ASSIGNOP){ - gen_label(t->r); - print_tree(t->r); + char buf[100]; + + if (!t) + return; + + switch (t->type){ + case ASSIGNOP: + + break; + case PCALL: + + break; + case LIST: + + break; + case IF: + + break; + case WHILE: + + break; + + case FOR: + break; + default: + snprintf(buf, 100, "Unknown statement type: %d\n", t->type); + yyerror(buf); } } +void gen_code(t, name) +ptree *t; +char *name; +{ + printf("\n.globl %s\n.type %s, @function\n%s:\n", name, name, name); + + /*TODO call gen_statement on all statements in LIST t*/ + /*Look at set_type for list traverseal code*/ +} |