-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ChangingLanguageSet
- Loading branch information
Showing
27 changed files
with
621 additions
and
249 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
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
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
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
18 changes: 18 additions & 0 deletions
18
tools/dotnet-linker/Steps/ConfigurationAwareMarkHandler.cs
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,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Xamarin.Bundler; | ||
|
||
namespace Xamarin.Linker { | ||
public abstract class ConfigurationAwareMarkHandler : ExceptionalMarkHandler { | ||
protected override void Report (Exception exception) | ||
{ | ||
LinkerConfiguration.Report (context, exception); | ||
} | ||
|
||
protected void Report (List<Exception> exceptions) | ||
{ | ||
LinkerConfiguration.Report (context, exceptions); | ||
} | ||
} | ||
} |
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,11 @@ | ||
using Mono.Linker.Steps; | ||
|
||
namespace Xamarin.Linker.Steps { | ||
// MarkSubStepsDispatcher is abstract, so create a subclass we can instantiate. | ||
// Can be removed when we update to the preview4 linker, which makes MarkSubStepsDispatcher non-abstract. | ||
class DotNetMarkAssemblySubStepDispatcher : MarkSubStepsDispatcher { | ||
public DotNetMarkAssemblySubStepDispatcher (params BaseSubStep[] subSteps) : base (subSteps) | ||
{ | ||
} | ||
} | ||
} |
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,121 @@ | ||
// Copyright 2016 Xamarin Inc. | ||
|
||
using System; | ||
using Mono.Cecil; | ||
using Mono.Tuner; | ||
using Xamarin.Bundler; | ||
|
||
using Xamarin.Tuner; | ||
|
||
using Mono.Linker; | ||
using Mono.Linker.Steps; | ||
|
||
namespace Xamarin.Linker { | ||
|
||
// Similar to ExceptionalSubStep, but this only runs for marked members | ||
// that were registered for handling by the subclass. | ||
public abstract class ExceptionalMarkHandler : IMarkHandler | ||
{ | ||
public abstract void Initialize (LinkContext context, MarkContext markContext); | ||
|
||
public virtual void Initialize (LinkContext context) | ||
{ | ||
this.context = context; | ||
} | ||
|
||
protected DerivedLinkContext LinkContext => Configuration.DerivedLinkContext; | ||
|
||
protected LinkContext context { get; private set; } | ||
|
||
protected AnnotationStore Annotations => context.Annotations; | ||
protected LinkerConfiguration Configuration => LinkerConfiguration.GetInstance (context); | ||
|
||
protected Profile Profile => Configuration.Profile; | ||
|
||
public void ProcessAssembly (AssemblyDefinition assembly) | ||
{ | ||
try { | ||
Process (assembly); | ||
} catch (Exception e) { | ||
Report (Fail (assembly, e)); | ||
} | ||
} | ||
|
||
public void ProcessType (TypeDefinition type) | ||
{ | ||
try { | ||
Process (type); | ||
} catch (Exception e) { | ||
Report (Fail (type, e)); | ||
} | ||
} | ||
|
||
public void ProcessField (FieldDefinition field) | ||
{ | ||
try { | ||
Process (field); | ||
} catch (Exception e) { | ||
Report (Fail (field, e)); | ||
} | ||
} | ||
|
||
public void ProcessMethod (MethodDefinition method) | ||
{ | ||
try { | ||
Process (method); | ||
} catch (Exception e) { | ||
Report (Fail (method, e)); | ||
} | ||
} | ||
|
||
// state-aware versions to be subclassed | ||
|
||
protected virtual void Process (AssemblyDefinition assembly) | ||
{ | ||
} | ||
|
||
protected virtual void Process (TypeDefinition type) | ||
{ | ||
} | ||
|
||
protected virtual void Process (FieldDefinition field) | ||
{ | ||
} | ||
|
||
protected virtual void Process (MethodDefinition method) | ||
{ | ||
} | ||
|
||
// failure overrides, with defaults | ||
|
||
protected virtual Exception Fail (AssemblyDefinition assembly, Exception e) | ||
{ | ||
return ErrorHelper.CreateError (ErrorCode, e, Errors.MX_ExceptionalSubSteps, Name, assembly?.FullName); | ||
} | ||
|
||
protected virtual Exception Fail (TypeDefinition type, Exception e) | ||
{ | ||
return ErrorHelper.CreateError (ErrorCode | 1, e, Errors.MX_ExceptionalSubSteps, Name, type?.FullName); | ||
} | ||
|
||
protected virtual Exception Fail (FieldDefinition field, Exception e) | ||
{ | ||
return ErrorHelper.CreateError (ErrorCode | 2, e, Errors.MX_ExceptionalSubSteps, Name, field?.FullName); | ||
} | ||
|
||
protected virtual Exception Fail (MethodDefinition method, Exception e) | ||
{ | ||
return ErrorHelper.CreateError (ErrorCode | 3, e, Errors.MX_ExceptionalSubSteps, Name, method?.FullName); | ||
} | ||
protected virtual void Report (Exception e) | ||
{ | ||
throw e; | ||
} | ||
|
||
// abstracts | ||
|
||
protected abstract string Name { get; } | ||
|
||
protected abstract int ErrorCode { get; } | ||
} | ||
} |
Oops, something went wrong.