Fix metatable processing on luaGetTable
This commit is contained in:
@@ -223,11 +223,10 @@ public class LTable extends LValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void luaSetTable(VM vm, LValue table, LValue key, LValue val) {
|
public void luaSetTable(VM vm, LValue table, LValue key, LValue val) {
|
||||||
if ( !containsKey( key ) && m_metatable != null ) {
|
if ( (!containsKey( key )) && m_metatable != null && m_metatable.containsKey(TM_NEWINDEX) )
|
||||||
super.luaSetTable( vm, table, key, val );
|
m_metatable.get(TM_NEWINDEX).luaSetTable( vm, table, key, val );
|
||||||
} else {
|
else
|
||||||
put(key, val);
|
put(key,val);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ public class LuaJTest extends TestCase {
|
|||||||
runTest( "setlist" );
|
runTest( "setlist" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSimpleMetatables() throws IOException, InterruptedException {
|
||||||
|
runTest( "simplemetatables" );
|
||||||
|
}
|
||||||
|
|
||||||
public void testStrLib() throws IOException, InterruptedException {
|
public void testStrLib() throws IOException, InterruptedException {
|
||||||
runTest( "strlib" );
|
runTest( "strlib" );
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/test/res/simplemetatables.lua
Normal file
14
src/test/res/simplemetatables.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- The purpose of this test case is to check
|
||||||
|
-- that certain simple metatable operations work properly
|
||||||
|
t = { b='bbb' }
|
||||||
|
t.__index = t
|
||||||
|
u = {}
|
||||||
|
setmetatable( u, t )
|
||||||
|
u.c = 'ccc'
|
||||||
|
|
||||||
|
print( 't.a', t.a )
|
||||||
|
print( 'u.a', u.a )
|
||||||
|
print( 't.b', t.b )
|
||||||
|
print( 'u.b', u.b )
|
||||||
|
print( 't.c', t.c )
|
||||||
|
print( 'u.c', u.c )
|
||||||
BIN
src/test/res/simplemetatables.luac
Normal file
BIN
src/test/res/simplemetatables.luac
Normal file
Binary file not shown.
Reference in New Issue
Block a user