Пример #1
0
        public void SimpleTest()
        {
            var template  = new RegisterReadTemplate();
            var templates = new List <InstructionTemplate> {
                template
            };
            var root     = new RegisterRead(new VirtualRegister());
            var tree     = new Tree(root, new Ret());
            var selector = new InstructionSelector(templates);
            var ins      = selector.GetInstructions(tree);

            Assert.AreEqual(2, ins.Count());
        }
Пример #2
0
        public void NullTest()
        {
            InstructionTemplate nullTemplate = new NullTemplate();
            var template  = new RegisterReadTemplate();
            var templates = new List <InstructionTemplate> {
                template, nullTemplate
            };
            var root       = new RegisterRead(new VirtualRegister());
            var trueTarget =
                this.labelFactory.GetLabel(new Tree(new UnitImmediateValue(), new UnconditionalJump(null)));
            var controlFlow = new ConditionalJump(trueTarget, null);
            var tree        = new Tree(root, controlFlow);
            var selector    = new InstructionSelector(templates);
            var ins         = selector.GetInstructions(tree);

            Assert.AreEqual(2, ins.Count());
        }