Search in sources :

Example 1 with SimpleTask1

use of edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleTask1 in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method doRun.

/**
 * This method executes a particular RUN or CHECK command.
 */
private Runner doRun(Integer commandIndex) {
    if (wrap)
        return wrapMe(commandIndex);
    final int index = commandIndex;
    if (WorkerEngine.isBusy())
        return null;
    if (index == (-2))
        subrunningTask = 1;
    else
        subrunningTask = 0;
    latestAutoInstance = "";
    if (index >= 0)
        latestCommand = index;
    if (index == -1 && commands != null) {
        latestCommand = commands.size() - 1;
        if (latestCommand < 0)
            latestCommand = 0;
    }
    // To update the accelerator to point to the command actually chosen
    doRefreshRun();
    OurUtil.enableAll(runmenu);
    if (commands == null)
        return null;
    if (commands.size() == 0 && index != -2 && index != -3) {
        log.logRed("There are no commands to execute.\n\n");
        return null;
    }
    int i = index;
    if (i >= commands.size())
        i = commands.size() - 1;
    SimpleCallback1 cb = new SimpleCallback1(this, null, log, VerbosityPref.get().ordinal(), latestAlloyVersionName, latestAlloyVersion);
    SimpleTask1 task = new SimpleTask1();
    A4Options opt = new A4Options();
    opt.tempDirectory = alloyHome() + fs + "tmp";
    opt.solverDirectory = alloyHome() + fs + "binary";
    opt.recordKodkod = RecordKodkod.get();
    opt.noOverflow = NoOverflow.get();
    opt.unrolls = Version.experimental ? Unrolls.get() : (-1);
    opt.skolemDepth = SkolemDepth.get();
    opt.coreMinimization = CoreMinimization.get();
    opt.inferPartialInstance = InferPartialInstance.get();
    opt.coreGranularity = CoreGranularity.get();
    opt.originalFilename = Util.canon(text.get().getFilename());
    opt.solver = Solver.get();
    task.bundleIndex = i;
    task.bundleWarningNonFatal = WarningNonfatal.get();
    task.map = text.takeSnapshot();
    task.options = opt.dup();
    task.resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
    task.tempdir = maketemp();
    try {
        runmenu.setEnabled(false);
        runbutton.setVisible(false);
        showbutton.setEnabled(false);
        stopbutton.setVisible(true);
        int newmem = SubMemory.get(), newstack = SubStack.get();
        if (newmem != subMemoryNow || newstack != subStackNow)
            WorkerEngine.stop();
        if (AlloyCore.isDebug() && VerbosityPref.get() == Verbosity.FULLDEBUG)
            WorkerEngine.runLocally(task, cb);
        else
            WorkerEngine.run(task, newmem, newstack, alloyHome() + fs + "binary", "", cb);
        subMemoryNow = newmem;
        subStackNow = newstack;
    } catch (Throwable ex) {
        WorkerEngine.stop();
        log.logBold("Fatal Error: Solver failed due to unknown reason.\n" + "One possible cause is that, in the Options menu, your specified\n" + "memory size is larger than the amount allowed by your OS.\n" + "Also, please make sure \"java\" is in your program path.\n");
        log.logDivider();
        log.flush();
        doStop(2);
    }
    return null;
}
Also used : SimpleCallback1(edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleCallback1) A4Options(edu.mit.csail.sdg.translator.A4Options) SimpleTask1(edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleTask1)

Aggregations

SimpleCallback1 (edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleCallback1)1 SimpleTask1 (edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleTask1)1 A4Options (edu.mit.csail.sdg.translator.A4Options)1