IronPython.Compiler.Ast.DictionaryExpression.ReduceDictionaryWithItems C# (CSharp) Method

ReduceDictionaryWithItems() private method

private ReduceDictionaryWithItems ( ) : Expression
return System.Linq.Expressions.Expression
        private MSAst.Expression ReduceDictionaryWithItems() {
            MSAst.Expression[] parts = new MSAst.Expression[_items.Length * 2];
            Type t = null;
            bool heterogeneous = false;
            for (int index = 0; index < _items.Length; index++) {
                SliceExpression slice = _items[index];
                // Eval order should be:
                //   { 2 : 1, 4 : 3, 6 :5 }
                // This is backwards from parameter list eval, so create temporaries to swap ordering.


                parts[index * 2] = TransformOrConstantNull(slice.SliceStop, typeof(object));
                MSAst.Expression key = parts[index * 2 + 1] = TransformOrConstantNull(slice.SliceStart, typeof(object));

                Type newType;
                if (key.NodeType == MSAst.ExpressionType.Convert) {
                    newType = ((MSAst.UnaryExpression)key).Operand.Type;
                } else {
                    newType = key.Type;
                }

                if (t == null) {
                    t = newType;
                } else if (newType == typeof(object)) {
                    heterogeneous = true;
                } else if (newType != t) {
                    heterogeneous = true;
                }
            }

            return Ast.Call(
                heterogeneous ? AstMethods.MakeDictFromItems : AstMethods.MakeHomogeneousDictFromItems,
                Ast.NewArrayInit(
                    typeof(object),
                    parts
                )
            );
        }