Skip to content

Commit a85c1a8

Browse files
committed
Merge branch 'heads/v2.1'
2 parents bfed445 + f95868c commit a85c1a8

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/PreferencesDialog.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public class PreferencesDialog extends JFrame {
9696
// private JPanel solverPane;
9797
// private JPanel miscPane;
9898

99+
final static boolean isDebug = "yes".equals(System.getProperty("debug"));
100+
99101
private static class MyIntSpinnerModel extends AbstractSpinnerModel {
100102

101103
private final IntPref pref;
@@ -338,7 +340,7 @@ private static boolean staticLibrary(String name) {
338340
for (int i = dirs.length - 1; i >= 0; i--) {
339341
final File file = new File(dirs[i] + File.separator + name);
340342
if (file.canExecute()) {
341-
if ("yes".equals(System.getProperty("debug")))
343+
if (isDebug)
342344
System.out.println("Loaded: " + name + " at " + file);
343345
return true;
344346
}
@@ -347,13 +349,13 @@ private static boolean staticLibrary(String name) {
347349
for (String str : (System.getenv("PATH")).split(Pattern.quote(File.pathSeparator))) {
348350
Path pth = Paths.get(str);
349351
if (Files.exists(pth.resolve(name))) {
350-
if ("yes".equals(System.getProperty("debug")))
352+
if (isDebug)
351353
System.out.println("Loaded: " + name + " at " + pth);
352354
return true;
353355
}
354356
}
355357

356-
if ("yes".equals(System.getProperty("debug")))
358+
if (isDebug)
357359
System.out.println("Failed to load: " + name);
358360
return false;
359361
}
@@ -362,7 +364,7 @@ private static boolean staticLibrary(String name) {
362364
private static boolean loadLibrary(String library) {
363365
boolean loaded = _loadLibrary(library);
364366
String libName = System.mapLibraryName(library);
365-
if ("yes".equals(System.getProperty("debug")))
367+
if (isDebug)
366368
if (loaded)
367369
System.out.println("Loaded: " + libName);
368370
else

org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleReporter.java

+1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ public void debug(final String msg) {
381381
@Override
382382
public void translate(String solver, int bitwidth, int maxseq, int mintrace, int maxtrace, int skolemDepth, int symmetry, String strat) {
383383
startTime = System.currentTimeMillis();
384+
startCount = 0;
384385
cb("translate", "Solver=" + solver + " Steps=" + mintrace + ".." + maxtrace + " Bitwidth=" + bitwidth + " MaxSeq=" + maxseq + (skolemDepth == 0 ? "" : " SkolemDepth=" + skolemDepth) + " Symmetry=" + (symmetry > 0 ? ("" + symmetry) : "OFF") + " Mode=" + strat + "\n");
385386
}
386387

org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/WorkerEngine.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import java.io.PrintStream;
2929
import java.io.Serializable;
3030
import java.lang.Thread.UncaughtExceptionHandler;
31-
import java.lang.reflect.Field;
32-
import java.util.Locale;
3331

3432
import org.alloytools.alloy.core.AlloyCore;
3533

@@ -185,16 +183,22 @@ public static void stop() {
185183
synchronized (WorkerEngine.class) {
186184
try {
187185
if (latest_sub != null) {
188-
if (!System.getProperty("os.name").toLowerCase(Locale.US).startsWith("windows"))
189-
try { // [electrod] needed to stop all child processes (electrod)
190-
Field f = latest_sub.getClass().getDeclaredField("pid");
191-
f.setAccessible(true);
192-
Runtime.getRuntime().exec("kill -SIGTERM " + f.get(latest_sub));
193-
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException | IOException e) {
194-
e.printStackTrace();
195-
}
196-
else
197-
latest_sub.destroy();
186+
// [electrum] this replaces the currently WorkerTask so that it exits gracefully
187+
try {
188+
ObjectOutputStream main2sub = new ObjectOutputStream(wrap(latest_sub.getOutputStream()));
189+
main2sub.writeObject(new WorkerTask() {
190+
191+
private static final long serialVersionUID = 1L;
192+
193+
@Override
194+
public void run(WorkerCallback out) throws Exception {
195+
}
196+
});
197+
main2sub.close();
198+
} catch (IOException e) {
199+
}
200+
201+
latest_sub.destroy();
198202
}
199203
} finally {
200204
latest_manager = null;

org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4Solution.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
import kodkod.engine.PardinusSolver;
9191
import kodkod.engine.Proof;
9292
import kodkod.engine.Solution;
93+
import kodkod.engine.config.AbstractReporter;
9394
import kodkod.engine.config.DecomposedOptions.DMode;
9495
import kodkod.engine.config.ExtendedOptions;
9596
import kodkod.engine.config.Options;
@@ -863,7 +864,10 @@ Expression a2k(Expr expr) throws ErrorFatal {
863864
* given expression.
864865
*/
865866
TupleSet approximate(Expression expression) {
866-
return factory.setOf(expression.arity(), Translator.approximate(expression, bounds, solver.options()).denseIndices());
867+
PardinusBounds b = bounds.clone();
868+
b.resolve(new AbstractReporter() {
869+
});
870+
return factory.setOf(expression.arity(), Translator.approximate(expression, b, solver.options()).denseIndices());
867871
}
868872

869873
/**
@@ -880,6 +884,8 @@ TupleSet query(boolean findUpper, Expression expr, boolean makeMutable) throws E
880884
if (expr == KK_STRING)
881885
return makeMutable ? stringBounds.clone() : stringBounds;
882886
if (expr instanceof Relation) {
887+
if (bounds.lowerSymbBound((Relation) expr) != null)
888+
return query(findUpper, findUpper ? bounds.upperSymbBound((Relation) expr) : bounds.lowerSymbBound((Relation) expr), makeMutable);
883889
TupleSet ans = findUpper ? bounds.upperBound((Relation) expr) : bounds.lowerBound((Relation) expr);
884890
if (ans != null)
885891
return makeMutable ? ans.clone() : ans;

0 commit comments

Comments
 (0)