1999-05-18 22:50:53 +00:00
|
|
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
class TryNode extends ControlNode {
|
|
|
|
|
|
|
|
TryNode(ControlNode tryCode)
|
|
|
|
{
|
|
|
|
super(null);
|
|
|
|
tryBody = tryCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addFinally(ControlNode finallyCode)
|
|
|
|
{
|
|
|
|
finallyBody = finallyCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addCatchClause(ExpressionNode e, ControlNode c)
|
|
|
|
{
|
|
|
|
catchExpr.addElement(e);
|
|
|
|
catchCode.addElement(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlNode eval(Environment theEnv)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
ControlNode c = tryBody;
|
|
|
|
while (c != null) c = c.eval(theEnv);
|
|
|
|
}
|
|
|
|
catch (JSException x) {
|
|
|
|
int count = catchExpr.size();
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
ExpressionNode e = (ExpressionNode)(catchExpr.elementAt(i));
|
1999-06-15 00:57:05 +00:00
|
|
|
String id = ((JSObject)e).oClass;
|
1999-05-25 21:49:40 +00:00
|
|
|
theEnv.scope.contents.put(id, x.getValue()); // XXX YAARGH !!!
|
1999-05-18 22:50:53 +00:00
|
|
|
return (ControlNode)(catchCode.elementAt(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector catchExpr = new Vector();
|
|
|
|
Vector catchCode = new Vector();
|
|
|
|
|
|
|
|
ControlNode tryBody;
|
|
|
|
ControlNode finallyBody;
|
|
|
|
|
|
|
|
}
|