Remove deprecated API's

This commit is contained in:
James Roseborough
2007-11-05 22:30:48 +00:00
parent e785b88f30
commit d0bd5c9ff8
2 changed files with 8 additions and 186 deletions

View File

@@ -69,26 +69,6 @@ public class StackState extends Lua implements VM {
// ================ interfaces for performing calls // ================ interfaces for performing calls
public void push( int value ) {
stack[top++] = LInteger.valueOf(value);
}
public void push( String value ) {
stack[top++] = new LString(value);
}
public void push( double value ) {
stack[top++] = new LDouble(value);
}
public void push( boolean value ) {
stack[top++] = value? LBoolean.TRUE: LBoolean.FALSE;
}
public void push( LValue value ) {
stack[top++] = value;
}
public void prepStackCall() { public void prepStackCall() {
Closure c = (Closure) stack[base]; Closure c = (Closure) stack[base];
int resultbase = base; int resultbase = base;
@@ -127,22 +107,15 @@ public class StackState extends Lua implements VM {
} }
public void doCall( Closure c, LValue[] args ) { public void doCall( Closure c, LValue[] args ) {
setResult( c ); settop(0);
pushlvalue( c );
for ( int i=0, n=(args!=null? args.length: 0); i<n; i++ ) for ( int i=0, n=(args!=null? args.length: 0); i<n; i++ )
push( args[i] ); pushlvalue( args[i] );
prepStackCall(); prepStackCall();
execute(); execute();
base = (cc>=0? calls[cc].base: 0); base = (cc>=0? calls[cc].base: 0);
} }
public void setExpectedResultCount( int nresults ) {
this.nresults = nresults;
}
public int getExpectedResultCount() {
return this.nresults;
}
public void invokeJavaFunction(JavaFunction javaFunction) { public void invokeJavaFunction(JavaFunction javaFunction) {
int resultbase = base; int resultbase = base;
int resultsneeded = nresults; int resultsneeded = nresults;
@@ -219,7 +192,8 @@ public class StackState extends Lua implements VM {
this.cc = oldcc; this.cc = oldcc;
close(oldtop); /* close eventual pending closures */ close(oldtop); /* close eventual pending closures */
String s = t.getMessage(); String s = t.getMessage();
setResult( s!=null? s: t.toString() ); settop(0);
pushstring( s!=null? s: t.toString() );
return (t instanceof OutOfMemoryError? LUA_ERRMEM: LUA_ERRRUN); return (t instanceof OutOfMemoryError? LUA_ERRMEM: LUA_ERRRUN);
} }
} }
@@ -228,73 +202,14 @@ public class StackState extends Lua implements VM {
public int load( InputStream is, String chunkname ) { public int load( InputStream is, String chunkname ) {
try { try {
Proto p = LoadState.undump(this, is, chunkname ); Proto p = LoadState.undump(this, is, chunkname );
push( new Closure( this, p ) ); pushlvalue( new Closure( p, _G ) );
return 0; return 0;
} catch ( Throwable t ) { } catch ( Throwable t ) {
setResult( t.getMessage() ); pushstring( t.getMessage() );
return (t instanceof OutOfMemoryError? LUA_ERRMEM: LUA_ERRSYNTAX); return (t instanceof OutOfMemoryError? LUA_ERRMEM: LUA_ERRSYNTAX);
} }
} }
// ================ interfaces for being called
public int getArgCount() {
return top - (base + 1);
}
public LValue getArg(int index) {
int off = (base + 1) + index;
return off < top? stack[off]: LNil.NIL;
}
public int getArgAsInt( int index ) {
return getArg(index).toJavaInt();
}
public double getArgAsDouble( int index ) {
return getArg(index).toJavaDouble();
}
public boolean getArgAsBoolean( int index ) {
return getArg(index).toJavaBoolean();
}
public LString getArgAsLuaString( int index ) {
return getArg(index).luaAsString();
}
public String getArgAsString( int index ) {
return getArgAsLuaString(index).toJavaString();
}
public void setResult() {
top = base;
}
public void setResult( LValue value ) {
setResult();
push( value );
}
public void setResult( String value ) {
setResult();
push( value );
}
public void setErrorResult(LValue value, String message) {
setResult();
push( value );
push( message );
}
public void adjustResults() {
if ( nresults != LUA_MULTRET ) {
adjustTop( base + nresults );
}
// Copy base back from value in call frame
base = (cc >= 0) ? calls[cc].base : 0;
}
// ================ execute instructions // ================ execute instructions
private LValue RKBC(LValue[] k, int bc) { private LValue RKBC(LValue[] k, int bc) {
return StackState.ISK(bc) ? return StackState.ISK(bc) ?
@@ -681,7 +596,7 @@ public class StackState extends Lua implements VM {
case StackState.OP_CLOSURE: { case StackState.OP_CLOSURE: {
b = StackState.GETARG_Bx(i); b = StackState.GETARG_Bx(i);
proto = cl.p.p[b]; proto = cl.p.p[b];
newClosure = new Closure(this, proto); newClosure = new Closure(proto, _G);
for (int j = 0; j < newClosure.upVals.length; j++, ci.pc++) { for (int j = 0; j < newClosure.upVals.length; j++, ci.pc++) {
i = code[ci.pc]; i = code[ci.pc];
o = StackState.GET_OPCODE(i); o = StackState.GET_OPCODE(i);

View File

@@ -46,31 +46,6 @@ public interface VM {
// ================ interfaces for performing calls // ================ interfaces for performing calls
/**
* @deprecated - push by type instead or use pushlvalue()
*/
public void push( LValue value );
/**
* @deprecated - use pushinteger() instead
*/
public void push( int value );
/**
* @deprecated - use pushnumber() instead
*/
public void push( double value );
/**
* @deprecated - use pushboolean() instead
*/
public void push( boolean value );
/**
* @deprecated - use pushstring or pushlstring instead
*/
public void push( String value );
/** /**
* Create a call frame for a call that has been set up on * Create a call frame for a call that has been set up on
* the stack. The first value on the stack must be a Closure, * the stack. The first value on the stack must be a Closure,
@@ -101,74 +76,6 @@ public interface VM {
public void doCall(Closure c, LValue[] values); public void doCall(Closure c, LValue[] values);
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public void setExpectedResultCount( int nresults );
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public int getExpectedResultCount();
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public void adjustResults();
// ================ interfaces for getting arguments when called
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public int getArgCount();
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public LValue getArg(int index);
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public int getArgAsInt( int index );
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public double getArgAsDouble( int index );
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public boolean getArgAsBoolean( int index );
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public String getArgAsString( int index );
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public LString getArgAsLuaString( int index );
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public void setResult();
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public void setResult(LValue val);
/**
* @deprecated - use JavaFunction and Java API instead.
*/
public void setErrorResult(LValue value, String message);
// =============================================================== // ===============================================================
// Lua Java API // Lua Java API
// =============================================================== // ===============================================================