SFE.Compiler
Class Expression

java.lang.Object
  extended by SFE.Compiler.Expression
Direct Known Subclasses:
ConstExpression, LvalExpression, OperationExpression

public abstract class Expression
extends java.lang.Object

Abstract class for representing expressions that can be defined in the program.


Constructor Summary
Expression()
           
 
Method Summary
 Expression bitAt(int i)
          This method should be overriden by subclasses that can return a single bit from their expression.
 Expression duplicate()
          Returns this expression.
 Expression evaluateExpression(AssignmentStatement as, BlockStatement result)
          Recursivly calculates inner arithmetic expression.
 boolean hasSharedInput(Expression exp)
          Returns true if this exression has input pin that share an input.
abstract  int size()
          Returns the number of bits needed to represent this expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expression

public Expression()
Method Detail

size

public abstract int size()
Returns the number of bits needed to represent this expression.

Returns:
the number of bits needed to represent this expression.

bitAt

public Expression bitAt(int i)
This method should be overriden by subclasses that can return a single bit from their expression. This implementations returns null.

Returns:
null

evaluateExpression

public Expression evaluateExpression(AssignmentStatement as,
                                     BlockStatement result)
Recursivly calculates inner arithmetic expression. This implementation returns this. Expressions that return something more complicated should override this method.

Parameters:
as - the AssignmentStatement that holds this expression (as rhs).
result - the BlockStatement to hold the result in.
Returns:
the result expression.

duplicate

public Expression duplicate()
Returns this expression. Expression are not duplicated.

Returns:
this expression. Expression are not duplicated.

hasSharedInput

public boolean hasSharedInput(Expression exp)
Returns true if this exression has input pin that share an input. this method returns false. Expressions that something better to say, should override this method.

Returns:
false.