Mercurial Hosting > luan
view src/luan/interp/TryStmt.java @ 165:94bbc4cbc106
merge luan/parser into interp
git-svn-id: https://luan-java.googlecode.com/svn/trunk@166 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 22 Jun 2014 04:10:59 +0000 |
parents | 8ebcccca13ab |
children |
line wrap: on
line source
package luan.interp; import luan.Luan; import luan.LuanException; final class TryStmt implements Stmt { private final Stmt tryBlock; private final int iExceptionVar; private final Stmt catchBlock; TryStmt(Stmt tryBlock,int iExceptionVar,Stmt catchBlock) { this.tryBlock = tryBlock; this.iExceptionVar = iExceptionVar; this.catchBlock = catchBlock; } @Override public void eval(LuanStateImpl luan) throws LuanException { try { tryBlock.eval(luan); } catch(LuanException e) { try { luan.stackSet( iExceptionVar, e ); catchBlock.eval(luan); } finally { luan.stackClear(iExceptionVar,iExceptionVar+1); } } } }