Search in sources :

Example 6 with ABSValue

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));
    }
}
Also used : ArrayList(java.util.ArrayList) ABSValue(abs.backend.java.lib.types.ABSValue)

Example 7 with ABSValue

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));
    }
}
Also used : ABSValue(abs.backend.java.lib.types.ABSValue)

Example 8 with ABSValue

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);
}
Also used : ABSValue(abs.backend.java.lib.types.ABSValue) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) LinkedList(java.util.LinkedList)

Example 9 with ABSValue

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;
    }
}
Also used : ABSValue(abs.backend.java.lib.types.ABSValue)

Example 10 with ABSValue

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();
    }
}
Also used : ABSValue(abs.backend.java.lib.types.ABSValue)

Aggregations

ABSValue (abs.backend.java.lib.types.ABSValue)14 ABSClosure (abs.backend.java.lib.runtime.ABSClosure)8 ABSDynamicObject (abs.backend.java.lib.runtime.ABSDynamicObject)8 ABSString (abs.backend.java.lib.types.ABSString)6 ArrayList (java.util.ArrayList)3 ABSDynamicFeature (abs.backend.java.lib.runtime.ABSDynamicFeature)2 ABSDynamicProduct (abs.backend.java.lib.runtime.ABSDynamicProduct)2 ABSDynamicReconfiguration (abs.backend.java.lib.runtime.ABSDynamicReconfiguration)2 ABSDynamicUpdate (abs.backend.java.lib.runtime.ABSDynamicUpdate)2 ABSUnit (abs.backend.java.lib.types.ABSUnit)2 DynamicException (abs.backend.java.codegeneration.dynamic.DynamicException)1 ABSDynamicClass (abs.backend.java.lib.runtime.ABSDynamicClass)1 ABSDynamicDelta (abs.backend.java.lib.runtime.ABSDynamicDelta)1 COG (abs.backend.java.lib.runtime.COG)1 ABSProcess (abs.backend.java.lib.types.ABSProcess)1 TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)1 SimpleTaskScheduler (abs.backend.java.scheduling.SimpleTaskScheduler)1 TaskInfo (abs.backend.java.scheduling.SimpleTaskScheduler.TaskInfo)1 TaskScheduler (abs.backend.java.scheduling.TaskScheduler)1 TaskSchedulingStrategy (abs.backend.java.scheduling.TaskSchedulingStrategy)1