public override void CaseAABlock(AABlock node)
 {
     if (node == null) return;
     //If this is the first block, it marks the end
     if (node.Parent() is AMethodDecl || node.Parent() is AInitializerDecl || node.Parent() is ATriggerDecl ||
         node.Parent() is APropertyDecl || node.Parent() is AConstructorDecl || node.Parent() is ADeconstructorDecl)
     {
         End = TextPoint.FromCompilerCoords(node.GetToken().Line, node.GetToken().Pos);
     }
     base.CaseAABlock(node);
 }
 public override void InAABlock(AABlock node)
 {
     if (!data.Locals.ContainsKey(node))
         data.Locals.Add(node, new List<AALocalDecl>());
     AABlock pBlock = Util.GetAncestor<AABlock>(node.Parent());
     if (pBlock != null)
         data.Locals[node].AddRange(data.Locals[pBlock]);
 }
        public MethodDescription(TextPoint start, PType returnType, AABlock block, PType propertyType)
        {
            Parser parser = new Parser(block);

            Start = start;
            End = parser.End;
            ReturnType = Util.TypeToString(returnType);
            Name = "";
            Formals = parser.Formals;
            Locals = parser.Locals;
            if (block.Parent() != null)
                block.Parent().RemoveChild(block);
            //Decl = initializer;
            IsStatic = false;
            realType = (PType) returnType.Clone();
            if (propertyType != null)
                this.propertyType = (PType)propertyType.Clone();
            Position = start;
        }
        private List<PStm> GetSuccessor(AABlock block)
        {
            List<PStm> list = new List<PStm>();
            if (block.Parent() is AMethodDecl) return list;

            PStm blockStm = (PStm)block.Parent();
            if (blockStm.Parent() is AWhileStm)
            {
                list.Add((PStm)blockStm.Parent());
                //And the statement after the while
                blockStm = (PStm)blockStm.Parent();

                //return list;
            }
            if (blockStm.Parent() is AIfThenStm || blockStm.Parent() is AIfThenElseStm)
            {
                blockStm = (PStm)blockStm.Parent();
            }

            block = (AABlock)blockStm.Parent();
            int index = block.GetStatements().IndexOf(blockStm);
            if (index == block.GetStatements().Count - 1)
                list.AddRange(GetSuccessor(block));
            else
            {
                PStm stm = (PStm)block.GetStatements()[index + 1];
                while (stm is ABlockStm)
                {
                    blockStm = stm;
                    block = (AABlock)((ABlockStm)blockStm).GetBlock();

                    if (block.GetStatements().Count == 0)
                    {
                        list.AddRange(GetSuccessor(block));
                        return list;
                    }
                    stm = (PStm)block.GetStatements()[0];
                }
                list.Add(stm);
            }
            return list;
        }