Generate exception handlers for the body.
Generate exception handlers for the body. Body is evaluated with a context where all the handlers are active. Handlers are evaluated in the 'outer' context.
It returns the resulting context, with the same active handlers as before the call. Use it like:
ctx.Try( ctx => {
ctx.bb.emit(...) // protected block
}, (ThrowableClass,
ctx => {
ctx.bb.emit(...); // exception handler
}), (AnotherExceptionClass,
ctx => {...
} ))
The resulting structure will look something like
outer: // this 'useless' jump will be removed later, // for now it separates the try body's blocks from previous // code since the try body needs its own exception handlers JUMP body
body: [ try body ] JUMP normalExit
catch[i]: [ handler[i] body ] JUMP normalExit
catchAll: STORE exception [ finally body ] THROW exception
normalExit: [ finally body ]
each catch[i] will cover body. catchAll will cover both body and each catch[i] Additional finally copies are created on the emission of every RETURN in the try body and exception handlers.
This could result in unreachable code which has to be cleaned up later, e.g. if the try and all the exception handlers always end in RETURN then there will be no "normal" flow out of the try/catch/finally. Later reachability analysis will remove unreacahble code.
The current basic block.
The current class.
The current monitors or finalizers, to be cleaned up upon return
.
The exception handlers we are currently generating code for
Current method definition.
Clone the current context
Prepare a new context upon entry into a method.
current exception handlers
Map from label symbols to label objects.
Make a fresh local variable.
Make a fresh local variable. It ensures the 'name' is unique.
The current method.
Return a new context for a new basic block.
The current package.
The current local variable scope.
The Context class keeps information relative to the current state in code generation