/** * Copyright (c) 2009-2011, The HATS Consortium. All rights reserved. * This file is licensed under the terms of the Modified BSD License. */ package abs.backend.java.lib.runtime.metaABS; import abs.backend.java.lib.runtime.ABSClosure; import abs.backend.java.lib.runtime.ABSDynamicClass; import abs.backend.java.lib.runtime.ABSDynamicObject; import abs.backend.java.lib.runtime.ABSDynamicUpdate; import abs.backend.java.lib.types.ABSString; import abs.backend.java.lib.types.ABSUnit; import abs.backend.java.lib.types.ABSValue; public class Update { private static ABSDynamicClass thisClass; /* * Create singleton object */ public static ABSDynamicClass singleton() { if (thisClass == null) { thisClass = new ABSDynamicClass(); setupMetaAPI(); } return thisClass; } /* * 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; } }); } }