Exemple #1
0
        private IModel BuildModel(string line)
        {
            var ast = TestExecutor.Parse(line);

            var cfg = new Yolol.Analysis.ControlFlowGraph.Builder(ast, 1).Build();

            cfg = cfg.StaticSingleAssignment(out var ssa);
            cfg = cfg.FlowTypingAssignment(ssa, out var types);
            cfg = cfg.TypeDrivenEdgeTrimming(types);
            cfg = cfg.MergeAdjacentBasicBlocks();
            cfg = cfg.VisitBlocks(t => new OpNumByConstNumCompressor(t), types);
            cfg = cfg.VisitBlocks(() => new ErrorCompressor());

            return(cfg.Vertices.First(x => x.LineNumber == 1 && x.Statements.Any()).BuildSAT(types));
        }
Exemple #2
0
        private static void Test([NotNull] IEnumerable <VariableName> bools, [NotNull] params string[] code)
        {
            var ast = TestExecutor.Parse(code);

            var cfg = new Yolol.Analysis.ControlFlowGraph.Builder(ast.StripTypes(), code.Length).Build();

            cfg = cfg.StaticSingleAssignment(out var ssa);
            cfg = cfg.FlowTypingAssignment(ssa, out var types);

            var variableNames = cfg.FindBooleanVariables(ssa, types).ToHashSet();

            var ok = variableNames.IsSupersetOf(bools);

            if (!ok)
            {
                Console.WriteLine("Not found: " + string.Join(",", bools.Where(b => !variableNames.Contains(b)).Select(a => a.ToString()).ToArray()));
                Assert.Fail();
            }
        }