public override void CaseAMethodDecl(AMethodDecl node)
 {
     if (node.GetInline() != null)
     {
         bool canAlwaysInline = true;
         foreach (KeyValuePair <ASimpleInvokeExp, AMethodDecl> pair in data.SimpleMethodLinks)
         {
             if (pair.Value == node && !Util.HasAncestor <AABlock>(pair.Key))
             {
                 canAlwaysInline = false;
                 break;
             }
         }
         if (canAlwaysInline)
         {
             node.Parent().RemoveChild(node);
             if (finalTrans.data.Methods.Any(item => item.Decl == node))
             {
                 finalTrans.data.Methods.Remove(finalTrans.data.Methods.First(item => item.Decl == node));
             }
         }
     }
     else
     {
         base.CaseAMethodDecl(node);
     }
 }
        public override void CaseAMethodDecl(AMethodDecl node)
        {
            if (node.GetInline() == null)
            {
                return;
            }

            //Variables marked as out can be made into ref
            foreach (AALocalDecl formal in node.GetFormals())
            {
                if (formal.GetOut() != null)
                {
                    formal.SetRef(new TRef("ref"));
                    formal.SetOut(null);
                }
            }
            assignedToLocals.Clear();
            base.CaseAMethodDecl(node);

            foreach (AALocalDecl formal in node.GetFormals())
            {
                if (!assignedToLocals.Contains(formal))
                {
                    formal.SetRef(new TRef("ref"));
                }
            }
        }
                public override void CaseASimpleInvokeExp(ASimpleInvokeExp node)
                {
                    AMethodDecl target = data.SimpleMethodLinks[node];

                    if (target == initialMethod)
                    {
                        InlinedCallToItself = true;
                    }
                    else if (target.GetInline() != null)
                    {
                        target.Apply(this);
                    }
                    base.CaseASimpleInvokeExp(node);
                }
        public override void OutASimpleInvokeExp(ASimpleInvokeExp node)
        {
            AMethodDecl decl = finalTrans.data.SimpleMethodLinks[node];

            if (decl.GetInline() != null && Util.HasAncestor <AABlock>(node))
            {
                foreach (AABlock block in Inline(node, finalTrans))
                {
                    block.Apply(this);
                }
            }

            /*else
             *  base.CaseASimpleInvokeExp(node);*/
        }
 public override void CaseAMethodDecl(AMethodDecl node)
 {
     if (node.GetInline() == null && node.GetTrigger() == null && !(data.ConstructorMap.ContainsValue(node) && !inlineConstructors) && node != finalTrans.mainEntry)
     {
         CountStatements counter = new CountStatements();
         node.Apply(counter);
         if (counter.Count <= 2)
         {
             //Don't inline if it has a recurssive call to itself
             FindRecurssiveCall recurssiveCallSearcher = new FindRecurssiveCall(node, data);
             node.Apply(recurssiveCallSearcher);
             if (!recurssiveCallSearcher.InlinedCallToItself)
             {
                 node.SetInline(new TInline("inline"));
             }
         }
     }
     base.CaseAMethodDecl(node);
 }