Exemple #1
0
        public override AstNode Visit(FixedStatement node)
        {
            // Push the scope.
            PushScope(node.GetScope());

            // Visit children.
            VisitList(node.GetChildren());

            // Pop the scope.
            PopScope();

            return node;
        }
Exemple #2
0
        public override AstNode Visit(FixedStatement node)
        {
            // Begin the node.
            builder.BeginNode(node);

            // Push the scope.
            PushScope(node.GetScope());

            // Create a block for the fixed statement.
            BasicBlock fixedBlock = CreateBasicBlock();
            fixedBlock.SetName("fixed");

            // Enter into the fixed block.
            builder.CreateJmp(fixedBlock);
            builder.SetBlock(fixedBlock);

            // Visit the declarations.
            VisitList(node.GetDeclarations());

            // Visit the children.
            VisitList(node.GetChildren());

            // Remove unreachable code.
            if(builder.IsLastTerminator())
            {
                AstNode next = node.GetNext();
                if(next != null)
                    Warning(next, "found unreachable code.");
                node.SetNext(null);
            }
            else
            {
                // Merge the block.
                BasicBlock merge = CreateBasicBlock();
                merge.SetName("fmerge");
                builder.CreateJmp(merge);
                builder.SetBlock(merge);
            }

            // Restore the scope.
            PopScope();

            return builder.EndNode();
        }