Last active
September 15, 2019 07:51
-
-
Save swilly22/db5f051f537a31aa5bae63b57475743b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ExecutionPlan.c | |
function Query_Execute() { | |
/* Set an exception-handling breakpoint to capture run-time errors. | |
* encountered_error will be set to 0 when setjmp is invoked, and will be nonzero if | |
* a downstream exception returns us to this breakpoint. */ | |
QueryCtx *ctx = pthread_getspecific(_tlsQueryCtxKey); | |
if(!ctx->breakpoint) ctx->breakpoint = rm_malloc(sizeof(jmp_buf)); | |
int encountered_error = setjmp(*ctx->breakpoint); | |
if(encountered_error) { | |
// Encountered a run-time error; return immediately. | |
reportError(); | |
return; | |
} | |
/* Start executing, if an exception is thrown somewhere down the road | |
* we will resume execution at: if(encountered_error) above. */ | |
ExecutionPlan_Execute(); | |
} | |
/* ArithmeticExpression.c | |
* AR_EXP_Evaluate is called from various points in our code base | |
* all originating from Query_Execute. */ | |
SIValue AR_EXP_Evaluate(AR_ExpNode *root, const Record r) { | |
SIValue result; | |
AR_EXP_Result res = _AR_EXP_Evaluate(root, r, &result); | |
if(res != EVAL_OK) { | |
/* An error was encountered during evaluation! | |
* Exit this routine and return to the point on the stack where the handler was | |
* instantiated. */ | |
jmp_buf *env = _QueryCtx_GetExceptionHandler(); | |
longjmp(*env, 1); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment