Exemple #1
0
        public static void Test3_preCH_delta()
        {
            // basic
            var C1 = new TypedSingleCH <sC1>();
            var C2 = new TypedSingleCH <sC2>();
            var C3 = new TypedSingleCH <sC3>();

            var clSC = new CH_closedScope()
                       .decl("c1", C1)
                       .decl("c2", C2)
                       .decl("c3", C3);

            var D1 = new TypedSingleCH <sD1>();
            var D2 = new TypedSingleCH <sD2>();
            var D3 = new TypedSingleCH <sD3>();

            var pD1 = new adapter_preCH(D1);
            var pD2 = new adapter_preCH(D2);
            var pD3 = new adapter_preCH(D3);

            var pdeltaSC = new preCH_deltaScope(clSC)
                           .decl("c1", pD1)
                           .decl("delta_2", pD2);

            AssertEquivalent(pdeltaSC.instantiate().close(),
                             new []        { "delta_2", "c1", "c3", "c2" },
                             new TypedCH[] { D2, D1, C3, C2 });

            // todo : MOAR!
            Console.WriteLine("================= preDeltaScoping ok ============= ");
        }
Exemple #2
0
        public OP_BinaryFilter_SingleC(TypedCH <A> CH_in, TypedCH <B> CH_arg, TypedSingleCH <A> CH_res, Func <A, B, bool> FilterF, bool use_repeater)
        {
            this.CH_in = CH_in; this.CH_arg = CH_arg; this.CH_res = CH_res;

            this.FilterF      = FilterF;
            this.use_repeater = use_repeater;
        }
Exemple #3
0
 public ColumnSingle <T> get <T> (TypedSingleCH <T> CH)
 {
     if (!D.ContainsKey(CH))
     {
         D[CH] = CH.SpawnColumn();
     }
     return((ColumnSingle <T>)D[CH]);
 }
Exemple #4
0
        public OP_BarrierShift(
            TypedCH <PayOrig> origCH,
            TypedSingleCH <PayLHS> lhsCH,
            TypedSingleCH <PayOrig> CH_out)
        {
            this.origCH = origCH; this.lhsCH = lhsCH; this.CH_out = CH_out;
            // starting from lhs count backwards the VBox-edges
            backsteps = 0;
            TypedCH currentCH = lhsCH;

            // TODO , throw when not ColumnSingle

            while (currentCH != origCH)
            {
                currentCH = currentCH.pred_SrcVBXTU.CH_in; backsteps++;
            }                                                                                           // if dataSrc is null, that's a bug in translate
        }
Exemple #5
0
        public static void Test4_deltasWithFunkyAdapters()
        {
            var D1 = new TypedSingleCH <sD1>();
            var D2 = new TypedSingleCH <sD2>();
            var D3 = new TypedSingleCH <sD3>();

            var CHdelta = new CH_deltaScope(new CH_closedScope())
                          .decl("D1", D1)
                          .decl("D2", D2)
            ;
            var LLchain = checkClosureTripwires(CHdelta);

            LLchain.LIFO() /*.NLSendRec("foo",1, obj => (obj as LL<preCH>).pay.CH )*/;

            D.Assert(LLchain.LIFO().Select(node => node.pay.CH).SequenceEqual(new TypedCH[] { D2, D1 }));
            Console.WriteLine("================= funky adapters ok ============= ");
        }
Exemple #6
0
        /*
         *  Since Frames and Fans are expected to "spread" nodes that would natrually have multi-VBoxes (ref types for example)
         *  into VBoxSingles TypedSingleCH can be assumed for all data gathering Columns
         */
        public OP_TupleExtract(SingleCH []                  data_CHs
                               , TypedCH lhs_CH                           // typing problem in case of 0 FrameElements [1]
                               , TypedSingleCH <arg_tuple> out_CH
                               )
        {
            this.data_CHs = data_CHs;
            this.lhs_CH   = lhs_CH;
            this.out_CH   = out_CH;
            steps2CH      = new int[data_CHs.Length];

            TypedCH current_CH = lhs_CH;

            for (int i = data_CHs.Length - 1; i >= 0; i--)
            {
                int step_sz = 0;
                while (current_CH != data_CHs[i])
                {
                    current_CH = current_CH.pred_SrcVBXTU.CH_in;
                    step_sz++;
                }
                steps2CH[i] = step_sz;
            }
        }
Exemple #7
0
 public OP_SuiGen(TypedSingleCH <T> CH_out, Func <Context, IEnumerable <T> > generator)
 {
     this.CH_out         = CH_out;
     this.generator_func = generator;
 }
Exemple #8
0
 public OP_lift_up(TypedCH <CollectionT> CH_in, TypedSingleCH <ElementT> CH_out)
 {
     this.CH_in  = CH_in;
     this.CH_out = CH_out;
 }
Exemple #9
0
 public OP_Funcall(TypedSingleCH <arg_tuple> args_CH, TypedSingleCH <OutT> out_CH, MethodInfo MI)
 {
     this.args_CH = args_CH;
     this.out_CH  = out_CH;
     this.MI      = MI;
 }
Exemple #10
0
 public OP_ComponentFilterComp(TypedCH <T_comp_in> CH_in, TypedSingleCH <T_comp_out> CH_out)
 {
     this.CH_in  = CH_in;
     this.CH_out = CH_out;
 }
Exemple #11
0
 public OP_const(TypedSingleCH <DeserializedPay> CH_out, DeserializedPay payload)
 {
     this.CH_out  = CH_out;
     this.payload = payload;
 }
