Search in sources :

Example 6 with ABSClosure

use of abs.backend.java.lib.runtime.ABSClosure in project abstools by abstools.

the class Delta method setupMetaAPI.

/*
     * Define the methods of this class
     */
public static void setupMetaAPI() {
    thisClass.setName("Delta");
    thisClass.addMethod(/*ABSString*/
    "getName", new ABSClosure() {

        @Override
        public ABSString exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicDelta delta = (ABSDynamicDelta) t;
            return ABSString.fromString(delta.getName());
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "apply", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicDelta delta = (ABSDynamicDelta) t;
            delta.apply();
            return ABSUnit.UNIT;
        }
    });
}
Also used : ABSDynamicObject(abs.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(abs.backend.java.lib.runtime.ABSClosure) ABSDynamicDelta(abs.backend.java.lib.runtime.ABSDynamicDelta) ABSValue(abs.backend.java.lib.types.ABSValue) ABSString(abs.backend.java.lib.types.ABSString)

Example 7 with ABSClosure

use of abs.backend.java.lib.runtime.ABSClosure in project abstools by abstools.

the class Feature method setupMetaAPI.

/*
     * Define the methods of this class
     */
public static void setupMetaAPI() {
    thisClass.setName("Feature");
    thisClass.addMethod(/*ABSString*/
    "getName", new ABSClosure() {

        @Override
        public ABSString exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicFeature f = (ABSDynamicFeature) t;
            return ABSString.fromString(f.getName());
        }
    });
    thisClass.addMethod(/*ABSString*/
    "getAttributes", new ABSClosure() {

        @Override
        public ABSString exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicFeature f = (ABSDynamicFeature) t;
            // TODO
            return ABSString.fromString("Not Implemented Yet");
        }
    });
}
Also used : ABSDynamicObject(abs.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(abs.backend.java.lib.runtime.ABSClosure) ABSDynamicFeature(abs.backend.java.lib.runtime.ABSDynamicFeature) ABSValue(abs.backend.java.lib.types.ABSValue) ABSString(abs.backend.java.lib.types.ABSString)

Example 8 with ABSClosure

use of abs.backend.java.lib.runtime.ABSClosure in project abstools by abstools.

the class Method method setupAPI.

/*
     * Define the methods of this class
     */
public static void setupAPI() {
    thisClass.setName("Method");
    // FIXME This does not work currently, because abslang.abs needs to declare
    // * the return type
    // * the number and types of arguments
    thisClass.addMethod(/*ABSValue*/
    "exec", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSClosure method = (ABSClosure) t;
            // FIXME
            // params[0] is the receiver object,
            // params[1] is an ABSList with the actual arguments
            ABSValue res = method.exec((ABSDynamicObject) params[0], params[1]);
            // FIXME return the result...
            return ABSUnit.UNIT;
        }
    });
}
Also used : ABSDynamicObject(abs.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(abs.backend.java.lib.runtime.ABSClosure) ABSValue(abs.backend.java.lib.types.ABSValue)

Example 9 with ABSClosure

use of abs.backend.java.lib.runtime.ABSClosure in project abstools by abstools.

the class Product method setupMetaAPI.

/*
     * Define the methods of this class
     */
public static void setupMetaAPI() {
    thisClass.setName("Product");
    /*
         * MetaABS Product API -- cf. abslang.abs module ABS.Meta
         */
    thisClass.addMethod(/*ABSString*/
    "getName", new ABSClosure() {

        @Override
        public ABSString exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            return ABSString.fromString(thisP.getName());
        }
    });
    thisClass.addMethod(/*List<ABSDynamicFeature>*/
    "getFeatures", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            ArrayList<ABSDynamicFeature> features = new ArrayList<>();
            for (ABSDynamicFeature f : thisP.getFeatures()) {
                features.add(f);
            }
            return ListUtils.toABSList(features);
        }
    });
    thisClass.addMethod(/*Set<ABSDynamicProduct>*/
    "getConfigurableProducts", new ABSClosure() {

        @Override
        public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            return ListUtils.toABSSet(thisP.getConfigurableProducts());
        }
    });
    thisClass.addMethod(/*ABSDynamicReconfiguration*/
    "getReconfiguration", new ABSClosure() {

        @Override
        public ABSDynamicReconfiguration exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct thisP = (ABSDynamicProduct) t;
            ABSDynamicProduct targetP = (ABSDynamicProduct) params[0];
            return thisP.getReconfiguration(targetP);
        }
    });
}
Also used : ABSDynamicObject(abs.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(abs.backend.java.lib.runtime.ABSClosure) ABSDynamicFeature(abs.backend.java.lib.runtime.ABSDynamicFeature) ABSDynamicProduct(abs.backend.java.lib.runtime.ABSDynamicProduct) ArrayList(java.util.ArrayList) ABSValue(abs.backend.java.lib.types.ABSValue) ABSString(abs.backend.java.lib.types.ABSString) ABSDynamicReconfiguration(abs.backend.java.lib.runtime.ABSDynamicReconfiguration)

Example 10 with ABSClosure

use of abs.backend.java.lib.runtime.ABSClosure in project abstools by abstools.

the class ProductLine method setupAPI.

private static void setupAPI() {
    thisClass.setName("ProductLine");
    /* 
         * MetaABS ProductLine API -- cf. abslang.abs module ABS.Meta 
         */
    thisClass.addMethod(/*ABSDynamicProduct*/
    "getCurrentProduct", new ABSClosure() {

        @Override
        public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct currentProd = t.__ABS_getRuntime().getDSPL().getCurrentProduct();
            return currentProd;
        }
    });
    thisClass.addMethod(/*ABSDynamicProduct*/
    "getProduct", new ABSClosure() {

        @Override
        public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
            ABSString name = (ABSString) params[0];
            ABSDynamicProduct product = t.__ABS_getRuntime().getDSPL().getProduct(name.getString());
            return product;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "reconfigure", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct targetProd = (ABSDynamicProduct) params[0];
            ABSDynamicProductLine pl = t.__ABS_getRuntime().getDSPL();
            pl.reconfigure(targetProd);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "addProduct", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct product = (ABSDynamicProduct) params[0];
            t.__ABS_getRuntime().getDSPL().addProduct(product);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "removeProduct", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicProduct product = (ABSDynamicProduct) params[0];
            t.__ABS_getRuntime().getDSPL().removeProduct(product);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "addReconfiguration", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration recf = (ABSDynamicReconfiguration) params[0];
            t.__ABS_getRuntime().getDSPL().addReconfiguration(recf);
            return ABSUnit.UNIT;
        }
    });
    thisClass.addMethod(/*ABSUnit*/
    "removeReconfiguration", new ABSClosure() {

        @Override
        public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
            ABSDynamicReconfiguration recf = (ABSDynamicReconfiguration) params[0];
            t.__ABS_getRuntime().getDSPL().removeReconfiguration(recf);
            return ABSUnit.UNIT;
        }
    });
}
Also used : ABSDynamicObject(abs.backend.java.lib.runtime.ABSDynamicObject) ABSClosure(abs.backend.java.lib.runtime.ABSClosure) ABSDynamicProductLine(abs.backend.java.lib.runtime.ABSDynamicProductLine) ABSDynamicProduct(abs.backend.java.lib.runtime.ABSDynamicProduct) ABSDynamicReconfiguration(abs.backend.java.lib.runtime.ABSDynamicReconfiguration)

