Fixes brace style (#248)

This commit is contained in:
Kamron Batman 2020-09-13 21:49:46 -07:00 • committed by GitHub
parent a236617ad9
commit 8149620b0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1503 changed files with 28575 additions and 1717 deletions

View file

@ -41,8 +41,12 @@ namespace Server.Commands.Generic
public bool IsValid(object obj)
{
for (var i = 0; i < Count; ++i)
{
if (!this[i].IsValid(obj))
{
return false;
}
}
return true;
}
@ -50,7 +54,9 @@ namespace Server.Commands.Generic
public void Filter(List<object> list)
{
for (var i = 0; i < Count; ++i)
{
this[i].Filter(list);
}
}
public static Extensions Parse(Mobile from, ref string[] args)
@ -64,17 +70,23 @@ namespace Server.Commands.Generic
for (var i = args.Length - 1; i >= 0; --i)
{
if (!ExtensionInfo.Table.TryGetValue(args[i], out var extInfo))
{
continue;
}
if (extInfo.IsFixedSize && i != size - extInfo.Size - 1)
{
throw new Exception("Invalid extended argument count.");
}
var ext = extInfo.Constructor();
ext.Parse(from, args, i + 1, size - i - 1);
if (ext is WhereExtension extension)
{
baseType = extension.Conditional.Type;
}
parsed.Add(ext);
@ -86,7 +98,9 @@ namespace Server.Commands.Generic
AssemblyEmitter emitter = null;
foreach (var update in parsed)
update.Optimize(from, baseType, ref emitter);
{
update.Optimize(@from, baseType, ref emitter);
}
if (size != args.Length)
{
@ -94,7 +108,9 @@ namespace Server.Commands.Generic
args = new string[size];
for (var i = 0; i < args.Length; ++i)
{
args[i] = old[i];
}
}
return parsed;

View file

@ -69,30 +69,50 @@ namespace Server.Commands.Generic
else
{
if (Value is int i)
{
method.Load(i);
}
else if (Value is long l)
{
method.Load(l);
}
else if (Value is float f)
{
method.Load(f);
}
else if (Value is double d)
{
method.Load(d);
}
else if (Value is char c)
{
method.Load(c);
}
else if (Value is bool b)
{
method.Load(b);
}
else if (Value is string s)
{
method.Load(s);
}
else if (Value is Enum e)
{
method.Load(e);
}
else
{
throw new InvalidOperationException("Unrecognized comparison value.");
}
}
}
public void Acquire(TypeBuilder typeBuilder, ILGenerator il, string fieldName)
{
if (!(Value is string toParse))
{
return;
}
if (!Type.IsValueType && toParse == "null")
{
@ -101,7 +121,9 @@ namespace Server.Commands.Generic
else if (Type == typeof(string))
{
if (toParse == @"@""null""")
{
toParse = "null";
}
Value = toParse;
}
@ -169,7 +191,9 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Ldstr, toParse);
if (parseArgs.Length == 2) // dirty evil hack :-(
{
il.Emit(OpCodes.Ldc_I4, (int)parseArgs[1]);
}
il.Emit(OpCodes.Call, parseMethod);
il.Emit(OpCodes.Stfld, Field);
@ -330,7 +354,9 @@ namespace Server.Commands.Generic
}
if (m_Not != inverse)
{
emitter.LogicalNot();
}
}
}
@ -437,7 +463,9 @@ namespace Server.Commands.Generic
}
if (m_Not != inverse)
{
emitter.LogicalNot();
}
}
}
@ -464,7 +492,9 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Call, typeof(object).GetConstructor(Type.EmptyTypes));
for (var i = 0; i < conditions.Length; ++i)
{
conditions[i].Construct(typeBuilder, il, i);
}
// return;
il.Emit(OpCodes.Ret);

View file

@ -94,7 +94,9 @@ namespace Server.Commands.Generic
);
if (!couldCompare)
{
throw new InvalidOperationException("Property is not comparable.");
}
emitter.StoreLocal(v);
}
@ -225,7 +227,9 @@ namespace Server.Commands.Generic
}
if (i > 0)
{
emitter.Xor();
}
}
emitter.Return();

View file

@ -39,7 +39,9 @@ namespace Server.Commands.Generic
m_Order = Math.Sign(value);
if (m_Order == 0)
{
throw new InvalidOperationException("Sign cannot be zero.");
}
}
}
}
@ -133,7 +135,9 @@ namespace Server.Commands.Generic
);
if (!couldCompare)
{
throw new InvalidOperationException("Property is not comparable.");
}
emitter.StoreLocal(v);
}

View file

@ -24,7 +24,9 @@ namespace Server.Commands.Generic
public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
{
if (baseType == null)
{
throw new Exception("Distinct extension may only be used in combination with an object conditional.");
}
foreach (var prop in m_Properties)
{
@ -40,7 +42,9 @@ namespace Server.Commands.Generic
public override void Parse(Mobile from, string[] arguments, int offset, int size)
{
if (size < 1)
{
throw new Exception("Invalid distinction syntax.");
}
var end = offset + size;
@ -55,7 +59,9 @@ namespace Server.Commands.Generic
public override void Filter(List<object> list)
{
if (m_Comparer == null)
{
throw new InvalidOperationException("The extension must first be optimized.");
}
var copy = new List<object>(list);

View file

@ -21,13 +21,17 @@ namespace Server.Commands.Generic
Limit = Utility.ToInt32(arguments[offset]);
if (Limit < 0)
{
throw new Exception("Limit cannot be less than zero.");
}
}
public override void Filter(List<object> list)
{
if (list.Count > Limit)
{
list.RemoveRange(Limit, list.Count - Limit);
}
}
}
}

View file

@ -23,7 +23,9 @@ namespace Server.Commands.Generic
public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
{
if (baseType == null)
{
throw new Exception("The ordering extension may only be used in combination with an object conditional.");
}
foreach (var order in m_Orders)
{
@ -39,7 +41,9 @@ namespace Server.Commands.Generic
public override void Parse(Mobile from, string[] arguments, int offset, int size)
{
if (size < 1)
{
throw new Exception("Invalid ordering syntax.");
}
if (Insensitive.Equals(arguments[offset], "by"))
{
@ -47,7 +51,9 @@ namespace Server.Commands.Generic
--size;
if (size < 1)
{
throw new Exception("Invalid ordering syntax.");
}
}
var end = offset + size;
@ -91,7 +97,9 @@ namespace Server.Commands.Generic
public override void Filter(List<object> list)
{
if (m_Comparer == null)
{
throw new InvalidOperationException("The extension must first be optimized.");
}
list.Sort(m_Comparer);
}

View file

@ -18,7 +18,9 @@ namespace Server.Commands.Generic
public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
{
if (baseType == null)
{
throw new InvalidOperationException("Insanity.");
}
Conditional.Compile(ref assembly);
}
@ -26,7 +28,9 @@ namespace Server.Commands.Generic
public override void Parse(Mobile from, string[] arguments, int offset, int size)
{
if (size < 1)
{
throw new Exception("Invalid condition syntax.");
}
Conditional = ObjectConditional.ParseDirect(from, arguments, offset, size);
}