예제 #1
0
파일: Scopes.cs 프로젝트: elkawee/UShell
        public static void Test1_basic_LL_tests()
        {
            LL <int> empty_int = null;

            foreach (var node in empty_int.chain("foo", 3).chain("bar", 4).LIFO())
            {
                Console.WriteLine(node.name + " " + node.pay);                                                                                 // mainly to test chaining from null
            }
            // hmm thats neat :)
            // also single assignment. empty int is still null

            D.Assert(empty_int.LIFO().ToArray().SequenceEqual(new LL <int> [0]));
            D.Assert(empty_int.LIFO_shadowed().ToArray().SequenceEqual(new LL <int> [0]));
            AUX.AssertThrows <LL_Exception> (() => empty_int.findPay("any key -- the LL is empty "));

            var zing = ((LL <string>)null).
                       chain("v1", "val1").
                       chain("v2", "boioioioioiing").
                       chain("v1", "shadowed");

            foreach (var node in zing.LIFO_shadowed())
            {
                Console.WriteLine(node.name + " " + node.pay);
            }

            AUX.AssertThrows <LL_Exception> (() => zing.findNode("non present key"));

            Console.WriteLine("================= LL ok ============= ");
        }
예제 #2
0
파일: Scopes.cs 프로젝트: elkawee/UShell
 /*
  * clones the entire chain
  */
 public CH_closedScope(IEnumerable <Ref> items)
 {
     foreach (var itm in items)
     {
         LL_head = LL_head.chain(itm.name, itm.CH);
     }
 }
예제 #3
0
파일: Scopes.cs 프로젝트: elkawee/UShell
 public preCH_deltaScope(CH_closedScope clSC)
 {
     D.Assert(clSC != null);
     origScope = clSC;
     foreach (var nodeCH in clSC.LL_head.LIFO_shadowed().Reverse())
     {
         origLL_head = origLL_head.chain(nodeCH.name, new adapter_preCH(nodeCH.pay));
     }
 }
예제 #4
0
파일: Scopes.cs 프로젝트: elkawee/UShell
 public CH_deltaScope addRef(string name, out TypedCH CH)          // instead of resolve - but this one has "side effects" i.e. it returns an updated variant
 {
     try { CH = ownLL_head.findNode(name).pay; return(this); }
     catch (LL_Exception) { }
     try {
         CH = orig_scope.LL_head.findNode(name).pay;
         return(new CH_deltaScope(orig_scope, ownLL_head, externals.chain(name, CH)));
     } catch (LL_Exception) { }
     throw new ScopeException();
 }
예제 #5
0
파일: Scopes.cs 프로젝트: elkawee/UShell
 public preCH_deltaScope addRef(string name, out preCH pCH_out)        // this needs a more descriptive name
 {
     try {
         pCH_out = ownLL_head.findNode(name).pay;
         return(this);
     }  catch (LL_Exception) { }
     try {
         pCH_out = origLL_head.findNode(name).pay;
         return(new preCH_deltaScope(origScope, origLL_head, ownLL_head, externals.chain(name, pCH_out)));
     } catch (LL_Exception) { }
     throw new ScopeException();
 }
예제 #6
0
파일: Scopes.cs 프로젝트: elkawee/UShell
        public CH_deltaScope instantiate()             // resolves all preCHs , triggers their instantiation to proper CHs
        // using the decl interface is too headscratchy, becuase the original order between decls and refs (not within them) would have to be reconstructed ( self shadowing )
        {
            LL <TypedCH> CHdelt_own = null;

            foreach (var n in ownLL_head.LIFO().Reverse())
            {
                CHdelt_own = CHdelt_own.chain(n.name, n.pay.CH);
            }

            LL <TypedCH> CHdelt_externals = null;

            foreach (var n in externals.LIFO().Reverse())
            {
                CHdelt_externals = CHdelt_externals.chain(n.name, n.pay.CH);
            }
            return(new CH_deltaScope(origScope, CHdelt_own, CHdelt_externals));
        }
예제 #7
0
파일: Scopes.cs 프로젝트: elkawee/UShell
        } // the readonlys need a detour over constructor

        public preCH_deltaScope decl(string name, preCH pre_ch) => new preCH_deltaScope(
            origScope,
            origLL_head,
            ownLL_head.chain(name, pre_ch),
            externals);
예제 #8
0
파일: Scopes.cs 프로젝트: elkawee/UShell
 public CH_deltaScope decl(string name, TypedCH CH)
 {
     return(new CH_deltaScope(orig_scope, ownLL_head.chain(name, CH), externals));
 }