/**************************************************************************** ** ** This file is part of GAP, a system for computational discrete algebra. ** ** Copyright of GAP belongs to its developers, whose names are too numerous ** to list here. Please refer to the COPYRIGHT file for details. ** ** SPDX-License-Identifier: GPL-2.0-or-later ** ** This file contains functions related to hooking the interpreter. **
*/
// List of active hooks struct InterpreterHooks * activeHooks[MAX_HOOK_COUNT];
// Number of active hooks staticInt HookActiveCount;
/**************************************************************************** ** ** Store the true values of each function we wrap for hooking. These always ** store the correct values and are never changed.
*/
/**************************************************************************** ** ** These functions install implementations of eval/expr functions, ** ensuring they are set up correctly if any hooks are already active.
*/
static Obj ProfileEvalBoolPassthrough(Expr stat)
{ // There are two cases we must pass through without touching // From TNUM_EXPR if (IS_REF_LVAR(stat)) { return OriginalEvalBoolFuncsForHook[EXPR_REF_LVAR](stat);
} if (IS_INTEXPR(stat)) { return OriginalEvalBoolFuncsForHook[EXPR_INT](stat);
}
GAP_HOOK_LOOP(visitStat, stat); return OriginalEvalBoolFuncsForHook[TNUM_STAT(stat)](stat);
}
/**************************************************************************** ** ** Activate, or deactivate hooks **
*/
BOOL ActivateHooks(struct InterpreterHooks * hook)
{ Int i;
if (HookActiveCount == MAX_HOOK_COUNT) { returnFALSE;
}
HashLock(&activeHooks); for (i = 0; i < MAX_HOOK_COUNT; ++i) { if (activeHooks[i] == hook) {
HashUnlock(&activeHooks); returnFALSE;
}
}
for (i = 0; i < ARRAY_SIZE(ExecStatFuncs); i++) {
ExecStatFuncs[i] = ProfileExecStatPassthrough;
EvalExprFuncs[i] = ProfileEvalExprPassthrough;
EvalBoolFuncs[i] = ProfileEvalBoolPassthrough;
}
for (i = 0; i < MAX_HOOK_COUNT; ++i) { if (!activeHooks[i]) {
activeHooks[i] = hook;
HookActiveCount++;
HashUnlock(&activeHooks); returnTRUE;
}
}
HashUnlock(&activeHooks); returnFALSE;
}
BOOL DeactivateHooks(struct InterpreterHooks * hook)
{
HashLock(&activeHooks); for (int i = 0; i < MAX_HOOK_COUNT; ++i) { if (activeHooks[i] == hook) {
activeHooks[i] = 0;
HookActiveCount--;
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.