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