MakeTemp() private method

Creates a temporary variable of the specified type.
private MakeTemp ( Type type ) : ParameterExpression
type System.Type The type for the temporary variable to create.
return ParameterExpression
            internal override Expression AsExpression(Expression target)
            {
                if (target.Type.IsValueType && MemberBinding.Member is Reflection.PropertyInfo)
                {
                    throw Error.CannotAutoInitializeValueTypeMemberThroughProperty(MemberBinding.Member);
                }
                RequireNotRefInstance(target);

                var member     = Expression.MakeMemberAccess(target, MemberBinding.Member);
                var memberTemp = StackSpiller.MakeTemp(member.Type);

                var block = new Expression[_bindings.Count + 2];

                block[0] = Expression.Assign(memberTemp, member);

                for (var i = 0; i < _bindings.Count; i++)
                {
                    var br = _bindingRewriters[i];
                    block[i + 1] = br.AsExpression(memberTemp);
                }

                // We need to copy back value types
                if (memberTemp.Type.IsValueType)
                {
                    block[_bindings.Count + 1] = Expression.Block(
                        typeof(void),
                        Expression.Assign(Expression.MakeMemberAccess(target, MemberBinding.Member), memberTemp)
                        );
                }
                else
                {
                    block[_bindings.Count + 1] = Expression.Empty();
                }
                return(MakeBlock(block));
            }
            internal override Expression AsExpression(Expression target)
            {
                RequireNotRefInstance(target);

                var member     = Expression.MakeMemberAccess(target, MemberBinding.Member);
                var memberTemp = StackSpiller.MakeTemp(member.Type);

                return(MakeBlock(
                           Expression.Assign(memberTemp, _rhs),
                           Expression.Assign(member, memberTemp),
                           Expression.Empty()
                           ));
            }
            private Expression SpillByRef(List <Expression> comma, Expression expression)
            {
                List <Expression> writebacks = null;

                RewriteByRefArgument(null, ref expression, (type, name) => _self.MakeTemp(type), comma, ref writebacks);

                if (writebacks != null)
                {
                    // TODO: Make a call on supporting writebacks or not and either remove them altogether
                    //       or provide a good error message here.
                    throw new NotSupportedException();
                }

                return(expression);
            }
            internal override Expression AsExpression(Expression target)
            {
                if (target.Type.IsValueType && MemberBinding.Member is Reflection.PropertyInfo)
                {
                    throw Error.CannotAutoInitializeValueTypeElementThroughProperty(MemberBinding.Member);
                }
                RequireNotRefInstance(target);

                var member     = Expression.MakeMemberAccess(target, MemberBinding.Member);
                var memberTemp = StackSpiller.MakeTemp(member.Type);

                var block = new Expression[_inits.Count + 2];

                block[0] = Expression.Assign(memberTemp, member);

                for (var i = 0; i < _inits.Count; i++)
                {
                    var cr  = _childRewriters[i];
                    var add = cr.Finish(Expression.Call(memberTemp, _inits[i].AddMethod, cr[0, -1]));
                    block[i + 1] = add.Node;
                }

                // We need to copy back value types
                if (memberTemp.Type.IsValueType)
                {
                    block[_inits.Count + 1] = Expression.Block(
                        typeof(void),
                        Expression.Assign(Expression.MakeMemberAccess(target, MemberBinding.Member), memberTemp)
                        );
                }
                else
                {
                    block[_inits.Count + 1] = Expression.Empty();
                }
                return(MakeBlock(block));
            }