001/*
002 * Copyright (c) 2013, 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 com.oracle.graal.replacements;
024
025import com.oracle.graal.replacements.nodes.*;
026
027// JaCoCo Exclude
028
029/**
030 * Substitutions for {@link java.util.Arrays} methods.
031 */
032public class ArraysSubstitutions {
033
034    public static boolean equals(boolean[] a, boolean[] a2) {
035        if (a == a2) {
036            return true;
037        }
038        if (a == null || a2 == null || a.length != a2.length) {
039            return false;
040        }
041        return ArrayEqualsNode.equals(a, a2, a.length);
042    }
043
044    public static boolean equals(byte[] a, byte[] a2) {
045        if (a == a2) {
046            return true;
047        }
048        if (a == null || a2 == null || a.length != a2.length) {
049            return false;
050        }
051        return ArrayEqualsNode.equals(a, a2, a.length);
052    }
053
054    public static boolean equals(char[] a, char[] a2) {
055        if (a == a2) {
056            return true;
057        }
058        if (a == null || a2 == null || a.length != a2.length) {
059            return false;
060        }
061        return ArrayEqualsNode.equals(a, a2, a.length);
062    }
063
064    public static boolean equals(short[] a, short[] a2) {
065        if (a == a2) {
066            return true;
067        }
068        if (a == null || a2 == null || a.length != a2.length) {
069            return false;
070        }
071        return ArrayEqualsNode.equals(a, a2, a.length);
072    }
073
074    public static boolean equals(int[] a, int[] a2) {
075        if (a == a2) {
076            return true;
077        }
078        if (a == null || a2 == null || a.length != a2.length) {
079            return false;
080        }
081        return ArrayEqualsNode.equals(a, a2, a.length);
082    }
083
084    public static boolean equals(long[] a, long[] a2) {
085        if (a == a2) {
086            return true;
087        }
088        if (a == null || a2 == null || a.length != a2.length) {
089            return false;
090        }
091        return ArrayEqualsNode.equals(a, a2, a.length);
092    }
093
094    public static boolean equals(float[] a, float[] a2) {
095        if (a == a2) {
096            return true;
097        }
098        if (a == null || a2 == null || a.length != a2.length) {
099            return false;
100        }
101        return ArrayEqualsNode.equals(a, a2, a.length);
102    }
103
104    public static boolean equals(double[] a, double[] a2) {
105        if (a == a2) {
106            return true;
107        }
108        if (a == null || a2 == null || a.length != a2.length) {
109            return false;
110        }
111        return ArrayEqualsNode.equals(a, a2, a.length);
112    }
113}