Skip to content

Instantly share code, notes, and snippets.

@lucasmeijer
Created May 25, 2014 08:16
Show Gist options
  • Save lucasmeijer/2afed0234aacbf391920 to your computer and use it in GitHub Desktop.
Save lucasmeijer/2afed0234aacbf391920 to your computer and use it in GitHub Desktop.
using ICSharpCode.Decompiler.Ast.Transforms;
using cil2as.Configuration;
using cil2as.Decompiler.Transforms;
using cil2as.Decompiler.Transforms.Generics;
namespace cil2as.Decompiler
{
class ActionScriptTransformationPipelineProvider : ITransformationPipelineProvider
{
private readonly ServiceProvider _serviceProvider;
public ActionScriptTransformationPipelineProvider(ServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
protected T Activate<T>()
{
return _serviceProvider.GetService<T>();
}
public virtual IAstTransform[] ActivateTransformationPipeline()
{
return new IAstTransform[]
{
Activate<EraseCompoundAssignmentOperators>(),
Activate<EraseIncAndDecOperatorsOnEnums>(),
Activate<AnnotatePrimitiveTypes>(),
Activate<AnnotateGenericParameterReferences>(),
Activate<NormalizeGenericInstanceTypeReferences>(),
Activate<AnnotateIndexerExpressionsWithTypeInformation>(),
Activate<IntroduceShortcutToDefaultConstructor>(),
Activate<EraseLambdaExpressions>(),
Activate<TypeAnonymousMethods>(),
Activate<ReplaceOperatorsByMethods>(),
Activate<ReplaceStringIndexer>(),
Activate<IntroduceMissingInterfaceImplementations>(),
Activate<ConvertPropertyAccessors>(),
Activate<EraseEvents>(),
Activate<UniquifyLocalVariables>(),
Activate<RenameReservedNames>(),
Activate<RawActionScriptRewriter>(),
Activate<AnnotateOriginalMethodReferences>(),
Activate<AnnotatePropertyDispatcherWithMethodSemantic>(),
Activate<MakePrivateMembersPublic>(),
Activate<FixOverrideModifiers>(),
Activate<PreserveByRefSemantics>(),
Activate<EraseNullableTypes>(),
Activate<EraseNestedTypes>(),
Activate<EraseNestedTypeReferences>(),
Activate<EraseNullCoalescingOperators>(),
Activate<EraseGenerics>(),
Activate<EraseStaticFieldsOfGenericTypeDefinitions>(),
Activate<ImplementExternMethods>(),
Activate<EraseEnums>(),
Activate<IntroduceDefaultEnumValueCheck>(),
Activate<EraseDecimalMethodInvocations>(),
Activate<ApplyMemberMappings>(),
Activate<IntroduceCastForArrayAssignment>(),
Activate<EraseAnonymousMethodStorey>(),
Activate<PreserveValueTypeSemantics>(),
Activate<ConvertStructs>(),
Activate<ImplementDeserializationSupport>(),
Activate<ImplementSequentialLayoutMarshalling>(),
Activate<ReplaceRethrowWithExplicitThrow>(),
Activate<EraseDelegates>(),
Activate<EraseConstructors>(),
Activate<EraseNestedTypeReferences>(),
Activate<IntroduceValueTypePools>(),
Activate<ReplaceValueTypeConstructorsWithPooledInstances>(),
Activate<EraseArrays>(),
Activate<ConvertStaticClasses>(),
Activate<IntroduceCLIObjectBaseType>(),
Activate<EraseGotos>(),
Activate<EraseTypeOfExpressions>(),
Activate<RecoverOperatorMethods>(),
// any transformations that introduce new AstType nodes in the
// tree (not clones of existing ones) must execute before ApplyTypeMapping
Activate<ApplyTypeMappings>(),
Activate<PushNegation>(),
Activate<PreserveIntegerMathSemantics>(),
Activate<OptimizeCasts>(),
Activate<EraseTypeAttributeSupport>(),
Activate<EraseASOperatorsCalls>(),
Activate<EraseAbstractMethods>(),
Activate<EraseDuplicatedVariables>(),
Activate<PreserveStaticConstructorSemantics>(),
Activate<EraseCheckedExpressions>(),
Activate<PreserveBitwiseOperatorSemantics>(),
Activate<IntroduceMethodsInvocationsForGenericStaticProperties>(),
Activate<MangleFieldNames>(),
Activate<MangleMethodNames>(),
Activate<FixIdentifiers>(),
Activate<IntroduceReflectionType>(),
Activate<EraseDelegateTypeReferences>(),
Activate<RemoveEnclosingTypeReferences>(),
Activate<OrganizeImports>(),
Activate<EnsureStackTracesForThrownExceptions>(),
Activate<DeferStaticFieldInitializers>(),
Activate<MoveFieldInitializersToActionScriptConstructor>(),
Activate<RemoveThisAndSuperReferencesFromAnonymousMethodsAndLambdas>()
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment