Mercurial Hosting > luan
diff core/src/luan/impl/FnDef.java @ 664:71f8f5075df8
compile FnDef
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 07 Apr 2016 15:11:52 -0600 |
parents | b438a47196bc |
children |
line wrap: on
line diff
--- a/core/src/luan/impl/FnDef.java Thu Apr 07 00:01:10 2016 -0600 +++ b/core/src/luan/impl/FnDef.java Thu Apr 07 15:11:52 2016 -0600 @@ -3,38 +3,22 @@ import luan.LuanException; -final class FnDef extends CodeImpl implements Expr { - final Expressions block; +public abstract class FnDef extends CodeImpl implements Expr { final int stackSize; final int numArgs; final boolean isVarArg; final UpValue.Getter[] upValueGetters; - FnDef(Expressions block,int stackSize,int numArgs,boolean isVarArg,UpValue.Getter[] upValueGetters) { - this.block = block; + public FnDef(int stackSize,int numArgs,boolean isVarArg,UpValue.Getter[] upValueGetters) { this.stackSize = stackSize; this.numArgs = numArgs; this.isVarArg = isVarArg; this.upValueGetters = upValueGetters; -// fixReturns(block); } -/* - private static void fixReturns(Stmt stmt) { - if( stmt instanceof ReturnStmt ) { - ReturnStmt rs = (ReturnStmt)stmt; - rs.throwReturnException = false; - } else if( stmt instanceof Block ) { - Block b = (Block)stmt; - fixReturns( b.stmts[b.stmts.length-1] ); - } else if( stmt instanceof IfStmt ) { - IfStmt is = (IfStmt)stmt; - fixReturns( is.thenStmt ); - fixReturns( is.elseStmt ); - } - } -*/ + @Override public Object eval(LuanStateImpl luan) throws LuanException { return new Closure(luan,this); } + public abstract Object run(LuanStateImpl luan) throws LuanException; }