Exemple #12
0
 public OP_MemA_PropSingle(TypedCH <Tobj> CH_in, TypedSingleCH <Tprop> CH_out, PropertyInfo pi)
 {
     this.CH_in = CH_in; this.CH_out = CH_out; this.pi = pi;
 }
Exemple #13
0
 public OP_MemA_FieldSingle(TypedCH <Tobj> CH_in, TypedSingleCH <Tfield> CH_out, FieldInfo fi)
 {
     this.CH_in = CH_in; this.CH_out = CH_out; this.fi = fi;
 }
Exemple #14
0
 public OP_UnaryFilter_SingleC(TypedCH <BoxT> CH_in, TypedSingleCH <BoxT> CH_out, Func <BoxT, bool> FilterF)
 {
     this.CH_in = CH_in; this.CH_out = CH_out; this.FilterF = FilterF;
 }
Exemple #15
0
 public OP_SG_immediate_Comp(TypedCH <in_CompType> CH_in, TypedSingleCH <GameObject> CH_out)
 {
     this.CH_in = CH_in; this.CH_out = CH_out;
 }
Exemple #16
0
 public OP_ComponentFilterGO(TypedCH <GameObject> CH_in, TypedSingleCH <T_component> CH_out)
 {
     this.CH_in  = CH_in;
     this.CH_out = CH_out;
 }
Exemple #17
0
 public OP_Const_Spread(TypedCH CH_in, TypedSingleCH <DeserializedPay> CH_out, DeserializedPay pay)
 {
     this.CH_in  = CH_in;
     this.CH_out = CH_out;
     this.pay    = pay;
 }
Exemple #18
0
 public OP_Dollar_Spread(TypedCH LHS_CH, TypedCH <T_variable> referenced_CH, TypedSingleCH <T_variable> CH_out)
 {
     this.LHS_CH        = LHS_CH;
     this.referenced_CH = referenced_CH;
     this.CH_out        = CH_out;
 }
Exemple #19
0
        public static void Test2_basic_scoping()
        {
            var closA = new TypedSingleCH <int>();
            var closB = new TypedMultiCH <string>();  // types and kinds don't matter

            var closedSC = new CH_closedScope()
                           .decl("cA", closA)
                           .decl("cB", closB);

            var D1 = new TypedSingleCH <int>();
            var D2 = new TypedMultiCH <string>();  // types and kinds don't matter

            TypedCH dummy1;
            TypedCH dummy2;

            var deltaCH = new CH_deltaScope(closedSC)
                          .decl("new name", D1)
                          .addRef("cA", out dummy1)
                          .addRef("new name", out dummy2);

            D.Assert(object.ReferenceEquals(dummy1, closA));
            D.Assert(object.ReferenceEquals(dummy2, D1));

            D.Assert(
                deltaCH.external_refs().Select(_ref => _ref.name).
                SequenceEqual(new [] { "cA" })                        // ref for "new name" is not external
                );

            // ----------------------------

            var deltaCH2 = new CH_deltaScope(closedSC)
                           .decl("cA", D1)
                           .decl("cA", D1)
                           .decl("cA", D1)
                           .decl("cB", D1) // shadow both, multiple "cA"s are compressed to one in LIFO_shadowed
                           .decl("cA", D2) // shadow cA again with a different target
                           .addRef("cA", out dummy1);

            var expected_names = new []        { "cA", "cB" };   // in reverse of insertion order
            var expected_chs   = new TypedCH[] { D2, D1 };       // for cA , cB resp.

            D.Assert(deltaCH2.refs().Select(r => r.name).SequenceEqual(expected_names));
            D.Assert(deltaCH2.refs().Select(r => r.CH).SequenceEqual(expected_chs));

            // -------------------------------------


            var closFunky = new TypedSingleCH <object>();


            var origSC = new CH_closedScope()
                         .decl("cA", closFunky) // never see this guy
                         .decl("cA", closA)
                         .decl("cB", closB);

            var     sh1       = new TypedMultiCH <float>();
            TypedCH sh_dummy1 = null;
            TypedCH sh_dummy2 = null;

            var shadowDelta1 = new CH_deltaScope(origSC)
                               .decl("sh1", sh1)
                               .addRef("cA", out sh_dummy1) // external ref
                               .decl("cA", sh1)
                               .addRef("cA", out sh_dummy2) // now cA is both an external and internal ref
            ;

            // cB is not touched , thus :
            // refs in order : [  "cA" -> sh_dummy2 == sh1 | "sh1" -> sh1 | "cB" -> closB ]
            //                 ["cA" -> closA == sh_dummy1] is preserved in external_refs

            D.Assert(ReferenceEquals(sh_dummy1, closA));
            D.Assert(ReferenceEquals(sh_dummy2, sh1));

            expected_names = new []        { "cA", "sh1", "cB" };
            expected_chs   = new TypedCH[] { sh1, sh1, closB };

            D.Assert(shadowDelta1.refs().Select(r => r.name).SequenceEqual(expected_names));
            D.Assert(shadowDelta1.refs().Select(r => r.CH).SequenceEqual(expected_chs));

            D.Assert(shadowDelta1.external_refs().Select(r => r.name).SequenceEqual(new        [] { "cA" }));
            D.Assert(shadowDelta1.external_refs().Select(r => r.CH).SequenceEqual(new TypedCH[] { closA }));

            // heheh :) two chaining deltaScopes need no extra testing   new DeltaScope ( fromDeltaScope ) is identical to its original in all fields - there is no point to this

            Console.WriteLine("================= basicScoping ok ============= ");
        }