comparison core/src/luan/impl/Block.java @ 171:3dcb0f9bee82

add core component git-svn-id: https://luan-java.googlecode.com/svn/trunk@172 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 22 Jun 2014 05:41:22 +0000
parents src/luan/impl/Block.java@4eaee12f6c65
children
comparison
equal deleted inserted replaced
170:7c792a328a83 171:3dcb0f9bee82
1 package luan.impl;
2
3 import luan.LuanException;
4
5
6 final class Block implements Stmt {
7 final Stmt[] stmts;
8 private final int stackStart;
9 private final int stackEnd;
10
11 Block(Stmt[] stmts,int stackStart,int stackEnd) {
12 if( stmts.length==0 )
13 throw new RuntimeException("empty block");
14 this.stmts = stmts;
15 this.stackStart = stackStart;
16 this.stackEnd = stackEnd;
17 }
18
19 @Override public void eval(LuanStateImpl luan) throws LuanException {
20 try {
21 for( Stmt stmt : stmts ) {
22 stmt.eval(luan);
23 }
24 } finally {
25 luan.stackClear(stackStart,stackEnd);
26 }
27 }
28
29 }