Convert return value of luaLength to be int
This commit is contained in:
@@ -585,7 +585,7 @@ public class LuaCompat extends LFunction {
|
|||||||
if ( i == 0 )
|
if ( i == 0 )
|
||||||
i = 1;
|
i = 1;
|
||||||
if ( j == 0 )
|
if ( j == 0 )
|
||||||
j = list.luaLength().luaAsInt();
|
j = list.luaLength();
|
||||||
vm.setResult();
|
vm.setResult();
|
||||||
for ( int k=i; k<=j; k++ )
|
for ( int k=i; k<=j; k++ )
|
||||||
vm.push( list.get(k) );
|
vm.push( list.get(k) );
|
||||||
|
|||||||
@@ -290,8 +290,8 @@ public class LString extends LValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Built-in opcode LEN, for Strings and Tables */
|
/** Built-in opcode LEN, for Strings and Tables */
|
||||||
public LValue luaLength() {
|
public int luaLength() {
|
||||||
return LInteger.valueOf( length() );
|
return m_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int luaGetType() {
|
public int luaGetType() {
|
||||||
|
|||||||
@@ -235,14 +235,14 @@ public class LTable extends LValue {
|
|||||||
* as the C version in all cases, but that's ok because the length operation
|
* 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.
|
* 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 ) {
|
for ( int i = Math.max( 0, m_arrayEntries-1 ); i < m_vector.length; ++i ) {
|
||||||
if ( m_vector[i] != LNil.NIL &&
|
if ( m_vector[i] != LNil.NIL &&
|
||||||
( i+1 == m_vector.length || m_vector[i+1] == 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 */
|
/** Valid for tables */
|
||||||
|
|||||||
@@ -146,9 +146,10 @@ public class LValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Built-in opcode LEN, for Strings and Tables */
|
/** Built-in opcode LEN, for Strings and Tables */
|
||||||
public LValue luaLength() {
|
public int luaLength() {
|
||||||
// TODO: call meta-method TM_LEN here
|
// TODO: call meta-method TM_LEN here
|
||||||
return luaUnsupportedOperation();
|
luaUnsupportedOperation();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Valid for tables
|
/** Valid for tables
|
||||||
|
|||||||
Reference in New Issue
Block a user