package eta.runtime.thunk;

import eta.runtime.stg.Closure;
import eta.runtime.stg.StgContext;

public abstract class SingleEntryThunk extends Thunk {

    @Override
    public final Closure evaluate(StgContext context) {
        if (context.interrupted()) {
            context.myCapability.idleLoop(false);
        }

        /* TODO: Have some mechanism to *ensure* that it doesn't run multiple times. */

        final boolean trampoline = context.getAndSetTrampolineUnlessFirst();
        Closure result = null;
        try {
            result = thunkEnter(context);
        } finally {
            context.trampoline = trampoline;
        }

        if (Runtime.shouldClearThunks()) {
            clear();
        }
        return result;
    }
}

@@ -21,16 +21,44 @@
 thunk;%0A%0A
+import eta.runtime.Runtime;%0A
 import e

Add missing import in SingleEntryThunk