From 6e1129cb6b2a434606bc11ea82e57a41e5aed34e Mon Sep 17 00:00:00 2001 From: Curle Date: Fri, 8 Dec 2023 03:56:09 +0000 Subject: [PATCH] Debug information improvements --- src/Parser.c | 3 ++- src/Types.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Parser.c b/src/Parser.c index 0da0e85..3a2b6fc 100644 --- a/src/Parser.c +++ b/src/Parser.c @@ -284,7 +284,7 @@ struct ASTNode* ParsePrecedenceASTNode(int PreviousTokenPrecedence) { RightTemp = NULL; LeftTemp = NULL; } else { - printf("\t\tAttempting to handle a %d in Binary Expression parsing\r\n", CurrentFile->CurrentSymbol.type); + printf("\t\tAttempting to handle a %s in Binary Expression parsing\r\n", TokenNames[CurrentFile->CurrentSymbol.type]); LeftNode->RVal = 1; RightNode->RVal = 1; @@ -392,6 +392,7 @@ struct ASTNode* ParseExpressionList(int terminate) { while (CurrentFile->CurrentSymbol.type != terminate) { // TODO: for(int x = 0; Child = ParsePrecedenceASTNode(0); + printf("\nFunction parameter %d is type %s.\n", Count, TypeNames(Child->ExprType)); Count++; Tree = ConstructASTNode(OP_COMP, PointerTo(RET_VOID), Tree, NULL, Child, NULL, Count); diff --git a/src/Types.c b/src/Types.c index c2ba01e..17c54f4 100644 --- a/src/Types.c +++ b/src/Types.c @@ -17,7 +17,7 @@ */ int TypeIsInt(int Type) { - printf("\tComparing type %d.\n", Type); + printf("\tComparing type %s.\n", TypeNames(Type)); return ( ((Type & 0xf) == 0) && (Type >= RET_CHAR && Type <= RET_LONG)); } @@ -96,7 +96,7 @@ char* TypeNames(int Type) { break; }; if (TypeIsPtr(Type)) memcpy((void*) ((size_t) TypeBuffer + 4), "Ptr", 3); - else memcpy((void*) ((size_t) TypeBuffer + 4), " ", 3); + else memcpy((void*) ((size_t) TypeBuffer + 4), "\0", 1); return TypeBuffer; } @@ -202,7 +202,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); + printf("\tCalculating compatibility between ltype %s and rtype %s\r\n", TypeNames(LeftType), TypeNames(RightType)); if (TypeIsInt(LeftType) && TypeIsInt(RightType)) { // Short-circuit for valid types