From ac01ec471948b8274671406858c7b167b37fad63 Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Fri, 23 May 2008 15:04:23 +0000 Subject: [PATCH] delegate metatable gets, sets to luastate --- src/core/org/luaj/vm/LFunction.java | 16 ---------------- src/core/org/luaj/vm/LTable.java | 14 +++----------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/core/org/luaj/vm/LFunction.java b/src/core/org/luaj/vm/LFunction.java index e33e6179..f6492d23 100644 --- a/src/core/org/luaj/vm/LFunction.java +++ b/src/core/org/luaj/vm/LFunction.java @@ -33,22 +33,6 @@ public class LFunction extends LValue { return true; } - public void luaSetTable(LuaState vm, LValue table, LValue key, LValue val) { - vm.pushlvalue( this ); - vm.pushlvalue( table ); - vm.pushlvalue( key ); - vm.pushlvalue( val ); - vm.call( 3, 0 ); - } - - public LValue luaGetTable(LuaState vm, LValue table, LValue key) { - vm.pushlvalue( this ); - vm.pushlvalue( table ); - vm.pushlvalue( key ); - vm.call( 2, 1 ); - return vm.poplvalue(); - } - public int luaGetType() { return Lua.LUA_TFUNCTION; } diff --git a/src/core/org/luaj/vm/LTable.java b/src/core/org/luaj/vm/LTable.java index 54b3fb98..665061a3 100644 --- a/src/core/org/luaj/vm/LTable.java +++ b/src/core/org/luaj/vm/LTable.java @@ -232,21 +232,13 @@ public class LTable extends LValue { (hashKeys.length>0 && hashKeys[hashFindSlot(LInteger.valueOf(key))]!=null)); } - public LValue luaGetTable(LuaState vm, LValue table, LValue key) { - LValue v = get(key); - if ( v.isNil() && m_metatable != null ) { - return super.luaGetTable( vm, table, key ); - } else { - return v; - } + vm.luaV_gettable(table, key); + return vm.poplvalue(); } public void luaSetTable(LuaState vm, LValue table, LValue key, LValue val) { - if ( (!containsKey( key )) && m_metatable != null && m_metatable.containsKey(TM_NEWINDEX) ) - m_metatable.get(TM_NEWINDEX).luaSetTable( vm, table, key, val ); - else - put(key,val); + vm.luaV_settable(table, key, val); } private static final int MAX_KEY = 0x3fffffff;