001/* 002 * Copyright (c) 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.graph; 024 025import static com.oracle.graal.graph.Edges.Type.*; 026 027import java.util.*; 028 029import com.oracle.graal.graph.NodeClass.InputInfo; 030import com.oracle.graal.nodeinfo.*; 031 032public final class InputEdges extends Edges { 033 034 private final InputType[] inputTypes; 035 private final boolean[] isOptional; 036 037 public InputEdges(int directCount, ArrayList<InputInfo> edges) { 038 super(Inputs, directCount, edges); 039 040 this.inputTypes = new InputType[edges.size()]; 041 this.isOptional = new boolean[edges.size()]; 042 for (int i = 0; i < edges.size(); i++) { 043 this.inputTypes[i] = edges.get(i).inputType; 044 this.isOptional[i] = edges.get(i).optional; 045 } 046 } 047 048 public static void translateInto(InputEdges inputs, ArrayList<InputInfo> infos) { 049 for (int index = 0; index < inputs.getCount(); index++) { 050 infos.add(new InputInfo(inputs.offsets[index], inputs.getName(index), inputs.getType(index), inputs.getDeclaringClass(index), inputs.inputTypes[index], inputs.isOptional(index))); 051 } 052 } 053 054 public InputType getInputType(int index) { 055 return inputTypes[index]; 056 } 057 058 public boolean isOptional(int index) { 059 return isOptional[index]; 060 } 061 062 @Override 063 public void update(Node node, Node oldValue, Node newValue) { 064 node.updateUsages(oldValue, newValue); 065 } 066}