view src/luan/interp/TryStmt.java @ 118:735708619119

add Debug.debug() git-svn-id: https://luan-java.googlecode.com/svn/trunk@119 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 01 Jun 2014 07:07:31 +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);
			}
		}
	}
}