X-Git-Url: http://git.megacz.com/?p=org.ibex.xt-crawshaw.git;a=blobdiff_plain;f=src%2Fjava%2Forg%2Fibex%2Fxt%2Fshell%2FShell.java;fp=src%2Fjava%2Forg%2Fibex%2Fxt%2Fshell%2FShell.java;h=da77e94a34503fc9f0a775960b6ae8b142b9dfd4;hp=f677f286824051240bd7c76f7f57f39b06bf460b;hb=7959860be8bb0ac8aa172e1de8bb140b65afdae6;hpb=e2e46233d9db6fe8728421016a41d5bf79db86e5 diff --git a/src/java/org/ibex/xt/shell/Shell.java b/src/java/org/ibex/xt/shell/Shell.java index f677f28..da77e94 100644 --- a/src/java/org/ibex/xt/shell/Shell.java +++ b/src/java/org/ibex/xt/shell/Shell.java @@ -40,7 +40,7 @@ public class Shell { /** Returns the object represented by the given path, * ignoring the current shell path context.*/ - public Object getFromPath(Object[] path) throws NoSuchPathException, JSExn { + public Object getFromPath(Object[] path) throws BadPathException, JSExn { if (path.length == 0) return root; if (root instanceof JSRemote) { @@ -54,21 +54,30 @@ public class Shell { JS cur = root; for (int i=0; i < path.length - 1; i++) { Object o = cur.get(path[i]); - if (o == null || !(o instanceof JS)) throw new Shell.NoSuchPathException(); + if (o == null || !(o instanceof JS)) throw new Shell.BadPathException(); cur = (JS)o; } return cur.get(path[path.length - 1]); } } + public void transaction(JS t) { + if (root instanceof JSRemote) { + ((JSRemote)root).transaction( + JS.cloneWithNewParentScope(t, new JSScope(null))); + } else { + // FIXME JS.eval(JS.cloneWithNewParentScope(t, root)); + } + } + /** Set the current path of the shell, modifiying the result of getScope(). */ - public void setPath(Object[] s) throws NoSuchPathException { + public void setPath(Object[] s) throws BadPathException { JS cur = root; if (s == null) s = new Object[0]; for (int i=0; i < s.length; i++) { Object o; - try { o = cur.get(s[i]); } catch (JSExn e) { throw new NoSuchPathException(); } - if (o == null || !(o instanceof JS)) throw new NoSuchPathException(); + try { o = cur.get(s[i]); } catch (JSExn e) { throw new BadPathException(); } + if (o == null || !(o instanceof JS)) throw new BadPathException(); cur = (JS)o; } scope = cur; @@ -174,5 +183,8 @@ public class Shell { } } - public static class NoSuchPathException extends Exception {} + public static class BadPathException extends Exception { + public BadPathException() {} + public BadPathException(String msg) { super(msg); } + } }