Add missing functions, fix missing breaks on switch
This commit is contained in:
parent
610c45e3e1
commit
764f89bb88
|
@ -123,7 +123,7 @@ enum SyntaxOps {
|
|||
|
||||
// A node in a Binary Tree that forms the syntax of Erythro
|
||||
struct ASTNode {
|
||||
int Operation;
|
||||
int Operation; // SyntaxOps Index
|
||||
int ExprType; // Value->IntValue's DataType
|
||||
struct ASTNode* Left;
|
||||
struct ASTNode* Middle;
|
||||
|
|
|
@ -454,10 +454,10 @@ void AsNewSymb(int ID) {
|
|||
Symbols[ID].Name);
|
||||
|
||||
switch(TypeSize) {
|
||||
case 1: fprintf(OutputFile, "%s:\t.byte\t0\n", Symbols[ID].Name);
|
||||
case 4: fprintf(OutputFile, "%s:\t.long\t0\n", Symbols[ID].Name);
|
||||
case 8: fprintf(OutputFile, "%s:\t.quad\t0\n", Symbols[ID].Name);
|
||||
default: DieDecimal("Unknown type in AsNewSymbol", TypeSize);
|
||||
case 1: fprintf(OutputFile, "%s:\t.byte\t0\n", Symbols[ID].Name); break;
|
||||
case 4: fprintf(OutputFile, "%s:\t.long\t0\n", Symbols[ID].Name); break;
|
||||
case 8: fprintf(OutputFile, "%s:\t.quad\t0\n", Symbols[ID].Name); break;
|
||||
default: DieDecimal("Unknown type in AsNewSymbol", TypeSize); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
14
src/Types.c
14
src/Types.c
|
@ -7,6 +7,19 @@
|
|||
#include <Defs.h>
|
||||
#include <Data.h>
|
||||
|
||||
|
||||
int TypeIsInt(int Type) {
|
||||
if(Type == RET_CHAR || Type == RET_INT || Type == RET_LONG)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TypeIsPtr(int Type) {
|
||||
if(Type == PTR_VOID || Type == PTR_CHAR || Type == PTR_INT || Type == PTR_LONG)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn a token type into its appropriate
|
||||
* primitive type.
|
||||
|
@ -136,6 +149,7 @@ struct ASTNode* MutateType(struct ASTNode* Tree, int RightType, int Operation) {
|
|||
LeftType = Tree->ExprType;
|
||||
|
||||
|
||||
printf("\tCalculating compatibility between ltype %d and rtype %d\r\n", LeftType, RightType);
|
||||
if(TypeIsInt(LeftType) && TypeIsInt(RightType)) {
|
||||
|
||||
// Short-circuit for valid types
|
||||
|
|
Loading…
Reference in New Issue
Block a user