comparison graal/GraalCompiler/src/com/sun/c1x/ir/Switch.java @ 2509:16b9a8b5ad39

Renamings Runtime=>GraalRuntime and Compiler=>GraalCompiler
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 11:50:44 +0200
parents graal/Compiler/src/com/sun/c1x/ir/Switch.java@9ec15d6914ca
children 0c6564c254af
comparison
equal deleted inserted replaced
2508:fea94949e0a2 2509:16b9a8b5ad39
1 /*
2 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.sun.c1x.ir;
24
25 import java.util.*;
26
27 import com.sun.c1x.value.*;
28 import com.sun.cri.ci.*;
29
30 /**
31 * The {@code Switch} class is the base of both lookup and table switches.
32 *
33 * @author Ben L. Titzer
34 */
35 public abstract class Switch extends BlockEnd {
36
37 Value value;
38
39 /**
40 * Constructs a new Switch.
41 * @param value the instruction that provides the value to be switched over
42 * @param successors the list of successors of this switch
43 * @param stateBefore the state before the switch
44 * @param isSafepoint {@code true} if this switch is a safepoint
45 */
46 public Switch(Value value, List<BlockBegin> successors, FrameState stateBefore, boolean isSafepoint) {
47 super(CiKind.Illegal, stateBefore, isSafepoint, successors);
48 this.value = value;
49 }
50
51 /**
52 * Gets the instruction that provides the input value to this switch.
53 * @return the instruction producing the input value
54 */
55 public Value value() {
56 return value;
57 }
58
59 /**
60 * Gets the number of cases that this switch covers (excluding the default case).
61 * @return the number of cases
62 */
63 public int numberOfCases() {
64 return successors.size() - 1;
65 }
66
67 /**
68 * Iterates over the inputs to this instruction.
69 * @param closure the closure to apply
70 */
71 @Override
72 public void inputValuesDo(ValueClosure closure) {
73 value = closure.apply(value);
74 }
75 }