From c82c6f004821e4dddb96f7240a652abb521f998a Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 4 Feb 2017 14:32:48 +0200 Subject: [PATCH] Removed the method for constructing the type of a function as we now read it in the parser. --- src/AST/Function.cs | 53 +++++---------------------------------------- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/src/AST/Function.cs b/src/AST/Function.cs index b5ba1e35..3015df6c 100644 --- a/src/AST/Function.cs +++ b/src/AST/Function.cs @@ -51,7 +51,7 @@ namespace CppSharp.AST DefaultArgument = p.DefaultArgument; } - public Type Type { get { return QualifiedType.Type; } } + public Type Type => QualifiedType.Type; public QualifiedType QualifiedType { get; set; } public bool IsIndirect { get; set; } public uint Index { get; set; } @@ -62,14 +62,11 @@ namespace CppSharp.AST public Expression DefaultArgument { get; set; } - public bool IsIn { get { return Usage == ParameterUsage.In; } } - public bool IsOut { get { return Usage == ParameterUsage.Out; } } - public bool IsInOut { get { return Usage == ParameterUsage.InOut; } } + public bool IsIn => Usage == ParameterUsage.In; + public bool IsOut => Usage == ParameterUsage.Out; + public bool IsInOut => Usage == ParameterUsage.InOut; - public bool IsSynthetized - { - get { return Kind != ParameterKind.Regular; } - } + public bool IsSynthetized => Kind != ParameterKind.Regular; public override T Visit(IDeclVisitor visitor) { @@ -240,44 +237,6 @@ namespace CppSharp.AST } public Type Type => ReturnType.Type; - public QualifiedType QualifiedType { get { return ReturnType; } } - - public FunctionType GetFunctionType() - { - var functionType = new FunctionType - { - CallingConvention = this.CallingConvention, - ReturnType = this.ReturnType - }; - - functionType.Parameters.AddRange(Parameters); - ReplaceIndirectReturnParamWithRegular(functionType); - - return functionType; - } - - static void ReplaceIndirectReturnParamWithRegular(FunctionType functionType) - { - for (var i = functionType.Parameters.Count - 1; i >= 0; i--) - { - var parameter = functionType.Parameters[i]; - if (parameter.Kind != ParameterKind.IndirectReturnType) - continue; - - var ptrType = new PointerType - { - QualifiedPointee = new QualifiedType(parameter.Type) - }; - - var retParam = new Parameter - { - Name = parameter.Name, - QualifiedType = new QualifiedType(ptrType) - }; - - functionType.Parameters.RemoveAt(i); - functionType.Parameters.Insert(i, retParam); - } - } + public QualifiedType QualifiedType => ReturnType; } } \ No newline at end of file