Fixed DEBUG_EXPRESSIONS option

Issue #179


git-svn-id: http://picoc.googlecode.com/svn/trunk@601 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2013-03-17 00:23:39 +00:00
parent 019c4cb42c
commit 6e9b4b3c84

View file

@ -79,9 +79,9 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionSta
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
/* show the contents of the expression stack */ /* show the contents of the expression stack */
void ExpressionStackShow(struct ExpressionStack *StackTop) void ExpressionStackShow(Picoc *pc, struct ExpressionStack *StackTop)
{ {
printf("Expression stack [0x%lx,0x%lx]: ", (long)HeapStackTop, (long)StackTop); printf("Expression stack [0x%lx,0x%lx]: ", (long)pc->HeapStackTop, (long)StackTop);
while (StackTop != NULL) while (StackTop != NULL)
{ {
@ -99,10 +99,10 @@ void ExpressionStackShow(struct ExpressionStack *StackTop)
case TypeInt: printf("%d:int", StackTop->Val->Val->Integer); break; case TypeInt: printf("%d:int", StackTop->Val->Val->Integer); break;
case TypeShort: printf("%d:short", StackTop->Val->Val->ShortInteger); break; case TypeShort: printf("%d:short", StackTop->Val->Val->ShortInteger); break;
case TypeChar: printf("%d:char", StackTop->Val->Val->Character); break; case TypeChar: printf("%d:char", StackTop->Val->Val->Character); break;
case TypeLong: printf("%d:long", StackTop->Val->Val->LongInteger); break; case TypeLong: printf("%ld:long", StackTop->Val->Val->LongInteger); break;
case TypeUnsignedShort: printf("%d:unsigned short", StackTop->Val->Val->UnsignedShortInteger); break; case TypeUnsignedShort: printf("%d:unsigned short", StackTop->Val->Val->UnsignedShortInteger); break;
case TypeUnsignedInt: printf("%d:unsigned int", StackTop->Val->Val->UnsignedInteger); break; case TypeUnsignedInt: printf("%d:unsigned int", StackTop->Val->Val->UnsignedInteger); break;
case TypeUnsignedLong: printf("%d:unsigned long", StackTop->Val->Val->UnsignedLongInteger); break; case TypeUnsignedLong: printf("%ld:unsigned long", StackTop->Val->Val->UnsignedLongInteger); break;
case TypeFP: printf("%f:fp", StackTop->Val->Val->FP); break; case TypeFP: printf("%f:fp", StackTop->Val->Val->FP); break;
case TypeFunction: printf("%s:function", StackTop->Val->Val->Identifier); break; case TypeFunction: printf("%s:function", StackTop->Val->Val->Identifier); break;
case TypeMacro: printf("%s:macro", StackTop->Val->Val->Identifier); break; case TypeMacro: printf("%s:macro", StackTop->Val->Val->Identifier); break;
@ -118,7 +118,7 @@ void ExpressionStackShow(struct ExpressionStack *StackTop)
case TypeStruct: printf("%s:struct", StackTop->Val->Val->Identifier); break; case TypeStruct: printf("%s:struct", StackTop->Val->Val->Identifier); break;
case TypeUnion: printf("%s:union", StackTop->Val->Val->Identifier); break; case TypeUnion: printf("%s:union", StackTop->Val->Val->Identifier); break;
case TypeEnum: printf("%s:enum", StackTop->Val->Val->Identifier); break; case TypeEnum: printf("%s:enum", StackTop->Val->Val->Identifier); break;
case Type_Type: PrintType(StackTop->Val->Val->Typ, CStdOut); printf(":type"); break; case Type_Type: PrintType(StackTop->Val->Val->Typ, pc->CStdOut); printf(":type"); break;
default: printf("unknown"); break; default: printf("unknown"); break;
} }
printf("[0x%lx,0x%lx]", (long)StackTop, (long)StackTop->Val); printf("[0x%lx,0x%lx]", (long)StackTop, (long)StackTop->Val);
@ -291,7 +291,7 @@ void ExpressionStackPushValueNode(struct ParseState *Parser, struct ExpressionSt
StackNode->CharacterPos = Parser->CharacterPos; StackNode->CharacterPos = Parser->CharacterPos;
#endif #endif
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
ExpressionStackShow(*StackTop); ExpressionStackShow(Parser->pc, *StackTop);
#endif #endif
} }
@ -900,7 +900,7 @@ void ExpressionStackCollapse(struct ParseState *Parser, struct ExpressionStack *
debugf("ExpressionStackCollapse(%d):\n", Precedence); debugf("ExpressionStackCollapse(%d):\n", Precedence);
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
ExpressionStackShow(*StackTop); ExpressionStackShow(Parser->pc, *StackTop);
#endif #endif
while (TopStackNode != NULL && TopStackNode->Next != NULL && FoundPrecedence >= Precedence) while (TopStackNode != NULL && TopStackNode->Next != NULL && FoundPrecedence >= Precedence)
{ {
@ -1005,13 +1005,13 @@ void ExpressionStackCollapse(struct ParseState *Parser, struct ExpressionStack *
*IgnorePrecedence = DEEP_PRECEDENCE; *IgnorePrecedence = DEEP_PRECEDENCE;
} }
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
ExpressionStackShow(*StackTop); ExpressionStackShow(Parser->pc, *StackTop);
#endif #endif
TopStackNode = *StackTop; TopStackNode = *StackTop;
} }
debugf("ExpressionStackCollapse() finished\n"); debugf("ExpressionStackCollapse() finished\n");
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
ExpressionStackShow(*StackTop); ExpressionStackShow(Parser->pc, *StackTop);
#endif #endif
} }
@ -1030,7 +1030,7 @@ void ExpressionStackPushOperator(struct ParseState *Parser, struct ExpressionSta
StackNode->CharacterPos = Parser->CharacterPos; StackNode->CharacterPos = Parser->CharacterPos;
#endif #endif
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
ExpressionStackShow(*StackTop); ExpressionStackShow(Parser->pc, *StackTop);
#endif #endif
} }
@ -1348,7 +1348,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
debugf("ExpressionParse() done\n\n"); debugf("ExpressionParse() done\n\n");
#ifdef DEBUG_EXPRESSIONS #ifdef DEBUG_EXPRESSIONS
ExpressionStackShow(StackTop); ExpressionStackShow(Parser->pc, StackTop);
#endif #endif
return StackTop != NULL; return StackTop != NULL;
} }