org.erights.e.elib.prim
Class Thrower

java.lang.Object
  |
  +--org.erights.e.elib.prim.Thrower

public class Thrower
extends Object

Safe: An StaticMaker on this class is the function named "throw" in the universalScope (and therefore also in the safeScope).

Author:
Mark S. Miller

Field Summary
static Thrower THE_ONE
          Enabled:
 
Constructor Summary
private Thrower()
           
 
Method Summary
 void __printOn(TextWriter out)
          Enabled: Prints as "throw", the name by which it's known in the universalScope.
 void breakpoint(Object diagnostic)
          Enabled: Just something callable from E to breakpoint on in Java.
 void eject(OneArgFunc optEjector, RuntimeException problem)
          Enabled: Exits according to optEjector with the provided value, for use from E.
 void run(RuntimeException problem)
          Enabled: Throws problem (coerced to a RuntimeException).
static RuntimeException toEject(OneArgFunc optEjector, Object prob)
          Enabled: Exits according to optEjector with the provided value, for use from Java.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THE_ONE

public static final Thrower THE_ONE
Enabled:

Constructor Detail

Thrower

private Thrower()
Method Detail

run

public void run(RuntimeException problem)
Enabled: Throws problem (coerced to a RuntimeException).


eject

public void eject(OneArgFunc optEjector,
                  RuntimeException problem)
Enabled: Exits according to optEjector with the provided value, for use from E.

If optEjector is null, then throws 'value' as a throwable problem that doesn't need to be declared. Otherwise, optEjector should eject rather than returning. If it does return, then 'eject' does its own (backtraced) throw rather than returning.


toEject

public static RuntimeException toEject(OneArgFunc optEjector,
                                       Object prob)
Enabled: Exits according to optEjector with the provided value, for use from Java.

If optEjector is null, then returns 'value' as a throwable problem that doesn't need to be declared. Otherwise, optEjector should eject rather than returning. If it does return, then 'toEject' does its own (backtraced) throw rather than returning.

The caller should typically say


     throw Thrower.toEject(optEjector, problem);
 
One of the reasons why 'toEject' has its caller do a throw is to provide the Java compiler with better control flow information.


breakpoint

public void breakpoint(Object diagnostic)
Enabled: Just something callable from E to breakpoint on in Java.


__printOn

public void __printOn(TextWriter out)
               throws IOException
Enabled: Prints as "throw", the name by which it's known in the universalScope.

IOException


comments?