public void TraverseDownSeparateBranch()
        {
            InheritanceHierarchy ih = init();

            var res = ih.traverseDown("F");

            Assert.AreEqual(res, Set("F", "G"));
        }
        public void TraverseDownLeaf()
        {
            InheritanceHierarchy ih = init();

            var res = ih.traverseDown("G");

            Assert.AreEqual(res, Set("G"));
        }
        public void TraverseDownDiamondSide()
        {
            InheritanceHierarchy ih = init();

            var res = ih.traverseDown("B");

            Assert.AreEqual(res, Set("B", "D", "E"));
        }
Exemple #4
0
        // Given function scope and inheritance hierarchy, for every function f we can find all the functions from scope, that conform to f's signature
        // Since F: -I => +O
        // We are searching for all the functions, which Input argument types are either equal or parents to f's ones
        // ...and output types are equal or childrens to f's ones.

        public Option <Set <Function> > resolve(Function f)
        {
            var fScope    = scope.Filter(fn => fn.I.Count == f.I.Count && fn.O.Count == f.O.Count);
            var resFilter = f.I.Fold((fScope, 0),
                                     (st, it) => (st.fScope.Filter(fn => hier.traverseUp(it.name()).Contains(fn.I[st.Item2].name())),
                                                  st.Item2 + 1));

            fScope    = resFilter.fScope;
            resFilter = f.O.Fold((fScope, 0),
                                 (st, it) => (st.fScope.Filter(fn => hier.traverseDown(it.name()).Contains(fn.O[st.Item2].name())),
                                              st.Item2 + 1));
            fScope = resFilter.fScope;
            return(fScope.IsEmpty ? None : Some(new Set <Function>(fScope)));
        }