예제 #1
0
        /// <summary>
        /// Creates a local variable with specified name and type.
        /// TODO: simplify by pushing logic into callers
        /// </summary>
        public Expression Variable(Type type, string name)
        {
            if (_global)
            {
                // special treatment of lambdas marked as global
                return(Utils.GlobalVariable(type, name, true));
            }

            ParameterExpression result = Expression.Variable(type, name);

            _locals.Add(result);
            _visibleVars.Add(new KeyValuePair <ParameterExpression, bool>(result, false));
            return(result);
        }