public static LuaConstant ReadConstant(KOARBinaryReader br) { int type = br.ReadInt(1); switch (type) { case 0: return(new LuaConstantNil()); case 1: return(new LuaConstantBool(br.ReadInt(1) == 1)); case 3: return(new LuaConstantNumber(br.ReadInt())); case 4: String s = br.ReadString(); return(new LuaConstantString(s.Substring(0, s.Length - 1))); case 11: return(new LuaConstantUI64(br.ReadUInt64())); default: throw new NotSupportedException(String.Format("constant type {0} is not supported", type)); } }