コード例 #1
0
ファイル: FunctionGenerator.cs プロジェクト: ronsaldo/chela
        public override AstNode Visit(DeleteRawArrayStatement 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.CreateDeleteRawArray();

            return builder.EndNode();
        }
コード例 #2
0
ファイル: FunctionSemantic.cs プロジェクト: ronsaldo/chela
        public override AstNode Visit(DeleteRawArrayStatement 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;
        }