diff --git a/include/Data.h b/include/Data.h index af1be8b..47acb49 100644 --- a/include/Data.h +++ b/include/Data.h @@ -51,4 +51,4 @@ extern_ struct Token CurrentToken; extern_ char CurrentIdentifier[TEXTLEN + 1]; extern_ int CurrentGlobal; -extern_ int CurrentLocal; \ No newline at end of file +extern_ int CurrentLocal; diff --git a/include/Defs.h b/include/Defs.h index 0f1abd0..ef6e1ab 100644 --- a/include/Defs.h +++ b/include/Defs.h @@ -374,12 +374,10 @@ struct SymbolTableEntry* AddSymbol(char* Name, int Type, int Structure, int Stor * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Die(char* Error); - void DieMessage(char* Error, char* Reason); - void DieDecimal(char* Error, int Number); - void DieChar(char* Error, int Char); +void DieBinary(char* Error, int Number); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/src/Main.c b/src/Main.c index f946b56..5a10236 100644 --- a/src/Main.c +++ b/src/Main.c @@ -216,6 +216,18 @@ void DieDecimal(char* Error, int Number) { exit(1); } +/** + * A variant of Die that prints the int in binary. + */ +void DieBinary(char* Error, int Number) { + char buf[33]; + itoa(Number, buf, 2); + printf("%s: %s\n", Error, buf); + fclose(OutputFile); + unlink(OutputFileName); + exit(1); +} + /* * A variant of Die with an extra character attached. */ diff --git a/src/Statements.c b/src/Statements.c index 673ec9c..6af8a78 100644 --- a/src/Statements.c +++ b/src/Statements.c @@ -208,6 +208,7 @@ struct ASTNode* ParseFunction(int Type) { if(NewFunction) { NewFunction->Elements = ParamCount; NewFunction->Start = Params; + NewFunction->Type = RET_LONG; OldFunction = NewFunction; } @@ -507,7 +508,7 @@ struct ASTNode* PostfixStatement() { // (as functions have been called and arrays have been indexed) // Check that the variable is recognized.. - if((Entry = FindSymbol(CurrentIdentifier)) == NULL || Entry->Structure != ST_VAR || Entry->Structure != ST_FUNC) { + if((Entry = FindSymbol(CurrentIdentifier)) == NULL || (Entry->Structure != ST_VAR && Entry->Structure != ST_FUNC)) { DumpAllLists(); DieMessage("Unknown Variable", CurrentIdentifier); } diff --git a/src/Symbols.c b/src/Symbols.c index 566fad4..3831211 100644 --- a/src/Symbols.c +++ b/src/Symbols.c @@ -67,7 +67,7 @@ static struct SymbolTableEntry* SearchList(char* Name, struct SymbolTableEntry* struct SymbolTableEntry* FindSymbol(char* Symbol) { struct SymbolTableEntry* Node; - if(CurrentFunction) { + if(FunctionEntry) { Node = SearchList(Symbol, FunctionEntry->Start); if(Node) return Node; diff --git a/src/Types.c b/src/Types.c index 2d6d056..c4e440a 100644 --- a/src/Types.c +++ b/src/Types.c @@ -48,7 +48,7 @@ int PrimitiveSize(int Type) { case RET_INT: return 4; case RET_LONG: return 8; default: - DieDecimal("Bad type in PrimitiveSize", Type); + DieBinary("Bad type in PrimitiveSize", Type); } return 0; } diff --git a/tests/gl.er b/tests/gl.er index aeb1835..a3261f4 100644 --- a/tests/gl.er +++ b/tests/gl.er @@ -36,5 +36,5 @@ int :: main(int argc, char** argv) { glutDisplayFunc(display); glutMainLoop(); - return 0; + return (0); } \ No newline at end of file