Inserting pre and post-call logic around a handle?

Charles Oliver Nutter headius at headius.com
Thu May 19 12:53:14 PDT 2011


I have cases where I want to do some pre and post-call logic around a
target handle. Basically, I need to twiddle some global state before
and after to set up one of our artificial call frames for the target
method to use. How could I do this in handles?

The logic basically looks like this:

preLogic(some of incoming args);
try {
  return callSomeDirectTargetHandle();
} finally {
  postLogic(some args);
}

The structure I figured would work best is something like this:

foldArguments(preLogic)
>catchException(Throwable)
=>body:direct MH to method
=>handler:foldArguments(postLogic)

fold seems to be the only way to insert some arbitrary logic, but it
has the side effect of trying to insert its result back into the
argument list. My pre/post logic has a void return, so I'd need to
wrap that logic with an additional call, I think.

Is there a better way to model this?

- Charlie


More information about the mlvm-dev mailing list