示例#1
0
        public void create_decrement_instruction()
        {
            string       input          = "dec d";
            var          factory        = new InstructionFactory();
            IInstruction newInstruction = factory.Create(input);

            Assert.IsInstanceOf <DecrementInstruction>(newInstruction);
        }
示例#2
0
        private static ProjectInstructions CreateProjectInstructions()
        {
            var helper = new InstructionFactory(typeof(ProjectInstructions));

            var instruction = helper.Create();

            return((ProjectInstructions)instruction);
        }
        public static NestedInstruction Parse(WordReader reader, uint wordCount)
        {
            var readWord    = reader.ReadWord();
            var instruction = InstructionFactory.Create((Spv.Op)readWord);

            instruction.ParseOperands(reader, wordCount);
            return(new NestedInstruction(instruction));
        }
示例#4
0
        public void create_increment_instruction()
        {
            string       input          = "inc d";
            var          factory        = new InstructionFactory();
            IInstruction newInstruction = factory.Create(input);

            Assert.IsInstanceOf <IncrementInstruction>(newInstruction);
            Assert.AreEqual('d', ((IncrementInstruction)newInstruction).Register);
        }
示例#5
0
        public void create_jump_instruction_with_registry()
        {
            string       input          = "jnz x -50";
            var          factory        = new InstructionFactory();
            IInstruction newInstruction = factory.Create(input);

            Assert.IsInstanceOf <JumpInstruction>(newInstruction);
            Assert.AreEqual('x', ((JumpInstruction)newInstruction).Register);
            Assert.AreEqual(-50, ((JumpInstruction)newInstruction).JumpDistance);
        }
示例#6
0
        public void create_copy_value_to_register_instruction()
        {
            string       input          = "cpy 50 a";
            var          factory        = new InstructionFactory();
            IInstruction newInstruction = factory.Create(input);

            Assert.IsInstanceOf <CopyValueToRegisterInstruction>(newInstruction);
            Assert.AreEqual('a', ((CopyValueToRegisterInstruction)newInstruction).Register);
            Assert.AreEqual(50, ((CopyValueToRegisterInstruction)newInstruction).Value);
        }
示例#7
0
        public void create_copy_register_to_register_instruction()
        {
            string       input          = "cpy a b";
            var          factory        = new InstructionFactory();
            IInstruction newInstruction = factory.Create(input);

            Assert.IsInstanceOf <CopyRegisterToRegisterInstruction>(newInstruction);
            Assert.AreEqual('a', ((CopyRegisterToRegisterInstruction)newInstruction).Source);
            Assert.AreEqual('b', ((CopyRegisterToRegisterInstruction)newInstruction).Destination);
        }
示例#8
0
        public void create_jump_instruction_with_integer()
        {
            string       input          = "jnz 1 50";
            var          factory        = new InstructionFactory();
            IInstruction newInstruction = factory.Create(input);

            Assert.IsInstanceOf <JumpInstruction>(newInstruction);
            Assert.AreEqual(1, ((JumpInstruction)newInstruction).StaticValue);
            Assert.AreEqual(true, ((JumpInstruction)newInstruction).SkipRegister);
            Assert.AreEqual(50, ((JumpInstruction)newInstruction).JumpDistance);
        }
        private ScriptedInstructionViewModel CreateAction(InstructionItem instructionItem)
        {
            var helper = new InstructionFactory(instructionItem.Type);

            var instruction = helper.Create();

            var viewModel = new ScriptedInstructionViewModel(this)
            {
                ScriptedInstruction = instruction
            };

            return(viewModel);
        }