use of abs.backend.java.lib.types.ABSValue in project abstools by abstools.
the class ListUtils method toABSList.
/*
* Transform a java.util.List into an ABS.StdLib.List
*/
public static ABSValue toABSList(java.util.List<? extends ABSValue> l) {
if (l.isEmpty()) {
return DynamicClassUtils.instance("ABS.StdLib.List_Nil");
} else {
// make sure we can use remove()
ArrayList<ABSValue> ml = new ArrayList<>(l);
ABSValue head = ml.remove(0);
return DynamicClassUtils.instance("ABS.StdLib.List_Cons", head, toABSList(ml));
}
}
use of abs.backend.java.lib.types.ABSValue in project abstools by abstools.
the class ListUtils method toABSSet.
/*
* Transform a java.util.Set into an ABS.StdLib.Set
*/
public static ABSValue toABSSet(java.util.Set<? extends ABSValue> set) {
if (set.isEmpty()) {
return DynamicClassUtils.instance("ABS.StdLib.Set_EmptySet");
} else {
ABSValue value = set.iterator().next();
set.remove(value);
return DynamicClassUtils.instance("ABS.StdLib.Set_Insert", value, toABSSet(set));
}
}
use of abs.backend.java.lib.types.ABSValue in project abstools by abstools.
the class TestModel method testStarted.
public void testStarted(TaskView task) {
final String testMethod;
final String className;
final List<ABSValue> testMethodArguments;
final LinkedList<ABSValue> arguments = new LinkedList<>();
if (task.getStack().hasFrames()) {
final TaskStackFrameView currentF = task.getStack().getCurrentFrame();
testMethod = currentF.getMethod().getName();
className = currentF.getMethod().getClassView().getName();
for (String parameterName : currentF.getVariableNames()) {
arguments.add(currentF.getValue(parameterName));
}
} else {
testMethod = task.getMethodName();
className = task.getTarget().getClassName();
arguments.addAll(task.getArgs());
}
if (!task.getStack().hasFrames()) {
System.out.println("Not yet started " + testMethod + " for task " + task.getID());
} else {
System.out.println("Test " + task.getStack().getCurrentFrame().getMethod() + " task: " + task.getID());
}
final TestStatus newTest = new TestStatus(task.getID(), testMethod, className, arguments, task.getStack().getFrames(), TestStatus.Status.ACTIVE);
push(newTest);
System.out.println("Test started: " + task.getMethodName() + " : " + testMethod);
informListenersTestStarted(newTest);
}
use of abs.backend.java.lib.types.ABSValue in project abstools by abstools.
the class NetCOG method registerFuture.
public synchronized void registerFuture(NetFut<? super ABSValue> fut) {
if (futureMap.containsKey(fut.getPromise()))
throw new IllegalStateException("Future for promises already existed");
futureMap.put(fut.getPromise(), fut);
ABSValue v = promises.get(fut.getPromise());
if (v != null) {
fut.resolve(v);
return;
}
}
use of abs.backend.java.lib.types.ABSValue in project abstools by abstools.
the class Task method run.
public void run() {
synchronized (this) {
if (view != null)
view.taskStarted();
executingThread = Thread.currentThread();
}
try {
ABSValue res = (ABSValue) call.execute();
future.resolve(res);
} catch (ABSException e) {
this.exception = e;
future.smash(e);
getCOG().getRuntime().handleABSException(this, e);
} catch (SystemTerminatedException e) {
} catch (Exception e) {
e.printStackTrace();
ABSException absException = new ABSAssertException("Sorry, this is a bug in the Java backend of ABS: " + "Unexpected exception: " + e);
// TODO new subclass for internal error
absException.setStackTrace(e.getStackTrace());
getCOG().getRuntime().handleABSException(this, absException);
}
synchronized (this) {
if (view != null)
view.taskFinished();
}
}
Aggregations