|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.clef.Node scale.clef.type.Bound
public class Bound
A Bound class represents a range of allowed integer values.
$Id: Bound.java,v 1.62 2007-10-04 19:58:08 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Field Summary | |
---|---|
static Bound |
noBound
Represents a "no bounds". |
static Bound |
noValues
Represents a range with no values. |
Method Summary | |
---|---|
int |
bitSize()
Return the number of bits required to represent the maximum. |
static void |
cleanup()
Remove static lists of types. |
static Bound |
create(Expression min,
Expression max)
Create a representation of a range from min to max. |
static Bound |
create(long min,
long max)
Create a representation of a range from min to
max . |
boolean |
equivalent(Node tc)
Return true if the types are equivalent. |
Node |
getChild(int i)
Return the specified AST child of this node. |
long |
getConstMax()
Return the integer value maximum value for the bound. |
long |
getConstMin()
Return the integer value minimum value for the bound. |
java.lang.String |
getDisplayLabel()
Return short description of current node. |
Expression |
getMax()
Return the expression representing the maximum of the bounds. |
Expression |
getMin()
Return the expression representing the minimum of the bounds. |
boolean |
isConstantBounds()
Check if the bounds represent integer contant expressions. |
long |
numberOfElements()
Return the number of elements in a bound (range) if the min and max expressions are integer literals |
int |
numChildren()
Return the number of AST children of this node. |
protected void |
setMax(Expression max)
Specify the expression representing the maximum of the bounds. |
protected void |
setMin(Expression min)
Specify the expression representing the minimum of the bounds. |
java.lang.String |
toString()
|
void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.clef.Node |
---|
getCoreType, getDecl, getSourceLineNumber, getType, setAnnotationLevel, setReportLevel, setSourceLineNumber, toString, toStringChildren, toStringSpecial |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayName, getDisplayShapeHint, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Bound noBound
[]
.
public static final Bound noValues
[0]
.
Method Detail |
---|
public static Bound create(Expression min, Expression max)
min
- is the lower boundmax
- is the upper boundpublic static Bound create(long min, long max)
min
to
max
. If min > max
, the bound is
considered to be unbounded.
min
- the lower boundmax
- the upper boundpublic final Expression getMin()
public final Expression getMax()
public final long getConstMax() throws InvalidException
InvalidException
- if the maximum value for
the bound is not statically knownpublic final long getConstMin() throws InvalidException
InvalidException
- if the minimum value for
the bound is not statically knownpublic final long numberOfElements() throws InvalidException
InvalidException
- if the number of elements
is not statically knownpublic int bitSize()
public final boolean isConstantBounds()
public void visit(Predicate p)
Node
Each class has a visit(Predicate p)
method. For
example, in class ABC
:
public void visit(Predicate p) { p.visitABC(this); }and the class that implements
Predicate
has a method
public void visitABC(Node n) { ABC a = (ABC) n; ... }Thus, the class that implements
Predicate
can call
n.visit(this);where
n
is a Node
sub-class without
determining which specific sub-class n
is.
The visit pattern basically avoids implementing a large
switch
statement or defining different methods
in each class for some purpose.
visit
in class Node
Predicate
protected final void setMin(Expression min)
protected final void setMax(Expression max)
public Node getChild(int i)
getChild
in class Node
public int numChildren()
numChildren
in class Node
public boolean equivalent(Node tc)
public java.lang.String getDisplayLabel()
getDisplayLabel
in interface DisplayNode
getDisplayLabel
in class Root
public static void cleanup()
public java.lang.String toString()
toString
in class Node
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |