Esempio n. 1
0
        public void GetTriadsFromPolis_ExpressionWithSeveralReturns_CorrectTriads()
        {
            var triadsConverter = new TriadsConverter();
            var program         = new TestProgramBuilder()
                                  .WithPolis(TestSourceKey.SeveralReturnsWithFirstWorking)
                                  .WithTriads(TestSourceKey.SeveralReturnsWithFirstWorking)
                                  .Build();

            var actual = triadsConverter.GetTriadsFromPolis(program.Polis, program.PolisConditionIndexes, null);

            Assert.AreEqual(program.Triads, actual);
            Assert.AreEqual(program.TriadsConditionIndexes, triadsConverter.TriadsConditionIndexes);
        }
Esempio n. 2
0
        public void GetTriadsFromPolis_ExpressionWithCycleWhileInCondition_CorrectTriads()
        {
            var triadsConverter = new TriadsConverter();
            var program         = new TestProgramBuilder()
                                  .WithPolis(TestSourceKey.CycleWhileInCondition)
                                  .WithTriads(TestSourceKey.CycleWhileInCondition)
                                  .Build();

            var actual = triadsConverter.GetTriadsFromPolis(program.Polis, program.PolisConditionIndexes, null);

            Assert.AreEqual(program.Triads, actual);
            Assert.AreEqual(program.TriadsConditionIndexes, triadsConverter.TriadsConditionIndexes);
        }
Esempio n. 3
0
        public void Compile(FunctionContext context, List <FunctionDescription> functionDescriptions)
        {
            var POLIS = SyntacticalAnalyzer.Convert(context.Tokens);

            DisplayManager.DisplayExpressionInPolishNotation(POLIS);
            var triads = TriadsConverter.GetTriadsFromPolis(POLIS, SyntacticalAnalyzer.PolisConditionsIndexes, functionDescriptions);

            DisplayManager.DisplayTriads(triads, "Triads");
            var optimizedTriads = TriadsOptimizer.Optimize(triads, TriadsConverter.TriadsConditionIndexes);

            DisplayManager.DisplayTriads(optimizedTriads, "Optimized triads");

            context.POLIS           = POLIS;
            context.Triads          = triads;
            context.OptimizedTriads = optimizedTriads;
        }