summaryrefslogtreecommitdiff
path: root/BCT/BytecodeTranslator/TranslationPlugins
diff options
context:
space:
mode:
Diffstat (limited to 'BCT/BytecodeTranslator/TranslationPlugins')
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/BytecodeTranslator/BytecodeTranslatorPlugin.cs21
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/ContractAwareTranslator.cs15
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/ITranslationPlugin.cs4
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneFeedbackPlugin.cs15
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneInitializationPlugin.cs21
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/Translator.cs169
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/Translators/BaseTranslator.cs41
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneFeedbackTranslator.cs34
-rw-r--r--BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneInitializationTranslator.cs61
9 files changed, 374 insertions, 7 deletions
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/BytecodeTranslator/BytecodeTranslatorPlugin.cs b/BCT/BytecodeTranslator/TranslationPlugins/BytecodeTranslator/BytecodeTranslatorPlugin.cs
index 425a9476..a7b00f63 100644
--- a/BCT/BytecodeTranslator/TranslationPlugins/BytecodeTranslator/BytecodeTranslatorPlugin.cs
+++ b/BCT/BytecodeTranslator/TranslationPlugins/BytecodeTranslator/BytecodeTranslatorPlugin.cs
@@ -6,11 +6,22 @@ using Microsoft.Cci;
using Microsoft.Cci.Contracts;
namespace BytecodeTranslator.TranslationPlugins.BytecodeTranslator {
- class BytecodeTranslatorPlugin : ITranslationPlugin {
- public ITranslator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractProviders, IDictionary<IUnit, PdbReader> pdbReaders) {
- // TODO take whole program options into account here
- return new CLRSemantics().MakeMetadataTraverser(sink, contractProviders, pdbReaders);
- // return new WholeProgram().MakeMetadataTraverser(sink, contractProviders, pdbReaders);
+ internal class BytecodeTranslatorPlugin : ITranslationPlugin {
+ private bool isWholeProgram = false;
+
+ public BytecodeTranslatorPlugin(Boolean isWholeProgram) {
+ this.isWholeProgram = isWholeProgram;
+ }
+
+ public Translator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractProviders, IDictionary<IUnit, PdbReader> pdbReaders) {
+ TraverserFactory factory;
+ if (isWholeProgram)
+ factory= new WholeProgram();
+ else
+ factory= new CLRSemantics();
+ // Translator translator= factory.MakeMetadataTraverser(sink, contractProviders, pdbReaders);
+ Translator translator= factory.getTranslator(sink, contractProviders, pdbReaders);
+ return translator;
}
}
}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/ContractAwareTranslator.cs b/BCT/BytecodeTranslator/TranslationPlugins/ContractAwareTranslator.cs
new file mode 100644
index 00000000..ceb8ca0a
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/ContractAwareTranslator.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Bpl= Microsoft.Boogie;
+using Microsoft.Cci.Contracts;
+
+namespace BytecodeTranslator.TranslationPlugins {
+ public abstract class ContractAwareTranslator : Translator {
+ public virtual IEnumerable<Bpl.Requires> getPreconditionTranslation(IMethodContract contract) {return new List<Bpl.Requires>(); }
+ public virtual IEnumerable<Bpl.Ensures> getPostconditionTranslation(IMethodContract contract) { return new List<Bpl.Ensures>(); }
+ public virtual IEnumerable<Bpl.IdentifierExpr> getModifiedIdentifiers(IMethodContract contract) { return new List<Bpl.IdentifierExpr>(); }
+ }
+}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/ITranslationPlugin.cs b/BCT/BytecodeTranslator/TranslationPlugins/ITranslationPlugin.cs
index c6157e49..9cf895fd 100644
--- a/BCT/BytecodeTranslator/TranslationPlugins/ITranslationPlugin.cs
+++ b/BCT/BytecodeTranslator/TranslationPlugins/ITranslationPlugin.cs
@@ -6,7 +6,7 @@ using Microsoft.Cci;
using Microsoft.Cci.Contracts;
namespace BytecodeTranslator.TranslationPlugins {
- interface ITranslationPlugin {
- ITranslator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractExtractors=null, IDictionary<IUnit, PdbReader> pdbReaders=null);
+ public interface ITranslationPlugin {
+ Translator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractExtractors=null, IDictionary<IUnit, PdbReader> pdbReaders=null);
}
}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneFeedbackPlugin.cs b/BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneFeedbackPlugin.cs
new file mode 100644
index 00000000..c6d9b24a
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneFeedbackPlugin.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Cci;
+using Microsoft.Cci.Contracts;
+using BytecodeTranslator.TranslationPlugins.Translators;
+
+namespace BytecodeTranslator.TranslationPlugins.PhoneTranslator {
+ class PhoneFeedbackPlugin : ITranslationPlugin {
+ public Translator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractProviders, IDictionary<IUnit, PdbReader> pdbReaders) {
+ return new PhoneFeedbackTranslator(sink);
+ }
+ }
+}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneInitializationPlugin.cs b/BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneInitializationPlugin.cs
new file mode 100644
index 00000000..98282faa
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/PhoneTranslator/PhoneInitializationPlugin.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Cci;
+using Microsoft.Cci.Contracts;
+using BytecodeTranslator.TranslationPlugins.Translators;
+
+namespace BytecodeTranslator.TranslationPlugins.PhoneTranslator {
+ class PhoneInitializationPlugin : ITranslationPlugin {
+ public Translator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractProviders, IDictionary<IUnit, PdbReader> pdbReaders) {
+ return new PhoneInitializationTranslator(sink);
+ }
+ }
+
+ class PhoneNavigationPlugin : ITranslationPlugin {
+ public Translator getTranslator(Sink sink, IDictionary<IUnit, IContractProvider> contractProviders, IDictionary<IUnit, PdbReader> pdbReaders) {
+ return new PhoneNavigationTranslator(sink);
+ }
+ }
+}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/Translator.cs b/BCT/BytecodeTranslator/TranslationPlugins/Translator.cs
new file mode 100644
index 00000000..60d7e2f6
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/Translator.cs
@@ -0,0 +1,169 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Cci;
+
+namespace BytecodeTranslator.TranslationPlugins {
+ public abstract class Translator {
+ public abstract void initialize();
+ public abstract bool isOneShot();
+ public abstract int getPriority();
+
+ public virtual void TranslateAssemblies(IEnumerable<IUnit> assemblies) { }
+
+ // Each plugged translator may choose to implement some action on each metadata / AST element
+ public virtual void onMetadataElement(IArrayTypeReference arrayTypeReference) { }
+ public virtual void onMetadataElement(IAssembly assembly) { }
+ public virtual void onMetadataElement(IAssemblyReference assemblyReference) { }
+ public virtual void onMetadataElement(ICustomAttribute customAttribute) { }
+ public virtual void onMetadataElement(ICustomModifier customModifier) { }
+ public virtual void onMetadataElement(IEventDefinition eventDefinition) { }
+ public virtual void onMetadataElement(IFieldDefinition fieldDefinition) { }
+ public virtual void onMetadataElement(IFieldReference fieldReference) { }
+ public virtual void onMetadataElement(IFileReference fileReference) { }
+ public virtual void onMetadataElement(IFunctionPointerTypeReference functionPointerTypeReference) { }
+ public virtual void onMetadataElement(IGenericMethodInstanceReference genericMethodInstanceReference) { }
+ public virtual void onMetadataElement(IGenericMethodParameter genericMethodParameter) { }
+ public virtual void onMetadataElement(IGenericMethodParameterReference genericMethodParameterReference) { }
+ public virtual void onMetadataElement(IGlobalFieldDefinition globalFieldDefinition) { }
+ public virtual void onMetadataElement(IGlobalMethodDefinition globalMethodDefinition) { }
+ public virtual void onMetadataElement(IGenericTypeInstanceReference genericTypeInstanceReference) { }
+ public virtual void onMetadataElement(IGenericTypeParameter genericTypeParameter) { }
+ public virtual void onMetadataElement(IGenericTypeParameterReference genericTypeParameterReference) { }
+ public virtual void onMetadataElement(ILocalDefinition localDefinition) { }
+ public virtual void onMetadataElement(IManagedPointerTypeReference managedPointerTypeReference) { }
+ public virtual void onMetadataElement(IMarshallingInformation marshallingInformation) { }
+ public virtual void onMetadataElement(IMetadataConstant constant) { }
+ public virtual void onMetadataElement(IMetadataCreateArray createArray) { }
+ public virtual void onMetadataElement(IMetadataExpression expression) { }
+ public virtual void onMetadataElement(IMetadataNamedArgument namedArgument) { }
+ public virtual void onMetadataElement(IMetadataTypeOf typeOf) { }
+ public virtual void onMetadataElement(IMethodBody methodBody) { }
+ public virtual void onMetadataElement(IMethodDefinition method) { }
+ public virtual void onMetadataElement(IMethodImplementation methodImplementation) { }
+ public virtual void onMetadataElement(IMethodReference methodReference) { }
+ public virtual void onMetadataElement(IModifiedTypeReference modifiedTypeReference) { }
+ public virtual void onMetadataElement(IModule module) { }
+ public virtual void onMetadataElement(IModuleReference moduleReference) { }
+ public virtual void onMetadataElement(INamespaceAliasForType namespaceAliasForType) { }
+ public virtual void onMetadataElement(INamespaceTypeDefinition namespaceTypeDefinition) { }
+ public virtual void onMetadataElement(INamespaceTypeReference namespaceTypeReference) { }
+ public virtual void onMetadataElement(INestedAliasForType nestedAliasForType) { }
+ public virtual void onMetadataElement(INestedTypeDefinition nestedTypeDefinition) { }
+ public virtual void onMetadataElement(INestedTypeReference nestedTypeReference) { }
+ public virtual void onMetadataElement(INestedUnitNamespace nestedUnitNamespace) { }
+ public virtual void onMetadataElement(INestedUnitNamespaceReference nestedUnitNamespaceReference) { }
+ public virtual void onMetadataElement(INestedUnitSetNamespace nestedUnitSetNamespace) { }
+ public virtual void onMetadataElement(IOperation operation) { }
+ public virtual void onMetadataElement(IOperationExceptionInformation operationExceptionInformation) { }
+ public virtual void onMetadataElement(IParameterDefinition parameterDefinition) { }
+ public virtual void onMetadataElement(IParameterTypeInformation parameterTypeInformation) { }
+ public virtual void onMetadataElement(IPESection peSection) { }
+ public virtual void onMetadataElement(IPlatformInvokeInformation platformInvokeInformation) { }
+ public virtual void onMetadataElement(IPointerTypeReference pointerTypeReference) { }
+ public virtual void onMetadataElement(IPropertyDefinition propertyDefinition) { }
+ public virtual void onMetadataElement(IResourceReference resourceReference) { }
+ public virtual void onMetadataElement(IRootUnitNamespace rootUnitNamespace) { }
+ public virtual void onMetadataElement(IRootUnitNamespaceReference rootUnitNamespaceReference) { }
+ public virtual void onMetadataElement(IRootUnitSetNamespace rootUnitSetNamespace) { }
+ public virtual void onMetadataElement(ISecurityAttribute securityAttribute) { }
+ public virtual void onMetadataElement(ISpecializedEventDefinition specializedEventDefinition) { }
+ public virtual void onMetadataElement(ISpecializedFieldDefinition specializedFieldDefinition) { }
+ public virtual void onMetadataElement(ISpecializedFieldReference specializedFieldReference) { }
+ public virtual void onMetadataElement(ISpecializedMethodDefinition specializedMethodDefinition) { }
+ public virtual void onMetadataElement(ISpecializedMethodReference specializedMethodReference) { }
+ public virtual void onMetadataElement(ISpecializedPropertyDefinition specializedPropertyDefinition) { }
+ public virtual void onMetadataElement(ISpecializedNestedTypeDefinition specializedNestedTypeDefinition) { }
+ public virtual void onMetadataElement(ISpecializedNestedTypeReference specializedNestedTypeReference) { }
+ public virtual void onMetadataElement(IUnitSet unitSet) { }
+ public virtual void onMetadataElement(IWin32Resource win32Resource) { }
+
+ public virtual void onASTElement(IAddition addition) { }
+ public virtual void onASTElement(IAddressableExpression addressableExpression) { }
+ public virtual void onASTElement(IAddressDereference addressDereference) { }
+ public virtual void onASTElement(IAddressOf addressOf) { }
+ public virtual void onASTElement(IAnonymousDelegate anonymousDelegate) { }
+ public virtual void onASTElement(IArrayIndexer arrayIndexer) { }
+ public virtual void onASTElement(IAssertStatement assertStatement) { }
+ public virtual void onASTElement(IAssignment assignment) { }
+ public virtual void onASTElement(IAssumeStatement assumeStatement) { }
+ public virtual void onASTElement(IBitwiseAnd bitwiseAnd) { }
+ public virtual void onASTElement(IBitwiseOr bitwiseOr) { }
+ public virtual void onASTElement(IBlockExpression blockExpression) { }
+ public virtual void onASTElement(IBlockStatement block) { }
+ public virtual void onASTElement(IBreakStatement breakStatement) { }
+ public virtual void onASTElement(IBoundExpression boundExpression) { }
+ public virtual void onASTElement(ICastIfPossible castIfPossible) { }
+ public virtual void onASTElement(ICatchClause catchClause) { }
+ public virtual void onASTElement(ICheckIfInstance checkIfInstance) { }
+ public virtual void onASTElement(ICompileTimeConstant constant) { }
+ public virtual void onASTElement(IConversion conversion) { }
+ public virtual void onASTElement(IConditional conditional) { }
+ public virtual void onASTElement(IConditionalStatement conditionalStatement) { }
+ public virtual void onASTElement(IContinueStatement continueStatement) { }
+ public virtual void onASTElement(ICreateArray createArray) { }
+ public virtual void onASTElement(ICreateDelegateInstance createDelegateInstance) { }
+ public virtual void onASTElement(ICreateObjectInstance createObjectInstance) { }
+ public virtual void onASTElement(IDebuggerBreakStatement debuggerBreakStatement) { }
+ public virtual void onASTElement(IDefaultValue defaultValue) { }
+ public virtual void onASTElement(IDivision division) { }
+ public virtual void onASTElement(IDoUntilStatement doUntilStatement) { }
+ public virtual void onASTElement(IDupValue dupValue) { }
+ public virtual void onASTElement(IEmptyStatement emptyStatement) { }
+ public virtual void onASTElement(IEquality equality) { }
+ public virtual void onASTElement(IExclusiveOr exclusiveOr) { }
+ public virtual void onASTElement(IExpressionStatement expressionStatement) { }
+ public virtual void onASTElement(IForEachStatement forEachStatement) { }
+ public virtual void onASTElement(IForStatement forStatement) { }
+ public virtual void onASTElement(IGotoStatement gotoStatement) { }
+ public virtual void onASTElement(IGotoSwitchCaseStatement gotoSwitchCaseStatement) { }
+ public virtual void onASTElement(IGetTypeOfTypedReference getTypeOfTypedReference) { }
+ public virtual void onASTElement(IGetValueOfTypedReference getValueOfTypedReference) { }
+ public virtual void onASTElement(IGreaterThan greaterThan) { }
+ public virtual void onASTElement(IGreaterThanOrEqual greaterThanOrEqual) { }
+ public virtual void onASTElement(ILabeledStatement labeledStatement) { }
+ public virtual void onASTElement(ILeftShift leftShift) { }
+ public virtual void onASTElement(ILessThan lessThan) { }
+ public virtual void onASTElement(ILessThanOrEqual lessThanOrEqual) { }
+ public virtual void onASTElement(ILocalDeclarationStatement localDeclarationStatement) { }
+ public virtual void onASTElement(ILockStatement lockStatement) { }
+ public virtual void onASTElement(ILogicalNot logicalNot) { }
+ public virtual void onASTElement(IMakeTypedReference makeTypedReference) { }
+ public virtual void onASTElement(IMethodCall methodCall) { }
+ public virtual void onASTElement(IModulus modulus) { }
+ public virtual void onASTElement(IMultiplication multiplication) { }
+ public virtual void onASTElement(INamedArgument namedArgument) { }
+ public virtual void onASTElement(INotEquality notEquality) { }
+ public virtual void onASTElement(IOldValue oldValue) { }
+ public virtual void onASTElement(IOnesComplement onesComplement) { }
+ public virtual void onASTElement(IOutArgument outArgument) { }
+ public virtual void onASTElement(IPointerCall pointerCall) { }
+ public virtual void onASTElement(IPopValue popValue) { }
+ public virtual void onASTElement(IPushStatement pushStatement) { }
+ public virtual void onASTElement(IRefArgument refArgument) { }
+ public virtual void onASTElement(IResourceUseStatement resourceUseStatement) { }
+ public virtual void onASTElement(IReturnValue returnValue) { }
+ public virtual void onASTElement(IRethrowStatement rethrowStatement) { }
+ public virtual void onASTElement(IReturnStatement returnStatement) { }
+ public virtual void onASTElement(IRightShift rightShift) { }
+ public virtual void onASTElement(IRuntimeArgumentHandleExpression runtimeArgumentHandleExpression) { }
+ public virtual void onASTElement(ISizeOf sizeOf) { }
+ public virtual void onASTElement(IStackArrayCreate stackArrayCreate) { }
+ public virtual void onASTElement(ISubtraction subtraction) { }
+ public virtual void onASTElement(ISwitchCase switchCase) { }
+ public virtual void onASTElement(ISwitchStatement switchStatement) { }
+ public virtual void onASTElement(ITargetExpression targetExpression) { }
+ public virtual void onASTElement(IThisReference thisReference) { }
+ public virtual void onASTElement(IThrowStatement throwStatement) { }
+ public virtual void onASTElement(ITryCatchFinallyStatement tryCatchFilterFinallyStatement) { }
+ public virtual void onASTElement(ITokenOf tokenOf) { }
+ public virtual void onASTElement(ITypeOf typeOf) { }
+ public virtual void onASTElement(IUnaryNegation unaryNegation) { }
+ public virtual void onASTElement(IUnaryPlus unaryPlus) { }
+ public virtual void onASTElement(IVectorLength vectorLength) { }
+ public virtual void onASTElement(IWhileDoStatement whileDoStatement) { }
+ public virtual void onASTElement(IYieldBreakStatement yieldBreakStatement) { }
+ public virtual void onASTElement(IYieldReturnStatement yieldReturnStatement) { }
+ }
+}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/Translators/BaseTranslator.cs b/BCT/BytecodeTranslator/TranslationPlugins/Translators/BaseTranslator.cs
new file mode 100644
index 00000000..60f39e03
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/Translators/BaseTranslator.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BytecodeTranslator.TranslationPlugins;
+using Microsoft.Cci;
+using Microsoft.Cci.Contracts;
+
+namespace BytecodeTranslator {
+ class BaseTranslator : ContractAwareTranslator {
+ public TraverserFactory Factory;
+ private Sink sink;
+ private IDictionary<IUnit, IContractProvider> contractProviders;
+ private IDictionary<IUnit, PdbReader> pdbReaders;
+ private MetadataTraverser traverser;
+
+ public BaseTranslator(TraverserFactory factory, Sink sink, IDictionary<IUnit, IContractProvider> contractProviders, IDictionary<IUnit, PdbReader> pdbReaders) {
+ Factory = factory;
+ this.sink = sink;
+ this.contractProviders = contractProviders;
+ this.pdbReaders = pdbReaders;
+ }
+
+ public override void initialize() {
+ traverser = Factory.MakeMetadataTraverser(sink, contractProviders, pdbReaders);
+ }
+
+ public override bool isOneShot() {
+ return true;
+ }
+
+ public override int getPriority() {
+ // TODO make configurable from outside
+ return 10;
+ }
+
+ public override void TranslateAssemblies(IEnumerable<Microsoft.Cci.IUnit> assemblies) {
+ traverser.TranslateAssemblies(assemblies);
+ }
+ }
+}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneFeedbackTranslator.cs b/BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneFeedbackTranslator.cs
new file mode 100644
index 00000000..f2932ac0
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneFeedbackTranslator.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BytecodeTranslator.Phone;
+using Microsoft.Cci;
+
+namespace BytecodeTranslator.TranslationPlugins.Translators {
+ class PhoneFeedbackTranslator : Translator {
+ private Sink sink;
+ PhoneControlFeedbackMetadataTraverser traverser;
+
+ public PhoneFeedbackTranslator(Sink sink) {
+ this.sink = sink;
+ }
+
+ public override void initialize() {
+ traverser = new PhoneControlFeedbackMetadataTraverser(sink.host as MetadataReaderHost);
+ }
+
+ public override bool isOneShot() {
+ return true;
+ }
+
+ public override int getPriority() {
+ // TODO make configurable from outside
+ return 3;
+ }
+
+ public override void TranslateAssemblies(IEnumerable<Microsoft.Cci.IUnit> assemblies) {
+ traverser.Visit(assemblies);
+ }
+ }
+}
diff --git a/BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneInitializationTranslator.cs b/BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneInitializationTranslator.cs
new file mode 100644
index 00000000..7cd35b44
--- /dev/null
+++ b/BCT/BytecodeTranslator/TranslationPlugins/Translators/PhoneInitializationTranslator.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using BytecodeTranslator.Phone;
+using Microsoft.Cci;
+
+namespace BytecodeTranslator.TranslationPlugins.Translators {
+ class PhoneInitializationTranslator : Translator {
+ private Sink sink;
+ PhoneInitializationMetadataTraverser traverser;
+
+ public PhoneInitializationTranslator(Sink sink) {
+ this.sink = sink;
+ }
+
+ public override void initialize() {
+ traverser = new PhoneInitializationMetadataTraverser(sink.host as MetadataReaderHost);
+ }
+
+ public override bool isOneShot() {
+ return true;
+ }
+
+ public override int getPriority() {
+ // TODO make configurable from outside
+ return 1;
+ }
+
+ public override void TranslateAssemblies(IEnumerable<Microsoft.Cci.IUnit> assemblies) {
+ traverser.InjectPhoneCodeAssemblies(assemblies);
+ }
+ }
+
+ class PhoneNavigationTranslator : Translator {
+ private Sink sink;
+ PhoneNavigationMetadataTraverser traverser;
+
+ public PhoneNavigationTranslator(Sink sink) {
+ this.sink = sink;
+ }
+
+ public override void initialize() {
+ traverser = new PhoneNavigationMetadataTraverser(sink.host as MetadataReaderHost);
+ }
+
+ public override bool isOneShot() {
+ return true;
+ }
+
+ public override int getPriority() {
+ // TODO make configurable from outside
+ return 2;
+ }
+
+ public override void TranslateAssemblies(IEnumerable<Microsoft.Cci.IUnit> assemblies) {
+ traverser.InjectPhoneCodeAssemblies(assemblies);
+ }
+ }
+}