From 9e09cdd66b96098b048265ece30a6fae3f72d8a3 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Tue, 13 May 2014 19:56:06 -0400 Subject: [PATCH] ide/debugger: Better errors for evaluating function calls --- compiler/bootstrap/libec/bootstrap/ecdefs.c | 1 + compiler/bootstrap/libec/bootstrap/freeAst.c | 7 +++++++ compiler/libec/src/ecdefs.ec | 2 +- compiler/libec/src/freeAst.ec | 9 ++++++++- ide/src/debugger/Debugger.ec | 8 +++++++- ide/src/debugger/debugTools.ec | 10 +++++++++- 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/compiler/bootstrap/libec/bootstrap/ecdefs.c b/compiler/bootstrap/libec/bootstrap/ecdefs.c index e749e73..5fcbe74 100644 --- a/compiler/bootstrap/libec/bootstrap/ecdefs.c +++ b/compiler/bootstrap/libec/bootstrap/ecdefs.c @@ -2277,6 +2277,7 @@ __ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "vaArgExp", 34); __ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "arrayExp", 35); __ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "typeAlignExp", 36); __ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "memberPropertyErrorExp", 37); +__ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "functionCallErrorExp", 38); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(4, "MemberType", 0, 0, 0, 0, 0, module, 1, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class) __ecereClass_MemberType = class; diff --git a/compiler/bootstrap/libec/bootstrap/freeAst.c b/compiler/bootstrap/libec/bootstrap/freeAst.c index 3bd650a..fc88270 100644 --- a/compiler/bootstrap/libec/bootstrap/freeAst.c +++ b/compiler/bootstrap/libec/bootstrap/freeAst.c @@ -1525,6 +1525,7 @@ break; } case 7: { +if(exp->call.exp) FreeExpression(exp->call.exp); if(exp->call.arguments) FreeList(exp->call.arguments, FreeExpression); @@ -1631,6 +1632,12 @@ FreeExpression(exp->member.exp); if(exp->member.member) FreeIdentifier(exp->member.member); break; +case 38: +if(exp->call.exp) +FreeExpression(exp->call.exp); +if(exp->call.arguments) +FreeList(exp->call.arguments, FreeExpression); +break; case 17: case 21: case 22: diff --git a/compiler/libec/src/ecdefs.ec b/compiler/libec/src/ecdefs.ec index 0dd0bec..1a53796 100644 --- a/compiler/libec/src/ecdefs.ec +++ b/compiler/libec/src/ecdefs.ec @@ -411,7 +411,7 @@ public enum ExpressionType extensionCompoundExp, classExp, classDataExp, new0Exp, renew0Exp, dbopenExp, dbfieldExp, dbtableExp, dbindexExp, extensionExpressionExp, extensionInitializerExp, vaArgExp, arrayExp, typeAlignExp, - memberPropertyErrorExp + memberPropertyErrorExp, functionCallErrorExp }; public enum MemberType diff --git a/compiler/libec/src/freeAst.ec b/compiler/libec/src/freeAst.ec index b0cce7b..a489c6b 100644 --- a/compiler/libec/src/freeAst.ec +++ b/compiler/libec/src/freeAst.ec @@ -407,7 +407,8 @@ static void _FreeExpression(Expression exp, bool freePointer) } case callExp: { - FreeExpression(exp.call.exp); + if(exp.call.exp) + FreeExpression(exp.call.exp); if(exp.call.arguments) FreeList(exp.call.arguments, FreeExpression); break; @@ -517,6 +518,12 @@ static void _FreeExpression(Expression exp, bool freePointer) if(exp.member.member) FreeIdentifier(exp.member.member); break; + case functionCallErrorExp: + if(exp.call.exp) + FreeExpression(exp.call.exp); + if(exp.call.arguments) + FreeList(exp.call.arguments, FreeExpression); + break; case dereferenceErrorExp: case unknownErrorExp: case noDebuggerErrorExp: diff --git a/ide/src/debugger/Debugger.ec b/ide/src/debugger/Debugger.ec index 4741821..cc2fbe4 100644 --- a/ide/src/debugger/Debugger.ec +++ b/ide/src/debugger/Debugger.ec @@ -2721,7 +2721,7 @@ class Debugger if(wh.type) wh.type.refCount++; DebugComputeExpression(exp); - if(ExpressionIsError(exp)) + if(ExpressionIsError(exp) && exp.type != functionCallErrorExp) { GDBFallBack(exp, expString); } @@ -2915,6 +2915,12 @@ class Debugger snprintf(watchmsg, sizeof(watchmsg), $"Missing property evaluation for \"%s\"", wh.expression); break; } + case functionCallErrorExp: + if(exp.call.exp && exp.call.exp.type == identifierExp && exp.call.exp.identifier.string) + snprintf(watchmsg, sizeof(watchmsg), $"Missing function evaluation for call to \"%s\"", exp.call.exp.identifier.string); + else + snprintf(watchmsg, sizeof(watchmsg), $"Missing function evaluation for \"%s\"", wh.expression); + break; case memoryErrorExp: // Need to ensure when set to memoryErrorExp, constant is set snprintf(watchmsg, sizeof(watchmsg), $"Memory can't be read at %s", /*(exp.type == constantExp) ? */exp.constant /*: null*/); diff --git a/ide/src/debugger/debugTools.ec b/ide/src/debugger/debugTools.ec index 9faf3bd..1d169ad 100644 --- a/ide/src/debugger/debugTools.ec +++ b/ide/src/debugger/debugTools.ec @@ -17,6 +17,10 @@ static void CarryExpressionError(Expression exp, Expression expError) // Nulling things that may be freed now, but this is all overly messy/complex switch(expError.type) { + case functionCallErrorExp: + expError.call.exp = null; + expError.call.arguments = null; + break; case symbolErrorExp: expError.identifier = null; break; @@ -98,7 +102,7 @@ static char GetGdbFormatChar(Type type) { return (exp.type == dereferenceErrorExp || exp.type == symbolErrorExp || exp.type == memberSymbolErrorExp || exp.type == memoryErrorExp || exp.type == unknownErrorExp || - exp.type == noDebuggerErrorExp || exp.type == memberPropertyErrorExp); + exp.type == noDebuggerErrorExp || exp.type == memberPropertyErrorExp || exp.type == functionCallErrorExp); } void DebugComputeExpression(Expression exp) @@ -1091,6 +1095,7 @@ void DebugComputeExpression(Expression exp) { Expression callExp = exp.call.exp; Identifier id = (callExp && callExp.type == identifierExp) ? callExp.identifier : null; + bool resolved = false; if(id && id.string) { if(!strcmp(id.string, "nan") || !strcmp(id.string, "inf")) @@ -1100,8 +1105,11 @@ void DebugComputeExpression(Expression exp) FreeExpContents(exp); exp.type = constantExp; exp.constant = s; + resolved = true; } } + if(!resolved) + exp.type = functionCallErrorExp; break; } case memberExp: -- 1.8.3.1