harpoon.IR.Quads
Class SWITCH

java.lang.Object
  extended by harpoon.IR.Quads.Quad
      extended by harpoon.IR.Quads.SIGMA
          extended by harpoon.IR.Quads.SWITCH
All Implemented Interfaces:
HCodeElement, CFGraphable<Quad,Edge>, UseDefable, Graph.Node<Quad,Edge>, Serializable, Cloneable, Comparable<Quad>

public class SWITCH
extends SIGMA

SWITCH represents a switch construct.

Version:
$Id: SWITCH.java,v 1.5 2002/04/11 04:00:35 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Field Summary
protected  Temp index
          The discriminant, compared against each value in keys.
protected  int[] keys
          Integer keys for switch cases.
 
Fields inherited from class harpoon.IR.Quads.SIGMA
dst, src
 
Fields inherited from class harpoon.IR.Quads.Quad
arrayFactory
 
Constructor Summary
SWITCH(QuadFactory qf, HCodeElement source, Temp index, int[] keys, Temp[] src)
          Creates a switch with arity defined by the keys array.
SWITCH(QuadFactory qf, HCodeElement source, Temp index, int[] keys, Temp[][] dst, Temp[] src)
          Creates a SWITCH operation.
 
Method Summary
<T> T
accept(QuadValueVisitor<T> v)
           
 void accept(QuadVisitor v)
          Accept a visitor.
 Temp index()
          Returns the Temp holding the discriminant.
 int[] keys()
          Returns the array of integer keys for the switch cases.
 int keys(int i)
          Returns a given element in the keys array.
 int keysLength()
          Returns the length of the keys array.
 int kind()
          Return an integer enumeration of the kind of this Quad.
 Quad rename(QuadFactory qqf, TempMap defMap, TempMap useMap)
          Create a new Quad identical to the receiver, but with all Temps renamed according to a mapping.
 String toString()
          Returns human-readable representation of this quad.
 Temp[] use()
          Returns the Temp used by this quad.
 
Methods inherited from class harpoon.IR.Quads.SIGMA
arity, assign, def, dst, dst, dst, numSigmas, removeSigma, src, src
 
Methods inherited from class harpoon.IR.Quads.Quad
addEdge, addEdges, addHandlers, clone, clone, clone, compareTo, defC, edgeC, edges, getFactory, getID, getLineNumber, getSourceFile, handlers, hashCode, isPred, isSucc, map, map, map, next, next, nextEdge, nextEdge, nextLength, pred, predC, prev, prev, prevEdge, prevEdge, prevLength, remove, removeHandlers, rename, replace, succ, succC, toLongString, transferHandlers, useC
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected Temp index
The discriminant, compared against each value in keys.


keys

protected int[] keys
Integer keys for switch cases.

next(n) is the jump target corresponding to keys[n] for 0 <= n < keys.length.

next(keys.length) is the default target.

Constructor Detail

SWITCH

public SWITCH(QuadFactory qf,
              HCodeElement source,
              Temp index,
              int[] keys,
              Temp[][] dst,
              Temp[] src)
Creates a SWITCH operation.

next[n] is the jump target corresponding to keys[n] for 0 <= n < keys.length.

next[keys.length] is the default target.

Parameters:
index - the discriminant.
keys - integer keys for switch cases.
dst - sigma function left-hand sides.
src - sigma function arguments.

SWITCH

public SWITCH(QuadFactory qf,
              HCodeElement source,
              Temp index,
              int[] keys,
              Temp[] src)
Creates a switch with arity defined by the keys array.

Method Detail

index

public Temp index()
Returns the Temp holding the discriminant.


keys

public int[] keys()
Returns the array of integer keys for the switch cases.


keys

public int keys(int i)
Returns a given element in the keys array.


keysLength

public int keysLength()
Returns the length of the keys array.


use

public Temp[] use()
Returns the Temp used by this quad.

Specified by:
use in interface UseDefable
Overrides:
use in class SIGMA
Returns:
the index field.

kind

public int kind()
Description copied from class: Quad
Return an integer enumeration of the kind of this Quad. The enumerated values are defined in QuadKind.

Specified by:
kind in class Quad

rename

public Quad rename(QuadFactory qqf,
                   TempMap defMap,
                   TempMap useMap)
Description copied from class: Quad
Create a new Quad identical to the receiver, but with all Temps renamed according to a mapping. The new Quad will have no edges.

The new Quad will come from the specified QuadFactory.

Specified by:
rename in class Quad

accept

public void accept(QuadVisitor v)
Description copied from class: Quad
Accept a visitor.

Overrides:
accept in class SIGMA

accept

public <T> T accept(QuadValueVisitor<T> v)
Overrides:
accept in class SIGMA

toString

public String toString()
Returns human-readable representation of this quad.

Overrides:
toString in class SIGMA