- record all line numbers during function generation. This is useful for error reporting and eventually debugging.

- throw a useful exception when a VM abort occurs, the simple enum was incapable of reporting anything more than the barest minimum, which at least for array index out of bounds errors was insufficient.

The current exception mechanism is still insufficient. It really has to report a proper crash location and print a stack trace to the maximum extent possible. Instead it just prints a message and happily goes on. This is not a good solution.
This commit is contained in:
Christoph Oelckers 2016-12-02 17:36:29 +01:00
commit 1e01e6e4df
10 changed files with 159 additions and 78 deletions

View file

@ -453,7 +453,7 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
}
throw;
}
catch (EVMAbortException exception)
catch (CVMAbortException &exception)
{
if (allocated)
{
@ -464,35 +464,7 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
*trap = nullptr;
}
Printf("VM execution aborted: ");
switch (exception)
{
case X_READ_NIL:
Printf("tried to read from address zero.");
break;
case X_WRITE_NIL:
Printf("tried to write to address zero.");
break;
case X_TOO_MANY_TRIES:
Printf("too many try-catch blocks.");
break;
case X_ARRAY_OUT_OF_BOUNDS:
Printf("array access out of bounds.");
break;
case X_DIVISION_BY_ZERO:
Printf("division by zero.");
break;
case X_BAD_SELF:
Printf("invalid self pointer.");
break;
}
Printf("\n");
Printf("%s\n", exception.GetMessage());
return -1;
}
catch (...)