Mercurial Hosting > luan
comparison src/luan/interp/TryStmt.java @ 101:8ebcccca13ab
add missing TryStmt
git-svn-id: https://luan-java.googlecode.com/svn/trunk@102 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Mon, 10 Jun 2013 23:07:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
100:6c827f7275df | 101:8ebcccca13ab |
---|---|
1 package luan.interp; | |
2 | |
3 import luan.Luan; | |
4 import luan.LuanException; | |
5 | |
6 | |
7 final class TryStmt implements Stmt { | |
8 private final Stmt tryBlock; | |
9 private final int iExceptionVar; | |
10 private final Stmt catchBlock; | |
11 | |
12 TryStmt(Stmt tryBlock,int iExceptionVar,Stmt catchBlock) { | |
13 this.tryBlock = tryBlock; | |
14 this.iExceptionVar = iExceptionVar; | |
15 this.catchBlock = catchBlock; | |
16 } | |
17 | |
18 @Override public void eval(LuanStateImpl luan) throws LuanException { | |
19 try { | |
20 tryBlock.eval(luan); | |
21 } catch(LuanException e) { | |
22 try { | |
23 luan.stackSet( iExceptionVar, e ); | |
24 catchBlock.eval(luan); | |
25 } finally { | |
26 luan.stackClear(iExceptionVar,iExceptionVar+1); | |
27 } | |
28 } | |
29 } | |
30 } |