import javax.imageio.*; import java.awt.image.*; import java.awt.event.*; import java.awt.*; import java.security.NoSuchAlgorithmException; import java.security.MessageDigest; import java.lang.reflect.*; import java.net.*; import java.io.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.*; import java.util.concurrent.atomic.*; import java.util.concurrent.*; import java.util.regex.*; import java.util.List; import java.util.zip.*; import java.util.*; abstract class Pred { boolean eval(Map s); } public class main { static int nextMCellID; static Map memoryCells = new TreeMap(); // a memory cell static class MCell { String id; Object value; long lastAccess; MCell(String id) { this.id = id; lastAccess = now(); } Object get() { lastAccess = now(); return value; } void set(Object value) { lastAccess = now(); this.value = value; } } static MCell newMCell() { String id = "m" + ++nextMCellID; MCell cell = new MCell(id); memoryCells.put(id, cell); return cell; } static MCell getMCell(String id) { return memoryCells.get(id); } public static void main(String[] args) throws Exception { defineVerification(" is occupied.", new Pred() { boolean eval(Map s) { String cell = s.get("memory cell"); return memoryCells.get(cell).get() != null; } }); verify("m1 is occupied."); } static void defineVerification(String sentence, Pred p) { } static long now_virtualTime; static long now() { return now_virtualTime != 0 ? now_virtualTime : System.currentTimeMillis(); } static void set(Class c, String field, Object value) { try { Field f = set_findStaticField(c, field); f.setAccessible(true); f.set(null, value); } catch (Exception e) { throw new RuntimeException(e); } } static Field set_findStaticField(Class c, String field) { for (Field f : c.getDeclaredFields()) if (f.getName().equals(field) && (f.getModifiers() & Modifier.STATIC) != 0) return f; throw new RuntimeException("Static field '" + field + "' not found in " + c.getName()); } static Object get(Object o, String field) { if (o instanceof Class) return get((Class) o, field); try { Field f = get_findField(o.getClass(), field); f.setAccessible(true); return f.get(o); } catch (Exception e) { throw new RuntimeException(e); } } static Object get(Class c, String field) { try { Field f = get_findStaticField(c, field); f.setAccessible(true); return f.get(null); } catch (Exception e) { throw new RuntimeException(e); } } static Field get_findStaticField(Class c, String field) { for (Field f : c.getDeclaredFields()) if (f.getName().equals(field) && (f.getModifiers() & Modifier.STATIC) != 0) return f; throw new RuntimeException("Static field '" + field + "' not found in " + c.getName()); } static Field get_findField(Class c, String field) { for (Field f : c.getDeclaredFields()) if (f.getName().equals(field)) return f; throw new RuntimeException("Field '" + field + "' not found in " + c.getName()); } }