Example #1
0
        public override AstNode Visit(FixedStatement node)
        {
            UnsafeError(node, "cannot use fixed statement under safe contexts.");

            // Create the lexical scope.
            LexicalScope scope = CreateLexicalScope(node);
            node.SetScope(scope);

            // Enter into the scope.
            PushScope(scope);

            // Visit the type expression.
            Expression typeExpr = node.GetTypeExpression();
            typeExpr.Accept(this);

            // Read the type expression.
            IChelaType fixedType = typeExpr.GetNodeType();
            fixedType = ExtractActualType(typeExpr, fixedType);

            // Make sure its a pointer.
            if(!fixedType.IsPointer())
                Error(typeExpr, "expected pointer type.");

            // Vist the declarations.
            AstNode decl = node.GetDeclarations();
            while(decl != null)
            {
                // Notify about the type.
                decl.SetNodeType(fixedType);

                // Visit it.
                decl.Accept(this);

                // Visit the next declaration.
                decl = decl.GetNext();
            }

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

            // Restore the scope.
            PopScope();

            return node;
        }