cetus.hir
Class SimpleExpression

java.lang.Object
  extended by cetus.hir.SimpleExpression
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<SimpleExpression>, java.util.Comparator<SimpleExpression>
Direct Known Subclasses:
Symbolic

public class SimpleExpression
extends java.lang.Object
implements java.util.Comparator<SimpleExpression>, java.lang.Comparable<SimpleExpression>, java.lang.Cloneable

SimpleExpression is another form of representing an expression which is effective in symbolic manipulation. Expressions with commutative and associative operators are flattend for easier manipulation, and only a subset of the Cetus expressions is represented specifically with an abbreviated operator name. Other types are marked as general "TREE" whose children are recursively represented using SimpleExpression.


Field Summary
protected static int ADD
           
protected static int AND
           
protected static int BAND
           
protected static int BCMP
           
protected static int BOR
           
protected static int BXOR
           
protected static int DISTRIBUTE
           
protected static int DIV
           
protected static int DIVIDE
           
protected static int EQ
           
protected static int FACTORIZE
           
protected static int FOLD
           
protected static int GE
           
protected static int GT
           
protected static int ID
           
protected static int LE
           
protected static int LEAF
           
protected static int LIT
           
protected static int LOGIC
           
protected static int LT
           
protected static int MAX
           
protected static int MIN
           
protected static int MOD
           
protected static int MUL
           
protected static int NE
           
protected static int NEG
           
protected static int OR
           
protected static int SFTL
           
protected static int SFTR
           
protected static SimpleExpression sone
           
protected static SimpleExpression szero
           
protected static int TREE
           
protected static int verbosity
           
 
Constructor Summary
protected SimpleExpression()
           
protected SimpleExpression(Expression e)
           
protected SimpleExpression(int sop)
           
protected SimpleExpression(SimpleExpression se)
           
protected SimpleExpression(SimpleExpression se1, int op, SimpleExpression se2)
           
 
Method Summary
protected  void add(SimpleExpression se)
           
protected static SimpleExpression add(SimpleExpression se1, SimpleExpression se2)
           
protected  void addAll(java.util.Collection<SimpleExpression> ses)
           
protected  void addAll(SimpleExpression se)
           
 java.lang.Object clone()
          Returns a clone of this simple expression.
 int compare(SimpleExpression se1, SimpleExpression se2)
          Returns if a simple expression is greater than, less than, or equal to the other.
 int compareTo(SimpleExpression se)
          Compares this simple expression with the given simple expression.
protected  boolean containsChildOfType(int op)
           
protected static SimpleExpression divide(SimpleExpression se1, SimpleExpression se2)
           
 boolean equals(java.lang.Object o)
          Checks if this simple expression is equal to the given object.
protected static int exchangeOp(int op)
           
protected static java.lang.Object getCetusOP(int op)
           
protected  SimpleExpression getChild(int id)
           
protected  java.util.List<SimpleExpression> getChildren()
           
protected  SimpleExpression getCoef()
           
protected static SimpleExpression getDouble(double num)
           
protected  Expression getExpression()
          Returns a reconstructed Cetus expression from the simple expression.
protected  Expression getExprRef()
           
protected static SimpleExpression getInt(int num)
           
protected static SimpleExpression getLCD(java.util.List<SimpleExpression> ses)
           
protected static SimpleExpression getLCM(java.util.List<SimpleExpression> ses)
           
protected  int getOP()
           
protected static int getOption()
           
protected  int getOrder()
           
protected  SimpleExpression getTerm()
           
protected  java.lang.Double getValue()
           
protected  boolean isCommAssoc()
           
protected  boolean isCompare()
           
protected static SimpleExpression mod(SimpleExpression se1, SimpleExpression se2)
           
protected static SimpleExpression multiply(SimpleExpression se1, SimpleExpression se2)
           
protected  java.util.List<SimpleExpression> multiplyByLCM()
           
protected static int negateOp(int op)
           
protected  SimpleExpression normalize()
           
protected  SimpleExpression normalizeDivisible()
           
protected  void setChild(int id, SimpleExpression child)
           
protected static void setOption(int opt)
           
protected  void sort()
           
protected static SimpleExpression subtract(SimpleExpression se1, SimpleExpression se2)
           
protected  SimpleExpression toDivision()
           
 java.lang.String toString()
          Returns a string representation of the simple expression.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADD

protected static final int ADD
See Also:
Constant Field Values

MUL

protected static final int MUL
See Also:
Constant Field Values

DIV

protected static final int DIV
See Also:
Constant Field Values

MOD

protected static final int MOD
See Also:
Constant Field Values

SFTL

protected static final int SFTL
See Also:
Constant Field Values

SFTR

protected static final int SFTR
See Also:
Constant Field Values

BAND

protected static final int BAND
See Also:
Constant Field Values

BOR

protected static final int BOR
See Also:
Constant Field Values

BXOR

protected static final int BXOR
See Also:
Constant Field Values

BCMP

protected static final int BCMP
See Also:
Constant Field Values

AND

protected static final int AND
See Also:
Constant Field Values

OR

protected static final int OR
See Also:
Constant Field Values

EQ

