gecko-dev/js/js2/java/TryNode.java

47 lines
1.1 KiB
Java
Raw Normal View History

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));
String id = ((JSObject)e).oClass;
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;
}