public override Expression CloneExpressionOnly()
        {
            Expression clonnedValue = Value != null?Value.CloneExpressionOnly() : null;

            ReturnExpression result = new ReturnExpression(clonnedValue, null);

            return(result);
        }
 public override void VisitReturnExpression(ReturnExpression node)
 {
     Visit(node.Value);
     if(this.searchResult == UsageFinderSearchResult.NotFound)
     {
         this.searchResult = UsageFinderSearchResult.Used;
     }
 }
        public override Expression Clone()
        {
            Expression clonnedValue = Value != null?Value.Clone() : null;

            ReturnExpression result = new ReturnExpression(clonnedValue, instructions);

            return(result);
        }
        public override bool Equals(Expression other)
        {
            if (!(other is ReturnExpression))
            {
                return(false);
            }
            ReturnExpression returnExp = other as ReturnExpression;

            if (this.Value == null)
            {
                return(returnExp.Value == null);
            }
            return(this.Value.Equals(returnExp.Value));
        }
		public override void VisitReturnExpression(ReturnExpression node)
		{
			base.VisitReturnExpression(node);
			if (node.Value == null)
			{
				return;
			}
			if (node.Value.CodeNodeType == CodeNodeType.DelegateCreationExpression)
			{
				DelegateCreationExpression theDelegate = (DelegateCreationExpression)node.Value;
				TypeReference returnType = context.MethodContext.Method.ReturnType;
				if (CanInferTypeOfDelegateCreation(returnType))
				{
					theDelegate.TypeIsImplicitlyInferable = true;
				}
			}
		}
		public override void VisitReturnExpression(ReturnExpression node)
		{
			base.VisitReturnExpression(node);

			if (decompiledMethodReturnType != null && node.Value != null && node.Value.HasType && ShouldAddCastToAssignment(decompiledMethodReturnType, node.Value.ExpressionType))
			{
				Expression toCast = node.Value;

				if (node.Value is CastExpression)
				{
					CastExpression valueCast = node.Value as CastExpression;
					if (IsIntegerType(valueCast.TargetType))
					{
						toCast = valueCast.Expression;
					}
				} 

				node.Value = new CastExpression(toCast, decompiledMethodReturnType, null);
			}
		}
		public override void VisitReturnExpression(ReturnExpression node)
		{
			WriteKeyword(KeyWordWriter.Return);

			if (node.Value != null)
			{
				WriteSpace();
				Visit(node.Value);
			}
		}
		private void WriteSplitPropertyGetter(PropertyDefinition property)
		{
			WriteKeyword(KeyWordWriter.Get);
			WriteBeginBlock();
			WriteLine();
			Indent();
			MethodReferenceExpression jdGetterReference = new MethodReferenceExpression(null, property.GetMethod, null);
			MethodInvocationExpression jdMethodInvocation = new MethodInvocationExpression(jdGetterReference, null);
			jdMethodInvocation.Arguments = CopyMethodParametersAsArguments(property.GetMethod);
			ReturnExpression returnEx = new ReturnExpression(jdMethodInvocation, null);
			ExpressionStatement toWrite = new ExpressionStatement(returnEx);
			Write(toWrite);
			WriteLine();
			Outdent();
			WriteEndBlock("Get");
		}
		public override ICodeNode VisitReturnExpression(ReturnExpression node)
		{
			node = (ReturnExpression)base.VisitReturnExpression(node);

			TypeDefinition methodReturnType = context.MethodContext.Method.ReturnType.Resolve();
			if (methodReturnType == null)
			{
				return node;
			}
			if (node.Value == null)
			{
				// Covers methods returning void.
				return node;
			}
			if (methodReturnType.IsEnum && !context.MethodContext.Method.ReturnType.IsArray)
			{
				if (node.Value.ExpressionType == null || node.Value.ExpressionType.FullName != methodReturnType.FullName)
				{
					if (node.Value is LiteralExpression)
					{
						node.Value = EnumHelper.GetEnumExpression(methodReturnType, node.Value as LiteralExpression, typeSystem);
					}
					else if (node.Value is CastExpression && (node.Value as CastExpression).Expression is LiteralExpression)
					{
						node.Value = EnumHelper.GetEnumExpression(methodReturnType, (node.Value as CastExpression).Expression as LiteralExpression, typeSystem);
					}
                    else if (node.Value.HasType && NeedsCast(node.Value.ExpressionType, methodReturnType))
					{
						node.Value = new CastExpression(node.Value, methodReturnType, null);
					}
				}
			}

			return node;
		}
 public override void VisitReturnExpression(ReturnExpression node)
 {
     states.Push(Step.Return);
     base.VisitReturnExpression(node);
     states.Pop();
 }
        public override ICodeNode VisitReturnExpression(ReturnExpression node)
        {
            base.VisitReturnExpression(node);

            LiteralExpression literalValue = node.Value as LiteralExpression;
            if (literalValue != null)
            {
                if (isBoolReturnType)
                {
                    FixBooleanLiteral(literalValue);
                }
                else if (isCharReturnType)
                {
                    FixCharLiteral(literalValue);
                }
            }

			CastExpression castValue = node.Value as CastExpression;
			if (castValue != null)
			{
				if (castValue.ExpressionType.FullName != methodContext.Method.ReturnType.FullName)
				{
					if (isCharReturnType && castValue.ExpressionType.FullName == currentTypeSystem.UInt16.FullName)
					{
						castValue.TargetType = currentTypeSystem.Char;
					}
				}
			}

            return node;
        }
 public virtual void VisitReturnExpression(ReturnExpression node)
 {
     Visit(node.Value);
 }
 public override Expression CloneExpressionOnly()
 {
     Expression clonnedValue = Value != null ? Value.CloneExpressionOnly() : null;
     ReturnExpression result = new ReturnExpression(clonnedValue, null);
     return result;
 }
        public override Expression Clone()
        {
            Expression clonnedValue = Value != null ? Value.Clone() : null;
			ReturnExpression result = new ReturnExpression(clonnedValue, instructions);
			return result;
        }
		public override void VisitReturnExpression(ReturnExpression node)
		{
			/// Add cast when the returned value is of enum type, but the signature of the method declares integer type.
			base.VisitReturnExpression(node);

			if (node.Value != null && node.Value.HasType)
			{
				TypeDefinition returnedType = node.Value.ExpressionType.Resolve();
				if (ShouldAddCast(returnedType, decompiledMethodReturnType))
				{
					node.Value = new CastExpression(node.Value, decompiledMethodReturnType, null);
				}
			}
		}