Fixed issue: #108
This commit is contained in:
@@ -91,7 +91,7 @@ public class Exp extends SyntaxElement {
|
||||
case Lua.OP_LT: case Lua.OP_GT: case Lua.OP_LE: case Lua.OP_GE: case Lua.OP_NEQ: case Lua.OP_EQ: return 2;
|
||||
case Lua.OP_CONCAT: return 3;
|
||||
case Lua.OP_ADD: case Lua.OP_SUB: return 4;
|
||||
case Lua.OP_MUL: case Lua.OP_DIV: case Lua.OP_MOD: return 5;
|
||||
case Lua.OP_MUL: case Lua.OP_DIV: case Lua.OP_IDIV: case Lua.OP_MOD: return 5;
|
||||
case Lua.OP_NOT: case Lua.OP_UNM: case Lua.OP_LEN: return 6;
|
||||
case Lua.OP_POW: return 7;
|
||||
default: throw new IllegalStateException("precedence of bad op "+op);
|
||||
|
||||
@@ -534,6 +534,7 @@ public class JavaBuilder {
|
||||
case Lua.OP_SUB: op = "sub"; break;
|
||||
case Lua.OP_MUL: op = "mul"; break;
|
||||
case Lua.OP_DIV: op = "div"; break;
|
||||
case Lua.OP_IDIV: op = "idiv"; break;
|
||||
case Lua.OP_MOD: op = "mod"; break;
|
||||
case Lua.OP_POW: op = "pow"; break;
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@ public class JavaGen {
|
||||
case Lua.OP_SUB: /* A B C R(A):= RK(B) - RK(C) */
|
||||
case Lua.OP_MUL: /* A B C R(A):= RK(B) * RK(C) */
|
||||
case Lua.OP_DIV: /* A B C R(A):= RK(B) / RK(C) */
|
||||
case Lua.OP_IDIV: /* A B C R(A):= RK(B) // RK(C) */
|
||||
case Lua.OP_MOD: /* A B C R(A):= RK(B) % RK(C) */
|
||||
case Lua.OP_POW: /* A B C R(A):= RK(B) ^ RK(C) */
|
||||
loadLocalOrConstant( p, builder, pc, b );
|
||||
|
||||
@@ -189,6 +189,7 @@ public class ProtoInfo {
|
||||
case Lua.OP_SUB: /* A B C R(A) := RK(B) - RK(C) */
|
||||
case Lua.OP_MUL: /* A B C R(A) := RK(B) * RK(C) */
|
||||
case Lua.OP_DIV: /* A B C R(A) := RK(B) / RK(C) */
|
||||
case Lua.OP_IDIV: /* A B C R(A) := RK(B) // RK(C) */
|
||||
case Lua.OP_MOD: /* A B C R(A) := RK(B) % RK(C) */
|
||||
case Lua.OP_POW: /* A B C R(A) := RK(B) ^ RK(C) */
|
||||
a = Lua.GETARG_A( ins );
|
||||
|
||||
@@ -960,6 +960,10 @@ public class LuaParser implements LuaParserConstants {
|
||||
|
||||
final public int Binop() throws ParseException {
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case IDIV:
|
||||
jj_consume_token(IDIV);
|
||||
{if (true) return Lua.OP_IDIV;}
|
||||
break;
|
||||
case 82:
|
||||
jj_consume_token(82);
|
||||
{if (true) return Lua.OP_ADD;}
|
||||
|
||||
@@ -33,6 +33,8 @@ public interface LuaParserConstants {
|
||||
/** RegularExpression Id. */
|
||||
int LONGSTRINGN = 27;
|
||||
/** RegularExpression Id. */
|
||||
int IDIV = 28;
|
||||
/** RegularExpression Id. */
|
||||
int AND = 29;
|
||||
/** RegularExpression Id. */
|
||||
int BREAK = 30;
|
||||
@@ -168,7 +170,7 @@ public interface LuaParserConstants {
|
||||
"\"]==]\"",
|
||||
"\"]===]\"",
|
||||
"<LONGSTRINGN>",
|
||||
"<token of kind 28>",
|
||||
"\"//\"",
|
||||
"\"and\"",
|
||||
"\"break\"",
|
||||
"\"do\"",
|
||||
|
||||
@@ -469,7 +469,8 @@ private int jjMoveStringLiteralDfa0_0()
|
||||
jjmatchedKind = 73;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x1008000L);
|
||||
case 47:
|
||||
return jjStopAtPos(0, 85);
|
||||
jjmatchedKind = 85;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x1L);
|
||||
case 58:
|
||||
jjmatchedKind = 74;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x2L);
|
||||
@@ -552,6 +553,10 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
|
||||
jjmatchedPos = 1;
|
||||
}
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x8000L);
|
||||
case 47:
|
||||
if ((active1 & 0x1L) != 0L)
|
||||
return jjStopAtPos(1, 28);
|
||||
break;
|
||||
case 58:
|
||||
if ((active1 & 0x2L) != 0L)
|
||||
return jjStopAtPos(1, 65);
|
||||
|
||||
@@ -104,6 +104,18 @@ public class FragmentsTest extends TestSuite {
|
||||
"end\n");
|
||||
|
||||
}
|
||||
|
||||
public void testFloorDivision() {
|
||||
runFragment(LuaValue.valueOf(2), "return 5//2\n");
|
||||
}
|
||||
|
||||
public void testFloorDivisionNegativeRoundsDown() {
|
||||
runFragment(LuaValue.valueOf(-3), "return 5//-2\n");
|
||||
}
|
||||
|
||||
public void testFloorDivisionInExpression() {
|
||||
runFragment(LuaValue.TRUE, "local x=5 local width=10 return x==width//2\n");
|
||||
}
|
||||
|
||||
public void testForloopParamUpvalues() {
|
||||
runFragment( LuaValue.varargsOf(new LuaValue[] {
|
||||
|
||||
Reference in New Issue
Block a user