Permalink
Browse files

Simplified the getting of base methods from only the primary bases.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jul 27, 2017
1 parent 0c22c4d commit e0367c56019393091f8f4de624e2328482ab5b8d
Showing with 7 additions and 19 deletions.
  1. +5 −17 src/AST/ClassExtensions.cs
  2. +1 −1 src/AST/FunctionExtensions.cs
  3. +1 −1 src/Generator/Passes/MultipleInheritancePass.cs
@@ -41,33 +41,21 @@ public static Class GetNonIgnoredRootBase(this Class @class)
}
}
public static Method GetBaseMethod(this Class @class, Method @override,
bool onlyPrimaryBase = false, bool getTopmost = false)
public static Method GetBaseMethod(this Class @class, Method @override)
{
foreach (var @base in @class.Bases.Where(
b => b.IsClass && b.Class.OriginalClass != @class && (!onlyPrimaryBase || !b.Class.IsInterface)))
b => b.IsClass && b.Class.OriginalClass != @class && !b.Class.IsInterface))
{
var baseClass = @base.Class.OriginalClass ?? @base.Class;
Method baseMethod;
if (!getTopmost)
{
baseMethod = baseClass.GetBaseMethod(@override, onlyPrimaryBase);
if (baseMethod != null)
return baseMethod;
}
Method baseMethod = baseClass.GetBaseMethod(@override);
if (baseMethod != null)
return baseMethod;
baseMethod = (from method in baseClass.Methods
where @override.CanOverride(method)
select method).FirstOrDefault();
if (baseMethod != null)
return baseMethod;
if (getTopmost)
{
baseMethod = (baseClass.GetBaseMethod(@override, onlyPrimaryBase, true));
if (baseMethod != null)
return baseMethod;
}
}
return null;
}
@@ -81,7 +81,7 @@ public static bool IsGeneratedOverride(this Method method)
var @class = method.Namespace as Class;
Method rootBaseMethod;
return method.IsOverride &&
(rootBaseMethod = @class.GetBaseMethod(method, true)) != null &&
(rootBaseMethod = @class.GetBaseMethod(method)) != null &&
rootBaseMethod.IsGenerated && rootBaseMethod.IsVirtual;
}
@@ -181,7 +181,7 @@ private void ImplementInterfaceMethods(Class @class, Class @interface)
OriginalNamespace = @interface,
OriginalFunction = method.OriginalFunction
};
var rootBaseMethod = @class.GetBaseMethod(method, true);
var rootBaseMethod = @class.GetBaseMethod(method);
if (rootBaseMethod != null && rootBaseMethod.IsDeclared)
impl.ExplicitInterfaceImpl = @interface;
@class.Methods.Add(impl);

0 comments on commit e0367c5

Please sign in to comment.