Skip to content

Commit

Permalink
Add IncompleteMethods back in.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Oct 9, 2024
1 parent 4f9e569 commit d4eab6a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -311,6 +312,66 @@ public void SetCustomAttribute(ICustomAttributeBuilder customBuilder)

#endregion

/// <inheritdoc />
public override IMethodSymbol? GetMethod(string name)
{
if (IsComplete)
return base.GetMethod(name);
else
return GetIncompleteMethods().FirstOrDefault(i => i.Name == name);
}

/// <inheritdoc />
public override IMethodSymbol? GetMethod(string name, BindingFlags bindingAttr, ITypeSymbol[] types, ParameterModifier[]? modifiers)
{
if (IsComplete)
return base.GetMethod(name, bindingAttr, types, modifiers);
else
throw new NotImplementedException();
}

/// <inheritdoc />
public override IMethodSymbol? GetMethod(string name, BindingFlags bindingAttr, CallingConventions callConvention, ITypeSymbol[] types, ParameterModifier[]? modifiers)
{
if (IsComplete)
return base.GetMethod(name, bindingAttr, callConvention, types, modifiers);
else
throw new NotImplementedException();
}

/// <inheritdoc />
public override IMethodSymbol[] GetMethods()
{
if (IsComplete)
return base.GetMethods();
else
return GetIncompleteMethods();
}

/// <inheritdoc />
public override IMethodSymbol[] GetMethods(BindingFlags bindingAttr)
{
if (IsComplete)
return base.GetMethods(bindingAttr);
else
return GetIncompleteMethods(bindingAttr);
}

/// <summary>
/// Gets the set of incomplete methods.
/// </summary>
/// <returns></returns>
IMethodSymbol[] GetIncompleteMethods(BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)
{
if (_incompleteMethods == null)
return [];
else
return SymbolUtil.FilterMethods(this, _incompleteMethods, bindingAttr).Cast<IMethodSymbol>().ToArray();
}

/// <inheritdoc />
public override bool IsComplete => _type != null;

/// <inheritdoc />
public void Complete()
{
Expand Down
20 changes: 10 additions & 10 deletions src/IKVM.CoreLib/Symbols/Reflection/ReflectionTypeSymbolBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,49 +483,49 @@ public IMemberSymbol[] GetMembers()
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr)
public virtual IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr)
{
return ResolveMethodSymbol(UnderlyingType.GetMethod(name, (BindingFlags)bindingAttr));
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, ITypeSymbol[] types)
public virtual IMethodSymbol? GetMethod(string name, ITypeSymbol[] types)
{
return ResolveMethodSymbol(UnderlyingType.GetMethod(name, types.Unpack()));
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, ITypeSymbol[] types)
public virtual IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, ITypeSymbol[] types)
{
return ResolveMethodSymbol(UnderlyingType.GetMethod(name, (BindingFlags)bindingAttr, null, types.Unpack(), null));
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name)
public virtual IMethodSymbol? GetMethod(string name)
{
return ResolveMethodSymbol(UnderlyingType.GetMethod(name));
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConvention, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
public virtual IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConvention, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
{
return ResolveMethodSymbol(UnderlyingType.GetMethod(name, (BindingFlags)bindingAttr, null, (CallingConventions)callConvention, types.Unpack(), modifiers?.Unpack()));
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConvention, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
public virtual IMethodSymbol? GetMethod(string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConvention, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
{
throw new NotImplementedException();
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
public virtual IMethodSymbol? GetMethod(string name, int genericParameterCount, System.Reflection.BindingFlags bindingAttr, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
{
throw new NotImplementedException();
}

/// <inheritdoc />
public IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
public virtual IMethodSymbol? GetMethod(string name, System.Reflection.BindingFlags bindingAttr, ITypeSymbol[] types, System.Reflection.ParameterModifier[]? modifiers)
{
return ResolveMethodSymbol(UnderlyingType.GetMethod(name, (BindingFlags)bindingAttr, null, types.Unpack(), modifiers?.Unpack()));
}
Expand All @@ -537,13 +537,13 @@ public IMemberSymbol[] GetMembers()
}

/// <inheritdoc />
public IMethodSymbol[] GetMethods(System.Reflection.BindingFlags bindingAttr)
public virtual IMethodSymbol[] GetMethods(System.Reflection.BindingFlags bindingAttr)
{
return ResolveMethodSymbols(UnderlyingType.GetMethods((BindingFlags)bindingAttr));
}

/// <inheritdoc />
public IMethodSymbol[] GetMethods()
public virtual IMethodSymbol[] GetMethods()
{
return ResolveMethodSymbols(UnderlyingType.GetMethods());
}
Expand Down

0 comments on commit d4eab6a

Please sign in to comment.