Mozilla/mozilla/js/js2/java/TryNode.java
rogerl%netscape.com 13a12a7a0e Switch to new JSValue hierarchy.
Added logical/bitwise ops.


git-svn-id: svn://10.0.0.236/trunk@32350 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-20 00:13:38 +00:00

49 lines
1.2 KiB
Java

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)
{
int stackHeight = theEnv.theStack.size();
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).value;
theEnv.theStack.setStack(stackHeight);
theEnv.theGlobals.put(id, new Double(x.getValue().d));
return (ControlNode)(catchCode.elementAt(i));
}
}
return next;
}
Vector catchExpr = new Vector();
Vector catchCode = new Vector();
ControlNode tryBody;
ControlNode finallyBody;
}