Mercurial Hosting > luan
diff core/src/luan/impl/LuanStateImpl.java @ 670:58ebfec6178b
all luan now compiles
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Apr 2016 01:05:57 -0600 |
parents | b438a47196bc |
children |
line wrap: on
line diff
--- a/core/src/luan/impl/LuanStateImpl.java Mon Apr 11 16:00:44 2016 -0600 +++ b/core/src/luan/impl/LuanStateImpl.java Tue Apr 12 01:05:57 2016 -0600 @@ -13,46 +13,7 @@ public final class LuanStateImpl extends LuanState { - - private static class Frame { - final Frame previousFrame; - final Closure closure; - final Object[] stack; - final Object[] varArgs; - UpValue[] downValues = null; - - Frame( Frame previousFrame, Closure closure, int stackSize, Object[] varArgs) { - this.previousFrame = previousFrame; - this.closure = closure; - this.stack = new Object[stackSize]; - this.varArgs = varArgs; - } - - void stackClear(int start,int end) { - if( downValues != null ) { - for( int i=start; i<end; i++ ) { - UpValue downValue = downValues[i]; - if( downValue != null ) { - downValue.close(); - downValues[i] = null; - } - } - } - for( int i=start; i<end; i++ ) { - stack[i] = null; - } - } - - UpValue getUpValue(int index) { - if( downValues==null ) - downValues = new UpValue[stack.length]; - if( downValues[index] == null ) - downValues[index] = new UpValue(stack,index); - return downValues[index]; - } - } - - private Frame frame = null; + Closure closure; LuanStateImpl() {} @@ -61,54 +22,17 @@ } @Override public LuanState shallowClone() { -// if( frame != null ) -// throw new IllegalStateException("frame isn't null"); return new LuanStateImpl(this); } - // returns stack - Object[] newFrame(Closure closure, int stackSize, Object[] varArgs) { - frame = new Frame(frame,closure,stackSize,varArgs); - return frame.stack; - } - - void popFrame() { - frame = frame.previousFrame; - } - - Object stackGet(int index) { - return frame.stack[index]; - } - - public void stackSet(int index,Object value) { - frame.stack[index] = value; - } - - public void stackClear(int start,int end) { - frame.stackClear(start,end); - } - - Object[] varArgs() { - return frame.varArgs; - } - - Closure closure() { - return frame.closure; - } - - UpValue getUpValue(int index) { - return frame.getUpValue(index); - } - @Override public boolean hasJava() { - if( frame==null ) + if( closure==null ) return false; - return ((LuanTable)frame.closure.upValues()[0].get()).hasJava; + return ((LuanTable)closure.upValues[0].o).hasJava; } @Override public void setJava() { - ((LuanTable)frame.closure.upValues()[0].get()).hasJava = true; + ((LuanTable)closure.upValues[0].o).hasJava = true; } - }