projects
/
org.ibex.xt-crawshaw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add mkdir and replace functions
[org.ibex.xt-crawshaw.git]
/
src
/
java
/
org
/
ibex
/
xt
/
shell
/
Shell.java
diff --git
a/src/java/org/ibex/xt/shell/Shell.java
b/src/java/org/ibex/xt/shell/Shell.java
index
f677f28
..
ceef6bf
100644
(file)
--- 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.*/
/** 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) {
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]);
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]);
}
}
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(). */
/** 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;
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;
cur = (JS)o;
}
scope = cur;
@@
-113,6
+122,8
@@
public class Shell {
new Command.Pwd(this),
new Command.Cd(this),
new Command.Rm(this),
new Command.Pwd(this),
new Command.Cd(this),
new Command.Rm(this),
+ new Command.Replace(this),
+ new Command.Mkdir(this),
new Command.Help(this)
};
}
new Command.Help(this)
};
}
@@
-174,5
+185,8
@@
public class Shell {
}
}
}
}
- public static class NoSuchPathException extends Exception {}
+ public static class BadPathException extends Exception {
+ public BadPathException() {}
+ public BadPathException(String msg) { super(msg); }
+ }
}
}