Improve compiler output
This commit is contained in:
@@ -135,6 +135,11 @@ public class Slots {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Lua.OP_SETTABLE: /* A B C R(A)[RK(B)]:= RK(C) */
|
case Lua.OP_SETTABLE: /* A B C R(A)[RK(B)]:= RK(C) */
|
||||||
|
s[a] |= BIT_REFER;
|
||||||
|
if (b<=0xff) s[b] |= BIT_REFER;
|
||||||
|
if (c<=0xff) s[c] |= BIT_REFER;
|
||||||
|
break;
|
||||||
|
|
||||||
case Lua.OP_ADD: /* A B C R(A):= RK(B) + RK(C) */
|
case Lua.OP_ADD: /* A B C R(A):= RK(B) + RK(C) */
|
||||||
case Lua.OP_SUB: /* A B C R(A):= RK(B) - RK(C) */
|
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_MUL: /* A B C R(A):= RK(B) * RK(C) */
|
||||||
@@ -142,7 +147,7 @@ public class Slots {
|
|||||||
case Lua.OP_MOD: /* 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) */
|
case Lua.OP_POW: /* A B C R(A):= RK(B) ^ RK(C) */
|
||||||
s[a] |= BIT_ASSIGN;
|
s[a] |= BIT_ASSIGN;
|
||||||
if (bx<=0xff) s[bx] |= BIT_REFER;
|
if (b<=0xff) s[b] |= BIT_REFER;
|
||||||
if (c<=0xff) s[c] |= BIT_REFER;
|
if (c<=0xff) s[c] |= BIT_REFER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -273,8 +278,13 @@ public class Slots {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Lua.OP_VARARG: /* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
|
case Lua.OP_VARARG: /* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
|
||||||
while ( a<b )
|
if ( b == 0 ) {
|
||||||
s[a++] |= BIT_ASSIGN;
|
while ( a<m )
|
||||||
|
s[a++] |= BIT_INVALID;
|
||||||
|
} else {
|
||||||
|
for ( int i=1; i<b; ++a, ++i )
|
||||||
|
s[a] |= BIT_ASSIGN;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,4 +282,13 @@ public class FragmentsTest extends TestCase {
|
|||||||
"function ccc(z) return z end\n" +
|
"function ccc(z) return z end\n" +
|
||||||
"return ccc( aaa(bbb(123)), aaa(456) )\n" );
|
"return ccc( aaa(bbb(123)), aaa(456) )\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSetUpvalueTableInitializer() {
|
||||||
|
runFragment( LuaValue.valueOf("b"),
|
||||||
|
"local aliases = {a='b'}\n" +
|
||||||
|
"local foo = function()\n" +
|
||||||
|
" return aliases\n" +
|
||||||
|
"end\n" +
|
||||||
|
"return foo().a\n" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,8 +508,8 @@ public class TypeTest extends TestCase {
|
|||||||
assertEquals( String.valueOf(sampledouble), stringdouble.toString() );
|
assertEquals( String.valueOf(sampledouble), stringdouble.toString() );
|
||||||
assertEquals( "thread: ", thread.toString().substring(0,8) );
|
assertEquals( "thread: ", thread.toString().substring(0,8) );
|
||||||
assertEquals( "table: ", table.toString().substring(0,7) );
|
assertEquals( "table: ", table.toString().substring(0,7) );
|
||||||
assertEquals( "userdata: ", userdataobj.toString().substring(0,10) );
|
assertEquals( sampleobject.toString(), userdataobj.toString() );
|
||||||
assertEquals( "userdata: ", userdatacls.toString().substring(0,10) );
|
assertEquals( sampledata.toString(), userdatacls.toString() );
|
||||||
assertEquals( "function: ", somefunc.toString().substring(0,10) );
|
assertEquals( "function: ", somefunc.toString().substring(0,10) );
|
||||||
assertEquals( "function: ", someclosure.toString().substring(0,10) );
|
assertEquals( "function: ", someclosure.toString().substring(0,10) );
|
||||||
}
|
}
|
||||||
@@ -868,7 +868,7 @@ public class TypeTest extends TestCase {
|
|||||||
fail( "did not throw bad type error" );
|
fail( "did not throw bad type error" );
|
||||||
assertTrue( o instanceof MyData );
|
assertTrue( o instanceof MyData );
|
||||||
} catch ( LuaError le ) {
|
} catch ( LuaError le ) {
|
||||||
assertEquals( le.getMessage(), "expected org.luaj.vm2.TypeTest$MyData got userdata" );
|
assertEquals( "org.luaj.vm2.TypeTest$MyData expected, got userdata", le.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,7 +1216,7 @@ public class TypeTest extends TestCase {
|
|||||||
fail( "did not throw bad type error" );
|
fail( "did not throw bad type error" );
|
||||||
assertTrue( o instanceof MyData );
|
assertTrue( o instanceof MyData );
|
||||||
} catch ( LuaError le ) {
|
} catch ( LuaError le ) {
|
||||||
assertEquals( le.getMessage(), "expected org.luaj.vm2.TypeTest$MyData got userdata" );
|
assertEquals( "org.luaj.vm2.TypeTest$MyData expected, got userdata", le.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user