using System; using System.Collections.Generic; using System.Reflection.Emit; using System.Text; using Sunweaver.VM; namespace Sunweaver.Commands { [Attributes.BasePair("Swap the top two values of the boolean stack.")] public class swab : Abstracts.BinaryBooleanLogic { public override void Operation(bool a, bool b) { VM.BoolStack.Push(b); VM.BoolStack.Push(a); } public override void CompileOperation(ILGenerator il, Locals locals) { il.Emit(OpCodes.Ldloc, locals[typeof(VirtualMachine)]); il.Emit(OpCodes.Ldfld, typeof(VirtualMachine).GetField("BoolStack")); il.Emit(OpCodes.Ldloc, locals[typeof(bool), 1]); il.Emit(OpCodes.Call, typeof(BoolStack).GetMethod("Push")); il.Emit(OpCodes.Ldloc, locals[typeof(VirtualMachine)]); il.Emit(OpCodes.Ldfld, typeof(VirtualMachine).GetField("BoolStack")); il.Emit(OpCodes.Ldloc, locals[typeof(bool), 0]); il.Emit(OpCodes.Call, typeof(BoolStack).GetMethod("Push")); } } }