Permalink
Browse files

Based if a method is an override exclusively on if it has any overrid…

…den methods.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jul 27, 2017
1 parent 8cb7207 commit 845bf5b7f17c7a6c673b48963622cc704dd2bf2b
@@ -94,7 +94,6 @@ public Method(Method method)
Access = method.Access;
IsVirtual = method.IsVirtual;
IsConst = method.IsConst;
IsOverride = method.IsOverride;
IsFinal = method.IsFinal;
IsProxy = method.IsProxy;
IsStatic = method.IsStatic;
@@ -118,11 +117,7 @@ public Method(Function function)
public bool IsStatic { get; set; }
public bool IsConst { get; set; }
public bool IsExplicit { get; set; }
public bool IsOverride
{
get { return isOverride ?? OverriddenMethods.Any(); }
set { isOverride = value; }
}
public bool IsOverride => OverriddenMethods.Any();
// True if the method is final / sealed.
public bool IsFinal { get; set; }
@@ -174,7 +169,5 @@ public override T Visit<T>(IDeclVisitor<T> visitor)
{
return visitor.VisitMethodDecl(this);
}
private bool? isOverride;
}
}
@@ -57,17 +57,18 @@ private static Class AddInternalImplementation(Class @class)
var internalImpl = GetInternalImpl(@class);
var abstractMethods = GetRelevantAbstractMethods(@class);
internalImpl.Methods.AddRange(
from method in abstractMethods
select new Method(method)
{
Namespace = internalImpl,
OriginalFunction = method,
IsPure = false,
IsOverride = true,
SynthKind = FunctionSynthKind.AbstractImplCall
});
foreach (var abstractMethod in abstractMethods)
{
var impl = new Method(abstractMethod)
{
Namespace = internalImpl,
OriginalFunction = abstractMethod,
IsPure = false,
SynthKind = FunctionSynthKind.AbstractImplCall
};
impl.OverriddenMethods.Add(abstractMethod);
internalImpl.Methods.Add(impl);
}
internalImpl.Layout = @class.Layout;
@@ -127,10 +127,9 @@ public override bool VisitClassDecl(Class @class)
Namespace = @class,
ReturnType = new QualifiedType(stringType),
SynthKind = FunctionSynthKind.ComplementOperator,
IsOverride = true,
IsProxy = true
};
toStringMethod.OverriddenMethods.Add(new Method { Name = "Equals" });
@class.Methods.Add(toStringMethod);
Diagnostics.Debug("Function converted to ToString: {0}::{1}",
@@ -152,9 +151,9 @@ public override bool VisitClassDecl(Class @class)
ReturnType = new QualifiedType(new BuiltinType(PrimitiveType.Bool)),
Parameters = new List<Parameter> { methodEqualsParam },
SynthKind = FunctionSynthKind.ComplementOperator,
IsOverride = true,
IsProxy = true
};
methodEquals.OverriddenMethods.Add(new Method { Name = "Equals" });
@class.Methods.Add(methodEquals);
var methodHashCode = new Method
@@ -163,9 +162,9 @@ public override bool VisitClassDecl(Class @class)
Namespace = @class,
ReturnType = new QualifiedType(new BuiltinType(PrimitiveType.Int)),
SynthKind = FunctionSynthKind.ComplementOperator,
IsOverride = true,
IsProxy = true
};
methodHashCode.OverriddenMethods.Add(new Method { Name = "GetHashCode" });
@class.Methods.Add(methodHashCode);
return true;

0 comments on commit 845bf5b

Please sign in to comment.