Mercurial Hosting > luan
view src/luan/impl/Closure.java @ 784:6a7c6879158d
revert shallowClone()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 30 Aug 2016 12:08:49 -0600 |
parents | 655280eab1e2 |
children | d69d3c51c44e |
line wrap: on
line source
package luan.impl; import luan.Luan; import luan.LuanFunction; import luan.LuanState; import luan.LuanException; import luan.LuanCloner; import luan.LuanCloneable; import luan.LuanJava; public abstract class Closure extends LuanFunction implements LuanCloneable, Cloneable { public Pointer[] upValues; public LuanJava java; public Closure(int nUpValues,LuanJava java) throws LuanException { this.upValues = new Pointer[nUpValues]; this.java = java; } @Override public Closure shallowClone() { try { return (Closure)clone(); } catch(CloneNotSupportedException e) { throw new RuntimeException(e); } } @Override public void deepenClone(LuanCloneable dc,LuanCloner cloner) { Closure clone = (Closure)dc; clone.upValues = (Pointer[])cloner.clone(upValues); clone.java = (LuanJava)cloner.clone(java); } @Override public final Object call(LuanState luan,Object[] args) throws LuanException { LuanJava old = luan.java; luan.java = java; try { return doCall(luan,args); } catch(StackOverflowError e) { throw new LuanException( "stack overflow" ); } finally { luan.java = old; } } public abstract Object doCall(LuanState luan,Object[] args) throws LuanException; }