SFE.Compiler
Class UnaryOpExpression

java.lang.Object
  extended by SFE.Compiler.Expression
      extended by SFE.Compiler.OperationExpression
          extended by SFE.Compiler.UnaryOpExpression
All Implemented Interfaces:
Multi2SingleBit

public class UnaryOpExpression
extends OperationExpression

A class for representing unary operator expressions that can be defined in the program.


Field Summary
static java.util.Vector inputFormat
           
 
Constructor Summary
UnaryOpExpression(Operator op, Expression middle)
          Constructs a new UnaryOpExpression from a given oparator and input.
 
Method Summary
 void changeReference(UniqueVariables unique)
           
 OperationExpression combineConstInput()
          Combines an input expression that is constant and return the result expression.
 OperationExpression combineEqualInputs()
          Returns this expression since there is nothig to do.
 void combineUnaryInput()
          Combined an input expression the is the output of an unary operator into this Operation expression.
 Expression duplicate()
          returns a replica of this expression
 java.util.Vector getLvalExpressionInputs()
          Returns an array of the input LvalExpressions of this gate.
 Expression getMiddle()
          return the input of the expression
 boolean hasConstantInput()
          Checks if the input is constant and the unary operator is not
 boolean hasEqualInputs()
          Returns false as there is only one input to UnaryOpExpression.
 boolean hasUnaryInput()
          Returns true iff one of the operand of this operator expression is a result of an unary operator.
 boolean isComplexIDOrNeg()
          cannot happen
 BlockStatement multi2SingleBit(java.lang.Object obj)
          Transforms this multibit expression into singlebit statements and adds them to the appropriate function.
 OperationExpression negate()
          returns the negate gate (OperatorExpression) of this OperatorExpression.
 java.util.Vector returnInputs()
          Returns an array of the input LvalExpressions of this gate.
 OperationExpression simplify()
          never called
 OperationExpression sortInputs()
          Sorts the input gates according to their names and returns the result OperationExpression.
 void toCircuit(java.io.PrintWriter circuit)
          Returns a string representing this object as it appear at the output circuit.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class SFE.Compiler.OperationExpression
combineSharedInput, evaluateExpression, getConstantOutput, getOperator, hasSharedInput, isConstant, size
 
Methods inherited from class SFE.Compiler.Expression
bitAt, hasSharedInput
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inputFormat

public static final java.util.Vector inputFormat
Constructor Detail

UnaryOpExpression

public UnaryOpExpression(Operator op,
                         Expression middle)
Constructs a new UnaryOpExpression from a given oparator and input.

Parameters:
op - the unary operator.
middle - the input.
Method Detail

returnInputs

public java.util.Vector returnInputs()
Returns an array of the input LvalExpressions of this gate. This method is used in the second phase of the optimization.

Returns:
an array of the input LvalExpressions of this gate.

toString

public java.lang.String toString()
Returns a string representation of the object. Returns a string representing this object as it appear at the output circuit.

Overrides:
toString in class java.lang.Object
Returns:
a string representing this object as it appear at the output circuit.

multi2SingleBit

public BlockStatement multi2SingleBit(java.lang.Object obj)
Transforms this multibit expression into singlebit statements and adds them to the appropriate function.

Parameters:
obj - the AssignmentStatement that holds this UnaryOpExpression.
Returns:
a BlockStatement containing the statements as single bits.

getMiddle

public Expression getMiddle()
return the input of the expression

Returns:
Expression the input of the unary expression

toCircuit

public void toCircuit(java.io.PrintWriter circuit)
Returns a string representing this object as it appear at the output circuit.


hasUnaryInput

public boolean hasUnaryInput()
Returns true iff one of the operand of this operator expression is a result of an unary operator.

Specified by:
hasUnaryInput in class OperationExpression
Returns:
true if one of the operand of this operator expression is a result of an unary operator.

combineUnaryInput

public void combineUnaryInput()
Combined an input expression the is the output of an unary operator into this Operation expression. this method should be call only if hasUnaryInput() is true.

Specified by:
combineUnaryInput in class OperationExpression

hasConstantInput

public boolean hasConstantInput()
Checks if the input is constant and the unary operator is not

Specified by:
hasConstantInput in class OperationExpression
Returns:
true if the input is constant and the unary operator is not

combineConstInput

public OperationExpression combineConstInput()
Combines an input expression that is constant and return the result expression. This method reduces the arity of this OperationExpression. This method should be called only if hasConstantInput is true.

Specified by:
combineConstInput in class OperationExpression
Returns:
the result expression.

hasEqualInputs

public boolean hasEqualInputs()
Returns false as there is only one input to UnaryOpExpression.

Specified by:
hasEqualInputs in class OperationExpression
Returns:
false.

combineEqualInputs

public OperationExpression combineEqualInputs()
Returns this expression since there is nothig to do. See hasEqualInputs() notes.

Specified by:
combineEqualInputs in class OperationExpression
Returns:
this.

sortInputs

public OperationExpression sortInputs()
Sorts the input gates according to their names and returns the result OperationExpression. This method is used in the optimization process. In UnaryOpExpression there is nothing to sort since it has only one input.

Specified by:
sortInputs in class OperationExpression
Returns:
the OperationExpression with the sorted inputs (this).

negate

public OperationExpression negate()
returns the negate gate (OperatorExpression) of this OperatorExpression.

Specified by:
negate in class OperationExpression
Returns:
the negate gate (OperatorExpression) of this OperatorExpression.

getLvalExpressionInputs

public java.util.Vector getLvalExpressionInputs()
Returns an array of the input LvalExpressions of this gate. This method is used in the second phase of the optimization.

Specified by:
getLvalExpressionInputs in class OperationExpression
Returns:
an array of the input LvalExpressions of this gate.

changeReference

public void changeReference(UniqueVariables unique)
Specified by:
changeReference in class OperationExpression

isComplexIDOrNeg

public boolean isComplexIDOrNeg()
cannot happen

Specified by:
isComplexIDOrNeg in class OperationExpression
Returns:
true if this gate outputs true of false(constant output). for any input.

simplify

public OperationExpression simplify()
never called

Specified by:
simplify in class OperationExpression
Returns:
the simplified gate.

duplicate

public Expression duplicate()
returns a replica of this expression

Specified by:
duplicate in class OperationExpression
Returns:
a replica of this expression