001/*
002 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package jdk.internal.jvmci.hotspot;
024
025import jdk.internal.jvmci.meta.*;
026
027/**
028 * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}.
029 */
030public final class HotSpotCompressedNullConstant extends AbstractValue implements JavaConstant, HotSpotConstant {
031
032    public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant();
033
034    private HotSpotCompressedNullConstant() {
035        super(LIRKind.reference(Kind.Int));
036    }
037
038    @Override
039    public boolean isNull() {
040        return true;
041    }
042
043    @Override
044    public boolean isCompressed() {
045        return true;
046    }
047
048    @Override
049    public boolean isDefaultForKind() {
050        return true;
051    }
052
053    @Override
054    public Object asBoxedPrimitive() {
055        throw new IllegalArgumentException();
056    }
057
058    @Override
059    public int asInt() {
060        throw new IllegalArgumentException();
061    }
062
063    @Override
064    public boolean asBoolean() {
065        throw new IllegalArgumentException();
066    }
067
068    @Override
069    public long asLong() {
070        throw new IllegalArgumentException();
071    }
072
073    @Override
074    public float asFloat() {
075        throw new IllegalArgumentException();
076    }
077
078    @Override
079    public double asDouble() {
080        throw new IllegalArgumentException();
081    }
082
083    @Override
084    public String toString() {
085        return JavaConstant.toString(this);
086    }
087
088    @Override
089    public String toValueString() {
090        return "null";
091    }
092
093    @Override
094    public int hashCode() {
095        return System.identityHashCode(this);
096    }
097
098    @Override
099    public boolean equals(Object o) {
100        return o instanceof HotSpotCompressedNullConstant;
101    }
102}