Add binary compares, some unary ops, fix binary arithmetic, add plain for loop.

This commit is contained in:
James Roseborough
2007-06-10 19:49:47 +00:00
parent 70dfc20f57
commit e1e6625aa1
8 changed files with 121 additions and 1 deletions

View File

@@ -40,4 +40,32 @@ public class LInteger extends LNumber {
public LValue luaBinOpDouble(int opcode, double rhs) {
return LDouble.luaBinOpDoubleDouble(opcode, (double) m_value, rhs );
}
// binary compare for integers, first dispatch
public boolean luaBinCmpUnknown(int opcode, LValue lhs) {
return lhs.luaBinCmpInteger( opcode, this.m_value );
}
// unsupported except for numbers
public boolean luaBinCmpInteger(int opcode, int rhs) {
switch ( opcode ) {
case Lua.OP_EQ: return m_value == rhs;
case Lua.OP_LT: return m_value < rhs;
case Lua.OP_LE: return m_value <= rhs;
}
luaUnsupportedOperation();
return false;
}
// unsupported except for numbers
public boolean luaBinCmpDouble(int opcode, double rhs) {
return LDouble.luaBinCmpDoubleDouble(opcode, (double) m_value, rhs );
}
/** Arithmetic negative */
public LValue luaUnaryMinus() {
return new LInteger( -m_value );
}
}