Skip to content

Commit

Permalink
Add a callback to FuncJUMP_TO_CATCH
Browse files Browse the repository at this point in the history
This is another bit of the GAP dynamic library code. Again without tests
and without a guarantee that this will work in HPC-GAP
  • Loading branch information
markuspf authored and Markus Pfeiffer committed Feb 13, 2018
1 parent e755b88 commit 80cc26f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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

0 comments on commit 80cc26f

Please sign in to comment.