Esempio n. 1
0
        public void TestNestedTupleSize()
        {
            int size = 8;

            Type[] args = new Type[size];
            for (int i = 0; i < size; i++)
            {
                if (i == 5)
                {
                    var nestedTupleType = MutableTuple.MakeTupleType(typeof(int), typeof(int));
                    args[i] = nestedTupleType;
                }
                else
                {
                    args[i] = typeof(int);
                }
            }

            var tupleType = MutableTuple.MakeTupleType(args);

            // these both fail - https://github.com/IronLanguages/dlr/issues/231
            //Assert.AreEqual(MutableTuple.GetSize(tupleType), size);
            //Assert.Throws<ArgumentException>(() => MutableTuple.GetAccessPath(tupleType, size).ToArray());
            Assert.AreEqual(MutableTuple.GetSize(tupleType), size + 1);
            Assert.Throws <InvalidOperationException>(() => MutableTuple.GetAccessPath(tupleType, size).ToArray());
        }
Esempio n. 2
0
 internal Type GetClosureTupleType() {
     if (TupleCells > 0) {
         Type[] args = new Type[TupleCells];
         for (int i = 0; i < TupleCells; i++) {
             args[i] = typeof(ClosureCell);
         }
         return MutableTuple.MakeTupleType(args);
     }
     return null;
 }
Esempio n. 3
0
 private Type /*!*/ MakeLocalsTupleType()
 {
     // Note: The actual tuple type might be a subclass of the type used here. Accesses to the additional fields would need to down-cast.
     // This will only happen if a hidden lifted variable is defined, which is needed only for flip-flop operator so far.
     Type[] types = new Type[LiftedVisibleVariableCount];
     for (int i = 0; i < types.Length; i++)
     {
         types[i] = typeof(object);
     }
     return(MutableTuple.MakeTupleType(types));
 }
Esempio n. 4
0
        private Tuple <Type, Dictionary <string, int> > FinishAnalysis(bool scriptCmdlet = false)
        {
            List <Block> list             = Block.GenerateReverseDepthFirstOrder(this._entryBlock);
            BitArray     assignedBitArray = new BitArray(this._variables.Count);

            list[0]._visitData = assignedBitArray;
            this.AnalyzeBlock(assignedBitArray, list[0]);
            for (int i = 1; i < list.Count; i++)
            {
                Block block = list[i];
                assignedBitArray = new BitArray(this._variables.Count);
                assignedBitArray.SetAll(true);
                block._visitData = assignedBitArray;
                int num2 = 0;
                foreach (Block block2 in block._predecessors)
                {
                    if (block2._visitData != null)
                    {
                        num2++;
                        assignedBitArray.And((BitArray)block2._visitData);
                    }
                }
                this.AnalyzeBlock(assignedBitArray, block);
            }
            var v = this._variables.Values.Where(x => x.LocalTupleIndex == -2).SelectMany(x => x.AssociatedAsts);

            foreach (Ast ast in v)
            {
                FixTupleIndex(ast, -2);
            }
            VariableAnalysisDetails[] detailsArray = (from details in this._variables.Values
                                                      where details.LocalTupleIndex >= 0
                                                      orderby details.LocalTupleIndex
                                                      select details).ToArray <VariableAnalysisDetails>();
            Dictionary <string, int> dictionary = new Dictionary <string, int>(0, StringComparer.OrdinalIgnoreCase);

            for (int j = 0; j < detailsArray.Length; j++)
            {
                VariableAnalysisDetails details = detailsArray[j];
                string name = details.Name;
                dictionary.Add(name, j);
                if (details.LocalTupleIndex != j)
                {
                    foreach (Ast ast2 in details.AssociatedAsts)
                    {
                        FixTupleIndex(ast2, j);
                    }
                }
            }
            return(Tuple.Create <Type, Dictionary <string, int> >(MutableTuple.MakeTupleType((from l in detailsArray select l.Type).ToArray <Type>()), dictionary));
        }