-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on adding support for generics (#124)
- Loading branch information
1 parent
6f5a569
commit ffc10a0
Showing
13 changed files
with
237 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace nanoFramework.Tools.MetadataProcessor.Core | ||
{ | ||
public class GenericParam | ||
{ | ||
public string Position; | ||
|
||
public string GenericParamToken; | ||
|
||
public string Name; | ||
|
||
public string Owner; | ||
|
||
public string Signature; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using Mono.Cecil; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace nanoFramework.Tools.MetadataProcessor | ||
{ | ||
/// <summary> | ||
/// Encapsulates logic for storing generic parameters list and writing | ||
/// this collected list into target assembly in .NET nanoFramework format. | ||
/// </summary> | ||
public sealed class nanoGenericParamTable : | ||
nanoReferenceTableBase<GenericParameter> | ||
{ | ||
/// <summary> | ||
/// Helper class for comparing two instances of <see cref="GenericParameter"/> objects | ||
/// using <see cref="MetadataToken"/> property as unique key for comparison. | ||
/// </summary> | ||
private sealed class MemberReferenceComparer : IEqualityComparer<GenericParameter> | ||
{ | ||
/// <inheritdoc/> | ||
public bool Equals(GenericParameter x, GenericParameter y) | ||
{ | ||
if (x is null) | ||
{ | ||
throw new ArgumentNullException(nameof(x)); | ||
} | ||
|
||
if (y is null) | ||
{ | ||
throw new ArgumentNullException(nameof(y)); | ||
} | ||
|
||
return x.MetadataToken.ToInt32() == y.MetadataToken.ToInt32(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public int GetHashCode(GenericParameter obj) | ||
{ | ||
return obj.MetadataToken.ToInt32().GetHashCode(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Creates new instance of <see cref="nanoGenericParamTable"/> object. | ||
/// </summary> | ||
/// <param name="items">List of member references in Mono.Cecil format.</param> | ||
/// <param name="context"> | ||
/// Assembly tables context - contains all tables used for building target assembly. | ||
/// </param> | ||
public nanoGenericParamTable( | ||
IEnumerable<GenericParameter> items, | ||
nanoTablesContext context) | ||
: base(items, new MemberReferenceComparer(), context) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets method reference ID if possible (if method is external and stored in this table). | ||
/// </summary> | ||
/// <param name="genericParameter">Method reference metadata in Mono.Cecil format.</param> | ||
/// <param name="referenceId">Method reference ID in .NET nanoFramework format.</param> | ||
/// <returns>Returns <c>true</c> if reference found, otherwise returns <c>false</c>.</returns> | ||
public bool TryGetParameterId( | ||
GenericParameter genericParameter, | ||
out ushort referenceId) | ||
{ | ||
return TryGetIdByValue(genericParameter, out referenceId); | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void WriteSingleItem( | ||
nanoBinaryWriter writer, | ||
GenericParameter item) | ||
{ | ||
if (!_context.MinimizeComplete) | ||
{ | ||
return; | ||
} | ||
|
||
// TODO | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.