Aggregations

ABSClosure (abs.backend.java.lib.runtime.ABSClosure)10 ABSDynamicObject (abs.backend.java.lib.runtime.ABSDynamicObject)10 ABSValue (abs.backend.java.lib.types.ABSValue)8 ABSString (abs.backend.java.lib.types.ABSString)6 ABSDynamicProduct (abs.backend.java.lib.runtime.ABSDynamicProduct)3 ABSDynamicReconfiguration (abs.backend.java.lib.runtime.ABSDynamicReconfiguration)3 ABSDynamicClass (abs.backend.java.lib.runtime.ABSDynamicClass)2 ABSDynamicFeature (abs.backend.java.lib.runtime.ABSDynamicFeature)2 ABSDynamicUpdate (abs.backend.java.lib.runtime.ABSDynamicUpdate)2 COG (abs.backend.java.lib.runtime.COG)2 ABSUnit (abs.backend.java.lib.types.ABSUnit)2 ArrayList (java.util.ArrayList)2 DynamicException (abs.backend.java.codegeneration.dynamic.DynamicException)1 ABSDynamicDelta (abs.backend.java.lib.runtime.ABSDynamicDelta)1 ABSDynamicProductLine (abs.backend.java.lib.runtime.ABSDynamicProductLine)1 ABSProcess (abs.backend.java.lib.types.ABSProcess)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