Convert return value of luaLength to be int

This commit is contained in:
James Roseborough
2007-10-04 23:17:09 +00:00
parent a67783899f
commit 9be13fcc1d
4 changed files with 9 additions and 8 deletions

View File

@@ -585,7 +585,7 @@ public class LuaCompat extends LFunction {
if ( i == 0 )
i = 1;
if ( j == 0 )
j = list.luaLength().luaAsInt();
j = list.luaLength();
vm.setResult();
for ( int k=i; k<=j; k++ )
vm.push( list.get(k) );

View File

@@ -290,8 +290,8 @@ public class LString extends LValue {
}
/** Built-in opcode LEN, for Strings and Tables */
public LValue luaLength() {
return LInteger.valueOf( length() );
public int luaLength() {
return m_length;
}
public int luaGetType() {

View File

@@ -235,14 +235,14 @@ public class LTable extends LValue {
* as the C version in all cases, but that's ok because the length operation
* on a table where the integer keys are sparse is vaguely defined.
*/
public LValue luaLength() {
public int luaLength() {
for ( int i = Math.max( 0, m_arrayEntries-1 ); i < m_vector.length; ++i ) {
if ( m_vector[i] != LNil.NIL &&
( i+1 == m_vector.length || m_vector[i+1] == LNil.NIL ) ) {
return LInteger.valueOf( i+1 );
return i+1;
}
}
return LInteger.valueOf( 0 );
return 0;
}
/** Valid for tables */

View File

@@ -146,9 +146,10 @@ public class LValue {
}
/** Built-in opcode LEN, for Strings and Tables */
public LValue luaLength() {
public int luaLength() {
// TODO: call meta-method TM_LEN here
return luaUnsupportedOperation();
luaUnsupportedOperation();
return 0;
}
/** Valid for tables