use of abs.backend.java.lib.types.ABSString in project abstools by abstools.
the class Clazz method setupMetaAPI.
/*
* Define the methods of this class
*/
public static void setupMetaAPI() {
thisClass.setName("Class");
thisClass.addMethod(/*ABSString*/
"getName", new ABSClosure() {
@Override
public ABSString exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicClass cls = (ABSDynamicClass) t.getFieldValue_Internal("class");
return ABSString.fromString(cls.getName());
}
});
thisClass.addMethod(/*ABSClosure*/
"getMethod", new ABSClosure() {
@Override
public ABSDynamicObject exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicClass cls = (ABSDynamicClass) t.getFieldValue_Internal("class");
ABSString name = (ABSString) params[0];
ABSClosure method = cls.getMethod(name.getString());
return method;
}
});
thisClass.addMethod(/*ABSUnit*/
"addMethod", new ABSClosure() {
@Override
public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicClass cls = (ABSDynamicClass) t.getFieldValue_Internal("class");
ABSString name = (ABSString) params[0];
ABSClosure method = (ABSClosure) ((ABSDynamicObject) params[1]).getFieldValue_Internal("method");
cls.addMethod(name.getString(), method);
return ABSUnit.UNIT;
}
});
thisClass.addMethod(/*ABSUnit*/
"removeMethod", new ABSClosure() {
@Override
public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicClass cls = (ABSDynamicClass) t.getFieldValue_Internal("class");
ABSString name = (ABSString) params[0];
cls.removeMethod(name.getString());
return ABSUnit.UNIT;
}
});
}
use of abs.backend.java.lib.types.ABSString in project abstools by abstools.
the class Reconfiguration method setupMetaAPI.
/*
* Define the methods of this class
*/
public static void setupMetaAPI() {
thisClass.setName("Reconfiguration");
/*
* MetaABS Reconfiguration API -- cf. abslang.abs module ABS.Meta
*/
thisClass.addMethod(/*ABSString*/
"getName", new ABSClosure() {
@Override
public ABSString exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
return ABSString.fromString(thisR.getName());
}
});
thisClass.addMethod(/*ABSDynamicProduct*/
"getCurrentProduct", new ABSClosure() {
@Override
public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
return thisR.getCurrentProduct();
}
});
thisClass.addMethod(/*ABSUnit*/
"setCurrentProduct", new ABSClosure() {
@Override
public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
ABSDynamicProduct prod = (ABSDynamicProduct) params[0];
thisR.setCurrentProduct(prod);
return ABSUnit.UNIT;
}
});
thisClass.addMethod(/*ABSDynamicProduct*/
"getTargetProduct", new ABSClosure() {
@Override
public ABSDynamicProduct exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
return thisR.getTargetProduct();
}
});
thisClass.addMethod(/*ABSUnit*/
"setTargetProduct", new ABSClosure() {
@Override
public ABSUnit exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
ABSDynamicProduct prod = (ABSDynamicProduct) params[0];
thisR.setTargetProduct(prod);
return ABSUnit.UNIT;
}
});
thisClass.addMethod(/*List<ABSDynamicDelta>*/
"getDeltas", new ABSClosure() {
@Override
public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
List<ABSDynamicDelta> deltas = thisR.getDeltas();
return ListUtils.toABSList(deltas);
}
});
thisClass.addMethod(/*List<ABSDynamicDelta>*/
"setDeltas", new ABSClosure() {
@Override
public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
// TODO
return ABSUnit.UNIT;
}
});
thisClass.addMethod(/*ABSDynamicUpdate*/
"getStateUpdate", new ABSClosure() {
@Override
public ABSDynamicUpdate exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
return thisR.getUpdate();
}
});
thisClass.addMethod(/*List<ABSDynamicDelta>*/
"setStateUpdate", new ABSClosure() {
@Override
public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicReconfiguration thisR = (ABSDynamicReconfiguration) t;
ABSDynamicUpdate upd = (ABSDynamicUpdate) params[0];
thisR.setUpdate(upd);
return ABSUnit.UNIT;
}
});
}
use of abs.backend.java.lib.types.ABSString in project abstools by abstools.
the class Update method setupMetaAPI.
/*
* Define the methods of this class
*/
public static void setupMetaAPI() {
thisClass.setName("Update");
thisClass.addMethod(/*ABSString*/
"getName", new ABSClosure() {
@Override
public ABSString exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicUpdate update = (ABSDynamicUpdate) t;
return ABSString.fromString(update.getName());
}
});
thisClass.addMethod(/*ABSUnit*/
"apply", new ABSClosure() {
@Override
public ABSValue exec(ABSDynamicObject t, ABSValue... params) {
ABSDynamicUpdate update = (ABSDynamicUpdate) t;
update.apply();
return ABSUnit.UNIT;
}
});
}
use of abs.backend.java.lib.types.ABSString in project abstools by abstools.
the class ABSBuiltInFunctions method readln.
public static ABSString readln() {
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
// scanner.close();
return ABSString.fromString(line.trim());
}
use of abs.backend.java.lib.types.ABSString in project abstools by abstools.
the class ForeignClassImpl method fli_visit.
@Override
public ABSUnit fli_visit(List<ABSString> planets) {
if (planets.isNil())
System.out.println("Planet list is Empty");
else {
List_Cons<ABSString> cons = planets.toCons();
ABSString s = cons.getArg0();
System.out.println("Found planet " + s);
}
return null;
}
Aggregations