public bool mustInlineMethod(IMethodDefinition method) { if (PhoneFeedbackToggled) { // FEEDBACK TODO this may be too coarse // top level inlined methods are feedback relevant ones. For now, this is basically everything that has EventArgs as parameters if (isMethodInputHandlerOrFeedbackOverride(method)) { return(true); } } if (PhoneNavigationToggled) { // NAVIGATION TODO this may be too coarse // for now, assume any method in a PhoneApplicationPage is potentially interesting to navigation inlining ITypeReference methodContainer = method.ContainingType; if (PhoneTypeHelper.isPhoneApplicationClass(methodContainer, host) || PhoneTypeHelper.isPhoneApplicationPageClass(methodContainer, host)) { return(true); } } return(false); }
public override void TraverseChildren(IMethodDefinition method) { this.methodTraversed = method; if (method.IsConstructor && PhoneTypeHelper.isPhoneApplicationClass(typeTraversed, host)) { navigationCallers.Add(method); string mainPageUri = PhoneCodeHelper.instance().PhonePlugin.getMainPageXAML(); SourceMethodBody sourceBody = method.Body as SourceMethodBody; if (sourceBody != null) { BlockStatement bodyBlock = sourceBody.Block as BlockStatement; if (bodyBlock != null) { Assignment uriInitAssign = new Assignment() { Source = new CompileTimeConstant() { Type = host.PlatformType.SystemString, Value = UriHelper.getURIBase(mainPageUri), }, Type = host.PlatformType.SystemString, Target = new TargetExpression() { Type = host.PlatformType.SystemString, // TODO unify code for current uri fieldreference Definition = new FieldReference() { ContainingType = PhoneCodeHelper.instance().getMainAppTypeReference(), IsStatic = true, Type = host.PlatformType.SystemString, Name = host.NameTable.GetNameFor(PhoneCodeHelper.IL_CURRENT_NAVIGATION_URI_VARIABLE), InternFactory = host.InternFactory, }, }, }; Statement uriInitStmt = new ExpressionStatement() { Expression = uriInitAssign, }; bodyBlock.Statements.Insert(0, uriInitStmt); } } } base.TraverseChildren(method); }