- JS t = JS.fromReader("input", 0, new StringReader(sw.toString()));
- t = JS.cloneWithNewParentScope(t, new JSScope(null));
+ StringReader sr = new StringReader(sw.toString());
+
+ JS t;
+ try { t = JS.cloneWithNewParentScope(
+ JS.fromReader("input", 0, sr), new JSScope(null)); }
+ catch (IOException e) { throw new JSLeaf.Exn(e.getMessage()); }
+
+ try {
+ JSScope scope = JS.getParentScope(t);
+
+ Object u = scope().get("use"); if (u != null) scope().undeclare("use");
+ if (u != null) {
+ if (!(u instanceof String)) throw new JSLeaf.Exn(
+ "<"+getPrefix()+":transaction> requires 'use' attribute "+
+ "to be a valid space-seperated list of variables");
+ StringTokenizer st = new StringTokenizer((String)u);
+ while (st.hasMoreTokens()) {
+ String k = st.nextToken();
+ scope.put(k, scope().get(k));
+ }
+ }
+ } catch (JSExn e) { throw new JSLeaf.Exn(e); }
+