Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a callback to FuncJUMP_TO_CATCH #1690

Merged
merged 1 commit into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,11 +1103,14 @@ Obj FuncCALL_WITH_CATCH( Obj self, Obj func, volatile Obj args )
return res;
}

Obj FuncJUMP_TO_CATCH( Obj self, Obj payload)
Obj FuncJUMP_TO_CATCH(Obj self, Obj payload)
{
STATE(ThrownObject) = payload;
syLongjmp(&(STATE(ReadJmpError)), 1);
return 0;
STATE(ThrownObject) = payload;
if (STATE(JumpToCatchCallback) != 0) {
(*STATE(JumpToCatchCallback))();
}
syLongjmp(&(STATE(ReadJmpError)), 1);
return 0;
}

Obj FuncSetUserHasQuit( Obj Self, Obj value)
Expand Down Expand Up @@ -3047,10 +3050,12 @@ void InitializeGap (
STATE(ThrownObject) = 0;
STATE(UserHasQUIT) = 0;
STATE(UserHasQuit) = 0;
STATE(JumpToCatchCallback) = 0;

NrImportedGVars = 0;
NrImportedFuncs = 0;


sysenviron = environ;

/* get info structures for the built in modules */
Expand Down
3 changes: 3 additions & 0 deletions src/gapstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ typedef struct GAPState {
Obj BaseShellContext;
Obj ErrorLVars; // ErrorLVars as modified by DownEnv / UpEnv
Int ErrorLLevel; // record where on the stack ErrorLVars is relative to the top, i.e. BaseShellContext
void (*JumpToCatchCallback)(); // This callback is called in FuncJUMP_TO_CATCH,
// this is not used by GAP itself but by programs
// that use GAP as a library to handle errors

/* From objects.c */
Int PrintObjIndex;
Expand Down