view core/src/luan/impl/Block.java @ 576:4723d22062ce

remove LuanBit
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Jul 2015 20:38:26 -0600
parents 3dcb0f9bee82
children
line wrap: on
line source

package luan.impl;

import luan.LuanException;


final class Block implements Stmt {
	final Stmt[] stmts;
	private final int stackStart;
	private final int stackEnd;

	Block(Stmt[] stmts,int stackStart,int stackEnd) {
		if( stmts.length==0 )
			throw new RuntimeException("empty block");
		this.stmts = stmts;
		this.stackStart = stackStart;
		this.stackEnd = stackEnd;
	}

	@Override public void eval(LuanStateImpl luan) throws LuanException {
		try {
			for( Stmt stmt : stmts ) {
				stmt.eval(luan);
			}
		} finally {
			luan.stackClear(stackStart,stackEnd);
		}
	}

}