Added type promotion to allow progress on mes.c
This commit is contained in:
parent
589217b3b6
commit
3f9808a19a
17
cc.c
17
cc.c
|
@ -29,23 +29,6 @@ int match(char* a, char* b);
|
|||
void file_print(char* s, FILE* f);
|
||||
char* parse_string(char* string);
|
||||
|
||||
void test0(struct token_list* l, FILE* o)
|
||||
{
|
||||
while(NULL != l)
|
||||
{
|
||||
if(l->s[0] == 34)
|
||||
{
|
||||
file_print(parse_string(l->s), o);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_print(l->s, o);
|
||||
}
|
||||
fputc(10, o);
|
||||
l = l->next;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FILE* in = stdin;
|
||||
|
|
37
cc_core.c
37
cc_core.c
|
@ -239,17 +239,54 @@ struct token_list* process_expression_list(struct token_list* out, struct token_
|
|||
return out;
|
||||
}
|
||||
|
||||
struct type* last_type;
|
||||
|
||||
struct token_list* pre_recursion(struct token_list* out, struct token_list* func)
|
||||
{
|
||||
last_type = current_target;
|
||||
global_token = global_token->next;
|
||||
out = emit("PUSH_eax\t#_common_recursion\x0A", out);
|
||||
func->temps = func->temps + 1;
|
||||
return out;
|
||||
}
|
||||
|
||||
struct type* promote_type(struct type* a, struct type* b)
|
||||
{
|
||||
if(NULL == a)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
if(NULL == b)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
struct type* i;
|
||||
for(i = global_types; NULL != i; i = i->next)
|
||||
{
|
||||
if(a->name == i->name)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
if(b->name == i->name)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
if(a->name == i->indirect->name)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
if(b->name == i->indirect->name)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct token_list* post_recursion(struct token_list* out, struct token_list* func)
|
||||
{
|
||||
current_target = promote_type(current_target, last_type);
|
||||
func->temps = func->temps - 1;
|
||||
out = emit("POP_ebx\t# _common_recursion\x0A", out);
|
||||
return out;
|
||||
|
|
|
@ -9,7 +9,7 @@ d27eb315d694324650b11a421d6990eee60ac5921a5625bbccb43d806f09e156 test/results/t
|
|||
8cc38294fb1261843cfc3956fad5a451c95bbc2ed687435d4e2d59df2c4a8567 test/results/test08-binary
|
||||
cc8f252877a85c0d7832094ff574d7173ac33940917bc1591358b8970651a81c test/results/test09-binary
|
||||
3857aee4183de41bd00b014d616a5d73f4bfc57aa60a6073bb4113d6ff2fb8d5 test/results/test10-binary
|
||||
e9f2c016b3119069d808c113a7cfdd01d1d6d205c81e34fe16a659e700e48c34 test/results/test100-binary
|
||||
ab2341e89491192eb5b6dbb432661025b762ee1f0b419b8f98deda65c2b3f289 test/results/test100-binary
|
||||
dce2f0b35323cf6a2b01f74a9335100f2d8626028af545832dbdb503573db0e5 test/results/test11-binary
|
||||
88602970fa07b5da7a42b4f2b2486fe03accc6796e05453c4ab934e986790bef test/results/test12-binary
|
||||
c85a57b5b1d65288efd47a3b12c6fca1efade9e7ec91e65efda5531d2c40d293 test/results/test13-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
7aa6bad31f78227761301b4f5fc26147c7ed22b6e4265c0cbca3641a54e459b5 test/test100/proof
|
||||
8945ef74cc5a843cf004bca54d10d14da8a5369babbce9f2bc584ab98a59e84c test/test100/proof
|
||||
|
|
Loading…
Reference in New Issue