protected static final int EQ
See Also:
Constant Field Values

NE

protected static final int NE
See Also:
Constant Field Values

LE

protected static final int LE
See Also:
Constant Field Values

LT

protected static final int LT
See Also:
Constant Field Values

GE

protected static final int GE
See Also:
Constant Field Values

GT

protected static final int GT
See Also:
Constant Field Values

NEG

protected static final int NEG
See Also:
Constant Field Values

TREE

protected static final int TREE
See Also:
Constant Field Values

ID

protected static final int ID
See Also:
Constant Field Values

LIT

protected static final int LIT
See Also:
Constant Field Values

LEAF

protected static final int LEAF
See Also:
Constant Field Values

MIN

protected static final int MIN
See Also:
Constant Field Values

MAX

protected static final int MAX
See Also:
Constant Field Values

sone

protected static final SimpleExpression sone

szero

protected static final SimpleExpression szero

verbosity

protected static final int verbosity

FACTORIZE

protected static final int FACTORIZE
See Also:
Constant Field Values

FOLD

protected static final int FOLD
See Also:
Constant Field Values

DISTRIBUTE

protected static final int DISTRIBUTE
See Also:
Constant Field Values

DIVIDE

protected static final int DIVIDE
See Also:
Constant Field Values

LOGIC

protected static final int LOGIC
See Also:
Constant Field Values
Constructor Detail

SimpleExpression

protected SimpleExpression()

SimpleExpression

protected SimpleExpression(int sop)

SimpleExpression

protected SimpleExpression(SimpleExpression se)

SimpleExpression

protected SimpleExpression(SimpleExpression se1,
                           int op,
                           SimpleExpression se2)

SimpleExpression

protected SimpleExpression(Expression e)
Method Detail

add

protected void add(SimpleExpression se)

addAll

protected void addAll(java.util.Collection<SimpleExpression> ses)

addAll

protected void addAll(SimpleExpression se)

getInt

protected static SimpleExpression getInt(int num)

getDouble

protected static SimpleExpression getDouble(double num)

toString

public java.lang.String toString()
Returns a string representation of the simple expression.

Overrides:
toString in class java.lang.Object
Returns:
the string representation.

getExpression

protected Expression getExpression()
Returns a reconstructed Cetus expression from the simple expression.

Returns:
the Cetus expression.

getChild

protected SimpleExpression getChild(int id)

setChild

protected void setChild(int id,
                        SimpleExpression child)

setOption

protected static void setOption(int opt)

isCommAssoc

protected boolean isCommAssoc()

isCompare

protected boolean isCompare()

containsChildOfType

protected boolean containsChildOfType(int op)

compareTo

public int compareTo(SimpleExpression se)
Compares this simple expression with the given simple expression.

Specified by:
compareTo in interface java.lang.Comparable<SimpleExpression>
Parameters:
the - given simple expression.
Returns:
the result of Expression.compareTo(Expression).

clone

public java.lang.Object clone()
Returns a clone of this simple expression.

Overrides:
clone in class java.lang.Object
Returns:
a clone object.

equals

public boolean equals(java.lang.Object o)
Checks if this simple expression is equal to the given object.

Specified by:
equals in interface java.util.Comparator<SimpleExpression>
Overrides:
equals in class java.lang.Object
Parameters:
the - given object.
Returns:
true if it is, false otherwise.

compare

public int compare(SimpleExpression se1,
                   SimpleExpression se2)
Returns if a simple expression is greater than, less than, or equal to the other.

Specified by:
compare in interface java.util.Comparator<SimpleExpression>
Parameters:
se1 - the first simple expression.
se2 - the second simple expression.
Returns:
the comparison result (-1, 0, 1).

getTerm

protected SimpleExpression getTerm()

getValue

protected java.lang.Double getValue()

add

protected static SimpleExpression add(SimpleExpression se1,
                                      SimpleExpression se2)

subtract

protected static SimpleExpression subtract(SimpleExpression se1,
                                           SimpleExpression se2)

multiply

protected static SimpleExpression multiply(SimpleExpression se1,
                                           SimpleExpression se2)

divide

protected static SimpleExpression divide(SimpleExpression se1,
                                         SimpleExpression se2)

mod

protected static SimpleExpression mod(SimpleExpression se1,
                                      SimpleExpression se2)

sort

protected void sort()

getCoef

protected SimpleExpression getCoef()

normalize

protected SimpleExpression normalize()

getLCM

protected static SimpleExpression getLCM(java.util.List<SimpleExpression> ses)

getLCD

protected static SimpleExpression getLCD(java.util.List<SimpleExpression> ses)

multiplyByLCM

protected java.util.List<SimpleExpression> multiplyByLCM()

normalizeDivisible

protected SimpleExpression normalizeDivisible()

toDivision

protected SimpleExpression toDivision()

negateOp

protected static int negateOp(int op)

exchangeOp

protected static int exchangeOp(int op)

getOption

protected static int getOption()

getOrder

protected int getOrder()

getExprRef

protected Expression getExprRef()

getOP

protected int getOP()

getChildren

protected java.util.List<SimpleExpression> getChildren()

getCetusOP

protected static java.lang.Object getCetusOP(int op)