Example #1
0
        public override AstNode Visit(UnsafeBlockNode node)
        {
            // Begin the node.
            builder.BeginNode(node);

            // Push the unsafe scope.
            PushUnsafe();

            // Create the block lexical scope.
            LexicalScope blockScope = (LexicalScope) node.GetScope();
            node.SetScope(blockScope);

            // Create the new basic block.
            BasicBlock block = CreateBasicBlock();
            block.SetName("block");

            // Jump into the basic block.
            builder.CreateJmp(block);
            builder.SetBlock(block);

            // Push the scope.
            PushScope(blockScope);

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

            // Pop the scope.
            PopScope();

            // Create a merge block and jump into it.
            if(!builder.IsLastTerminator())
            {
                BasicBlock mergeBlock = CreateBasicBlock();
                mergeBlock.SetName("merge");

                builder.CreateJmp(mergeBlock);
                builder.SetBlock(mergeBlock);
            }

            // Pop the unsafe scope.
            PopUnsafe();

            return builder.EndNode();
        }
Example #2
0
        public override AstNode Visit(UnsafeBlockNode node)
        {
            // Ignore pure declarations.
            if(node.GetChildren() == null)
                return node;

            // Push the unsafe.
            PushUnsafe();

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

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

            // Restore the scope.
            PopScope();

            // Pop the unsafe scope.
            PopUnsafe();

            return node;
        }
Example #3
0
        public override AstNode Visit(UnsafeBlockNode node)
        {
            // Create the block lexical scope.
            LexicalScope blockScope = CreateLexicalScope(node);
            node.SetScope(blockScope);

            // Push the unsafe.
            PushUnsafe();

            // Push the scope.
            PushScope(blockScope);

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

            // Restore the scope.
            PopScope();

            // Pop the unsafe scope.
            PopUnsafe();

            return node;
        }