Reject nan as table index.
This commit is contained in:
@@ -192,4 +192,9 @@ public class LuaDouble extends LuaNumber {
|
|||||||
return LuaString.valueOf(tojstring());
|
return LuaString.valueOf(tojstring());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LuaValue checkvalidkey() {
|
||||||
|
if ( Double.isNaN(v) )
|
||||||
|
throw new LuaError("table index expected, got nan");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ public class LuaNil extends LuaValue {
|
|||||||
public LuaValue checknotnil() {
|
public LuaValue checknotnil() {
|
||||||
return typerror("value");
|
return typerror("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LuaValue checkvalidkey() {
|
||||||
|
return typerror("table index");
|
||||||
|
}
|
||||||
|
|
||||||
// optional argument conversions - nil alwas falls badk to default value
|
// optional argument conversions - nil alwas falls badk to default value
|
||||||
public boolean optboolean(boolean defval) { return defval; }
|
public boolean optboolean(boolean defval) { return defval; }
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class LuaTable extends LuaValue {
|
|||||||
|
|
||||||
/** caller must ensure key is not nil */
|
/** caller must ensure key is not nil */
|
||||||
public void set( LuaValue key, LuaValue value ) {
|
public void set( LuaValue key, LuaValue value ) {
|
||||||
key.checknotnil();
|
key.checkvalidkey();
|
||||||
if ( m_metatable==null || ! rawget(key).isnil() || ! settable(this,key,value) )
|
if ( m_metatable==null || ! rawget(key).isnil() || ! settable(this,key,value) )
|
||||||
rawset(key, value);
|
rawset(key, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,8 @@ public class LuaValue extends Varargs {
|
|||||||
public Object checkuserdata() { typerror("userdata"); return null; }
|
public Object checkuserdata() { typerror("userdata"); return null; }
|
||||||
public Object checkuserdata(Class c) { typerror("userdata"); return null; }
|
public Object checkuserdata(Class c) { typerror("userdata"); return null; }
|
||||||
public LuaValue checknotnil() { return this; }
|
public LuaValue checknotnil() { return this; }
|
||||||
|
public LuaValue checkvalidkey() { return this; }
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated - use checkjstring() instead */
|
/** @deprecated - use checkjstring() instead */
|
||||||
public String checkString() { return checkjstring(); }
|
public String checkString() { return checkjstring(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user