Package com.cloudbees.groovy.cps

Examples of com.cloudbees.groovy.cps.Continuation


    public Next eval(final Env e, final Continuation k) {
        final TryBlockEnv f = new TryBlockEnv(e,finally_);
        // possible evaluation of the finally block, if present.

        for (final CatchExpression c : catches) {
            f.addHandler(c.type, new Continuation() {
                public Next receive(Object t) {
                    BlockScopeEnv b = new BlockScopeEnv(e);
                    b.declareVariable(c.type, c.name);
                    b.setLocalVariable(c.name, t);
View Full Code Here


    public NotBlock(Block b) {
        this.b = b;
    }

    public Next eval(Env e, final Continuation k) {
        return b.eval(e,new Continuation() {
            public Next receive(Object o) {
                boolean b = DefaultTypeTransformation.booleanUnbox(o);
                return k.receive(!b);
            }
        });
View Full Code Here

    public final Continuation getExceptionHandler(Class<? extends Throwable> type) {
        if (caller==null) {
            // TODO: maybe define a mechanism so that the run() or start() kinda method will return
            // by having this exception thrown?
            return new Continuation() {
                public Next receive(Object o) {
                    return Next.unhandledException((Throwable)o);
                }
            };
        } else {
View Full Code Here

    public final Continuation getExceptionHandler(Class<? extends Throwable> type) {
        if (caller==null) {
            // TODO: maybe define a mechanism so that the run() or start() kinda method will return
            // by having this exception thrown?
            return new Continuation() {
                public Next receive(Object o) {
                    return Next.unhandledException((Throwable)o);
                }
            };
        } else {
View Full Code Here

    public ThrowBlock(Block exp) {
        this.exp = exp;
    }

    public Next eval(final Env e, Continuation _) {
        return new Next(exp,e,new Continuation() {
            public Next receive(Object t) {
                if (t==null) {
                    t = new NullPointerException();
                }
                if (!(t instanceof Throwable)) {
                    t = new ClassCastException(t.getClass()+" cannot be cast to Throwable");
                }
                // TODO: fake the stack trace information

                Continuation v = e.getExceptionHandler(Throwable.class.cast(t).getClass());
                return v.receive(t);
            }
        });
    }
View Full Code Here

TOP

Related Classes of com.cloudbees.groovy.cps.Continuation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.