private void InlineConstantVariables()
        {
            Dictionary <Expression, Expression> oldToNewValueMap = new Dictionary <Expression, Expression>();

            foreach (VariableDefinition varDef in variablesToInline)
            {
                StackVariableDefineUseInfo defineUseInfo = methodContext.StackData.VariableToDefineUseInfo[varDef];
                int        usageOffset = defineUseInfo.UsedAt.First();
                Expression containingExpression;
                if (!offsetToExpression.TryGetValue(usageOffset, out containingExpression))
                {
                    continue;
                }

                Expression value = offsetToExpression[defineUseInfo.DefinedAt.First()];
                if (!ConstantDeterminator.IsConstantExpression(value))
                {
                    continue;
                }

                ICodeNode result;
                if (inliner.TryInlineVariable(varDef, value, containingExpression, true, out result))
                {
                    inlinedOnSecondPass.Add(varDef);
                    FixContextAfterInlining(varDef);

                    if (containingExpression != result)
                    {
                        oldToNewValueMap.Add(containingExpression, (Expression)result);
                    }
                }
            }

            FixBlockExpressions(oldToNewValueMap);
        }
            public static bool IsConstantExpression(Expression expression)
            {
                ConstantDeterminator determinator = new ConstantDeterminator();

                determinator.isConstant = true;
                determinator.Visit(expression);
                return(determinator.isConstant);
            }