001/*
002 * Copyright (c) 2014, 2014, 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.meta;
024
025/**
026 * The implementation type of the {@link JavaConstant#NULL_POINTER null constant}.
027 */
028final class NullConstant extends AbstractValue implements JavaConstant {
029
030    protected NullConstant() {
031        super(LIRKind.reference(Kind.Object));
032    }
033
034    @Override
035    public boolean isNull() {
036        return true;
037    }
038
039    @Override
040    public boolean isDefaultForKind() {
041        return true;
042    }
043
044    @Override
045    public Object asBoxedPrimitive() {
046        throw new IllegalArgumentException();
047    }
048
049    @Override
050    public int asInt() {
051        throw new IllegalArgumentException();
052    }
053
054    @Override
055    public boolean asBoolean() {
056        throw new IllegalArgumentException();
057    }
058
059    @Override
060    public long asLong() {
061        throw new IllegalArgumentException();
062    }
063
064    @Override
065    public float asFloat() {
066        throw new IllegalArgumentException();
067    }
068
069    @Override
070    public double asDouble() {
071        throw new IllegalArgumentException();
072    }
073
074    @Override
075    public String toString() {
076        return JavaConstant.toString(this);
077    }
078
079    @Override
080    public String toValueString() {
081        return "null";
082    }
083
084    @Override
085    public int hashCode() {
086        return 13;
087    }
088
089    @Override
090    public boolean equals(Object o) {
091        return o instanceof NullConstant;
092    }
093}