package org.hecl.playground; import org.hecl.ClassCommand; import org.hecl.ClassCommandInfo; import org.hecl.Command; import org.hecl.HeclException; import org.hecl.Interp; import org.hecl.ObjectThing; import org.hecl.Thing; class CrashListener { private Interp ip; private Thing fun; public CrashListener(Interp ip, Thing fun) { this.ip = ip; this.fun = fun; } public void handle() { try { Thing code = fun.deepcopy(); ip.eval(code); } catch (HeclException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } class Crash { public Crash(CrashListener listener) { listener.handle(); } } public class CrashCmd implements Command, ClassCommand { public static final CrashCmd cmd = new CrashCmd(); public static void load(Interp ip) { ip.addCommand("crash", cmd); ip.addClassCmd(Crash.class, cmd); } public Thing cmdCode(Interp interp, Thing[] argv) throws HeclException { return ObjectThing.create(new Crash(new CrashListener(interp, argv[1]))); } public Thing method(Interp interp, ClassCommandInfo context, Thing[] argv) throws HeclException { System.out.println("foo"); return null; } }