2013-12-30 01:58:44 +00:00
|
|
|
|
namespace BizHawk.Client.Common
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
public class BitLuaLibrary : LuaLibraryBase
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
public override string Name { get { return "bit"; } }
|
|
|
|
|
public override string[] Functions
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
"band",
|
|
|
|
|
"bnot",
|
|
|
|
|
"bor",
|
|
|
|
|
"bxor",
|
|
|
|
|
"lshift",
|
|
|
|
|
"rol",
|
|
|
|
|
"ror",
|
|
|
|
|
"rshift",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-29 13:52:59 +00:00
|
|
|
|
|
|
|
|
|
public static uint bit_band(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)(LuaInt(val) & LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_bnot(object val)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)(~LuaInt(val));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_bor(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)(LuaInt(val) | LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_bxor(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)(LuaInt(val) ^ LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_lshift(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)(LuaInt(val) << LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_rol(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)((LuaInt(val) << LuaInt(amt))
|
|
|
|
|
| (LuaInt(val) >> (32 - LuaInt(amt))));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_ror(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)((LuaInt(val) >> LuaInt(amt))
|
|
|
|
|
| (LuaInt(val) << (32 - LuaInt(amt))));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_rshift(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-31 00:31:25 +00:00
|
|
|
|
return (uint)(LuaInt(val) >> LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|