示例#1
0
        public override AstNode Visit(CatchStatement node)
        {
            // Update the scope.
            PushScope(node.GetScope());

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

            // Restore the scope.
            PopScope();

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

            // Read the exception.
            Structure exception = (Structure)node.GetNodeType();

            // Create the block.
            BasicBlock block = CreateBasicBlock();
            block.SetName("catch");
            builder.SetBlock(block);

            // Add the catch to the context.
            ExceptionContext context = node.GetContext();
            context.AddCatch(exception, block);

            // Load the exception.
            LocalVariable local = node.GetVariable();
            if(local != null)
                builder.CreateStoreLocal(local);
            else
                builder.CreatePop();

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

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

            // Restore the scope.
            PopScope();

            return builder.EndNode();
        }