Exemplo n.º 1
0
        public override AstNode Visit(DeleteStatement node)
        {
            // Begin the node.
            builder.BeginNode(node);

            // Get the pointer.
            Expression pointer = node.GetPointer();
            pointer.Accept(this);

            // Cast the pointer.
            IChelaType pointerType = pointer.GetNodeType();
            IChelaType coercionType = node.GetCoercionType();
            if(pointerType != coercionType)
                Cast(node, pointer.GetNodeValue(), pointerType, coercionType);

            // Delete the object.
            builder.CreateDeleteObject();

            return builder.EndNode();
        }
Exemplo n.º 2
0
        public override AstNode Visit(DeleteStatement node)
        {
            // Get the pointer.
            Expression pointer = node.GetPointer();
            pointer.Accept(this);

            // Get the pointer type.
            IChelaType pointerType = pointer.GetNodeType();

            // Dereference the expression.
            if(pointerType.IsReference())
            {
                ReferenceType refType = (ReferenceType)pointerType;
                pointerType = refType.GetReferencedType();
            }

            // The expression must be a pointer expression.
            if(!pointerType.IsPointer())
                Error(node, "cannot delete something without a pointer.");

            // Set the coercion type.
            node.SetCoercionType(pointerType);

            return node;
        }