summaryrefslogtreecommitdiff
path: root/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs
diff options
context:
space:
mode:
authorGravatar Unknown <t-espave@A3479886.redmond.corp.microsoft.com>2011-07-14 11:33:08 -0700
committerGravatar Unknown <t-espave@A3479886.redmond.corp.microsoft.com>2011-07-14 11:33:08 -0700
commit0c7dae500c2856afdd6481608cfae47d44120864 (patch)
treeb7b5e14b42fd13b2fe8c352edbbaaeb0c1de805c /BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs
parent0b4b3d7200a0dea361f96ce84e4e95b8d7c47a96 (diff)
parent31169d7faf36a17b32e7e0b9052b5b07ec5858ca (diff)
more static URI detection
Diffstat (limited to 'BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs')
-rw-r--r--BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs52
1 files changed, 29 insertions, 23 deletions
diff --git a/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs b/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs
index edefa24d..0cb6d91e 100644
--- a/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs
+++ b/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs
@@ -59,6 +59,7 @@ namespace BytecodeTranslator.Phone {
Expression= uriInitAssign,
};
bodyBlock.Statements.Insert(0, uriInitStmt);
+ bodyBlock.Statements.Insert(0, uriInitStmt);
}
}
}
@@ -100,39 +101,33 @@ namespace BytecodeTranslator.Phone {
return;
} else {
navCallFound = true;
- bool targetIsStatic=false;
+ bool isStatic=false;
string notStaticReason = "";
+ StaticURIMode staticMode = StaticURIMode.NOT_STATIC;
+
if (methodToCallName == "GoBack")
- targetIsStatic = true;
+ isStatic= true;
else { // Navigate()
// check for different static patterns that we may be able to verify
- bool isStatic = false;
- StaticURIMode staticMode = StaticURIMode.NOT_STATIC;
-
IExpression uriArg= methodCall.Arguments.First();
if (isArgumentURILocallyCreatedStatic(uriArg)) {
isStatic = true;
staticMode = StaticURIMode.STATIC_URI_CREATION_ONSITE;
} else if (isArgumentURILocallyCreatedStaticRoot(uriArg)) {
- isStatic=true;
- staticMode=StaticURIMode.STATIC_URI_ROOT_CREATION_ONSITE;
- }
-
- ICreateObjectInstance creationSite= methodCall.Arguments.First() as ICreateObjectInstance;
- if (creationSite != null) {
- if (creationSite.Arguments.First().Type.ResolvedType.Equals(host.PlatformType.SystemString.ResolvedType) && creationSite.Arguments.First() is ICompileTimeConstant) {
- targetIsStatic = true;
- } else {
- targetIsStatic = false;
- notStaticReason = "URI not initialized as a static string";
- }
+ isStatic = true;
+ staticMode = StaticURIMode.STATIC_URI_ROOT_CREATION_ONSITE;
} else {
- targetIsStatic = false;
- notStaticReason = "URI not created at call site";
+ // get reason
+ ICreateObjectInstance creationSite = methodCall.Arguments.First() as ICreateObjectInstance;
+ if (creationSite == null)
+ notStaticReason = "URI not created at call site";
+ else
+ notStaticReason = "URI not initialized as a static string";
}
}
- Console.Write("Page navigation event found. Target is static? " + (targetIsStatic ? "YES" : "NO"));
- if (!targetIsStatic) {
+
+ Console.Write("Page navigation event found. Target is static? " + (isStatic ? "YES" : "NO"));
+ if (!isStatic) {
nonStaticNavEvtCount++;
Console.WriteLine(" -- Reason: " + notStaticReason);
} else {
@@ -172,8 +167,19 @@ namespace BytecodeTranslator.Phone {
/// <returns></returns>
private bool isArgumentURILocallyCreatedStaticRoot(IExpression arg) {
// Pre: !isArgumentURILocallyCreatedStatic
- // TODO
- return false;
+ if (!arg.isCreateObjectInstance())
+ return false;
+
+ if (!arg.Type.isURIClass(host))
+ return false;
+
+ ICreateObjectInstance creationSite = arg as ICreateObjectInstance;
+ IExpression uriTargetArg = creationSite.Arguments.First();
+
+ if (!uriTargetArg.Type.isStringClass(host))
+ return false;
+
+ return uriTargetArg.IsStaticURIRootExtractable();
}
private void injectNavigationUpdateCode(IBlockStatement block, IEnumerable<IStatement> stmts) {