Mercurial Hosting > luan
view src/luan/LuanClosure.java @ 1784:fdc59d390615
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 07 Dec 2023 15:07:55 -0700 |
parents | c922446f53aa |
children |
line wrap: on
line source
package luan; import luan.impl.Pointer; public abstract class LuanClosure extends LuanFunction implements LuanMutable { public Pointer[] upValues; public boolean javaOk; public final String sourceName; private boolean immutable = false; public LuanClosure(Pointer[] upValues,boolean javaOk,String sourceName) throws LuanException { this.upValues = upValues; this.javaOk = javaOk; this.sourceName = sourceName; } @Override public final boolean isImmutable() { return immutable; } @Override public final void makeImmutable() { if(immutable) return; immutable = true; LuanMutable.makeImmutable(upValues); } @Override public final Object call(Luan luan,Object... args) throws LuanException { luan.push(this); try { return doCall(luan,args); } catch(StackOverflowError e) { throw new LuanException( "stack overflow", e ); } finally { luan.pop(); } } @Override public final String toString() { return super.toString()+"="+sourceName; } public abstract Object doCall(Luan luan,Object[] args) throws LuanException; }