de.cau.cs.kieler.krep.compiler.lustre
Class WhenExpression

java.lang.Object
  extended by de.cau.cs.kieler.krep.compiler.lustre.Expression
      extended by de.cau.cs.kieler.krep.compiler.lustre.WhenExpression

public class WhenExpression
extends Expression

Implementation of the when operator.

Rating yellow
(2010-02-05) review by cmot, msp, tam

Field Summary
 
Fields inherited from class de.cau.cs.kieler.krep.compiler.lustre.Expression
STAGE_CURRENT, STAGE_INIT, STAGE_NEW, STAGE_WHEN
 
Constructor Summary
WhenExpression(String name, Expression e, VarAccessExpression c)
          generate new when operator.
 
Method Summary
 Equation declock(String basename, int stage, String c, LinkedList<Equation> aux, Program prog)
          remove all clock operators inside.
 Expression extractPre(HashMap<String,Expression> eqs)
           
 Expression getExpression()
           
 ClockList inferClock(HashMap<String,Variable> env)
          Compute clock on which this expression runs.
protected  void inferType()
          compute types and set type member recursively in all sub-expressions.
 boolean isAtom()
           
 Expression liftClock()
           
 void propagateClock(ClockList l)
          Propagate to each expression, on which clock it runs.
 Expression propagatePre(HashMap<String,Expression> eqs)
          make sure only simple variables are inside of pre operators.
 boolean sameClock(WhenExpression w)
           
 void setExpression(Expression e)
           
 String toString()
           
 
Methods inherited from class de.cau.cs.kieler.krep.compiler.lustre.Expression
addClock, getClock, getInit, getName, getType, setClock, setInit, setName, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WhenExpression

public WhenExpression(String name,
                      Expression e,
                      VarAccessExpression c)
generate new when operator.

Parameters:
name - of the expression
e - expression
c - clock on which the expression runs
Method Detail

toString

public String toString()
Overrides:
toString in class Object

isAtom

public boolean isAtom()
Specified by:
isAtom in class Expression
Returns:
true if expression does not contain any subexpressions

inferType

protected void inferType()
                  throws TypeException
Description copied from class: Expression
compute types and set type member recursively in all sub-expressions.

Specified by:
inferType in class Expression
Throws:
TypeException - thrown if any type problem occurs

propagatePre

public Expression propagatePre(HashMap<String,Expression> eqs)
Description copied from class: Expression
make sure only simple variables are inside of pre operators.

Specified by:
propagatePre in class Expression
Parameters:
eqs - additionally added equations
Returns:
simplified expression

inferClock

public ClockList inferClock(HashMap<String,Variable> env)
                     throws ClockException
Description copied from class: Expression
Compute clock on which this expression runs.

Specified by:
inferClock in class Expression
Parameters:
env - list of all defined variables
Returns:
list of all sub-clocks
Throws:
ClockException - thrown if any clock error occurs

propagateClock

public void propagateClock(ClockList l)
Description copied from class: Expression
Propagate to each expression, on which clock it runs. The clock vector should be computed by inferClock before.

Specified by:
propagateClock in class Expression
Parameters:
l - clock-vector for the expression

declock

public Equation declock(String basename,
                        int stage,
                        String c,
                        LinkedList<Equation> aux,
                        Program prog)
Description copied from class: Expression
remove all clock operators inside.

Specified by:
declock in class Expression
Parameters:
basename - name of the expression, used for auxiliary expressions
stage - indicate what clock operators have already been in this equation: 0: on top level 1: beyond current 2: beyond when 3: beyond ->
c - clock
aux - additional equations
prog - program that contains the expression
Returns:
new expression, without current, ->, and when

liftClock

public Expression liftClock()
Specified by:
liftClock in class Expression
Returns:
equivalent expression with clocks lifted as much as possible.

setExpression

public void setExpression(Expression e)
Parameters:
e - new expression for the when

getExpression

public Expression getExpression()
Returns:
expression of the when

sameClock

public boolean sameClock(WhenExpression w)
Parameters:
w - another when operator
Returns:
true, if both use the same clock.

extractPre

public Expression extractPre(HashMap<String,Expression> eqs)
Specified by:
extractPre in class Expression
Parameters:
eqs - add auxiliary equations
Returns:
expression without multiple pres