All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cloudbees.groovy.cps.CpsDefaultGroovyStaticMethods Maven / Gradle / Ivy

There is a newer version: 1.31
Show newest version

package com.cloudbees.groovy.cps;

import java.util.Arrays;
import javax.annotation.Generated;
import com.cloudbees.groovy.cps.impl.Caller;
import com.cloudbees.groovy.cps.impl.CpsCallableInvocation;
import com.cloudbees.groovy.cps.impl.CpsFunction;
import groovy.lang.Closure;
import org.codehaus.groovy.runtime.DefaultGroovyStaticMethods;

@Generated(value = "com.cloudbees.groovy.cps.tool.Translator", date = "Tue Sep 05 14:35:45 EDT 2017", comments = "based on groovy-cps-dgm-builder-1.19-jar-with-dependencies.jar")
@SuppressWarnings("rawtypes")
public class CpsDefaultGroovyStaticMethods {


    private CpsDefaultGroovyStaticMethods() {
    }

    static Thread createThread(String name, boolean daemon, Closure closure) {
        return CpsDefaultGroovyStaticMethods.$createThread__java_lang_String__boolean__groovy_lang_Closure(name, daemon, closure);
    }

    private static Thread $createThread__java_lang_String__boolean__groovy_lang_Closure(String name, boolean daemon, Closure closure) {
        Builder b = new Builder(loc("createThread")).contextualize(com.cloudbees.groovy.cps.sandbox.Trusted.INSTANCE);
        CpsFunction f = new CpsFunction(Arrays.asList("name", "daemon", "closure"), b.block(b.declareVariable(102, Thread.class, "thread", b.ternaryOp(b.compareNotEqual(102, b.localVariable("name"), b.constant(null)), b.new_(102, Thread.class, b.localVariable("closure"), b.localVariable("name")), b.new_(102, Thread.class, b.localVariable("closure")))), b.if_(b.localVariable("daemon"), b.functionCall(103, b.localVariable("thread"), "setDaemon", b.constant(true))), b.functionCall(104, b.localVariable("thread"), "start"), b.return_(b.localVariable("thread"))));
        throw new CpsCallableInvocation(f, null, name, daemon, closure);
    }

    static void sleepImpl(long millis, Closure closure) {
        CpsDefaultGroovyStaticMethods.$sleepImpl__long__groovy_lang_Closure(millis, closure);
    }

    private static void $sleepImpl__long__groovy_lang_Closure(long millis, Closure closure) {
        Builder b = new Builder(loc("sleepImpl")).contextualize(com.cloudbees.groovy.cps.sandbox.Trusted.INSTANCE);
        CpsFunction f = new CpsFunction(Arrays.asList("millis", "closure"), b.block(b.declareVariable(128, long.class, "start", b.functionCall(128, b.constant(System.class), "currentTimeMillis")), b.declareVariable(129, long.class, "rest", b.localVariable("millis")), b.declareVariable(130, long.class, "current", null), b.while_(null, b.greaterThan(131, b.localVariable("rest"), b.constant(0)), b.block(b.tryCatch(b.block(b.functionCall(133, b.constant(Thread.class), "sleep", b.localVariable("rest")), b.assign(134, b.localVariable("rest"), b.constant(0))), null)))));
        throw new CpsCallableInvocation(f, null, millis, closure);
    }

    public static void sleep(Object self, long milliseconds, Closure onInterrupt) {
        if ((!Caller.isAsynchronous(self, "sleep", milliseconds, onInterrupt))&&(!Caller.isAsynchronous(CpsDefaultGroovyStaticMethods.class, "sleep", self, milliseconds, onInterrupt))) {
            DefaultGroovyStaticMethods.sleep(self, milliseconds, onInterrupt);
            return ;
        }
        CpsDefaultGroovyStaticMethods.$sleep__java_lang_Object__long__groovy_lang_Closure(self, milliseconds, onInterrupt);
    }

    private static void $sleep__java_lang_Object__long__groovy_lang_Closure(Object self, long milliseconds, Closure onInterrupt) {
        Builder b = new Builder(loc("sleep")).contextualize(com.cloudbees.groovy.cps.sandbox.Trusted.INSTANCE);
        CpsFunction f = new CpsFunction(Arrays.asList("self", "milliseconds", "onInterrupt"), b.block(b.staticCall(168, CpsDefaultGroovyStaticMethods.class, "$sleepImpl__long__groovy_lang_Closure", b.localVariable("milliseconds"), b.localVariable("onInterrupt"))));
        throw new CpsCallableInvocation(f, null, self, milliseconds, onInterrupt);
    }

    private static MethodLocation loc(String methodName) {
        return new MethodLocation(CpsDefaultGroovyStaticMethods.class, methodName);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy