예제 #1
0
 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);
 }
예제 #2
0
        public override void OutAConstructorDecl(AConstructorDecl node)
        {
            //If void return is missing, insert it.
            AABlock block        = (AABlock)node.GetBlock();
            bool    insertReturn = false;

            while (true)
            {
                if (block.GetStatements().Count == 0)
                {
                    insertReturn = true;
                    break;
                }
                PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                if (lastStm is AVoidReturnStm)
                {
                    break;
                }
                if (lastStm is ABlockStm)
                {
                    block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                    continue;
                }
                insertReturn = true;
                break;
            }
            if (insertReturn)
            {
                block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
            }


            base.OutAConstructorDecl(node);
        }
예제 #3
0
        public override void OutATriggerDecl(ATriggerDecl node)
        {
            //If no actions, insert it
            if (node.GetActions() == null)
            {
                node.SetActions(new AABlock(new ArrayList(), new TRBrace("}", -1, -1)));
                node.SetActionsToken(new TActions("actions", -1, -1));
            }

            //If return in events is missing, insert it.
            if (node.GetEvents() != null)
            {
                AABlock block        = (AABlock)node.GetEvents();
                bool    insertReturn = false;
                while (true)
                {
                    if (block.GetStatements().Count == 0)
                    {
                        insertReturn = true;
                        break;
                    }
                    PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                    if (lastStm is AVoidReturnStm)
                    {
                        break;
                    }
                    if (lastStm is ABlockStm)
                    {
                        block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                        continue;
                    }
                    insertReturn = true;
                    break;
                }
                if (insertReturn)
                {
                    block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
                }
            }
            //Also for actions
            //if (node.GetActions() != null)
            {
                AABlock block        = (AABlock)node.GetActions();
                bool    insertReturn = false;
                while (true)
                {
                    if (block.GetStatements().Count == 0)
                    {
                        insertReturn = true;
                        break;
                    }
                    PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
                    if (lastStm is AVoidReturnStm)
                    {
                        break;
                    }
                    if (lastStm is ABlockStm)
                    {
                        block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
                        continue;
                    }
                    insertReturn = true;
                    break;
                }
                if (insertReturn)
                {
                    block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
                }
            }
        }