Mercurial Hosting > luan
comparison core/src/luan/impl/FnDef.java @ 663:b438a47196bc
finish compiling function blocks
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 07 Apr 2016 00:01:10 -0600 |
parents | 859c0dedc8b6 |
children | 71f8f5075df8 |
comparison
equal
deleted
inserted
replaced
662:ee00a619eec1 | 663:b438a47196bc |
---|---|
2 | 2 |
3 import luan.LuanException; | 3 import luan.LuanException; |
4 | 4 |
5 | 5 |
6 final class FnDef extends CodeImpl implements Expr { | 6 final class FnDef extends CodeImpl implements Expr { |
7 final Stmt block; | 7 final Expressions block; |
8 final int stackSize; | 8 final int stackSize; |
9 final int numArgs; | 9 final int numArgs; |
10 final boolean isVarArg; | 10 final boolean isVarArg; |
11 final UpValue.Getter[] upValueGetters; | 11 final UpValue.Getter[] upValueGetters; |
12 | 12 |
13 FnDef(Stmt block,int stackSize,int numArgs,boolean isVarArg,UpValue.Getter[] upValueGetters) { | 13 FnDef(Expressions block,int stackSize,int numArgs,boolean isVarArg,UpValue.Getter[] upValueGetters) { |
14 this.block = block; | 14 this.block = block; |
15 this.stackSize = stackSize; | 15 this.stackSize = stackSize; |
16 this.numArgs = numArgs; | 16 this.numArgs = numArgs; |
17 this.isVarArg = isVarArg; | 17 this.isVarArg = isVarArg; |
18 this.upValueGetters = upValueGetters; | 18 this.upValueGetters = upValueGetters; |
19 fixReturns(block); | 19 // fixReturns(block); |
20 } | 20 } |
21 | 21 /* |
22 private static void fixReturns(Stmt stmt) { | 22 private static void fixReturns(Stmt stmt) { |
23 if( stmt instanceof ReturnStmt ) { | 23 if( stmt instanceof ReturnStmt ) { |
24 ReturnStmt rs = (ReturnStmt)stmt; | 24 ReturnStmt rs = (ReturnStmt)stmt; |
25 rs.throwReturnException = false; | 25 rs.throwReturnException = false; |
26 } else if( stmt instanceof Block ) { | 26 } else if( stmt instanceof Block ) { |
30 IfStmt is = (IfStmt)stmt; | 30 IfStmt is = (IfStmt)stmt; |
31 fixReturns( is.thenStmt ); | 31 fixReturns( is.thenStmt ); |
32 fixReturns( is.elseStmt ); | 32 fixReturns( is.elseStmt ); |
33 } | 33 } |
34 } | 34 } |
35 | 35 */ |
36 @Override public Object eval(LuanStateImpl luan) throws LuanException { | 36 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
37 return new Closure(luan,this); | 37 return new Closure(luan,this); |
38 } | 38 } |
39 | 39 |
40 } | 40 } |